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