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