#
-# (C) Copyright 2002
+# (C) Copyright 2002-2006
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# MA 02111-1307 USA
#
-SOURCES := crc32.c fw_env.c fw_env_main.c
-HEADERS := fw_env.h
+include $(TOPDIR)/config.mk
-all: fw_printenv
+HOSTSRCS := $(SRCTREE)/lib/crc32.c fw_env.c fw_env_main.c
+HEADERS := fw_env.h $(OBJTREE)/include/config.h
-fw_printenv: $(SOURCES) $(HEADERS)
- $(CROSS_COMPILE)gcc -Wall -DUSE_HOSTCC $(SOURCES) -o fw_printenv
+# Compile for a hosted environment on the target
+HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
+ -idirafter $(OBJTREE)/include2 \
+ -idirafter $(OBJTREE)/include \
+ -DUSE_HOSTCC \
+ -DTEXT_BASE=$(TEXT_BASE)
-clean:
- rm -f fw_printenv crc32.c
+ifeq ($(MTD_VERSION),old)
+HOSTCPPFLAGS += -DMTD_OLD
+endif
+
+all: $(obj)fw_printenv
-crc32.c:
- ln -s ../../lib_generic/crc32.c crc32.c
+# Some files complain if compiled with -pedantic, use HOSTCFLAGS_NOPED
+$(obj)fw_printenv: $(HOSTSRCS) $(HEADERS)
+ $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTLDFLAGS) -o $@ $(HOSTSRCS)
+ $(HOSTSTRIP) $@
+
+clean:
+ rm -f $(obj)fw_printenv
#########################################################################
-.depend: Makefile $(SOURCES)
- $(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) -DUSE_HOSTCC $(SOURCES) > $@
+include $(TOPDIR)/rules.mk
-sinclude .depend
+sinclude $(obj).depend
#########################################################################