Makefile-bin.in 9.72 KB
Newer Older
sof's avatar
sof committed
1
2
3
#
# @configure_input@
#
4
5
6
7
8
9
# Instructions for configuring an fptools package.
#
# There are two ways you can get started with an fptools package, either
# by using the unpacked distribution tree in-situ or by installing the
# package.
#
10
# Using the package directly is easy, just do `make in-place'. (The
sof's avatar
sof committed
11
12
# distribution will *not* work straight out of the box, you'll have to do
# this first)
13
14
15
16
17
18
19
20
21
22
23
#
# To install the package, you'll have to set one or more of the
# following variables:
#
#  * bindir 
#     path to directory of where you want the executables
#     to be installed.
#  * libdir
#     where you want the library archives to go.
#     Note, if you specify /usr/foo/lib for libdir,
#     the library files for your fptools package will be
sof's avatar
sof committed
24
#     installed in  /usr/foo/lib/<package>-<version>, e.g.,
sof's avatar
sof committed
25
#     /usr/foo/lib/ghc-3.00. If you don't want the package/version
26
27
28
29
30
31
32
#     directory appended, you'll have to modify $(real_libdir)
#     below.
#
#  * datadir
#     path to where the platform-independent files will go.
#     As for libdir, the effective path for the platform-indep
#     stuff is $(datadir)/<package>-<version>. If you want
sof's avatar
sof committed
33
#     complete control, see $(real_datadir)
34
35
#
#  * platform 
sof's avatar
sof committed
36
37
38
#     the platform you're installing for. The configure script
#     makes an educated guess, so you'll only have to set this
#     if it clashes with your reality, I guess.
39
40
#
#  * htmldir
41
42
43
44
45
#     where to install the HTML documentation files.
#  * pdfdir
#     where to install the PDF documentation files.
#  * psdir
#     where to install the Postscript documentation files.
46
47
48
49
50
#
# For more complete instructions, consult the INSTALL file
# that came with the bundle, and/or consult the installation
# documentation in one of the document directories.
#
sof's avatar
sof committed
51
52
53
54
55
56
# Please report any bugs, problems etc. with installing and using this bundle
# Makefile setup to glasgow-haskell-bugs@dcs.gla.ac.uk
# 

# Where the different pieces of the bundle should go:
bindir      = @bindir@
57
58
libdir      = @libdir@/$(package)-$(version)
datadir     = @datadir@/$(package)-$(version)
sof's avatar
sof committed
59
60
61
62

platform    = @TargetPlatform@
prefix      = @prefix@
exec_prefix = @exec_prefix@
63

sof's avatar
sof committed
64
# default
65
htmldir     = $(datadir)/html
66
67
psdir       = $(datadir)
pdfdir      = $(datadir)
68

sof's avatar
sof committed
69
70

PERL        = @PerlCmd@
71
SH	    = /bin/sh
sof's avatar
sof committed
72
73
RM          = rm -f
MV          = mv
74
CP          = cp
sof's avatar
sof committed
75
76
77
LN_S        = @LN_S@
CHMOD       = chmod
INSTALL	    = @INSTALL@
sof's avatar
sof committed
78
exeext      = @exeext@
sof's avatar
sof committed
79
SED	    = @SedCmd@
80
DEFAULT_TMPDIR = /tmp
sof's avatar
sof committed
81

sof's avatar
sof committed
82
83
# sigh
INSTALL_DIR  = ./mkdirhier
84

sof's avatar
sof committed
85
86
#
# Set of package scripts for which you'd like a name-<version> symlink
sof's avatar
sof committed
87
# to be created, i.e., create a symlink, ghc-$(version), pointing to ghc to
sof's avatar
sof committed
88
89
# avoid version vertigo.
#
90
VERSION_SYMLINKS_FOR=$(PACKAGE_LINKS)
sof's avatar
sof committed
91
92

# Binaries to install
sof's avatar
sof committed
93
PACKAGE_BIN_INSTALL=$(PACKAGE_PRL_SCRIPTS) $(PACKAGE_SH_SCRIPTS)
sof's avatar
sof committed
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

#----------end of user-serviceable parts------------
#
#
# How to install the different pieces
# 
INSTALL_BIN  = $(INSTALL) $(INSTALL_BIN_OPTS)
INSTALL_LIB  = $(INSTALL) $(INSTALL_LIB_OPTS)
INSTALL_DATA = $(INSTALL) $(INSTALL_DATA_OPTS)

