[project @ 2005-02-02 11:04:23 by simonmar]
[ghc-hetmet.git] / distrib / Makefile-bin.in
1 #
2 # @configure_input@
3 #
4 # Instructions for configuring an fptools package.
5 #
6 # There are two ways you can get started with an fptools package, either
7 # by using the unpacked distribution tree in-situ or by installing the
8 # package.
9 #
10 # Using the package directly is easy, just do `make in-place'. (The
11 # distribution will *not* work straight out of the box, you'll have to do
12 # this first)
13 #
14 # To install the package, you'll have to set one or more of the
15 # following variables:
16 #
17 #  * bindir 
18 #     path to directory of where you want the executables
19 #     to be installed.
20 #  * libdir
21 #     where you want the library archives to go.
22 #     Note, if you specify /usr/foo/lib for libdir,
23 #     the library files for your fptools package will be
24 #     installed in  /usr/foo/lib/<package>-<version>, e.g.,
25 #     /usr/foo/lib/ghc-3.00. If you don't want the package/version
26 #     directory appended, you'll have to modify $(real_libdir)
27 #     below.
28 #
29 #  * datadir
30 #     path to where the platform-independent files will go.
31 #     As for libdir, the effective path for the platform-indep
32 #     stuff is $(datadir)/<package>-<version>. If you want
33 #     complete control, see $(real_datadir)
34 #
35 #  * platform 
36 #     the platform you're installing for. The configure script
37 #     makes an educated guess, so you'll only have to set this
38 #     if it clashes with your reality, I guess.
39 #
40 #  * htmldir
41 #     where to install the HTML documentation files.
42 #  * pdfdir
43 #     where to install the PDF documentation files.
44 #  * psdir
45 #     where to install the Postscript documentation files.
46 #
47 # For more complete instructions, consult the INSTALL file
48 # that came with the bundle, and/or consult the installation
49 # documentation in one of the document directories.
50 #
51 # Please report any bugs, problems etc. with installing and using this bundle
52 # Makefile setup to glasgow-haskell-bugs@dcs.gla.ac.uk
53
54
55 # Where the different pieces of the bundle should go:
56 bindir      = @bindir@
57 libdir      = @libdir@/$(package)-$(version)
58 datadir     = @datadir@/$(package)-$(version)
59
60 platform    = @TargetPlatform@
61 prefix      = @prefix@
62 exec_prefix = @exec_prefix@
63
64 # default
65 htmldir     = $(datadir)/html
66 psdir       = $(datadir)
67 pdfdir      = $(datadir)
68
69
70 PERL        = @PerlCmd@
71 SH          = /bin/sh
72 RM          = rm -f
73 MV          = mv
74 CP          = cp
75 LN_S        = @LN_S@
76 CHMOD       = chmod
77 INSTALL     = @INSTALL@
78 exeext      = @exeext@
79 SED         = @SedCmd@
80 DEFAULT_TMPDIR = /tmp
81
82 # sigh
83 INSTALL_DIR  = ./mkdirhier
84
85 #
86 # Set of package scripts for which you'd like a name-<version> symlink
87 # to be created, i.e., create a symlink, ghc-$(version), pointing to ghc to
88 # avoid version vertigo.
89 #
90 VERSION_SYMLINKS_FOR=$(PACKAGE_LINKS)
91
92 # Binaries to install
93 PACKAGE_BIN_INSTALL=$(PACKAGE_PRL_SCRIPTS) $(PACKAGE_SH_SCRIPTS)
94
95 #----------end of user-serviceable parts------------
96 #
97 #
98 # How to install the different pieces
99
100 INSTALL_BIN  = $(INSTALL) $(INSTALL_BIN_OPTS)
101 INSTALL_LIB  = $(INSTALL) $(INSTALL_LIB_OPTS)
102 INSTALL_DATA = $(INSTALL) $(INSTALL_DATA_OPTS)
103
104 # What's common to all installs
105 INSTALL_OPTS= $(EXTRA_INSTALL_OPTS)
106
107 BIN_PERMS = 755
108 LIB_PERMS = 644
109
110 INSTALL_BIN_OPTS  = -m $(BIN_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_BIN_OPTS)
111 INSTALL_LIB_OPTS  = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_LIB_OPTS)
112 INSTALL_DATA_OPTS = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_DATA_OPTS)
113
114 .PHONY: in-place config-pkgs mk-version-symlinks install-dirs install
115
116 config-pkgs ::
117         @echo "Configuring $(package), version $(version), on $(platform) ..."
118         @for i in $(PACKAGE_PRL_SCRIPTS) ""; do \
119           if test "$$i"; then \
120            echo "Creating a configured version of $$i .."; \
121            $(RM) bin/$(platform)/$$i.bak; \
122            if [ -f bin/$(platform)/$$i ]; then $(MV) bin/$(platform)/$$i bin/$(platform)/$$i.bak; fi; \
123            echo "#! $(PERL)"                        >  bin/$(platform)/$$i ; \
124            echo '$$'"bindir='$(bindir)';"           >> bin/$(platform)/$$i ; \
125            echo '$$'"libdir='$(libdir)';"           >> bin/$(platform)/$$i ; \
126            echo '$$'"libexecdir='$(libdir)';"       >> bin/$(platform)/$$i ; \
127            echo '$$'"datadir='$(datadir)';"         >> bin/$(platform)/$$i ; \
128            echo '$$'"SED='$(SED)';"                 >> bin/$(platform)/$$i ; \
129            echo '$$'"DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)';" >> bin/$(platform)/$$i ; \
130            cat bin/$(platform)/$$i.prl              >> bin/$(platform)/$$i ; \
131            $(CHMOD) $(BIN_PERMS) bin/$(platform)/$$i; \
132            echo "Done."; \
133           fi; \
134         done
135         @for i in $(PACKAGE_LIB_PRL_SCRIPTS) ""; do \
136           if test "$$i"; then \
137            echo "Creating a configured version of $$i .."; \
138            $(RM) lib/$(platform)/$$i.bak; \
139            if [ -f lib/$(platform)/$$i ]; then $(MV) lib/$(platform)/$$i lib/$(platform)/$$i.bak; fi; \
140            echo "#! $(PERL)"                       >  lib/$(platform)/$$i ; \
141            echo '$$'"bindir='$(bindir)';"          >> lib/$(platform)/$$i ; \
142            echo '$$'"libdir='$(libdir)';"          >> lib/$(platform)/$$i ; \
143            echo '$$'"libexecdir='$(libdir)';"      >> lib/$(platform)/$$i ; \
144            echo '$$'"datadir='$(datadir)';"        >> lib/$(platform)/$$i ; \
145            echo '$$'"SED='$(SED)';"                >> lib/$(platform)/$$i ; \
146            echo '$$'"DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)';"  >> lib/$(platform)/$$i ; \
147            cat lib/$(platform)/$$i.prl >> lib/$(platform)/$$i; \
148            $(CHMOD) $(BIN_PERMS) lib/$(platform)/$$i; \
149            echo "Done."; \
150           fi; \
151         done
152         @for i in $(PACKAGE_SH_SCRIPTS) ""; do \
153           if test "$$i"; then \
154            echo "Creating a configured version of $$i .."; \
155            $(RM) bin/$(platform)/$$i.bak; \
156            if [ -f bin/$(platform)/$$i ]; then $(MV) bin/$(platform)/$$i bin/$(platform)/$$i.bak; fi; \
157            echo "#! $(SH)"                      >  bin/$(platform)/$$i ; \
158            echo "bindir='$(bindir)'"            >> bin/$(platform)/$$i ; \
159            echo "libdir='$(libdir)'"            >> bin/$(platform)/$$i ; \
160            echo "libexecdir='$(libdir)'"        >> bin/$(platform)/$$i ; \
161            echo "datadir='$(datadir)'"          >> bin/$(platform)/$$i ; \
162            echo "SED='$(SED)'"                  >> bin/$(platform)/$$i ; \
163            echo "DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)'" >> bin/$(platform)/$$i ; \
164            cat bin/$(platform)/$$i.sh >> bin/$(platform)/$$i; \
165            $(CHMOD) $(BIN_PERMS) bin/$(platform)/$$i; \
166            echo "Done."; \
167           fi; \
168         done
169         @for i in $(PACKAGE_LIB_SPLICED_FILES) ""; do \
170           if test "$$i"; then \
171             echo "Creating a configured version of $$i .."; \
172            if [ -f lib/$(platform)/$$i ]; then $(MV) lib/$(platform)/$$i lib/$(platform)/$$i.bak; fi; \
173            $(SED) -e "s|\$$libdir|$(libdir)|g;s|\$$datadir|$(datadir)|g" <lib/$(platform)/$$i.bak >lib/$(platform)/$$i; \
174           fi; \
175         done
176
177 in-place ::
178         $(MAKE) $(MFLAGS) config-pkgs bindir=`pwd`/bin/$(platform) libdir=`pwd`/lib/$(platform) datadir=`pwd`/share
179         @if test -x "./post-inplace-script" ; then \
180                 echo "Running project-specific post-inplace script ..." ; \
181                 ./post-inplace-script $(platform) `pwd` \
182                         $(package)-$(version); \
183                 echo "Done" ; \
184         fi
185         @echo "Finished configuring..to use, add `pwd`/bin/$(platform) to your PATH."
186
187 install-dirs ::
188         $(INSTALL_DIR) $(bindir)
189         (cd lib/$(platform); find . -type d -exec sh -c '../../$(INSTALL_DIR) $$0 $(libdir)/$$0' {} \; )
190         (cd share; find . -type d -exec sh -c '../$(INSTALL_DIR) $(datadir)/$$0' {} \; )
191
192 install :: config-pkgs install-dirs install-bin install-libs install-datas install-docs postinstall denounce
193
194 .PHONY: install-bin install-libs install-datas postinstall denounce
195
196 denounce:
197         @echo
198         @echo =======================================================================
199         @echo Installation of $(package)-$(version) was successful.
200         @echo
201         @echo To use, add $(bindir) to your PATH.
202         @echo
203         @if test -f share/html/index.html; then \
204            echo For documentation, see $(htmldir)/index.html ; \
205         elif test -d share/html ; then \
206            echo Docs can be found in $(htmldir). ; \
207         else \
208            echo "Warning: this binary distribution does NOT contain documentation!" ; \
209         fi
210         @echo =======================================================================
211
212 postinstall:
213         @if test -x "./post-install-script" ; then \
214                 echo "Running project-specific post-install script ..." ; \
215                 ./post-install-script $(platform) $(libdir) ; \
216                 echo "Done" ; \
217         fi
218
219 install-bin:
220         for i in $(PACKAGE_BIN_INSTALL) ""; do \
221            if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i $(bindir); fi; \
222         done;
223         for i in $(PACKAGE_BINS) ""; do \
224            if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i$(exeext) $(bindir); fi; \
225         done;
226         @for i in $(VERSION_SYMLINKS_FOR) ""; do \
227            if [ "x$$i" != "x" ]; then           \
228                 ( cd $(bindir);                 \
229                   if ( $(PERL) -e '$$fn="'$$i'"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
230                      echo "Creating a symbolic link from $$i-$(version) to $$i"; \
231                      $(RM) $$i; \
232                      $(LN_S) $$i-$(version) $$i; \
233                   else \
234                      echo "Creating a symbolic link from $$i-$(version) to $$i failed: \`$$i' already exists"; \
235                      echo "Perhaps remove \`$$i' manually?"; \
236                      exit 1; \
237                   fi;\
238                 );                              \
239            fi;                                  \
240         done
241
242
243 install-libs:
244         (cd lib/$(platform); find . -type f -exec sh -c '$(CP) $$0 $(libdir)/$$0' {} \; )
245
246 install-datas:
247         for i in `(cd share; find . -type f )`; do \
248            $(INSTALL_DATA) share/$$i $(datadir)/$$i; \
249         done
250
251 show-install-setup:
252         @echo "Install setup..."
253         @echo "bindir  = $(bindir)"
254         @echo "libdir  = $(libdir) (libdir  = $(libdir))"
255         @echo "datadir = $(datadir) (datadir = $(datadir))"
256
257 #
258 # Documentation targets: install-docs.
259 #
260
261 .PHONY: show-install-setup install-docs install-dirs-docs
262
263 install-docs : install-dirs-docs
264         if test -d share/html ; then $(CP) -r share/html/* $(htmldir) ; fi
265         for i in share/*.ps; do \
266                 $(CP) $$i $(psdir) ; \
267         done
268
269 install-dirs-docs:
270         $(INSTALL_DIR) $(htmldir) 
271