[project @ 1997-12-16 11:38:12 by simonm]
[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-2.07. 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 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 RAWCPP      = @RAWCPP@
89 SED         = @SedCmd@
90 # sigh
91 INSTALL_DIR  = ./mkdirhier
92
93 #
94 # Set of package scripts for which you'd like a name-<version> symlink
95 # to be created, i.e., create a symlink, ghc-$(version), pointing to ghc to
96 # avoid version vertigo.
97 #
98 VERSION_SYMLINKS_FOR=$(package)
99
100 # Binaries to install
101 PACKAGE_BINS=$(PACKAGE_SCRIPTS) $(PACKAGE_SH_SCRIPTS) hp2ps
102
103 #----------end of user-serviceable parts------------
104 #
105 #
106 # How to install the different pieces
107
108 INSTALL_BIN  = $(INSTALL) $(INSTALL_BIN_OPTS)
109 INSTALL_LIB  = $(INSTALL) $(INSTALL_LIB_OPTS)
110 INSTALL_DATA = $(INSTALL) $(INSTALL_DATA_OPTS)
111
112 # What's common to all installs
113 INSTALL_OPTS= $(EXTRA_INSTALL_OPTS)
114
115 BIN_PERMS = 755
116 LIB_PERMS = 644
117
118 INSTALL_BIN_OPTS  = -m $(BIN_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_BIN_OPTS)
119 INSTALL_LIB_OPTS  = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_LIB_OPTS)
120 INSTALL_DATA_OPTS = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_DATA_OPTS)
121
122 .PHONY: in-place config-pkgs mk-version-symlinks install-dirs install
123
124 config-pkgs ::
125         @echo "Configuring $(package), version $(version), on $(platform) ..."
126         @for i in $(PACKAGE_PRL_SCRIPTS); do \
127            echo "Creating a configured version of $$i .."; \
128            $(RM) bin/$(platform)/$(package)-$(version)/$$i.bak; \
129            test -f bin/$(platform)/$(package)-$(version)/$$i && $(MV) bin/$(platform)/$(package)-$(version)/$$i bin/$(platform)/$(package)-$(version)/$$i.bak; \
130            echo "#! $(PERL)"                                    > bin/$(platform)/$(package)-$(version)/$$i ; \
131            echo '$$'"bindir='$(bindir)';"                        >> bin/$(platform)/$(package)-$(version)/$$i ; \
132            echo '$$'"libdir='$(real_libdir)';"                   >> bin/$(platform)/$(package)-$(version)/$$i ; \
133            echo '$$'"libexecdir='$(real_libdir)';"               >> bin/$(platform)/$(package)-$(version)/$$i ; \
134            echo '$$'"datadir='$(real_datadir)';"                 >> bin/$(platform)/$(package)-$(version)/$$i ; \
135            echo '$$'"SED='$(SED)';"             >> bin/$(platform)/$(package)-$(version)/$$i ; \
136            echo '$$'"RAWCPP='$(RAWCPP)';"               >> bin/$(platform)/$(package)-$(version)/$$i ; \
137            cat bin/$(platform)/$(package)-$(version)/$$i.prl   >> bin/$(platform)/$(package)-$(version)/$$i ; \
138            $(CHMOD) $(BIN_PERMS) bin/$(platform)/$(package)-$(version)/$$i; \
139            echo "Done."; \
140         done
141         @for i in $(PACKAGE_LIB_PRL_SCRIPTS); do \
142            echo "Creating a configured version of $$i .."; \
143            $(RM) lib/$(platform)/$(package)-$(version)/$$i.bak; \
144            test -f lib/$(platform)/$(package)-$(version)/$$i && $(MV) lib/$(platform)/$(package)-$(version)/$$i lib/$(platform)/$(package)-$(version)/$$i.bak; \
145            echo "#! $(PERL)"                      > lib/$(platform)/$(package)-$(version)/$$i ; \
146            echo '$$'"bindir='$(bindir)';"          >> lib/$(platform)/$(package)-$(version)/$$i ; \
147            echo '$$'"libdir='$(real_libdir)';"     >> lib/$(platform)/$(package)-$(version)/$$i ; \
148            echo '$$'"libexecdir='$(real_libdir)';" >> lib/$(platform)/$(package)-$(version)/$$i ; \
149            echo '$$'"datadir='$(real_datadir)';"   >> lib/$(platform)/$(package)-$(version)/$$i ; \
150            echo '$$'"SED='$(SED)';"              >> lib/$(platform)/$(package)-$(version)/$$i ; \
151            echo '$$'"RAWCPP='$(RAWCPP)';"                >> lib/$(platform)/$(package)-$(version)/$$i ; \
152            cat lib/$(platform)/$(package)-$(version)/$$i.prl >> lib/$(platform)/$(package)-$(version)/$$i; \
153            $(CHMOD) $(BIN_PERMS) lib/$(platform)/$(package)-$(version)/$$i; \
154            echo "Done."; \
155         done
156         @for i in $(PACKAGE_SH_SCRIPTS); do \
157            echo "Creating a configured version of $$i .."; \
158            $(RM) bin/$(platform)/$(package)-$(version)/$$i.bak; \
159            test -f bin/$(platform)/$(package)-$(version)/$$i && $(MV) bin/$(platform)/$(package)-$(version)/$$i bin/$(platform)/$(package)-$(version)/$$i.bak; \
160            echo "#! $(SH)"                      > bin/$(platform)/$(package)-$(version)/$$i ; \
161            echo "bindir='$(bindir)'"          >> bin/$(platform)/$(package)-$(version)/$$i ; \
162            echo "libdir='$(real_libdir)'"     >> bin/$(platform)/$(package)-$(version)/$$i ; \
163            echo "libexecdir='$(real_libdir)'" >> bin/$(platform)/$(package)-$(version)/$$i ; \
164            echo "datadir='$(real_datadir)'"   >> bin/$(platform)/$(package)-$(version)/$$i ; \
165            echo "SED='$(SED)'"                   >> bin/$(platform)/$(package)-$(version)/$$i ; \
166            echo "RAWCPP='$(RAWCPP)'"             >> bin/$(platform)/$(package)-$(version)/$$i ; \
167            cat bin/$(platform)/$(package)-$(version)/$$i.sh >> bin/$(platform)/$(package)-$(version)/$$i; \
168            $(CHMOD) $(BIN_PERMS) bin/$(platform)/$(package)-$(version)/$$i; \
169            echo "Done."; \
170         done
171
172
173 mk-version-symlinks ::
174         @for i in $(VERSION_SYMLINKS_FOR) ""; do \
175           if [ "x$$i" != "x" ]; then \
176              echo "Symlinking $$i to $$i-$(version)"; \
177              (cd bin/$(platform)/$(package)-$(version); $(RM) $$i-$(version); $(LN_S) $$i $$i-$(version) ); \
178           fi;\
179         done
180
181 in-place ::
182         $(MAKE) $(MFLAGS) config-pkgs bindir=`pwd`/bin/$(platform)/$(package)-$(version) libdir=`pwd`/lib/$(platform) datadir=`pwd`/share/$(package)-$(version)
183         $(MAKE) $(MFLAGS) mk-version-symlinks
184         @echo "Finished configuring..to use, add `pwd`/bin/$(platform)/$(package)-$(version) to your PATH."
185
186 install-dirs ::
187         $(INSTALL_DIR) $(bindir)
188         (cd lib/$(platform)/$(package)-$(version); find . -type d -exec sh -c '../../../$(INSTALL_DIR) $$0 $(real_libdir)/$$0' {} \; )
189         (cd share/$(package)-$(version); find . -type d -exec sh -c '../../$(INSTALL_DIR) $(real_datadir)/$$0' {} \; )
190
191 install :: config-pkgs mk-version-symlinks install-dirs install-bin install-libs install-datas
192
193 .PHONY: install-bin install-libs install-datas
194
195 install-bin:
196         for i in $(PACKAGE_BINS); do \
197            $(INSTALL_BIN) bin/$(platform)/$(package)-$(version)/$$i $(bindir); \
198         done;
199         for i in $(VERSION_SYMLINKS_FOR) ""; do \
200            if [ "x$$i" != "x" ]; then           \
201                 ( cd $(bindir);                 \
202                   $(RM) $$i-$(version);         \
203                   $(MV) $$i $$i-$(version);     \
204                   $(LN_S) $$i-$(version) $$i    \
205                 );                              \
206            fi;                                  \
207         done
208
209
210 install-libs:
211         (cd lib/$(platform)/$(package)-$(version); find . -type f -exec sh -c '$(CP) $$0 $(real_libdir)/$$0' {} \; )
212
213 install-datas:
214         (cd share/$(package)-$(version); find . -type f -exec sh -c '$(INSTALL_DATA) $$0 $(real_datadir)/$$0' {} \; )
215
216 show-install-setup:
217         @echo "Install setup..."
218         @echo "bindir  = $(bindir)"
219         @echo "libdir  = $(libdir) (real_libdir  = $(real_libdir))"
220         @echo "datadir = $(datadir) (real_datadir = $(real_datadir))"
221
222 #
223 # Documentation targets, install-docs for the whole lot, or
224 # install-{dvi,html,info}
225 #
226
227 .PHONY: show-install-setup install-docs install-html install-info install-dirs-dvi install-dirs-html install-dirs-info
228
229 install-docs : install-html install-dvi install-info
230
231 install-dvi: install-dirs-dvi
232         $(INSTALL_DATA) dvi/$(package)-$(version)/* $(dvidir)
233
234 install-info: install-dirs-info
235         $(INSTALL_DATA) info/$(package)-$(version)/* $(infodir)
236
237 install-html: install-dirs-html
238         $(INSTALL_DATA) html/$(package)-$(version)/* $(htmldir)
239
240 install-dirs-html:
241         $(INSTALL_DIR) $(htmldir) 
242
243 install-dirs-info:
244         $(INSTALL_DIR) $(infodir) 
245
246 install-dirs-dvi:
247         $(INSTALL_DIR) $(dvidir) 
248