# What's common to all installs
INSTALL_OPTS= $(EXTRA_INSTALL_OPTS)

BIN_PERMS = 755
LIB_PERMS = 644

INSTALL_BIN_OPTS  = -m $(BIN_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_BIN_OPTS)
INSTALL_LIB_OPTS  = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_LIB_OPTS)
INSTALL_DATA_OPTS = -m $(LIB_PERMS) $(INSTALL_OPTS) $(EXTRA_INSTALL_DATA_OPTS)

.PHONY: in-place config-pkgs mk-version-symlinks install-dirs install

config-pkgs ::
	@echo "Configuring $(package), version $(version), on $(platform) ..."
118
119
	@for i in $(PACKAGE_PRL_SCRIPTS) ""; do \
	  if test "$$i"; then \
sof's avatar
sof committed
120
	   echo "Creating a configured version of $$i .."; \
121
122
123
124
125
126
127
128
	   $(RM) bin/$(platform)/$$i.bak; \
	   if [ -f bin/$(platform)/$$i ]; then $(MV) bin/$(platform)/$$i bin/$(platform)/$$i.bak; fi; \
	   echo "#! $(PERL)"  		            >  bin/$(platform)/$$i ; \
	   echo '$$'"bindir='$(bindir)';"           >> bin/$(platform)/$$i ; \
	   echo '$$'"libdir='$(libdir)';"      	    >> bin/$(platform)/$$i ; \
	   echo '$$'"libexecdir='$(libdir)';"       >> bin/$(platform)/$$i ; \
	   echo '$$'"datadir='$(datadir)';"         >> bin/$(platform)/$$i ; \
	   echo '$$'"SED='$(SED)';"		    >> bin/$(platform)/$$i ; \
129
	   echo '$$'"DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)';" >> bin/$(platform)/$$i ; \
130
131
	   cat bin/$(platform)/$$i.prl   	    >> bin/$(platform)/$$i ; \
	   $(CHMOD) $(BIN_PERMS) bin/$(platform)/$$i; \
sof's avatar
sof committed
132
	   echo "Done."; \
133
134
	  fi; \
	done
135
136
	@for i in $(PACKAGE_LIB_PRL_SCRIPTS) ""; do \
	  if test "$$i"; then \
sof's avatar
sof committed
137
	   echo "Creating a configured version of $$i .."; \
138
139
140
141
142
143
144
145
	   $(RM) lib/$(platform)/$$i.bak; \
	   if [ -f lib/$(platform)/$$i ]; then $(MV) lib/$(platform)/$$i lib/$(platform)/$$i.bak; fi; \
	   echo "#! $(PERL)"                       >  lib/$(platform)/$$i ; \
	   echo '$$'"bindir='$(bindir)';"          >> lib/$(platform)/$$i ; \
	   echo '$$'"libdir='$(libdir)';"          >> lib/$(platform)/$$i ; \
	   echo '$$'"libexecdir='$(libdir)';"      >> lib/$(platform)/$$i ; \
	   echo '$$'"datadir='$(datadir)';"        >> lib/$(platform)/$$i ; \
	   echo '$$'"SED='$(SED)';"		   >> lib/$(platform)/$$i ; \
146
	   echo '$$'"DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)';"  >> lib/$(platform)/$$i ; \
147
148
	   cat lib/$(platform)/$$i.prl >> lib/$(platform)/$$i; \
	   $(CHMOD) $(BIN_PERMS) lib/$(platform)/$$i; \
sof's avatar
sof committed
149
	   echo "Done."; \
150
151
	  fi; \
	done
152
153
	@for i in $(PACKAGE_SH_SCRIPTS) ""; do \
	  if test "$$i"; then \
154
	   echo "Creating a configured version of $$i .."; \
155
156
157
158
159
160
161
162
	   $(RM) bin/$(platform)/$$i.bak; \
	   if [ -f bin/$(platform)/$$i ]; then $(MV) bin/$(platform)/$$i bin/$(platform)/$$i.bak; fi; \
	   echo "#! $(SH)"                      >  bin/$(platform)/$$i ; \
	   echo "bindir='$(bindir)'"            >> bin/$(platform)/$$i ; \
	   echo "libdir='$(libdir)'"            >> bin/$(platform)/$$i ; \
	   echo "libexecdir='$(libdir)'"        >> bin/$(platform)/$$i ; \
	   echo "datadir='$(datadir)'"          >> bin/$(platform)/$$i ; \
	   echo "SED='$(SED)'"			>> bin/$(platform)/$$i ; \
