Enable building Cabal with parsec
[ghc.git] / rules / sdist-ghc-file.mk
1 # -----------------------------------------------------------------------------
2 #
3 # This file is part of the GHC build system.
4 #
5 # To understand how the build system works and how to modify it, see
6 # http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
7 # http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
8 #
9 # -----------------------------------------------------------------------------
10
11
12 # Add files generated by alex and happy to a source distribution.
13 #
14 # Invoke like this:
15 #
16 # $(eval $(call sdist-ghc-file,compiler,stage2,parser,Parser,y))
17 #
18 # This adds the file 'compiler/stage2/build/Parser.hs' to the sdist, in the
19 # same directory as 'compiler/parser/Parser.y' (which is renamed).
20
21 define sdist-ghc-file
22 # $1 = dir
23 # $2 = distdir
24 # $3 = srcdir (can be empty)
25 # $4 = filename
26 # $5 = extension
27
28 .PHONY: sdist_$1_$2_$4
29
30 # We should do this before creating the `sdist-ghc` tarball, or when just
31 # running `make sdist-ghc-prep`.
32 sdist-ghc-prep : sdist_$1_$2_$4
33
34 # But first create SRC_DIST_GHC_DIR.
35 sdist_$1_$2_$4 : sdist-ghc-prep-tree
36
37 # Generate the .hs files if they don't exist yet, then do actual copying and
38 # moving.
39 sdist_$1_$2_$4 : $1/$2/build/$4.hs
40 "$(CP)" $1/$2/build/$4.hs $(SRC_DIST_GHC_DIR)/$1/$3
41 mv $(SRC_DIST_GHC_DIR)/$1/$3/$4.$5 $(SRC_DIST_GHC_DIR)/$1/$3/$4.$5.source
42
43 # And make sure the rules for generating the .hs files exist, even when we
44 # didn't generate all package-data.mk files.
45 $$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$3))
46 endef
47
48 # -----------------------------------------------------------------------------
49 # Variant of sdist-ghc-file whose `$3`-argument is interpreted
50 # differently in a more appropriate way for cabal-packages
51
52 define sdist-ghc-file2
53 # $1 = dir
54 # $2 = distdir
55 # $3 = moduledir
56 # $4 = filename
57 # $5 = extension
58
59 .PHONY: sdist_$1_$2_$4
60
61 # We should do this before creating the `sdist-ghc` tarball, or when just
62 # running `make sdist-ghc-prep`.
63 sdist-ghc-prep : sdist_$1_$2_$4
64
65 # But first create SRC_DIST_GHC_DIR.
66 sdist_$1_$2_$4 : sdist-ghc-prep-tree
67
68 # Generate the .hs files if they don't exist yet, then do actual copying and
69 # moving.
70 sdist_$1_$2_$4 : $1/$2/build/$3/$4.hs
71 "$(CP)" $1/$2/build/$3/$4.hs $(SRC_DIST_GHC_DIR)/$1/$3
72 mv $(SRC_DIST_GHC_DIR)/$1/$3/$4.$5 $(SRC_DIST_GHC_DIR)/$1/$3/$4.$5.source
73
74 # And make sure the rules for generating the .hs files exist, even when we
75 # didn't generate all package-data.mk files.
76 $$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$3))
77 endef