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