Merge remote branch 'origin/master' into ghc-new-co
[ghc.git] / rules / extra-packages.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2010 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 # For each package P marked as "dph" or "extra" in $(TOP)/packages:
14 # if $(TOP)/libraries/P exists, then
15 # if $(TOP)/libraries/P/ghc-packages exists, then
16 # * add each package from $(TOP)/libraries/P/ghc-packages2 to the list of
17 # packages.
18 # Note: ghc-packages2 might have a different list from
19 # ghc-packages, this is to support dph which has some
20 # packages that are automatically derived from a single
21 # source by the build system).
22 # * add $(TOP)/libraries/P to $(BUILD_DIRS)
23 # This step is necessary in the case of dph, which has some
24 # build system code in libraries/dph/ghc.mk, but
25 # libraries/dph is not itself a package.
26 # else
27 # add P to the list of packages
28
29 define extra-packages
30 $$(foreach p,$$(patsubst libraries/%,%,$$(wildcard $$(shell grep '^[^ #][^ ]* \+\(dph\|extra\) \+[^ ]\+ \+[^ ]\+ \+[^ ]\+' packages | sed 's/ .*//'))),\
31 $$(if $$(wildcard libraries/$$p/ghc-packages),\
32 $$(eval BUILD_DIRS += libraries/$$p) \
33 $$(foreach q,$$(shell cat libraries/$$p/ghc-packages2),$$(eval $$(call extra-package,$$p,$$p/$$q))),\
34 $$(eval $$(call extra-package,$$p,$$p)))\
35 )
36 endef
37
38 define extra-package # $1 = package root, $2 = package
39 $(call trace, extra-package($1,$2))
40
41 EXTRA_PACKAGES += $2
42 $$(eval $$(call addPackage,$2))
43
44 endef