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/config.mk b/config.mk
index 8cfd60c..cb1c4af 100644
--- a/config.mk
+++ b/config.mk
@@ -46,13 +46,41 @@
 
 #########################################################################
 
+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
 
 #########################################################################
 #
@@ -200,7 +228,7 @@
 
 #########################################################################
 
-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