This is an update of a similar patch posted a few days ago.
It seems to be working quite well for cross-compiles across
all architectures, as well as narive builds.

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/


[BUILD] CPPFLAGS, CFLAGS and LDFLAGS fixes

* Set internal CPPFLAGS as EXTRA_CPPFLAGS, CFLAGS as EXTRA_CFLAGS,
  and LDFLAGS as EXTRA_LDFLAGS
  - Don't overwrite CPPFLAGS, LDLFAGS or CFLAGS from the environment
  - They are irrelevant for BUILD_CC
  - When cross-compiling for a ppc64 host on a non-ppc64 host,
    EXTRA_CFLAGS, which is included in BUILD_CPPFLAGS contains
  -mcall-aixdesc, which does not work on i386 at least
* Use LDFLAGS when linking kexec
  - Append rather than overwrite in purgatory/Makefile

The purpose of these changes is three-fold. 

  * CPPFLAGS, CFLAGS and LDFLAGS from the environment really ought
    to be honoured. For one thing;
  * Without these changes, the confgiure taget in
    the toplevel makefile can't work
  * Without these changes, cross compiling does not work -
    well, I can't work out how to get it to work anyway.
    
Signed-Off-By: Simon Horman <[EMAIL PROTECTED]>

Index: kexec-tools-build-fix+vivek_kcore/Makefile
===================================================================
--- kexec-tools-build-fix+vivek_kcore.orig/Makefile     2006-09-22 
11:18:49.000000000 +0900
+++ kexec-tools-build-fix+vivek_kcore/Makefile  2006-09-22 11:19:14.000000000 
+0900
@@ -13,7 +13,7 @@
 # Useful for building binary packages
 DESTDIR =
 
-CPPFLAGS:= -I./include -I./util_lib/include \
+EXTRA_CPPFLAGS:= -I./include -I./util_lib/include \
        -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"' \
        $(DEFS) $(EXTRA_CFLAGS)
 
@@ -54,8 +54,9 @@
 
 # cc-option
 # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
-cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
-             > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+cc-option = $(shell if $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(1) -S -o /dev/null \
+            -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else \
+            echo "$(2)"; fi ;)
 
 # Utility function library
 #
Index: kexec-tools-build-fix+vivek_kcore/configure.ac
===================================================================
--- kexec-tools-build-fix+vivek_kcore.orig/configure.ac 2006-09-22 
11:18:49.000000000 +0900
+++ kexec-tools-build-fix+vivek_kcore/configure.ac      2006-09-22 
11:19:14.000000000 +0900
@@ -50,7 +50,9 @@
 if test "${host_alias}" ; then
        OBJDIR="$OBJDIR-${host_alias}"
 fi 
-EXTRA_CFLAGS=""
+
+EXTRA_CFLAGS='-Wall -g -fno-strict-aliasing $(CPPFLAGS) $(EXTRA_CPPFLAGS)'
+BUILD_CFLAGS='-O2 -Wall $(CPPFLAGS)'
 
 # Check whether ppc64. Add -m64 for building 64-bit binary
 # Add -mcall-aixdesc to generate dot-symbols as in gcc 3.3.3
@@ -104,11 +106,6 @@
        AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, inflateInit_, 
[AC_DEFINE(HAVE_ZLIB_H, 1) LIBS="$LIBS -lz"]))
 fi
 
-dnl ---Hard codes
-
-CFLAGS='-Wall -g -fno-strict-aliasing $(CPPFLAGS)'
-BUILD_CFLAGS='-O2 -Wall $(CPPFLAGS)'
-
 dnl ---Sanity checks
 if test "$CC"      = "no"; then AC_MSG_ERROR([cc not found]) fi
 if test "$CPP"     = "no"; then AC_MSG_ERROR([cpp not found]) fi
Index: kexec-tools-build-fix+vivek_kcore/kexec/Makefile
===================================================================
--- kexec-tools-build-fix+vivek_kcore.orig/kexec/Makefile       2006-09-22 
11:18:49.000000000 +0900
+++ kexec-tools-build-fix+vivek_kcore/kexec/Makefile    2006-09-22 
11:19:14.000000000 +0900
@@ -7,7 +7,7 @@
        $(MKDIR) -p $(@D)
        $(BIN_TO_HEX) purgatory < $(PURGATORY) > $@
 
