[project @ 2002-09-20 13:08:42 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
170 in-place ::
171         $(MAKE) $(MFLAGS) config-pkgs bindir=`pwd`/bin/$(platform) libdir=`pwd`/lib/$(platform) datadir=`pwd`/share
172         if test -x "./post-inplace-script" ; then \
173                 echo "Running project-specific post-inplace script ..." ; \
174                 ./post-inplace-script $(platform) `pwd` \
175                         $(package)-$(version); \
176                 echo "Done" ; \
177         fi
178         @echo "Finished configuring..to use, add `pwd`/bin/$(platform) to your PATH."
179
180 install-dirs ::
181         $(INSTALL_DIR) $(bindir)
182         (cd lib/$(platform); find . -type d -exec sh -c '../../$(INSTALL_DIR) $$0 $(libdir)/$$0' {} \; )
183         (cd share; find . -type d -exec sh -c '../$(INSTALL_DIR) $(datadir)/$$0' {} \; )
184
185 install :: config-pkgs install-dirs install-bin install-libs install-datas install-docs postinstall denounce
186
187 .PHONY: install-bin install-libs install-datas postinstall denounce
188
189 denounce:
190         @echo
191         @echo =======================================================================
192         @echo Installation of $(package)-$(version) was successful.
193         @echo
194         @echo To use, add $(bindir) to your PATH.
195         @echo
196         @if test -f share/html/index.html; then \
197            echo For documentation, see $(htmldir)/index.html ; \
198         elif test -d share/html ; then \
199            echo Docs can be found in $(htmldir). ; \
200         else \
201            echo "Warning: this binary distribution does NOT contain documentation!" ; \
202         fi
203         @echo =======================================================================
204
205 postinstall:
206         @if test -x "./post-install-script" ; then \
207                 echo "Running project-specific post-install script ..." ; \
208                 ./post-install-script $(platform) $(libdir) ; \
209                 echo "Done" ; \
210         fi
211
212 install-bin:
213         for i in $(PACKAGE_BIN_INSTALL) ""; do \
214            if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i $(bindir); fi; \
215         done;
216         for i in $(PACKAGE_BINS) ""; do \
217            if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i$(exeext) $(bindir); fi; \
218         done;
219         @for i in $(VERSION_SYMLINKS_FOR) ""; do \
220            if [ "x$$i" != "x" ]; then           \
221                 ( cd $(bindir);                 \
222                   if ( $(PERL) -e '$$fn="'$$i'"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
223                      echo "Creating a symbolic link from $$i-$(version) to $$i"; \
224                      $(RM) $$i; \
225                      $(LN_S) $$i-$(version) $$i; \
226                   else \
227                      echo "Creating a symbolic link from $$i-$(version) to $$i failed: \`$$i' already exists"; \
228                      echo "Perhaps remove \`$$i' manually?"; \
229                      exit 1; \
230                   fi;\
231                 );                              \
232            fi;                                  \
233         done
234
235
236 install-libs:
237         (cd lib/$(platform); find . -type f -exec sh -c '$(CP) $$0 $(libdir)/$$0' {} \; )
238
239 install-datas:
240         for i in `(cd share; find . -type f )`; do \
241            $(INSTALL_DATA) share/$$i $(datadir)/$$i; \
242         done
243
244 show-install-setup:
245         @echo "Install setup..."
246         @echo "bindir  = $(bindir)"
247         @echo "libdir  = $(libdir) (libdir  = $(libdir))"
248         @echo "datadir = $(datadir) (datadir = $(datadir))"
249
250 #
251 # Documentation targets: install-docs.
252 #
253
254 .PHONY: show-install-setup install-docs install-dirs-docs
255
256 install-docs : install-dirs-docs
257         if test -d share/html ; then $(CP) -r share/html/* $(htmldir) ; fi
258         for i in share/*.ps; do \
259                 $(CP) $$i $(psdir) ; \
260         done
261
262 install-dirs-docs:
263         $(INSTALL_DIR) $(htmldir) 
264