Add typed holes support in Template Haskell.
[ghc.git] / rules / foreachLibrary.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://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 # For each line in $(TOP)/packages:
14 # libraries/foo tag ...
15 # this calls
16 # $(call $1,foo,tag)
17 #
18 # Except! If there's a libraries/foo/ghc-packages then it calls
19 # $(call $1,foo/bar,tag)
20 # for each word 'bar' in libraries/foo/ghc-packages.
21 #
22
23 # We use an FEL_ prefix for the variable names, to avoid trampling on
24 # other variables, as make has no concept of local variables.
25
26 # We need to handle the following packages specially, as those don't
27 # have an entry in the packages file, since they don't live in
28 # repositories of their own:
29 #
30 # - base
31 # - ghc-boot
32 # - ghc-prim
33 # - integer-gmp
34 # - integer-simple
35 # - template-haskell
36
37 define foreachLibrary
38 # $1 = function to call for each library
39 # We will give it the package path and the tag as arguments
40 $$(foreach hashline,libraries/ghc-boot#-#no-remote-repo#no-vcs \
41 libraries/base#-#no-remote-repo#no-vcs \
42 libraries/ghc-prim#-#no-remote-repo#no-vcs \
43 libraries/integer-gmp#-#no-remote-repo#no-vcs \
44 libraries/integer-simple#-#no-remote-repo#no-vcs \
45 libraries/template-haskell#-#no-remote-repo#no-vcs \
46 $$(shell grep '^libraries/' packages | sed 's/ */#/g'),\
47 $$(eval FEL_line := $$(subst #,$$(space),$$(hashline))) \
48 $$(eval FEL_libdir := $$(word 1,$$(FEL_line))) \
49 $$(eval FEL_tag := $$(word 2,$$(FEL_line))) \
50 $$(eval FEL_libroot := $$(patsubst libraries/%,%,$$(FEL_libdir))) \
51 $$(if $$(wildcard $$(FEL_libdir)/ghc-packages), \
52 $$(foreach lib,$$(shell cat $$(FEL_libdir)/ghc-packages), \
53 $$(eval $$(call $1,$$(FEL_libroot)/$$(lib),$$(FEL_tag)))), \
54 $$(if $$(wildcard $$(FEL_libdir)/), \
55 $$(eval $$(call $1,$$(FEL_libroot),$$(FEL_tag))))))
56 endef