[project @ 1999-07-15 16:20:46 by panne]
[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@
62 datadir     = @datadir@
63
64 platform    = @TargetPlatform@
65 prefix      = @prefix@
66 exec_prefix = @exec_prefix@
67
68 # default
69 infodir   = $(real_datadir)
70 htmldir   = $(real_datadir)
71 dvidir    = $(real_datadir)
72
73 #
74 # Putting the package stuff in package-specific
75 # directories:
76 #
77 real_libdir      = $(libdir)/$(package)-$(version)
78 real_datadir     = $(datadir)/$(package)-$(version)
79
80 PERL        = @PerlCmd@
81 SH          = /bin/sh
82 RM          = rm -f
83 MV          = mv
84 CP          = cp
85 LN_S        = @LN_S@
86 CHMOD       = chmod
87 INSTALL     = @INSTALL@
88 exeext      = @exeext@
89 SED         = @SedCmd@
90 TMPDIR      = /tmp
91
92 # sigh
93 INSTALL_DIR  = ./mkdirhier
94
95 #
96 # Set of package scripts for which you'd like a name-<version> symlink
97 # to be created, i.e., create a symlink, ghc-$(version), pointing to ghc to
98 # avoid version vertigo.
99 #
100 VERSION_SYMLINKS_FOR=$(package)
101
102 # Binaries to install
103 PACKAGE_BIN_INSTALL=$(PACKAGE_PRL_SCRIPTS) $(PACKAGE_SH_SCRIPTS)
104
105 #----------end of user-serviceable parts------------
106 #
107 #
108 # How to install the different pieces
109
110 INSTALL_BIN  = $(INSTALL) $(INSTALL_BIN_OPTS)
111 INSTALL_LIB  = $(INSTALL) $(INSTALL_LIB_OPTS)
112 INSTALL_DATA = $(INSTALL) $(INSTALL_DATA_OPTS)
113
114 # What's common to all installs
115 INSTALL_OPTS= $(EXTRA_INSTALL_OPTS)
116
117 BIN_PERMS = 755
118 LIB_PERMS = 644
119
120 INSTALL_BIN_OPTS  = -m $(BIN_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_BIN_OPTS)
121 INSTALL_LIB_OPTS  = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_LIB_OPTS)
122 INSTALL_DATA_OPTS = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_DATA_OPTS)
123
124 .PHONY: in-place config-pkgs mk-version-symlinks install-dirs install
125
126 config-pkgs ::
127         @echo "Configuring $(package), version $(version), on $(platform) ..."
128         @for i in $(PACKAGE_PRL_SCRIPTS) ""; do \
129           if test "$$i"; then \
130            echo "Creating a configured version of $$i .."; \
131            $(RM) bin/$(platform)/$(package)-$(version)/$$i.bak; \
132            if [ -f bin/$(platform)/$(package)-$(version)/$$i ]; then $(MV) bin/$(platform)/$(package)-$(version)/$$i bin/$(platform)/$(package)-$(version)/$$i.bak; fi; \
133            echo "#! $(PERL)"                                    > bin/$(platform)/$(package)-$(version)/$$i ; \
134            echo '$$'"bindir='$(bindir)';"                        >> bin/$(platform)/$(package)-$(version)/$$i ; \
135            echo '$$'"libdir='$(real_libdir)';"                   >> bin/$(platform)/$(package)-$(version)/$$i ; \
136            echo '$$'"libexecdir='$(real_libdir)';"               >> bin/$(platform)/$(package)-$(version)/$$i ; \
137            echo '$$'"datadir='$(real_datadir)';"                 >> bin/$(platform)/$(package)-$(version)/$$i ; \
138            echo '$$'"SED='$(SED)';"             >> bin/$(platform)/$(package)-$(version)/$$i ; \
139            echo '$$'"TMPDIR='$(TMPDIR)';"               >> bin/$(platform)/$(package)-$(version)/$$i ; \
140            cat bin/$(platform)/$(package)-$(version)/$$i.prl   >> bin/$(platform)/$(package)-$(version)/$$i ; \
141            $(CHMOD) $(BIN_PERMS) bin/$(platform)/$(package)-$(version)/$$i; \
142            echo "Done."; \
143           fi; \
144         done
145         @for i in $(PACKAGE_LIB_PRL_SCRIPTS) ""; do \
146           if test "$$i"; then \
147            echo "Creating a configured version of $$i .."; \
148            $(RM) lib/$(platform)/$(package)-$(version)/$$i.bak; \
149            if [ -f lib/$(platform)/$(package)-$(version)/$$i ]; then $(MV) lib/$(platform)/$(package)-$(version)/$$i lib/$(platform)/$(package)-$(version)/$$i.bak; fi; \
150            echo "#! $(PERL)"                      > lib/$(platform)/$(package)-$(version)/$$i ; \
151            echo '$$'"bindir='$(bindir)';"          >> lib/$(platform)/$(package)-$(version)/$$i ; \
152            echo '$$'"libdir='$(real_libdir)';"     >> lib/$(platform)/$(package)-$(version)/$$i ; \
153            echo '$$'"libexecdir='$(real_libdir)';" >> lib/$(platform)/$(package)-$(version)/$$i ; \
154            echo '$$'"datadir='$(real_datadir)';"   >> lib/$(platform)/$(package)-$(version)/$$i ; \
155            echo '$$'"SED='$(SED)';"              >> lib/$(platform)/$(package)-$(version)/$$i ; \
156            echo '$$'"TMPDIR='$(TMPDIR)';"                >> lib/$(platform)/$(package)-$(version)/$$i ; \
157            cat lib/$(platform)/$(package)-$(version)/$$i.prl >> lib/$(platform)/$(package)-$(version)/$$i; \
158            $(CHMOD) $(BIN_PERMS) lib/$(platform)/$(package)-$(version)/$$i; \
159            echo "Done."; \
160           fi; \
161         done
162         @for i in $(PACKAGE_SH_SCRIPTS) ""; do \
163           if test "$$i"; then \
164            echo "Creating a configured version of $$i .."; \
165            $(RM) bin/$(platform)/$(package)-$(version)/$$i.bak; \
166            if [ -f bin/$(platform)/$(package)-$(version)/$$i ]; then $(MV) bin/$(platform)/$(package)-$(version)/$$i bin/$(platform)/$(package)-$(version)/$$i.bak; fi; \
167            echo "#! $(SH)"                      > bin/$(platform)/$(package)-$(version)/$$i ; \
168            echo "bindir='$(bindir)'"          >> bin/$(platform)/$(package)-$(version)/$$i ; \
169            echo "libdir='$(real_libdir)'"     >> bin/$(platform)/$(package)-$(version)/$$i ; \
170            echo "libexecdir='$(real_libdir)'" >> bin/$(platform)/$(package)-$(version)/$$i ; \
171            echo "datadir='$(real_datadir)'"   >> bin/$(platform)/$(package)-$(version)/$$i ; \
172            echo "SED='$(SED)'"                   >> bin/$(platform)/$(package)-$(version)/$$i ; \
173            echo "TMPDIR='$(TMPDIR)'"             >> bin/$(platform)/$(package)-$(version)/$$i ; \
174            cat bin/$(platform)/$(package)-$(version)/$$i.sh >> bin/$(platform)/$(package)-$(version)/$$i; \
175            $(CHMOD) $(BIN_PERMS) bin/$(platform)/$(package)-$(version)/$$i; \
176            echo "Done."; \
177           fi; \
178         done
179
180 # Convert pwd's UNC reported path into DOS style
181 # (cygwin32 only.)
182 CURRENT_DIR = $(shell pwd | sed 's|^//\(.\)|\1:|' )
183
184 in-place ::
185         $(MAKE) $(MFLAGS) config-pkgs bindir=$(CURRENT_DIR)/bin/$(platform)/$(package)-$(version) libdir=$(CURRENT_DIR)/lib/$(platform) datadir=$(CURRENT_DIR)/share/$(package)-$(version)
186         @echo "Finished configuring..to use, add $(CURRENT_DIR)/bin/$(platform)/$(package)-$(version) to your PATH."
187
188 install-dirs ::
189         $(INSTALL_DIR) $(bindir)
190         (cd lib/$(platform)/$(package)-$(version); find . -type d -exec sh -c '../../../$(INSTALL_DIR) $$0 $(real_libdir)/$$0' {} \; )
191         (cd share/$(package)-$(version); find . -type d -exec sh -c '../../$(INSTALL_DIR) $(real_datadir)/$$0' {} \; )
192
193 install :: config-pkgs install-dirs install-bin install-libs install-datas
194
195 .PHONY: install-bin install-libs install-datas
196
197 install-bin:
198         for i in $(PACKAGE_BIN_INSTALL) ""; do \
199            test -n "$i" && $(INSTALL_BIN) bin/$(platform)/$(package)-$(version)/$$i $(bindir); \
200         done;
201         for i in $(PACKAGE_BINS) ""; do \
202            test -n "$i" && $(INSTALL_BIN) bin/$(platform)/$(package)-$(version)/$$i$(exeext) $(bindir); \
203         done;
204         for i in $(VERSION_SYMLINKS_FOR) ""; do \
205            if [ "x$$i" != "x" ]; then           \
206                 ( cd $(bindir);                 \
207                   if ( $(PERL) -e '$$fn="'$$i'"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
208                      echo "Creating a symbol link from $$i-$(version) to $$i"; \
209                      $(RM) $$i; \
210                      $(LN_S) $$i-$(version) $$i; \
211                   else \
212                      echo "Creating a symbol link from $$i-$(version) to $$i failed: \`$$i' already exists"; \
213                      echo "Perhaps remove \`$$i' manually?"; \
214                      exit 1; \
215                   fi;\
216                 );                              \
217            fi;                                  \
218         done
219
220
221 install-libs:
222         (cd lib/$(platform)/$(package)-$(version); find . -type f -exec sh -c '$(CP) $$0 $(real_libdir)/$$0' {} \; )
223
224 install-datas:
225         (cd share/$(package)-$(version); find . -type f -exec sh -c '$(INSTALL_DATA) $$0 $(real_datadir)/$$0' {} \; )
226
227 show-install-setup:
228         @echo "Install setup..."
229         @echo "bindir  = $(bindir)"
230         @echo "libdir  = $(libdir) (real_libdir  = $(real_libdir))"
231         @echo "datadir = $(datadir) (real_datadir = $(real_datadir))"
232
233 #
234 # Documentation targets, install-docs for the whole lot, or
235 # install-{dvi,html,info}
236 #
237
238 .PHONY: show-install-setup install-docs install-html install-info install-dirs-dvi install-dirs-html install-dirs-info
239
240 install-docs : install-html install-dvi install-info
241
242 install-dvi: install-dirs-dvi
243         $(INSTALL_DATA) dvi/$(package)-$(version)/* $(dvidir)
244
245 install-info: install-dirs-info
246         $(INSTALL_DATA) info/$(package)-$(version)/* $(infodir)
247
248 install-html: install-dirs-html
249         $(INSTALL_DATA) html/$(package)-$(version)/* $(htmldir)
250
251 install-dirs-html:
252         $(INSTALL_DIR) $(htmldir) 
253
254 install-dirs-info:
255         $(INSTALL_DIR) $(infodir) 
256
257 install-dirs-dvi:
258         $(INSTALL_DIR) $(dvidir) 
259