#########################################################################
+HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
+ $(HOSTCPPFLAGS)
+HOSTSTRIP = strip
+
+#
+# Mac OS X / Darwin's C preprocessor is Apple specific. It
+# generates numerous errors and warnings. We want to bypass it
+# and use GNU C's cpp. To do this we pass the -traditional-cpp
+# option to the compiler. Note that the -traditional-cpp flag
+# DOES NOT have the same semantics as GNU C's flag, all it does
+# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
+#
+# Apple's linker is similar, thanks to the new 2 stage linking
+# multiple symbol definitions are treated as errors, hence the
+# -multiply_defined suppress option to turn off this error.
+#
+
ifeq ($(HOSTOS),darwin)
HOSTCC = cc
+HOSTCFLAGS += -traditional-cpp
+HOSTLDFLAGS += -multiply_defined suppress
else
HOSTCC = gcc
endif
-HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
-HOSTSTRIP = strip
+
+ifeq ($(HOSTOS),cygwin)
+HOSTCFLAGS += -ansi
+endif
+
+# We build some files with extra pedantic flags to try to minimize things
+# that won't build on some weird host compiler -- though there are lots of
+# exceptions for files that aren't complaint.
+
+HOSTCFLAGS_NOPED = $(filter-out -pedantic,$(HOSTCFLAGS))
+HOSTCFLAGS += -pedantic
#########################################################################
#
#########################################################################
-export HOSTCC HOSTCFLAGS CROSS_COMPILE \
+export HOSTCC HOSTCFLAGS HOSTLDFLAGS PEDCFLAGS HOSTSTRIP CROSS_COMPILE \
AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
TOOLSUBDIRS =
#
-# Mac OS X / Darwin's C preprocessor is Apple specific. It
-# generates numerous errors and warnings. We want to bypass it
-# and use GNU C's cpp. To do this we pass the -traditional-cpp
-# option to the compiler. Note that the -traditional-cpp flag
-# DOES NOT have the same semantics as GNU C's flag, all it does
-# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
-#
-# Apple's linker is similar, thanks to the new 2 stage linking
-# multiple symbol definitions are treated as errors, hence the
-# -multiply_defined suppress option to turn off this error.
-#
-
-HOSTCFLAGS = -Wall
-HOST_LDFLAGS =
-
-ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
-HOSTCFLAGS += -traditional-cpp
-HOST_LDFLAGS += -multiply_defined suppress
-else
-HOSTCFLAGS += -pedantic
-endif
-
-ifeq ($(HOSTOS),cygwin)
-HOSTCFLAGS += -ansi
-endif
-
-#
# toolchains targeting win32 generate .exe files
#
ifneq (,$(findstring WIN32 ,$(shell $(HOSTCC) -E -dM -xc /dev/null)))
# Source files located in the tools directory
OBJ_FILES-$(CONFIG_LCD_LOGO) += bmp_logo.o
OBJ_FILES-$(CONFIG_VIDEO_LOGO) += bmp_logo.o
-OBJ_FILES-y += default_image.o
-OBJ_FILES-$(CONFIG_ENV_IS_EMBEDDED) += envcrc.o
-OBJ_FILES-y += fit_image.o
+NOPED_OBJ_FILES-y += default_image.o
+OBJ_FILES-y += envcrc.o
+NOPED_OBJ_FILES-y += fit_image.o
OBJ_FILES-$(CONFIG_CMD_NET) += gen_eth_addr.o
OBJ_FILES-$(CONFIG_CMD_LOADS) += img2srec.o
OBJ_FILES-$(CONFIG_INCA_IP) += inca-swap-bytes.o
-OBJ_FILES-y += kwbimage.o
-OBJ_FILES-y += mkimage.o
+NOPED_OBJ_FILES-y += kwbimage.o
+NOPED_OBJ_FILES-y += mkimage.o
OBJ_FILES-$(CONFIG_NETCONSOLE) += ncb.o
-OBJ_FILES-y += os_support.o
+NOPED_OBJ_FILES-y += os_support.o
OBJ_FILES-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1.o
# Don't build by default
endif
# now $(obj) is defined
-SRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
-SRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
-SRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
+HOSTSRCS += $(addprefix $(SRCTREE)/,$(EXT_OBJ_FILES-y:.o=.c))
+HOSTSRCS += $(addprefix $(SRCTREE)/tools/,$(OBJ_FILES-y:.o=.c))
+HOSTSRCS += $(addprefix $(SRCTREE)/libfdt/,$(LIBFDT_OBJ_FILES-y:.o=.c))
BINS := $(addprefix $(obj),$(sort $(BIN_FILES-y)))
LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
+HOSTOBJS := $(addprefix $(obj),$(OBJ_FILES-y))
+NOPEDOBJS := $(addprefix $(obj),$(NOPED_OBJ_FILES-y))
+
#
# Use native tools and options
# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
#
-CPPFLAGS = -idirafter $(SRCTREE)/include \
+HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
-idirafter $(OBJTREE)/include2 \
-idirafter $(OBJTREE)/include \
-I $(SRCTREE)/libfdt \
-I $(SRCTREE)/tools \
-DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \
-D__KERNEL_STRICT_NAMES
-CFLAGS = $(HOSTCFLAGS) $(CPPFLAGS) -O
-
-# No -pedantic switch to avoid libfdt compilation warnings
-FIT_CFLAGS = -Wall $(CPPFLAGS) -O
-AFLAGS = -D__ASSEMBLY__ $(CPPFLAGS)
-CC = $(HOSTCC)
-STRIP = $(HOSTSTRIP)
-MAKEDEPEND = makedepend
all: $(obj).depend $(BINS) $(LOGO-y) subdirs
$(obj)bin2header$(SFX): $(obj)bin2header.o
- $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
- $(STRIP) $@
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
- $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
- $(STRIP) $@
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
$(obj)envcrc$(SFX): $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
- $(CC) $(CFLAGS) -o $@ $^
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
- $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
- $(STRIP) $@
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
$(obj)img2srec$(SFX): $(obj)img2srec.o
- $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
- $(STRIP) $@
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
- $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
- $(STRIP) $@
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
$(obj)mkimage$(SFX): $(obj)crc32.o \
$(obj)default_image.o \
$(obj)os_support.o \
$(obj)sha1.o \
$(LIBFDT_OBJS)
- $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
- $(STRIP) $@
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
- $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
- $(STRIP) $@
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
$(obj)ncb$(SFX): $(obj)ncb.o
- $(CC) $(CFLAGS) $(HOST_LDFLAGS) -o $@ $^
- $(STRIP) $@
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(HOSTSTRIP) $@
$(obj)ubsha1$(SFX): $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
- $(CC) $(CFLAGS) -o $@ $^
-
-# Some files complain if compiled with -pedantic, use FIT_CFLAGS
-$(obj)default_image.o: $(SRCTREE)/tools/default_image.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
-
-$(obj)fit_image.o: $(SRCTREE)/tools/fit_image.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
-
-$(obj)image.o: $(SRCTREE)/common/image.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
-
-$(obj)kwbimage.o: $(SRCTREE)/tools/kwbimage.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
-
-$(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
-
-$(obj)os_support.o: $(SRCTREE)/tools/os_support.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
# Some of the tool objects need to be accessed from outside the tools directory
$(obj)%.o: $(SRCTREE)/common/%.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
+ $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
$(obj)%.o: $(SRCTREE)/lib_generic/%.c
- $(CC) -g $(CFLAGS) -c -o $@ $<
+ $(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $<
$(LIBFDT_OBJS):
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
+ $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
subdirs:
ifeq ($(TOOLSUBDIRS),)
$(MAKE) \
HOSTOS=$(HOSTOS) \
HOSTARCH=$(HOSTARCH) \
- HOSTCFLAGS="$(HOSTCFLAGS)" \
- HOST_LDFLAGS="$(HOST_LDFLAGS)" \
-C $$dir || exit 1 ; \
done
endif
include $(TOPDIR)/config.mk
-HOSTCFLAGS = -Wall -pedantic
-
# Generated executable files
BIN_FILES-y += imls
LIBFDT_OBJS := $(addprefix $(obj),$(LIBFDT_OBJ_FILES-y))
#
-# Use native tools and options
+# Compile for a hosted environment on the target
# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
#
-CPPFLAGS = -idirafter $(SRCTREE)/include \
+HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
-idirafter $(OBJTREE)/include2 \
-idirafter $(OBJTREE)/include \
-I $(SRCTREE)/libfdt \
-I $(SRCTREE)/tools \
-DUSE_HOSTCC -D__KERNEL_STRICT_NAMES
-CFLAGS = $(HOSTCFLAGS) $(CPPFLAGS) -O
-
-# No -pedantic switch to avoid libfdt compilation warnings
-FIT_CFLAGS = -Wall $(CPPFLAGS) -O
-
-CC = $(CROSS_COMPILER)gcc
-STRIP = $(CROSS_COMPILER)strip
ifeq ($(MTD_VERSION),old)
-CPPFLAGS += -DMTD_OLD
+HOSTCPPFLAGS += -DMTD_OLD
endif
all: $(BINS)
$(obj)imls: $(obj)imls.o $(obj)crc32.o $(obj)image.o $(obj)md5.o \
$(obj)sha1.o $(LIBFDT_OBJS)
- $(CC) $(CFLAGS) -o $@ $^
+ $(CC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
$(STRIP) $@
# Some files complain if compiled with -pedantic, use FIT_CFLAGS
$(obj)image.o: $(SRCTREE)/common/image.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
+ $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
-$(obj)imls.o: imls.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
+$(obj)imls.o: $(SRCTREE)/tools/imls/imls.c
+ $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
# Some of the tool objects need to be accessed from outside the tools/imls directory
$(obj)%.o: $(SRCTREE)/common/%.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
+ $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
$(obj)%.o: $(SRCTREE)/lib_generic/%.c
- $(CC) -g $(CFLAGS) -c -o $@ $<
+ $(CC) -g $(HOSTCFLAGS) -c -o $@ $<
$(obj)%.o: $(SRCTREE)/libfdt/%.c
- $(CC) -g $(FIT_CFLAGS) -c -o $@ $<
+ $(CC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
clean:
rm -rf *.o imls