Make binary-dist tarballs automatically, and add support for uploading
[ghc-hetmet.git] / Makefile
1 ############################################################################
2 #
3 #               This is the top-level Makefile for GHC
4 #
5 # Targets: 
6 #
7 #       bootstrap (DEFAULT)
8 #               Builds GHC, then builds the libraries,
9 #               then uses this GHC ("stage 1") to build itself
10 #               ("stage 2").
11 #
12 #       bootstrap2
13 #               Same as bootstrap
14 #
15 #       bootstrap3
16 #               bootstrap2 + we build GHC one more time ("stage 3")
17 #
18 #       stage1
19 #               Just build up to stage 1
20 #
21 #       stage2
22 #               Just build stage 2 (stage 1 must be built)
23 #
24 #       stage3
25 #               Just build stage 3 (stage 2 must be built)
26 #
27 #       all
28 #               Same as bootstrap
29 #
30 #       install
31 #               Install everything, including stage 2 compiler by default
32 #               (override with stage=3, for example).
33 #
34 #       dist
35 #               Make a source dist (WARNING: runs 'make distclean' first)
36 #
37 #       binary-dist
38 #               Builds a binary distribution
39 #
40 #       hc-file-bundle
41 #               Builds an HC-file bundle, for bootstrapping
42 #
43 #       clean, distclean, maintainer-clean
44 #               Increasing levels of cleanliness
45 #
46 ############################################################################
47
48 TOP=.
49 include $(TOP)/mk/boilerplate.mk
50
51 #
52 # Order is important! It's e.g. necessary to descend into include/
53 # before the rest to have a config.h, etc.
54 #
55 # If we're booting from .hc files, swap the order
56 # we descend into subdirs - to boot utils must be before driver.
57 #
58 .PHONY: stage1 stage2 stage3 bootstrap bootstrap2 bootstrap3
59
60 # We can't 'make boot' in libraries until stage1 is built
61 ifeq "$(BootingFromHc)" "YES"
62 SUBDIRS_NOLIB = includes rts compat compiler docs utils driver
63 else
64 SUBDIRS_NOLIB = includes compat utils driver docs compiler rts
65 endif
66
67 SUBDIRS = $(SUBDIRS_NOLIB) libraries
68
69 # Sanity check that all the core libraries are in the tree, to catch
70 # failure to run darcs-all.
71 check-packages :
72         @for d in `cat libraries/core-packages`; do \
73           if test ! -d libraries/$$d; then \
74              echo "Looks like you're missing libraries/$$d,"; \
75              echo "maybe you haven't done 'sh darcs-all get'?"; \
76              exit 1; \
77           fi \
78         done
79
80 stage1 : check-packages
81         $(MAKE) -C utils/mkdependC boot
82         @case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
83         for i in $(SUBDIRS_NOLIB); do \
84           echo "------------------------------------------------------------------------"; \
85           echo "== $(MAKE) boot $(MFLAGS);"; \
86           echo " in $(shell pwd)/$$i"; \
87           echo "------------------------------------------------------------------------"; \
88           $(MAKE) --no-print-directory -C $$i $(MFLAGS) boot; \
89           if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ;  then true; else exit 1; fi; \
90         done; \
91         for i in $(SUBDIRS_NOLIB); do \
92           echo "------------------------------------------------------------------------"; \
93           echo "== $(MAKE) all $(MFLAGS);"; \
94           echo " in $(shell pwd)/$$i"; \
95           echo "------------------------------------------------------------------------"; \
96           $(MAKE) --no-print-directory -C $$i $(MFLAGS) all; \
97           if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ;  then true; else exit 1; fi; \
98         done
99         @$(MAKE) -C libraries boot
100         @$(MAKE) -C libraries all
101
102 stage2 : check-packages
103         $(MAKE) -C compiler boot stage=2
104         $(MAKE) -C compiler stage=2
105
106 stage3 : check-packages
107         $(MAKE) -C compiler boot stage=3
108         $(MAKE) -C compiler stage=3
109
110 bootstrap  : bootstrap2
111
112 bootstrap2 : stage1
113         $(MAKE) stage2
114
115 bootstrap3 : bootstrap2
116         $(MAKE) stage3
117
118 all :: bootstrap
119
120 # -----------------------------------------------------------------------------
121 # Installing
122
123 # We want to install the stage 2 bootstrapped compiler by default, but we let
124 # the user override this by saying 'make install stage=1', for example.
125 ifeq "$(stage)" ""
126 INSTALL_STAGE = stage=2
127 else
128 INSTALL_STAGE =
129 endif
130
131 # Same as default rule, but we pass $(INSTALL_STAGE) to $(MAKE) too
132 install :: check-packages
133         @case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
134         for i in $(SUBDIRS); do \
135           echo "------------------------------------------------------------------------"; \
136           echo "== $(MAKE) $@ $(MFLAGS);"; \
137           echo " in $(shell pwd)/$$i"; \
138           echo "------------------------------------------------------------------------"; \
139           $(MAKE) --no-print-directory -C $$i $(INSTALL_STAGE) $(MFLAGS) $@; \
140           if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ;  then true; else exit 1; fi; \
141         done
142
143 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
144 # These files need to be in the InstallShield
145 # INSTALL_DATAS rather than INSTALL_DOCS is used so these files go
146 # in the top-level directory of the distribution
147 INSTALL_DATAS += ANNOUNCE LICENSE README
148 endif
149
150 # If installing on Windows with MinGW32, copy the gcc compiler, headers and libs
151 # and the perl interpreter and dll into the GHC prefix directory.
152 # Gcc and Perl source locations derived from configuration data.
153 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
154 ifneq "$(WhatGccIsCalled)" ""
155 install ::
156         -mkdir $(prefix)/gcc-lib
157         -mkdir $(prefix)/include
158         -mkdir $(prefix)/include/mingw
159         -cp -rp $(GccDir)../include/* $(prefix)/include/mingw
160         -cp -rp $(GccDir)../lib/gcc-lib/mingw32/$(GccVersion)/* $(prefix)/gcc-lib
161         -cp -rp $(GccDir)../lib/gcc/mingw32/$(GccVersion)/* $(prefix)/gcc-lib
162         -cp -rp $(GccDir)../libexec/gcc/mingw32/$(GccVersion)/* $(prefix)/gcc-lib
163         -cp $(GccDir)../lib/*.* $(prefix)/gcc-lib
164         -cp $(GccDir)gcc.exe $(prefix)
165         -cp $(GccDir)as.exe $(prefix)/gcc-lib
166         -cp $(GccDir)ld.exe $(prefix)/gcc-lib
167         -cp $(GccDir)dllwrap.exe $(prefix)/gcc-lib
168         -cp $(GccDir)dlltool.exe $(prefix)/gcc-lib
169         -cp $(GhcDir)../perl.exe $(prefix)
170         -cp $(GhcDir)../perl56.dll $(prefix)
171 endif
172 endif
173
174 install-docs ::
175         @case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
176         for i in $(SUBDIRS); do \
177           echo "------------------------------------------------------------------------"; \
178           echo "== $(MAKE) $@ $(MFLAGS);"; \
179           echo " in $(shell pwd)/$$i"; \
180           echo "------------------------------------------------------------------------"; \
181           $(MAKE) --no-print-directory -C $$i $(INSTALL_STAGE) $(MFLAGS) $@; \
182           if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ;  then true; else exit 1; fi; \
183         done
184
185 # -----------------------------------------------------------------------------
186 # Making a binary distribution
187 #
188 # `dist' `binary-dist'
189 #      Create a distribution tar file for this program. The tar file
190 #      should be set up so that the file names in the tar file start with
191 #      a subdirectory name which is the name of the package it is a
192 #      distribution for. This name can include the version number.
193 #
194 #      For example, the distribution tar file of GCC version 1.40 unpacks
195 #      into a subdirectory named `gcc-1.40'.
196
197 #      The easiest way to do this is to create a subdirectory
198 #      appropriately named, use ln or cp to install the proper files in
199 #      it, and then tar that subdirectory.
200
201 #      The dist target should explicitly depend on all non-source files
202 #      that are in the distribution, to make sure they are up to date in
203 #      the distribution. See Making Releases.
204 #
205 #       binary-dist is a GHC addition for binary distributions
206
207
208 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
209 BinDistShScripts = ghc-$(ProjectVersion) ghci-$(ProjectVersion) ghc-pkg-$(ProjectVersion) hsc2hs
210 else
211 BinDistShScripts =
212 endif
213
214 BinDistPrlScripts = ghcprof
215 BinDistLibPrlScripts = ghc-asm ghc-split
216 BinDistBins = hp2ps runghc
217 BinDistOptBins = runhaskell
218 BinDistLinks = ghc ghci ghc-pkg
219 BinDistLibSplicedFiles = package.conf
220 BinDistDirs = includes compiler docs driver libraries rts utils
221
222 BIN_DIST_NAME=ghc-$(ProjectVersion)
223 BIN_DIST_TMPDIR=$(FPTOOLS_TOP_ABS)
224
225 BIN_DIST_TARBALL=ghc-$(ProjectVersion)-$(TARGETPLATFORM).tar.bz2
226
227 BIN_DIST_TOP= distrib/Makefile-bin.in \
228               distrib/configure-bin.ac \
229               distrib/INSTALL \
230               distrib/README \
231               ANNOUNCE \
232               LICENSE \
233               utils/mkdirhier/mkdirhier \
234               install-sh \
235               config.guess \
236               config.sub   \
237               aclocal.m4
238
239 ifeq "$(darwin_TARGET_OS)" "1"
240 BIN_DIST_TOP+=mk/fix_install_names.sh
241 endif
242
243 .PHONY: binary-dist-pre binary-dist binary-pack
244
245 binary-dist:: binary-dist-pre
246
247 binary-dist-pre::
248 ifeq "$(BIN_DIST)" ""
249         @echo "WARNING: To run the binary-dist target, you need to set BIN_DIST=1 in mk/build.mk" && exit 1
250 endif
251         -rm -rf $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)
252         -$(RM) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME).tar.gz
253         @for i in $(BinDistDirs); do                     \
254           if test -d "$$i"; then                         \
255            echo $(MKDIRHIER) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM); \
256            $(MKDIRHIER) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM); \
257            echo $(MKDIRHIER) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM); \
258            $(MKDIRHIER) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM); \
259            echo $(MKDIRHIER) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/share; \
260            $(MKDIRHIER) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/share; \
261            echo $(MAKE) -C $$i $(MFLAGS) $(INSTALL_STAGE) install \
262                 prefix=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME) \
263                 exec_prefix=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME) \
264                 bindir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM) \
265                 libdir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM) \
266                 libexecdir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM) \
267                 datadir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/share; \
268            $(MAKE) -C $$i $(MFLAGS) $(INSTALL_STAGE) install \
269                 prefix=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME) \
270                 exec_prefix=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME) \
271                 bindir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM) \
272                 libdir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM) \
273                 libexecdir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM) \
274                 datadir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/share; \
275           fi; \
276         done
277
278 binary-dist::
279         @for i in $(BIN_DIST_TOP); do \
280           if test -f "$$i"; then \
281              echo cp $$i $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME); \
282              cp $$i $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME); \
283           fi; \
284         done;
285         @echo "Configuring the Makefile for this project..."
286         touch $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
287         echo "package = ghc" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
288         echo "version = $(ProjectVersion)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
289         echo "PACKAGE_SH_SCRIPTS = $(BinDistShScripts)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
290         echo "PACKAGE_PRL_SCRIPTS = $(BinDistPrlScripts)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
291         echo "PACKAGE_LIB_PRL_SCRIPTS = $(BinDistLibPrlScripts)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
292         echo "PACKAGE_LIB_SPLICED_FILES = $(BinDistLibSplicedFiles)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
293         echo "PACKAGE_BINS = $(BinDistBins)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
294         echo "PACKAGE_OPT_BINS = $(BinDistOptBins)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
295         echo "PACKAGE_LINKS = $(BinDistLinks)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
296         cat $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile-bin.in >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
297         @echo "Generating a shippable configure script.."
298         $(MV) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/configure-bin.ac $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/configure.ac
299         ( cd $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME); autoconf )
300 #
301 # binary dist'ing the documentation.  
302 # The default documentation to build/install is given below; overrideable
303 # via build.mk or the 'make' command-line.
304
305 ifndef BINDIST_DOC_WAYS
306
307 ifneq "$(XSLTPROC)" ""
308 BINDIST_DOC_WAYS = html
309 ifneq "$(FOP)" ""
310 BINDIST_DOC_WAYS += ps pdf
311 else
312 ifneq "$(PDFXMLTEX)" ""
313 BINDIST_DOC_WAYS += pdf
314 endif
315 ifneq "$(XMLTEX)" ""
316 ifneq "$(DVIPS)" ""
317 BINDIST_DOC_WAYS += ps
318 endif # DVIPS
319 endif # XMLTEX
320 endif # FOP
321 endif # XSLTPROC
322
323 endif # BINDIST_DOC_WAYS
324
325 binary-dist ::
326 ifneq "$(DIR_DOCBOOK_XSL)" ""
327         @for i in $(BinDistDirs); do                            \
328           if test -d "$$i"; then                                \
329             $(MAKE) -C $$i $(MFLAGS) $(BINDIST_DOC_WAYS);       \
330             echo $(MAKE) -C $$i $(MFLAGS) install-docs XMLDocWays="$(BINDIST_DOC_WAYS)" \
331                 prefix=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)      \
332                 exec_prefix=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME) \
333                 bindir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM) \
334                 libdir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM) \
335                 libexecdir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM) \
336                 datadir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/share; \
337             $(MAKE) -C $$i $(MFLAGS) install-docs XMLDocWays="$(BINDIST_DOC_WAYS)" \
338                 prefix=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)      \
339                 exec_prefix=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME) \
340                 bindir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM) \
341                 libdir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM) \
342                 libexecdir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM) \
343                 datadir=$(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/share; \
344           fi \
345         done
346 endif
347
348 # Rename scripts to $i.prl and $i.sh where necessary.
349 # ToDo: do this in a cleaner way...
350
351 ifneq "$(BinDistPrlScripts)" ""
352 binary-dist::
353         @for i in $(BinDistPrlScripts); do \
354              echo "Renaming $$i to $$i.prl"; \
355             $(MV) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM)/$$i  $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM)/$$i.prl; \
356         done
357 endif
358
359 ifneq "$(BinDistLibPrlScripts)" ""
360 binary-dist::
361         @for i in $(BinDistLibPrlScripts); do \
362              echo "Renaming $$i to $$i.prl"; \
363             $(MV) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM)/$$i  $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM)/$$i.prl; \
364         done
365 endif
366
367 ifneq "$(BinDistShScripts)" ""
368 binary-dist::
369         @for i in $(BinDistShScripts); do \
370             if test -x $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM)/$$i ; then \
371                 echo "Renaming $$i to $$i.sh"; \
372                 $(MV) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM)/$$i  $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM)/$$i.sh; \
373             fi \
374         done
375 endif
376
377 # Tar up the distribution and build a manifest
378 binary-dist ::
379         ( cd $(BIN_DIST_TMPDIR); tar cf - $(BIN_DIST_NAME) | bzip2 >$(BIN_DIST_TARBALL) )
380         ( cd $(BIN_DIST_TMPDIR); bunzip2 -c $(BIN_DIST_TARBALL) | tar tf - | sed "s/^ghc-$(ProjectVersion)/fptools/" | sort >bin-manifest-$(ProjectVersion) )
381
382 # Upload the distribution
383 ifneq "$(PublishLocation)" ""
384 binary-dist ::
385         @for i in 0 1 2 3 4 5 6 7 8 9; do \
386                 echo "Try $$i: $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation)"; \
387                 if $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation); then break; fi\
388         done
389 endif
390
391 binary-dist::
392         @echo "Mechanical and super-natty! Inspect the result and *if* happy; freeze, sell and get some sleep!"
393
394 # -----------------------------------------------------------------------------
395 # Building source distributions
396 #
397 # Do it like this: 
398 #
399 #       $ make
400 #       $ make dist
401 #
402 # WARNING: `make dist' calls `make distclean' before tarring up the tree.
403 #
404
405 .PHONY: dist
406
407 #
408 # Directory in which we're going to build the src dist
409 #
410 SRC_DIST_NAME=ghc-$(ProjectVersion)
411 SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAME)
412
413 #
414 # Files to include in source distributions
415 #
416 SRC_DIST_DIRS += mk docs distrib $(filter-out docs distrib,$(SUBDIRS))
417 SRC_DIST_FILES += \
418         configure.ac config.guess config.sub configure \
419         aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
420         ghc.spec.in
421
422 # -----------------------------------------------------------------------------
423 # Source distributions
424
425 # A source dist is built from a complete build tree, because we
426 # require some extra files not contained in a darcs checkout: the
427 # output from Happy and Alex, for example.
428
429 # The steps performed by 'make dist' are as follows:
430 #   - create a complete link-tree of the current build tree in /tmp
431 #   - run 'make distclean' on that tree
432 #   - remove a bunch of other files that we know shouldn't be in the dist
433 #   - tar up first the extralibs package, then the main source package
434
435 EXTRA_LIBS=$(patsubst %, $(SRC_DIST_NAME)/libraries/%, $(shell cat libraries/extra-packages))
436
437 SRC_DIST_TARBALL = ghc-$(ProjectVersion)-src.tar.bz2
438 SRC_DIST_EXTRALIBS_TARBALL = ghc-$(ProjectVersion)-src-extralibs.tar.bz2
439
440 dist ::
441         $(RM) -rf $(SRC_DIST_DIR)
442         $(RM) $(SRC_DIST_NAME).tar.gz
443         mkdir $(SRC_DIST_DIR)
444         ( cd $(SRC_DIST_DIR) \
445           && for i in $(SRC_DIST_DIRS); do mkdir $$i; (cd $$i && lndir $(FPTOOLS_TOP_ABS)/$$i ); done \
446           && for i in $(SRC_DIST_FILES); do $(LN_S) $(FPTOOLS_TOP_ABS)/$$i .; done \
447           && $(MAKE) distclean \
448           && $(RM) -rf compiler/stage[123] mk/build.mk \
449           && $(FIND) $(SRC_DIST_DIRS) \( -name _darcs -o -name SRC -o -name "autom4te*" -o -name "*~" -o -name ".cvsignore" -o -name "\#*" -o -name ".\#*" -o -name "log" -o -name "*-SAVE" -o -name "*.orig" -o -name "*.rej" \) -print | xargs $(RM) -rf \
450         )
451         tar chf - $(EXTRA_LIBS) | bzip2 >$(FPTOOLS_TOP_ABS)/$(SRC_DIST_EXTRALIBS_TARBALL)
452         $(RM) -rf $(EXTRA_LIBS)
453         tar chf - $(SRC_DIST_NAME) 2>$src_log | bzip2 >$(FPTOOLS_TOP_ABS)/$(SRC_DIST_TARBALL)
454
455 # Upload the distribution(s)
456 # Retrying is to work around buggy firewalls that corrupt large file transfers
457 # over SSH.
458 ifneq "$(PublishLocation)" ""
459 dist ::
460         @for i in 0 1 2 3 4 5 6 7 8 9; do \
461                 echo "Try $$i: $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation)"; \
462                 if $(PublishCp) $(SRC_DIST_EXTRALIBS_TARBALL) $(PublishLocation); then break; fi\
463         done
464         @for i in 0 1 2 3 4 5 6 7 8 9; do \
465                 echo "Try $$i: $(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation)"; \
466                 if $(PublishCp) $(SRC_DIST_TARBALL) $(PublishLocation); then break; fi\
467         done
468 endif
469
470 # -----------------------------------------------------------------------------
471 # HC file bundles
472
473 hc-file-bundle :
474         $(RM) -r ghc-$(ProjectVersion)
475         $(LN_S) . ghc-$(ProjectVersion)
476         $(FIND) ghc-$(ProjectVersion)/compiler \
477              ghc-$(ProjectVersion)/utils \
478              ghc-$(ProjectVersion)/compat \
479              ghc-$(ProjectVersion)/libraries -follow \
480           \( -name "*.hc" -o -name "*_hsc.[ch]" -o -name "*_stub.[ch]" \) -print > hc-files-to-go
481         for f in `$(FIND) ghc-$(ProjectVersion)/compiler ghc-$(ProjectVersion)/utils ghc-$(ProjectVersion)/libraries -name "*.hsc" -follow -print` ""; do \
482              if test "x$$f" != "x" && test -e `echo "$$f" | sed 's/hsc$$/hs/g'`; then \
483                 echo `echo "$$f" | sed 's/hsc$$/hs/g' ` >> hc-files-to-go ; \
484              fi; \
485         done;
486         for f in `$(FIND) ghc-$(ProjectVersion)/compiler ghc-$(ProjectVersion)/rts -name "*.cmm" -follow -print` ""; do \
487              if test "x$$f" != "x"; then \
488                 echo `echo "$$f" | sed 's/cmm$$/hc/g' ` >> hc-files-to-go ; \
489              fi; \
490         done;
491         echo ghc-$(ProjectVersion)/libraries/base/GHC/PrimopWrappers.hs >> hc-files-to-go
492         echo ghc-$(ProjectVersion)/compiler/parser/Parser.hs >> hc-files-to-go
493         echo ghc-$(ProjectVersion)/compiler/parser/ParserCore.hs >> hc-files-to-go
494         echo ghc-$(ProjectVersion)/compiler/main/ParsePkgConf.hs >> hc-files-to-go
495         echo ghc-$(ProjectVersion)/libraries/haskell-src/Language/Haskell/Parser.hs >> hc-files-to-go
496         tar czf ghc-$(ProjectVersion)-$(TARGETPLATFORM)-hc.tar.gz `cat hc-files-to-go`
497
498 # -----------------------------------------------------------------------------
499 # Cleaning
500
501 CLEAN_FILES += hc-files-to-go *-hc.tar.gz
502
503 DIST_CLEAN_FILES += config.cache config.status mk/config.h mk/stamp-h \
504         ghc.spec docs/users_guide/ug-book.xml
505
506 # don't clean config.mk: it's needed when cleaning stuff later on
507 LATE_DIST_CLEAN_FILES += mk/config.mk 
508
509 extraclean::
510         $(RM) -rf autom4te.cache
511
512 # -----------------------------------------------------------------------------
513
514 # Turn off target.mk's rules for 'all', 'boot' and 'install'.
515 NO_BOOT_TARGET=YES
516 NO_ALL_TARGET=YES
517 NO_INSTALL_TARGET=YES
518
519 include $(TOP)/mk/target.mk
520
521 # -----------------------------------------------------------------------------
522