GHC new build system megapatch
[ghc-hetmet.git] / rules / build-package-way.mk
1
2 define build-package-way # $1 = dir, $2 = distdir, $3 = way, $4 = stage
3
4 $(call distdir-way-opts,$1,$2,$3)
5 $(call hs-suffix-rules,$1,$2,$3)
6 $$(foreach dir,$$($1_$2_HS_SRC_DIRS),\
7   $$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$3,$$(dir))))
8
9 $(call hs-objs,$1,$2,$3)
10
11 $1_$2_$3_LIB = $1/$2/build/libHS$$($1_PACKAGE)-$$($1_$2_VERSION)$$($3__way).a
12
13 $1_$2_$3_MKSTUBOBJS = find $1/$2/build -name "*_stub.$$($3_osuf)" -print
14 # HACK ^^^ we tried to use $(wildcard), but apparently it fails due to
15 # make using cached directory contents, or something.
16
17 # Build the ordinary .a library
18 ifeq "$$($1_$2_SplitObjs)" "YES"
19 $$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS)
20         $$(RM) $$@
21         (echo $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)`; find $$(patsubst %.$$($3_osuf),%_split,$$($1_$2_$3_HS_OBJS)) -name '*.$$($3_osuf)' -print) | xargs $$(AR) $$(EXTRA_AR_ARGS) $$@
22 else
23 $$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS)
24         $$(RM) $$@
25         echo $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) $$($1_$2_$3_HS_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` | xargs $$(AR) $$(EXTRA_AR_ARGS) $$@
26 endif
27
28 $(call all-target,$1_$2,all_$1_$2_$3)
29 $(call all-target,$1_$2_$3,$$($1_$2_$3_LIB))
30
31 # Don't put bootstrapping packages in the bindist
32 ifneq "$4" "0"
33 BINDIST_HI += $$($1_$2_$3_HI)
34 BINDIST_LIBS += $$($1_$2_$3_LIB)
35 endif
36
37 # Build the GHCi library
38 ifeq "$3" "v"
39 $1_$2_GHCI_LIB = $1/$2/build/HS$$($1_PACKAGE)-$$($1_$2_VERSION).$$($3_osuf)
40 # Don't put bootstrapping packages in the bindist
41 ifneq "$4" "0"
42 BINDIST_LIBS += $$($1_$2_GHCI_LIB)
43 endif
44 $$($1_$2_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS)
45         $$(RM) $$@
46         $$(LD) -r -o $$@ $$(EXTRA_LD_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)`
47
48 $(call all-target,$1_$2,$$($1_$2_GHCI_LIB))
49 endif
50
51 endef
52