1 # -----------------------------------------------------------------------------
3 # (c) 2009 The University of Glasgow
5 # This file is part of the GHC build system.
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
11 # -----------------------------------------------------------------------------
14 define hs-sources # args: $1 = dir, $2 = distdir
16 ifeq "$$($1_$2_HS_SRC_DIRS)" ""
20 # Here we collect all the .hs/.lhs source files that we can find. If
21 # we can't find a Haskell source file for a given module, then presumably
22 # it can be generated by preprocessing something (.hsc, .y, .x etc.), so
23 # we depend on dist/build/Foo.hs in anticipation that the implicit rules
24 # will put the preprocessed source file there.
26 # NB. use :=, we only want this thing evaluated once.
28 $1_$2_HS_SRCS := $$(foreach file,$$($1_$2_SLASH_MODS),\
31 $$(foreach dir,$$($1_$2_HS_SRC_DIRS) $2/build/autogen,\
32 $1/$$(dir)/$$(file).hs $1/$$(dir)/$$(file).lhs)) \
33 $1/$2/build/$$(file).hs))
35 # .hs-boot files must be in the same place as the .hs file they go
36 # with (GHC assumes this). When we preprocess a source file, and
37 # that module has a .hs-boot or .lhs-boot file, we must arrange to
38 # copy the file into the distdir so that it ends up alongside the
39 # preprocessed .hs file. This complicated macro figures out for which
40 # files we need to do this, so we can add them as dependencies of the
43 # for each .hs file in the build dir,
44 # if there is a .hs-boot or .lhs-boot file for it in a source dir,
45 # we want that file in the build dir.
47 # NB. use :=, we only want this thing evaluated once.
49 $1_$2_HS_BOOT_SRCS := $$(foreach dir,$$($1_$2_HS_SRC_DIRS),\
50 $$(subst $1/$$(dir),$1/$2/build,\
52 $$(subst $1/$2/build,$1/$$(dir),\
54 $$(filter $1/$2/build%,$$($1_$2_HS_SRCS)),\
55 $$(patsubst %.hs,%.hs-boot,$$(file)) \
56 $$(patsubst %.hs,%.lhs-boot,$$(file)))))))