Make stage-specific CC variables
authorIan Lynagh <igloo@earth.li>
Sat, 23 Apr 2011 12:40:52 +0000 (13:40 +0100)
committerIan Lynagh <igloo@earth.li>
Sat, 23 Apr 2011 12:40:52 +0000 (13:40 +0100)
This allows different gcc's to be used when building different stages,
which we need to do when cross-compiling.

libffi/ghc.mk
mk/config.mk.in
rules/build-prog.mk
rules/c-suffix-rules.mk
rules/hs-suffix-rules-srcdir.mk
rules/package-config.mk

index 1efb8fb..46400ab 100644 (file)
@@ -114,7 +114,7 @@ $(libffi_STAMP_CONFIGURE):
            PATH=`pwd`:$$PATH; \
            export PATH; \
            cd build && \
-           CC=$(WhatGccIsCalled) \
+           CC=$(CC_STAGE1) \
            LD=$(LD) \
            AR=$(AR) \
            NM=$(NM) \
@@ -177,7 +177,7 @@ $(eval $(call all-target,libffi,$(INSTALL_HEADERS) $(INSTALL_LIBS)))
 libffi/dist-install/build/HSffi.o: libffi/dist-install/build/libHSffi.a
        cd libffi/dist-install/build && \
          touch empty.c && \
-         "$(CC)" $(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE1) -c empty.c -o HSffi.o
+         "$(CC_STAGE1)" $(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE1) -c empty.c -o HSffi.o
 
 $(eval $(call all-target,libffi,libffi/dist-install/build/HSffi.o))
 
index 4d93905..9434218 100644 (file)
@@ -544,6 +544,10 @@ WhatGccIsCalled = @WhatGccIsCalled@
 GccVersion      = @GccVersion@
 GccLT34         = @GccLT34@
 CC              = $(WhatGccIsCalled)
+CC_STAGE0       = $(CC)
+CC_STAGE1       = $(CC)
+CC_STAGE2       = $(CC)
+CC_STAGE3       = $(CC)
 
 # C compiler and linker flags from configure (e.g. -m<blah> to select
 # correct C compiler backend). The stage number is the stage of GHC
index c39f947..99093d3 100644 (file)
@@ -156,7 +156,7 @@ $1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2
        "$$($1_$2_HC)" -o $$@ $$($1_$2_v_ALL_HC_OPTS) $$(LD_OPTS) $$($1_$2_GHC_LD_OPTS) $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
 else
 $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) | $$$$(dir $$$$@)/.
-       "$$(CC)" -o $$@ $$($1_$2_v_ALL_CC_OPTS) $$(LD_OPTS) $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) $$($1_$2_v_EXTRA_CC_OPTS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
+       "$$($1_$2_CC)" -o $$@ $$($1_$2_v_ALL_CC_OPTS) $$(LD_OPTS) $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) $$($1_$2_v_EXTRA_CC_OPTS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
 endif
 
 # Note [lib-depends] if this program is built with stage1 or greater, we
index fa7dd6f..bba73a8 100644 (file)
@@ -43,19 +43,19 @@ $1/$2/build/%.$$($3_way_)s : $1/%.c $$($1_$2_HC_DEP)
 else
 
 $1/$2/build/%.$$($3_osuf) : $1/%.c | $$$$(dir $$$$@)/.
-       "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@
+       "$$($1_$2_CC)" $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@
 
 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.c
-       "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@
+       "$$($1_$2_CC)" $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@
 
 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_way_)s
        "$$(AS)" $$($1_$2_$3_ALL_AS_OPTS) -o $$@ $$<
 
 $1/$2/build/%.$$($3_osuf) : $1/%.S | $$$$(dir $$$$@)/.
-       "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@
+       "$$($1_$2_CC)" $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@
 
 $1/$2/build/%.$$($3_way_)s : $1/$2/build/%.c
-       "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -S $$< -o $$@
+       "$$($1_$2_CC)" $$($1_$2_$3_ALL_CC_OPTS) -S $$< -o $$@
 
 endif
 
index 7e9c8d3..bdb9d00 100644 (file)
@@ -52,10 +52,10 @@ endif
 # .hs->.o rule, I don't know why --SDM
 
 $1/$2/build/%.$$($3_osuf) : $1/$4/%.hc includes/ghcautoconf.h includes/ghcplatform.h | $$$$(dir $$$$@)/.
-       "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -Iincludes -x c -c $$< -o $$@
+       "$$($1_$2_CC)" $$($1_$2_$3_ALL_CC_OPTS) -Iincludes -x c -c $$< -o $$@
 
 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc includes/ghcautoconf.h includes/ghcplatform.h
-       "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -Iincludes -x c -c $$< -o $$@
+       "$$($1_$2_CC)" $$($1_$2_$3_ALL_CC_OPTS) -Iincludes -x c -c $$< -o $$@
 
 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_way_)hc
 #      "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
index 2091779..65df6bf 100644 (file)
@@ -16,6 +16,7 @@ $(call trace, package-config($1,$2,$3))
 $(call profStart, package-config($1,$2,$3))
 
 $1_$2_HC = $$(GHC_STAGE$3)
+$1_$2_CC = $$(CC_STAGE$3)
 
 # configuration stuff that depends on which GHC we're building with
 ifeq "$3" "0"