[project @ 2001-04-03 15:08:35 by sewardj]
[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 documentation HTML files.
42 #  * dvidir
43 #     where to install the DVI files.
44 #  * infodir
45 #     where to install the Emacs info 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 infodir   = $(datadir)
70 htmldir   = $(datadir)
71 dvidir    = $(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 = $(shell 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 postinstall
194
195 .PHONY: install-bin install-libs install-datas postinstall
196
197 postinstall:
198         if test -x "./post-install-script" ; then \
199                 echo "Running project-specific post-install script ..." ; \
200                 ./post-install-script $(platform) $(prefix) \
201                         $(package)-$(version); \
202                 echo "Done" ; \
203         fi
204
205 install-bin:
206         for i in $(PACKAGE_BIN_INSTALL) ""; do \
207            if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i $(bindir); fi; \
208         done;
209         for i in $(PACKAGE_BINS) ""; do \
210            if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i$(exeext) $(bindir); fi; \
211         done;
212         @for i in $(VERSION_SYMLINKS_FOR) ""; do \
213            if [ "x$$i" != "x" ]; then           \
214                 ( cd $(bindir);                 \
215                   if ( $(PERL) -e '$$fn="'$$i'"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
216                      echo "Creating a symbolic link from $$i-$(version) to $$i"; \
217                      $(RM) $$i; \
218                      $(LN_S) $$i-$(version) $$i; \
219                   else \
220                      echo "Creating a symbolic link from $$i-$(version) to $$i failed: \`$$i' already exists"; \
221                      echo "Perhaps remove \`$$i' manually?"; \
222                      exit 1; \
223                   fi;\
224                 );                              \
225            fi;                                  \
226         done
227
228
229 install-libs:
230         (cd lib/$(platform); find . -type f -exec sh -c '$(CP) $$0 $(libdir)/$$0' {} \; )
231
232 install-datas:
233         (cd share; find . -type f -exec sh -c '$(INSTALL_DATA) $$0 $(datadir)/$$0' {} \; )
234
235 show-install-setup:
236         @echo "Install setup..."
237         @echo "bindir  = $(bindir)"
238         @echo "libdir  = $(libdir) (libdir  = $(libdir))"
239         @echo "datadir = $(datadir) (datadir = $(datadir))"
240
241 #
242 # Documentation targets, install-docs for the whole lot, or
243 # install-{dvi,html,info}
244 #
245
246 .PHONY: show-install-setup install-docs install-html install-info install-dirs-dvi install-dirs-html install-dirs-info
247
248 install-docs : install-html install-dvi install-info
249
250 install-dvi: install-dirs-dvi
251         $(INSTALL_DATA) dvi/* $(dvidir)
252
253 install-info: install-dirs-info
254         $(INSTALL_DATA) info/* $(infodir)
255
256 install-html: install-dirs-html
257         $(CP) -r html/* $(htmldir)
258         $(CHMOD) -R $(LIB_PERMS) $(htmldir)
259 #       $(INSTALL_DATA) html/* $(htmldir)
260
261 install-dirs-html:
262         $(INSTALL_DIR) $(htmldir) 
263
264 install-dirs-info:
265         $(INSTALL_DIR) $(infodir) 
266
267 install-dirs-dvi:
268         $(INSTALL_DIR) $(dvidir) 
269