163
	   echo "DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)'" >> bin/$(platform)/$$i ; \
164
165
	   cat bin/$(platform)/$$i.sh >> bin/$(platform)/$$i; \
	   $(CHMOD) $(BIN_PERMS) bin/$(platform)/$$i; \
166
	   echo "Done."; \
167
168
	  fi; \
	done
169
170
171
	@for i in $(PACKAGE_LIB_SPLICED_FILES) ""; do \
	  if test "$$i"; then \
	    echo "Creating a configured version of $$i .."; \
172
            $(PERL) -i.bak -lpe 's|\$$libdir|$(libdir)|g;s|\$$datadir|$(datadir)|g' lib/$(platform)/$$i; \
173
174
          fi; \
	done
175
	@if test "$(platform)" = "powerpc-apple-darwin"; then \
176
177
178
179
180
181
	  echo "Configuring install names..."; \
	  for i in lib/$(platform)/*; do \
	    sh fix_install_names.sh "$(libdir)" "$$i"; \
	  done; \
	  echo "Done."; \
	fi
182

sof's avatar
sof committed
183
in-place ::
sof's avatar
sof committed
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 ..." ; \
sof's avatar
sof committed
187
		./post-inplace-script $(platform) `pwd` \
188
189
190
			$(package)-$(version); \
		echo "Done" ; \
	fi
sof's avatar
sof committed
191
	@echo "Finished configuring..to use, add `pwd`/bin/$(platform) to your PATH."
192

sof's avatar
sof committed
193
194
install-dirs ::
	$(INSTALL_DIR) $(bindir)
195
196
	(cd lib/$(platform); find . -type d -exec sh -c '../../$(INSTALL_DIR) $$0 $(libdir)/$$0' {} \; )
	(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
201
202
203
.PHONY: install-bin install-libs install-datas postinstall denounce

denounce:
	@echo
204
205
	@echo =======================================================================
	@echo Installation of $(package)-$(version) was successful.
206
	@echo
207
	@echo To use, add $(bindir) to your PATH.
208
209
210
211
	@echo
	@if test -f share/html/index.html; then \
	   echo For documentation, see $(htmldir)/index.html ; \
	elif test -d share/html ; then \
212
	   echo Docs can be found in $(htmldir). ; \
213
214
215
	else \
	   echo "Warning: this binary distribution does NOT contain documentation!" ; \
	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
223
		echo "Done" ; \
	fi
224

sof's avatar
sof committed
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; \
sof's avatar
sof committed
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
237
	   if [ "x$$i" != "x" ]; then 		\
	   	( cd $(bindir); 		\
sof's avatar
sof committed
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"; \
sof's avatar
sof committed
240
241
242
	   	     $(RM) $$i; \
	             $(LN_S) $$i-$(version) $$i; \
	          else \
243
	             echo "Creating a symbolic link from $$i-$(version) to $$i failed: \`$$i' already exists"; \
sof's avatar
sof committed
244
245
246
	             echo "Perhaps remove \`$$i' manually?"; \
	             exit 1; \
	          fi;\
247
248
		); 				\
	   fi; 					\
sof's avatar
sof committed
249
	done
250
251


sof's avatar
sof committed
252
install-libs:
253
	(cd lib/$(platform); find . -type f -exec sh -c '$(CP) $$0 $(libdir)/$$0' {} \; )
254

sof's avatar
sof committed
255
install-datas:
256
257
258
	for i in `(cd share; find . -type f )`; do \
	   $(INSTALL_DATA) share/$$i $(datadir)/$$i; \
	done
259

sof's avatar
sof committed
260
261
262
show-install-setup:
	@echo "Install setup..."
	@echo "bindir  = $(bindir)"
263
264
	@echo "libdir  = $(libdir) (libdir  = $(libdir))"
	@echo "datadir = $(datadir) (datadir = $(datadir))"
265

sof's avatar
sof committed
266
#
267
# Documentation targets: install-docs.
sof's avatar
sof committed
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
275
276
	for i in share/*.ps; do \
		$(CP) $$i $(psdir) ; \
	done
sof's avatar
sof committed
277

278
install-dirs-docs:
sof's avatar
sof committed
279
280
	$(INSTALL_DIR) $(htmldir)