summaryrefslogtreecommitdiff
path: root/distrib/Makefile-bin.in
blob: 6df1e056d8ad176af0d4ba4900b820ef4031b6d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#
# @configure_input@
#
# 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.
#
# Using the package directly is easy, just do `make in-place'. (The
# distribution will *not* work straight out of the box, you'll have to do
# this first)
#
# 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
#     installed in  /usr/foo/lib/<package>-<version>, e.g.,
#     /usr/foo/lib/ghc-3.00. If you don't want the package/version
#     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
#     complete control, see $(real_datadir)
#
#  * platform 
#     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.
#
#  * htmldir
#     where to install the HTML documentation files.
#  * pdfdir
#     where to install the PDF documentation files.
#  * psdir
#     where to install the Postscript documentation files.
#
# 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.
#
# 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@
libdir      = @libdir@/$(package)-$(version)
datadir     = @datadir@/$(package)-$(version)

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

# default
htmldir     = $(datadir)/html
psdir       = $(datadir)
pdfdir      = $(datadir)


PERL        = @PerlCmd@
SH	    = /bin/sh
RM          = rm -f
MV          = mv
CP          = cp
LN_S        = @LN_S@
CHMOD       = chmod
INSTALL	    = @INSTALL@
exeext      = @exeext@
SED	    = @SedCmd@
DEFAULT_TMPDIR = /tmp

# sigh
INSTALL_DIR  = ./mkdirhier

#
# Set of package scripts for which you'd like a name-<version> symlink
# to be created, i.e., create a symlink, ghc-$(version), pointing to ghc to
# avoid version vertigo.
#
VERSION_SYMLINKS_FOR=$(PACKAGE_LINKS)

# Binaries to install
PACKAGE_BIN_INSTALL=$(PACKAGE_PRL_SCRIPTS) $(PACKAGE_SH_SCRIPTS)

#----------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) ..."
	@for i in $(PACKAGE_PRL_SCRIPTS) ""; do \
	  if test "$$i"; then \
	   echo "Creating a configured version of $$i .."; \
	   $(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 ; \
	   echo '$$'"DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)';" >> bin/$(platform)/$$i ; \
	   cat bin/$(platform)/$$i.prl   	    >> bin/$(platform)/$$i ; \
	   $(CHMOD) $(BIN_PERMS) bin/$(platform)/$$i; \
	   echo "Done."; \
	  fi; \
	done
	@for i in $(PACKAGE_LIB_PRL_SCRIPTS) ""; do \
	  if test "$$i"; then \
	   echo "Creating a configured version of $$i .."; \
	   $(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 ; \
	   echo '$$'"DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)';"  >> lib/$(platform)/$$i ; \
	   cat lib/$(platform)/$$i.prl >> lib/$(platform)/$$i; \
	   $(CHMOD) $(BIN_PERMS) lib/$(platform)/$$i; \
	   echo "Done."; \
	  fi; \
	done
	@for i in $(PACKAGE_SH_SCRIPTS) ""; do \
	  if test "$$i"; then \
	   echo "Creating a configured version of $$i .."; \
	   $(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 ; \
	   echo "DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)'" >> bin/$(platform)/$$i ; \
	   cat bin/$(platform)/$$i.sh >> bin/$(platform)/$$i; \
	   $(CHMOD) $(BIN_PERMS) bin/$(platform)/$$i; \
	   echo "Done."; \
	  fi; \
	done
	@for i in $(PACKAGE_LIB_SPLICED_FILES) ""; do \
	  if test "$$i"; then \
	    echo "Creating a configured version of $$i .."; \
            $(PERL) -i.bak -lpe 's|\$$libdir|$(libdir)|g;s|\$$datadir|$(datadir)|g' lib/$(platform)/$$i; \
          fi; \
	done
	@if test "$(platform)" = "powerpc-apple-darwin"; then \
	  echo "Configuring install names..."; \
	  for i in lib/$(platform)/*; do \
	    sh fix_install_names.sh "$(libdir)" "$$i"; \
	  done; \
	  echo "Done."; \
	fi

in-place ::
	$(MAKE) $(MFLAGS) config-pkgs bindir=`pwd`/bin/$(platform) libdir=`pwd`/lib/$(platform) datadir=`pwd`/share
	@if test -x "./post-inplace-script" ; then \
		echo "Running project-specific post-inplace script ..." ; \
		./post-inplace-script $(platform) `pwd` \
			$(package)-$(version); \
		echo "Done" ; \
	fi
	@echo "Finished configuring..to use, add `pwd`/bin/$(platform) to your PATH."

install-dirs ::
	$(INSTALL_DIR) $(bindir)
	(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' {} \; )

install :: config-pkgs install-dirs install-bin install-libs install-datas install-docs postinstall denounce

.PHONY: install-bin install-libs install-datas postinstall denounce

denounce:
	@echo
	@echo =======================================================================
	@echo Installation of $(package)-$(version) was successful.
	@echo
	@echo To use, add $(bindir) to your PATH.
	@echo
	@if test -f share/html/index.html; then \
	   echo For documentation, see $(htmldir)/index.html ; \
	elif test -d share/html ; then \
	   echo Docs can be found in $(htmldir). ; \
	else \
	   echo "Warning: this binary distribution does NOT contain documentation!" ; \
	fi
	@echo =======================================================================

postinstall:
	@if test -x "./post-install-script" ; then \
		echo "Running project-specific post-install script ..." ; \
		./post-install-script $(platform) $(libdir) ; \
		echo "Done" ; \
	fi

install-bin:
	for i in $(PACKAGE_BIN_INSTALL) ""; do \
	   if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i $(bindir); fi; \
	done;
	for i in $(PACKAGE_BINS) ""; do \
	   if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i$(exeext) $(bindir); fi; \
	done;
	for i in $(PACKAGE_OPT_BINS) ""; do \
	   if test -n "$$i" -a ! -f "$(bindir)/$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i$(exeext) $(bindir); fi; \
	done;
	@for i in $(VERSION_SYMLINKS_FOR) ""; do \
	   if [ "x$$i" != "x" ]; then 		\
	   	( cd $(bindir); 		\
		  if ( $(PERL) -e '$$fn="'$$i'"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
	   	     echo "Creating a symbolic link from $$i-$(version) to $$i"; \
	   	     $(RM) $$i; \
	             $(LN_S) $$i-$(version) $$i; \
	          else \
	             echo "Creating a symbolic link from $$i-$(version) to $$i failed: \`$$i' already exists"; \
	             echo "Perhaps remove \`$$i' manually?"; \
	             exit 1; \
	          fi;\
		); 				\
	   fi; 					\
	done


install-libs:
	(cd lib/$(platform); find . -type f -exec sh -c '$(CP) $$0 $(libdir)/$$0' {} \; )

install-datas:
	for i in `(cd share; find . -type f )`; do \
	   $(INSTALL_DATA) share/$$i $(datadir)/$$i; \
	done

show-install-setup:
	@echo "Install setup..."
	@echo "bindir  = $(bindir)"
	@echo "libdir  = $(libdir) (libdir  = $(libdir))"
	@echo "datadir = $(datadir) (datadir = $(datadir))"

#
# Documentation targets: install-docs.
#

.PHONY: show-install-setup install-docs install-dirs-docs

install-docs : install-dirs-docs
	if test -d share/html ; then $(CP) -r share/html/* $(htmldir) ; fi
	for i in share/*.ps; do \
		if test -f "$$i"; then \
		      $(CP) $$i $(psdir) ; \
		fi \
	done

install-dirs-docs:
	$(INSTALL_DIR) $(htmldir)