Make building binary dists work with cabalised libraries
[ghc.git] / distrib / Makefile
1
2 include Makefile-vars
3
4 .PHONY: in-place config-pkgs mk-version-symlinks install-dirs install
5
6 config-pkgs ::
7 @echo "Configuring $(package), version $(version), on $(platform) ..."
8 @for i in $(PACKAGE_PRL_SCRIPTS) ""; do \
9 if test "$$i"; then \
10 echo "Creating a configured version of $$i .."; \
11 $(RM) bin/$(platform)/$$i.bak; \
12 if [ -f bin/$(platform)/$$i ]; then $(MV) bin/$(platform)/$$i bin/$(platform)/$$i.bak; fi; \
13 echo "#! $(PERL)" > bin/$(platform)/$$i ; \
14 echo '$$'"bindir='$(bindir)';" >> bin/$(platform)/$$i ; \
15 echo '$$'"libdir='$(libdir)';" >> bin/$(platform)/$$i ; \
16 echo '$$'"libexecdir='$(libdir)';" >> bin/$(platform)/$$i ; \
17 echo '$$'"datadir='$(datadir)';" >> bin/$(platform)/$$i ; \
18 echo '$$'"SED='$(SED)';" >> bin/$(platform)/$$i ; \
19 echo '$$'"DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)';" >> bin/$(platform)/$$i ; \
20 cat bin/$(platform)/$$i.prl >> bin/$(platform)/$$i ; \
21 $(CHMOD) $(BIN_PERMS) bin/$(platform)/$$i; \
22 echo "Done."; \
23 fi; \
24 done
25 @for i in $(PACKAGE_LIB_PRL_SCRIPTS) ""; do \
26 if test "$$i"; then \
27 echo "Creating a configured version of $$i .."; \
28 $(RM) lib/$(platform)/$$i.bak; \
29 if [ -f lib/$(platform)/$$i ]; then $(MV) lib/$(platform)/$$i lib/$(platform)/$$i.bak; fi; \
30 echo "#! $(PERL)" > lib/$(platform)/$$i ; \
31 echo '$$'"bindir='$(bindir)';" >> lib/$(platform)/$$i ; \
32 echo '$$'"libdir='$(libdir)';" >> lib/$(platform)/$$i ; \
33 echo '$$'"libexecdir='$(libdir)';" >> lib/$(platform)/$$i ; \
34 echo '$$'"datadir='$(datadir)';" >> lib/$(platform)/$$i ; \
35 echo '$$'"SED='$(SED)';" >> lib/$(platform)/$$i ; \
36 echo '$$'"DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)';" >> lib/$(platform)/$$i ; \
37 cat lib/$(platform)/$$i.prl >> lib/$(platform)/$$i; \
38 $(CHMOD) $(BIN_PERMS) lib/$(platform)/$$i; \
39 echo "Done."; \
40 fi; \
41 done
42 @for i in $(PACKAGE_SH_SCRIPTS) ""; do \
43 if test "$$i"; then \
44 echo "Creating a configured version of $$i .."; \
45 $(RM) bin/$(platform)/$$i.bak; \
46 if [ -f bin/$(platform)/$$i ]; then $(MV) bin/$(platform)/$$i bin/$(platform)/$$i.bak; fi; \
47 echo "#! $(SH)" > bin/$(platform)/$$i ; \
48 echo "bindir='$(bindir)'" >> bin/$(platform)/$$i ; \
49 echo "libdir='$(libdir)'" >> bin/$(platform)/$$i ; \
50 echo "libexecdir='$(libdir)'" >> bin/$(platform)/$$i ; \
51 echo "datadir='$(datadir)'" >> bin/$(platform)/$$i ; \
52 echo "SED='$(SED)'" >> bin/$(platform)/$$i ; \
53 echo "DEFAULT_TMPDIR='$(DEFAULT_TMPDIR)'" >> bin/$(platform)/$$i ; \
54 cat bin/$(platform)/$$i.sh >> bin/$(platform)/$$i; \
55 $(CHMOD) $(BIN_PERMS) bin/$(platform)/$$i; \
56 echo "Done."; \
57 fi; \
58 done
59 @for i in $(PACKAGE_LIB_SPLICED_FILES) ""; do \
60 if test "$$i"; then \
61 echo "Creating a configured version of $$i .."; \
62 $(PERL) -i.bak -lpe 's|\$$libdir|$(libdir)|g;s|\$$datadir|$(datadir)|g' lib/$(platform)/$$i; \
63 fi; \
64 done
65 @if test "$(platform)" = "powerpc-apple-darwin"; then \
66 echo "Configuring install names..."; \
67 for i in lib/$(platform)/*; do \
68 sh fix_install_names.sh "$(libdir)" "$$i"; \
69 done; \
70 echo "Done."; \
71 fi
72
73 in-place ::
74 $(MAKE) $(MFLAGS) config-pkgs bindir=`pwd`/bin/$(platform) libdir=`pwd`/lib/$(platform) datadir=`pwd`/share
75 @if test -x "./post-inplace-script" ; then \
76 echo "Running project-specific post-inplace script ..." ; \
77 ./post-inplace-script $(platform) `pwd` \
78 $(package)-$(version); \
79 echo "Done" ; \
80 fi
81 @echo "Finished configuring..to use, add `pwd`/bin/$(platform) to your PATH."
82
83 install-dirs ::
84 $(INSTALL_DIR) $(bindir)
85 (cd lib/$(platform); find . -type d -exec sh -c '../../$(INSTALL_DIR) $$0 $(libdir)/$$0' {} \; )
86 (cd share; find . -type d -exec sh -c '../$(INSTALL_DIR) $(datadir)/$$0' {} \; )
87
88 install :: config-pkgs install-dirs install-bin install-libs install-datas install-docs postinstall denounce
89
90 .PHONY: install-bin install-libs install-datas postinstall denounce
91
92 denounce:
93 @echo
94 @echo =======================================================================
95 @echo Installation of $(package)-$(version) was successful.
96 @echo
97 @echo To use, add $(bindir) to your PATH.
98 @echo
99 @if test -f share/html/index.html; then \
100 echo For documentation, see $(htmldir)/index.html ; \
101 elif test -d share/html ; then \
102 echo Docs can be found in $(htmldir). ; \
103 else \
104 echo "Warning: this binary distribution does NOT contain documentation!" ; \
105 fi
106 @echo =======================================================================
107
108 postinstall:
109 @if test -x "./post-install-script" ; then \
110 echo "Running project-specific post-install script ..." ; \
111 ./post-install-script $(platform) $(libdir) ; \
112 echo "Done" ; \
113 fi
114
115 install-bin:
116 for i in $(PACKAGE_BIN_INSTALL) ""; do \
117 if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i $(bindir); fi; \
118 done;
119 for i in $(PACKAGE_BINS) ""; do \
120 if test -n "$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i$(exeext) $(bindir); fi; \
121 done;
122 for i in $(PACKAGE_OPT_BINS) ""; do \
123 if test -n "$$i" -a ! -f "$(bindir)/$$i" ; then $(INSTALL_BIN) bin/$(platform)/$$i$(exeext) $(bindir); fi; \
124 done;
125 @for i in $(VERSION_SYMLINKS_FOR) ""; do \
126 if [ "x$$i" != "x" ]; then \
127 ( cd $(bindir); \
128 if ( $(PERL) -e '$$fn="'$$i'"; exit ((! -f $$fn || -l $$fn) ? 0 : 1);' ); then \
129 echo "Creating a symbolic link from $$i-$(version) to $$i"; \
130 $(RM) $$i; \
131 $(LN_S) $$i-$(version) $$i; \
132 else \
133 echo "Creating a symbolic link from $$i-$(version) to $$i failed: \`$$i' already exists"; \
134 echo "Perhaps remove \`$$i' manually?"; \
135 exit 1; \
136 fi;\
137 ); \
138 fi; \
139 done
140
141 install-libs:
142 (cd lib/$(platform); find . -type f -exec sh -c '$(CP) $$0 $(libdir)/$$0' {} \; )
143 $(MAKE) -C libraries install IN_BIN_DIST=1
144
145 install-datas:
146 for i in `(cd share; find . -type f )`; do \
147 $(INSTALL_DATA) share/$$i $(datadir)/$$i; \
148 done
149
150 show-install-setup:
151 @echo "Install setup..."
152 @echo "bindir = $(bindir)"
153 @echo "libdir = $(libdir) (libdir = $(libdir))"
154 @echo "datadir = $(datadir) (datadir = $(datadir))"
155
156 #
157 # Documentation targets: install-docs.
158 #
159
160 .PHONY: show-install-setup install-docs install-dirs-docs
161
162 install-docs : install-dirs-docs
163 if test -d share/html ; then $(CP) -r share/html/* $(htmldir) ; fi
164 for i in share/*.ps; do \
165 if test -f "$$i"; then \
166 $(CP) $$i $(psdir) ; \
167 fi \
168 done
169
170 install-dirs-docs:
171 $(INSTALL_DIR) $(htmldir)
172