15882cf2d2643c927587c74ec6e1145e0566e889
[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 config'. (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-2.02. 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   = $(datadir)
70 htmldir   = $(datadir)
71 dvidir    = $(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 package     = ghc
81 version     = 2.02
82 PERL        = @PerlCmd@
83 RM          = rm -f
84 MV          = mv
85 CP          = cp -f
86 LN_S        = @LN_S@
87 CHMOD       = chmod
88 INSTALL     = @INSTALL@
89 # sigh
90 INSTALL_DIR  = ./mkdirhier
91
92 #
93 # Set of package scripts for which you'd like a name-<version> symlink
94 # to be created, i.e., create a symlink, ghc-2.02, pointing to ghc to
95 # avoid version vertigo.
96 #
97 VERSION_SYMLINKS_FOR=ghc
98
99 #
100 # List of files in bin directory that need to have
101 # local setup/install information prepended.
102 #
103 PACKAGE_SCRIPTS=ghc stat2resid hstags mkdependHS
104 PACKAGE_LIB_SCRIPTS=hscpp
105
106 # Binaries to install
107 PACKAGE_BINS=$(PACKAGE_SCRIPTS) hp2ps
108
109 #----------end of user-serviceable parts------------
110 #
111 #
112 # How to install the different pieces
113
114 INSTALL_BIN  = $(INSTALL) $(INSTALL_BIN_OPTS)
115 INSTALL_LIB  = $(INSTALL) $(INSTALL_LIB_OPTS)
116 INSTALL_DATA = $(INSTALL) $(INSTALL_DATA_OPTS)
117
118 # What's common to all installs
119 INSTALL_OPTS= $(EXTRA_INSTALL_OPTS)
120
121 BIN_PERMS = 755
122 LIB_PERMS = 644
123
124 INSTALL_BIN_OPTS  = -m $(BIN_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_BIN_OPTS)
125 INSTALL_LIB_OPTS  = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_LIB_OPTS)
126 INSTALL_DATA_OPTS = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_DATA_OPTS)
127
128 .PHONY: in-place config-pkgs mk-version-symlinks install-dirs install
129
130 config-pkgs ::
131         @echo "Configuring $(package), version $(version), on $(platform) ..."
132         $(RM) bin/$(platform)/$(package)-$(version)/$(package)-$(version)
133         @for i in $(PACKAGE_SCRIPTS); do \
134            echo "Creating a configured version of $$i .."; \
135            $(RM) bin/$(platform)/$(package)-$(version)/$$i.bak; \
136            test -f bin/$(platform)/$(package)-$(version)/$$i && $(MV) bin/$(platform)/$(package)-$(version)/$$i bin/$(platform)/$(package)-$(version)/$$i.bak; \
137            echo "eval 'exec $(PERL) -S $$$""0 $$""{1+\"$$$""@\"}'"         > bin/$(platform)/$(package)-$(version)/$$i; \
138            echo "      if $$""running_under_some_shell;"                  >> bin/$(platform)/$(package)-$(version)/$$i; \
139            echo $$"bindir='$(bindir)';"                                   >> bin/$(platform)/$(package)-$(version)/$$i; \
140            echo $$"libdir='$(real_libdir)';"                              >> bin/$(platform)/$(package)-$(version)/$$i; \
141            echo $$"datadir='$(real_datadir)';"                            >> bin/$(platform)/$(package)-$(version)/$$i; \
142            cat bin/$(platform)/$(package)-$(version)/$$i.prl              >> bin/$(platform)/$(package)-$(version)/$$i; \
143            $(CHMOD) $(BIN_PERMS) bin/$(platform)/$(package)-$(version)/$$i; \
144            echo "Done."; \
145         done
146         @for i in $(PACKAGE_LIB_SCRIPTS); do \
147            echo "Creating a configured version of $$i .."; \
148            $(RM) lib/$(platform)/$(package)-$(version)/$$i.bak; \
149            test -f lib/$(platform)/$(package)-$(version)/$$i && $(MV) lib/$(platform)/$(package)-$(version)/$$i lib/$(platform)/$(package)-$(version)/$$i.bak; \
150            echo "eval 'exec $(PERL) -S $$$""0 $$""{1+\"$$$""@\"}'"         > lib/$(platform)/$(package)-$(version)/$$i; \
151            echo "      if $$""running_under_some_shell;"                  >> lib/$(platform)/$(package)-$(version)/$$i; \
152            echo $$"bindir='$(bindir)';"                                   >> lib/$(platform)/$(package)-$(version)/$$i; \
153            echo $$"libdir='$(real_libdir)';"                              >> lib/$(platform)/$(package)-$(version)/$$i; \
154            echo $$"datadir='$(real_datadir)';"                            >> lib/$(platform)/$(package)-$(version)/$$i; \
155            cat lib/$(platform)/$(package)-$(version)/$$i.prl              >> lib/$(platform)/$(package)-$(version)/$$i; \
156            $(CHMOD) $(BIN_PERMS) lib/$(platform)/$(package)-$(version)/$$i; \
157            echo "Done."; \
158         done
159
160 #
161 # The vaguely funky eval 'exec ...' echo line above *might* be
162 # a tad too much for some `make's - here's what it should return
163 # if all is well:
164 #
165 #   eval 'exec /installed/path/for/perl -S $0 ${1+"$@"}'
166 #         if $running_under_some_shell;
167 #
168
169 mk-version-symlinks ::
170         @for i in $(VERSION_SYMLINKS_FOR) ""; do \
171           if [ "x$$i" != "x" ]; then \
172              echo "Symlinking $$i to $$i-$(version)"; \
173              (cd bin/$(platform)/$(package)-$(version); $(RM) $$i-$(version); $(LN_S) $$i $$i-$(version) ); \
174           fi;\
175         done
176
177 in-place ::
178         $(MAKE) $(MFLAGS) config-pkgs bindir=`pwd`/bin/$(platform)/$(package)-$(version) libdir=`pwd`/lib/$(platform) datadir=`pwd`/share/$(package)-$(version)
179         $(MAKE) $(MFLAGS) mk-version-symlinks
180         @echo "Finished configuring..to use, add `pwd`/bin/$(platform)/$(package)-$(version) to your PATH."
181
182 install-dirs ::
183         $(INSTALL_DIR) $(bindir)
184         (cd lib/$(platform)/$(package)-$(version); find . -type d -exec sh -c '../../../$(INSTALL_DIR) $$0 $(real_libdir)/$$0' {} \; )
185         (cd share/$(package)-$(version); find . -type d -exec sh -c '../../$(INSTALL_DIR) $$0 $(real_datadir)/$$0' {} \; )
186
187 install :: config-pkgs mk-version-symlinks install-dirs install-bin install-libs install-datas
188
189 .PHONY: install-bin install-libs install-datas
190
191 install-bin:
192         for i in $(PACKAGE_BINS); do \
193            $(INSTALL_BIN) bin/$(platform)/$(package)-$(version)/$$i $(bindir); \
194         done;
195         for i in $(VERSION_SYMLINKS_FOR) ""; do \
196            if [ "x$$i" != "x" ]; then \
197                 ( cd $(bindir); $(LN_S) $$i $$i-$(version) ); \
198            fi; \
199         done
200
201
202 install-libs:
203         (cd lib/$(platform)/$(package)-$(version); find . -type f -exec sh -c '$(CP) $$0 $(real_libdir)/$$0' {} \; )
204
205 install-datas:
206         (cd share/$(package)-$(version); find . -type f -exec sh -c '$(INSTALL_DATA) $$0 $(real_datadir)/$$0' {} \; )
207
208 show-install-setup:
209         @echo "Install setup..."
210         @echo "bindir  = $(bindir)"
211         @echo "libdir  = $(libdir) (real_libdir  = $(real_libdir))"
212         @echo "datadir = $(datadir) (real_datadir = $(real_datadir))"
213
214 #
215 # Documentation targets, install-docs for the whole lot, or
216 # install-{dvi,html,info}
217 #
218
219 .PHONY: show-install-setup install-docs install-html install-info install-dirs-dvi install-dirs-html install-dirs-info
220
221 install-docs : install-html install-dvi install-info
222
223 install-dvi: install-dirs-dvi
224         $(INSTALL_DATA) dvi/$(package)-$(version)/* $(dvidir)
225
226 install-info: install-dirs-info
227         $(INSTALL_DATA) info/$(package)-$(version)/* $(infodir)
228
229 install-html: install-dirs-html
230         $(INSTALL_DATA) html/$(package)-$(version)/* $(htmldir)
231
232 install-dirs-html:
233         $(INSTALL_DIR) $(htmldir) 
234
235 install-dirs-info:
236         $(INSTALL_DIR) $(infodir) 
237
238 install-dirs-dvi:
239         $(INSTALL_DIR) $(dvidir) 
240