-KCFLAGS:= $(CFLAGS) -Ikexec/arch/$(ARCH)/include
+KCFLAGS:= $(CFLAGS) $(EXTRA_CFLAGS) -Ikexec/arch/$(ARCH)/include
 
 KEXEC_C_SRCS:= kexec/kexec.c 
 KEXEC_C_SRCS+= kexec/ifdown.c
@@ -67,7 +67,8 @@
 
 $(KEXEC): $(KEXEC_OBJS) $(UTIL_LIB)
        mkdir -p $(@D)
-       $(CC) $(KCFLAGS) -o $@ $(KEXEC_OBJS) $(UTIL_LIB) $(LIBS)
+       $(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(KCFLAGS) -o $@ \
+               $(KEXEC_OBJS) $(UTIL_LIB) $(LIBS)
 
 $(KEXEC_MANPAGE): kexec/kexec.8
         $(MKDIR) -p     $(MANDIR)/man8
Index: kexec-tools-build-fix+vivek_kcore/kexec_test/Makefile
===================================================================
--- kexec-tools-build-fix+vivek_kcore.orig/kexec_test/Makefile  2006-09-22 
11:18:49.000000000 +0900
+++ kexec-tools-build-fix+vivek_kcore/kexec_test/Makefile       2006-09-22 
11:19:14.000000000 +0900
@@ -15,11 +15,11 @@
 
 $(KEXEC_TEST_S_DEPS): $(OBJDIR)/%.d: %.S
        mkdir -p $(@D)
-       $(CC) -m32 $(CFLAGS) -M $< | sed -e 's|$(patsubst 
%.d,%.o,$(@F))|$(patsubst %.d,%.o,$(@))|' > $@
+       $(CC) -m32 $(CFLAGS) $(EXTRA_CFLAGS) -M $< | sed -e 's|$(patsubst 
%.d,%.o,$(@F))|$(patsubst %.d,%.o,$(@))|' > $@
 
 $(KEXEC_TEST_S_TEMPS): $(OBJDIR)/%.s: %.S 
        mkdir -p $(@D)
-       $(CPP) $(CPPFLAGS) -DRELOC=$(RELOC) $< > $@
+       $(CPP) $(CPPFLAGS) $(EXTRA_CPPFLAGS) -DRELOC=$(RELOC) $< > $@
 
 $(KEXEC_TEST_S_OBJS): $(OBJDIR)/%.o: $(OBJDIR)/%.s 
        mkdir -p $(@D)
Index: kexec-tools-build-fix+vivek_kcore/purgatory/Makefile
===================================================================
--- kexec-tools-build-fix+vivek_kcore.orig/purgatory/Makefile   2006-09-22 
11:18:49.000000000 +0900
+++ kexec-tools-build-fix+vivek_kcore/purgatory/Makefile        2006-09-22 
11:19:14.000000000 +0900
@@ -8,13 +8,13 @@
 # or headers.
 
 ifeq ($(ARCH),ppc64)
-LDFLAGS = -melf64ppc
+EXTRA_LDFLAGS = -melf64ppc
 endif
 
 PCFLAGS:=-Wall -Os  \
        -I$(shell $(CC) -print-file-name=include) \
        -Ipurgatory/include -Ipurgatory/arch/$(ARCH)/include \
-       $(CPPFLAGS)
+       $(CPPFLAGS) $(EXTRA_CPPFLAGS)
 
 PCFLAGS += $(call cc-option, -ffreestanding)
 PCFLAGS += $(call cc-option, -fnobuiltin)
@@ -59,7 +59,7 @@
 
 $(PURGATORY): $(PURGATORY_OBJS) $(UTIL_LIB)
        $(MKDIR) -p $(@D)
-       $(LD) $(LDFLAGS) --no-undefined -e purgatory_start -r -o $@ 
$(PURGATORY_OBJS) $(UTIL_LIB)
+       $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r 
-o $@ $(PURGATORY_OBJS) $(UTIL_LIB)
 
 echo::
        @echo "PURGATORY_C_SRCS $(PURGATORY_C_SRCS)"
_______________________________________________
fastboot mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/fastboot

Reply via email to