From ce14988222b8da2abc57c68a087a61efe5ba709b Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Tue, 28 Apr 2009 12:34:52 +0000 Subject: [PATCH] extend the rules/c-objs macro to take the way as a parameter Previously we only built library package "cbits" the vanilla way, afterall C code does not need to be built differently for profiling builds. However for dynamic libs the C code needs to be built with -fPIC, so we do need to be able to build package .c (and .s?) files multiple ways. --- rules/build-package-way.mk | 12 ++++++------ rules/build-package.mk | 4 ++-- rules/build-prog.mk | 6 +++--- rules/c-objs.mk | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk index 12492d7..1f0832a 100644 --- a/rules/build-package-way.mk +++ b/rules/build-package-way.mk @@ -28,13 +28,13 @@ $1_$2_$3_MKSTUBOBJS = find $1/$2/build -name "*_stub.$$($3_osuf)" -print # Build the ordinary .a library ifeq "$$($1_$2_SplitObjs)" "YES" -$$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) +$$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$(RM) $$@ - (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) $$@ + (echo $$($1_$2_v_C_OBJS) $$($1_$2_v_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) $$@ else -$$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) +$$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$(RM) $$@ - echo $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) $$($1_$2_$3_HS_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` | xargs $$(AR) $$(EXTRA_AR_ARGS) $$@ + echo $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_$3_HS_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` | xargs $$(AR) $$(EXTRA_AR_ARGS) $$@ endif $(call all-target,$1_$2,all_$1_$2_$3) @@ -53,9 +53,9 @@ $1_$2_GHCI_LIB = $1/$2/build/HS$$($1_PACKAGE)-$$($1_$2_VERSION).$$($3_osuf) ifneq "$4" "0" BINDIST_LIBS += $$($1_$2_GHCI_LIB) endif -$$($1_$2_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) +$$($1_$2_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$(RM) $$@ - $$(LD) -r -o $$@ $$(EXTRA_LD_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` + $$(LD) -r -o $$@ $$(EXTRA_LD_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` $(call all-target,$1_$2,$$($1_$2_GHCI_LIB)) endif diff --git a/rules/build-package.mk b/rules/build-package.mk index b2b3093..863dc73 100644 --- a/rules/build-package.mk +++ b/rules/build-package.mk @@ -123,8 +123,8 @@ $1_$2_SplitObjs = NO endif endif -# C and S files are built only once, not once per way -$(call c-objs,$1,$2) +# C and S files are built the "v" vanlilla way +$(call c-objs,$1,$2,v) $(call distdir-opts,$1,$2,$3) $(call c-suffix-rules,$1,$2,v,YES) diff --git a/rules/build-prog.mk b/rules/build-prog.mk index 1a2256b..f5412fb 100644 --- a/rules/build-prog.mk +++ b/rules/build-prog.mk @@ -92,12 +92,12 @@ $(call hs-suffix-rules,$1,$2,v) $$(foreach dir,$$($1_$2_HS_SRC_DIRS),\ $$(eval $$(call hs-suffix-rules-srcdir,$1,$2,v,$$(dir)))) -$(call c-objs,$1,$2) +$(call c-objs,$1,$2,v) $(call hs-objs,$1,$2,v) -$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_v_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) $$($1_$2_OTHER_OBJS) +$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) $$(MKDIRHIER) $$(dir $$@) - $$($1_$2_HC) -o $$@ $$($1_$2_v_ALL_HC_OPTS) $$(LD_OPTS) $$($1_$2_v_HS_OBJS) $$($1_$2_C_OBJS) $$($1_$2_S_OBJS) $$($1_$2_OTHER_OBJS) + $$($1_$2_HC) -o $$@ $$($1_$2_v_ALL_HC_OPTS) $$(LD_OPTS) $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) # Note [lib-depends] if this program is built with stage1 or greater, we # need to depend on the libraries too. NB. since $(ALL_LIBS) and diff --git a/rules/c-objs.mk b/rules/c-objs.mk index fbf3553..3263f5b 100644 --- a/rules/c-objs.mk +++ b/rules/c-objs.mk @@ -10,8 +10,8 @@ # # ----------------------------------------------------------------------------- -define c-objs # args: $1 = dir, $2 = distdir -# C and S files are built only once, not once per way -$1_$2_C_OBJS = $$(patsubst %.c,$1/$2/build/%.$$(v_osuf),$$($1_$2_C_SRCS)) -$1_$2_S_OBJS = $$(patsubst %.S,$1/$2/build/%.$$(v_osuf),$$($1_$2_S_SRCS)) +define c-objs # args: $1 = dir, $2 = distdir, $3 = way +# C and S files are usually only built for way "v", but sometimes "dyn" too +$1_$2_$3_C_OBJS = $$(patsubst %.c,$1/$2/build/%.$$($3_osuf),$$($1_$2_C_SRCS)) +$1_$2_$3_S_OBJS = $$(patsubst %.S,$1/$2/build/%.$$($3_osuf),$$($1_$2_S_SRCS)) endef -- 1.7.10.4