[project @ 2001-09-15 04:29:58 by ken]
[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 # Installing the documentation is not done as part of the `install' rule, but
48 # via `install-docs' (or if you want to be selective: `install-html', `install-dvi'
49 # and `install-info').
50 #
51 # For more complete instructions, consult the INSTALL file
52 # that came with the bundle, and/or consult the installation
53 # documentation in one of the document directories.
54 #
55 # Please report any bugs, problems etc. with installing and using this bundle
56 # Makefile setup to glasgow-haskell-bugs@dcs.gla.ac.uk
57
58
59 # Where the different pieces of the bundle should go:
60 bindir      = @bindir@
61 libdir      = @libdir@/$(package)-$(version)
62 datadir     = @datadir@/$(package)-$(version)
63
64 platform    = @TargetPlatform@
65 prefix      = @prefix@
66 exec_prefix = @exec_prefix@
67
68 # default
69 htmldir     = $(datadir)
70 psdir       = $(datadir)
71 pdfdir      = $(datadir)
72
73
74 PERL        = @PerlCmd@
75 SH          = /bin/sh
76 RM          = rm -f
77 MV          = mv
78 CP          = cp
79 LN_S        = @LN_S@
80 CHMOD       = chmod
81 INSTALL     = @INSTALL@
82 exeext      = @exeext@
83 SED         = @SedCmd@
84 DEFAULT_TMPDIR = /tmp
85
86 # sigh
87 INSTALL_DIR  = ./mkdirhier
88
89 #
90 # Set of package scripts for which you'd like a name-<version> symlink
91 # to be created, i.e., create a symlink, ghc-$(version), pointing to ghc to
92 # avoid version vertigo.
93 #
94 VERSION_SYMLINKS_FOR=$(PACKAGE_LINKS)
95
96 # Binaries to install
97 PACKAGE_BIN_INSTALL=$(PACKAGE_PRL_SCRIPTS) $(PACKAGE_SH_SCRIPTS)
98
99 #----------end of user-serviceable parts------------
100 #
101 #
102 # How to install the different pieces
103
104 INSTALL_BIN  = $(INSTALL) $(INSTALL_BIN_OPTS)
105 INSTALL_LIB  = $(INSTALL) $(INSTALL_LIB_OPTS)
106 INSTALL_DATA = $(INSTALL) $(INSTALL_DATA_OPTS)
107
108 # What's common to all installs
109 INSTALL_OPTS= $(EXTRA_INSTALL_OPTS)
110
111 BIN_PERMS = 755
112 LIB_PERMS = 644
113
114 INSTALL_BIN_OPTS  = -m $(BIN_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_BIN_OPTS)
115 INSTALL_LIB_OPTS  = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_LIB_OPTS)
116 INSTALL_DATA_OPTS = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_DATA_OPTS)
117
118 .PHONY: in-place config-pkgs mk-version-symlinks install-dirs install
119
120 config-pkgs ::
121         @echo "Configuring $(package), version $(version), on $(platform) ..."
122         @for i in $(PACKAGE_PRL_SCRIPTS) ""; do \
123           if test "$$i"; then \
124            echo "Creating a configured version of $$i .."; \
125            $(RM) bin/$(platform)/$$i.bak; \
126            if [ -f bin/$(platform)/$$i ]; then $(MV) bin/$(platform)/$$i bin/$(platform)/$$i.bak; fi; \
127            echo "#! $(PERL)"                        >  bin/$(platform)/$$i ; \
128            echo '$$'"bindir='$(bindir)';"           >> bin/$(platform)/$$i ; \
129            echo '$$'"libdir='$(libdir)';"           >> bin/$(platform)/$$i ; \
130            echo '$$'"libexecdir='$(libdir)';"       >> bin/$(platform)/$$i ; \
131            echo '$$'"datadir='$(datadir)';"         >> bin/$(platform)/$$i ; \
132            echo '$$'"SED='$(SED)';"                 >> bin/$(platform)/$$i ; \
133            echo '$$'"DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)';" >> bin/$(platform)/$$i ; \
134            cat bin/$(platform)/$$i.prl              >> bin/$(platform)/$$i ; \
135            $(CHMOD) $(BIN_PERMS) bin/$(platform)/$$i; \
136            echo "Done."; \
137           fi; \
138         done
139         @for i in $(PACKAGE_LIB_PRL_SCRIPTS) ""; do \
140           if test "$$i"; then \
141            echo "Creating a configured version of $$i .."; \
142            $(RM) lib/$(platform)/$$i.bak; \
143            if [ -f lib/$(platform)/$$i ]; then $(MV) lib/$(platform)/$$i lib/$(platform)/$$i.bak; fi; \
144            echo "#! $(PERL)"                       >  lib/$(platform)/$$i ; \
145            echo '$$'"bindir='$(bindir)';"          >> lib/$(platform)/$$i ; \
146            echo '$$'"libdir='$(libdir)';"          >> lib/$(platform)/$$i ; \
147            echo '$$'"libexecdir='$(libdir)';"      >> lib/$(platform)/$$i ; \
148            echo '$$'"datadir='$(datadir)';"        >> lib/$(platform)/$$i ; \
149            echo '$$'"SED='$(SED)';"                >> lib/$(platform)/$$i ; \
150            echo '$$'"DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)';"  >> lib/$(platform)/$$i ; \
151            cat lib/$(platform)/$$i.prl >> lib/$(platform)/$$i; \
152            $(CHMOD) $(BIN_PERMS) lib/$(platform)/$$i; \
153            echo "Done."; \
154           fi; \
155         done
156         @for i in $(PACKAGE_SH_SCRIPTS) ""; do \
157           if test "$$i"; then \
158            echo "Creating a configured version of $$i .."; \
159            $(RM) bin/$(platform)/$$i.bak; \
160            if [ -f bin/$(platform)/$$i ]; then $(MV) bin/$(platform)/$$i bin/$(platform)/$$i.bak; fi; \
161            echo "#! $(SH)"                      >  bin/$(platform)/$$i ; \
162            echo "bindir='$(bindir)'"            >> bin/$(platform)/$$i ; \
163            echo "libdir='$(libdir)'"            >> bin/$(platform)/$$i ; \
164            echo "libexecdir='$(libdir)'"        >> bin/$(platform)/$$i ; \
165            echo "datadir='$(datadir)'"          >> bin/$(platform)/$$i ; \
166            echo "SED='$(SED)'"                  >> bin/$(platform)/$$i ; \
167            echo "DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)'" >> bin/$(platform)/$$i ; \
168            cat bin/$(platform)/$$i.sh >> bin/$(platform)/$$i; \
169            $(CHMOD) $(BIN_PERMS) bin/$(platform)/$$i; \
170            echo "Done."; \
171           fi; \
172         done
173
174 # Convert pwd's UNC reported path into DOS style
175 # (cygwin32 only.)
176 CURRENT_DIR = `pwd | sed 's|^//\(.\)|\1:|'`
177
178 in-place ::
179         $(MAKE) $(MFLAGS) config-pkgs bindir=$(CURRENT_DIR)/bin/$(platform) libdir=$(CURRENT_DIR)/lib/$(platform) datadir=$(CURRENT_DIR)/share
180         if test -x "./post-inplace-script" ; then \
181                 echo "Running project-specific post-inplace script ..." ; \
182                 ./post-inplace-script $(platform) $(CURRENT_DIR) \
183                         $(package)-$(version); \
184                 echo "Done" ; \
185         fi
186         @echo "Finished configuring..to use, add $(CURRENT_DIR)/bin/$(platform) to your PATH."
187
188 install-dirs ::
189         $(INSTALL_DIR) $(bindir)
190         (cd lib/$(platform); find . -type d -exec sh -c '../../$(INSTALL_DIR) $$0 $(libdir)/$$0' {} \; )
191         (cd share; find . -type d -exec sh -c '../$(INSTALL_DIR) $(datadir)/$$0' {} \; )
192
193 install :: config-pkgs install-dirs install-bin install-libs install-datas install-docs postinstall denounce
194
195 .PHONY: install-bin install-libs install-datas postinstall denounce
196
197 denounce:
198         @echo
199         @echo =======================================================================
200         @echo Installation of $(package)-$(version) was successful.
201         @echo To use, add $(bindir) to your PATH.
202         @if test -d html ; then \
203            echo Docs can be found in $(htmldir). ; \
204         else \
205            echo "Warning: this binary distribution does NOT contain documentation!" ; \
206         fi
207         @echo =======================================================================
208
209 postinstall:
210         @if test -x "./post-install-script" ; then \
211                 echo "Running project-specific post-install script ..." ; \
212                 ./post-install-script $(platform) $(libdir) ; \
213                 echo "Done" ; \
214         fi
215
216 install-bin:
217         for i in $(PACKAGE_BIN_INSTALL) ""; do \
218            if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i $(bindir); fi; \
219         done;
220         for i in $(PACKAGE_BINS) ""; do \
221            if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i$(exeext) $(bindir); fi; \
222         done;
223         @for i in $(VERSION_SYMLINKS_FOR) ""; do \
224            if [ "x$$i" != "x" ]; then           \
225                 ( cd $(bindir);                 \
226                   if ( $(PERL) -e '$$fn="'$$i'"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
227                      echo "Creating a symbolic link from $$i-$(version) to $$i"; \
228                      $(RM) $$i; \
229                      $(LN_S) $$i-$(version) $$i; \
230                   else \
231                      echo "Creating a symbolic link from $$i-$(version) to $$i failed: \`$$i' already exists"; \
232                      echo "Perhaps remove \`$$i' manually?"; \
233                      exit 1; \
234                   fi;\
235                 );                              \
236            fi;                                  \
237         done
238
239
240 install-libs:
241         (cd lib/$(platform); find . -type f -exec sh -c '$(CP) $$0 $(libdir)/$$0' {} \; )
242
243 install-datas:
244         (cd share; find . -type f -exec sh -c '$(INSTALL_DATA) $$0 $(datadir)/$$0' {} \; )
245
246 show-install-setup:
247         @echo "Install setup..."
248         @echo "bindir  = $(bindir)"
249         @echo "libdir  = $(libdir) (libdir  = $(libdir))"
250         @echo "datadir = $(datadir) (datadir = $(datadir))"
251
252 #
253 # Documentation targets: install-docs.
254 #
255
256 .PHONY: show-install-setup install-docs install-dirs-docs
257
258 install-docs : install-dirs-docs
259         if test -d html ; then $(CP) -r html/* $(htmldir) ; fi
260         if test -f ps/*.ps ; then $(CP) ps/*.ps $(psdir) ; fi
261
262 install-dirs-docs:
263         $(INSTALL_DIR) $(htmldir) 
264