makefiles: fixes for building build tools
Currently, some of the tools instead set CC to be HOSTCC in order to re-use
some pattern rules -- but this fails when the user overrides CC on the make
command line. Also, the HOSTCFLAGS in tools/Makefile are currently not
being used because config.mk overwrites them.
This patch adds static pattern rules for files that have been requested to
be built with the native compiler using $(HOSTSRCS) and $(HOSTOBJS), and
converts the tools to use them.
It restores easylogo to using the host compiler, which was broken by commit
38d299c2db81bd889c601b5dfc12c4e83ef83333 (if this was an intentional change,
please let me know -- but it seems to be a build tool).
It restores -pedantic and the special flags for darwin and cygwin that were
requested in tools/makefile (but keeps the flags added by config.mk) --
hopefully someone can test this on those platforms. It no longer
conditionalizes -pedantic on not being darwin; it wasn't clear that that was
intentional, and unless there's a real problem it's just inviting people to
contribute non-pedantic patches to those files (I'm not a fan of -pedantic
personally, but if it's on for one platform it should be on for all).
HOST_LDFLAGS is renamed HOSTLDFLAGS for consistency with the previous
HOST_CFLAGS to HOSTCFLAGS rename. A new HOSTCFLAGS_NOPED is made available
for those files which currently cannot be built with -pedantic, and replaces
the old FIT_CFLAGS.
imls now uses the cross compiler properly, rather than by trying to
reconstruct CC using the typoed $(CROSS_COMPILER).
envcrc.c is now dependency-processed unconditionally -- previously it would
be built without being on (HOST)SRCS if CONFIG_ENV_IS_EMBEDDED was not
selected.
Signed-off-by: Scott Wood <scottwood@freescale.com>
diff --git a/tools/imls/Makefile b/tools/imls/Makefile
index 59b928c..9b2afb0 100644
--- a/tools/imls/Makefile
+++ b/tools/imls/Makefile
@@ -19,8 +19,6 @@
include $(TOPDIR)/config.mk
-HOSTCFLAGS = -Wall -pedantic
-
# Generated executable files
BIN_FILES-y += imls
@@ -48,50 +46,43 @@
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