summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2007-06-26 12:45:51 +1000
committerJon Loeliger <jdl@freescale.com>2007-06-25 21:50:14 -0500
commitd9d679fb9690348730d5d274858d445f11e4cbd4 (patch)
tree2a4bbafdb597c364f60e604b62fa6a3ce718248f /Makefile
parent6c65eab11e19117516ed6a86222295b55e8adc9b (diff)
downloaddtc-d9d679fb9690348730d5d274858d445f11e4cbd4.tar.gz
dtc: Improve and better integrate dtc and libfdt Makefiles
This patch substantially revamps the dtc Makefiles, in particular better integrating the Makefile for dtc proper with the Makefiles imported from libfdt for libfdt and the shared testsuite. Notable changes: - No recursive make calls. Instead subsidiary Makefiles are included into the top-level Makefile so we get a complete dependency information. - Common pattern rules, CFLAGS etc. shared between dtc, libfdt and testsuite, rather than separate copies. - Vaguely Kbuild-like non-verbose mode used by default, which makes warnings more prominent. - libfdt Makefile consists only of variable definitions and helper rules, to make it more easily embeddable into other Makefile systems. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile130
1 files changed, 89 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index 2dcc5c9..67eb4ce 100644
--- a/Makefile
+++ b/Makefile
@@ -1,67 +1,115 @@
-TARGETS = dtc ftdump
+CPPFLAGS = -I libfdt
CFLAGS = -Wall -g
+LDFLAGS = -Llibfdt
BISON = bison
-DTC_OBJS = dtc.o flattree.o fstree.o data.o livetree.o \
- srcpos.o treesource.o \
- dtc-parser.tab.o lex.yy.o
+#
+# Overall rules
+#
+ifdef V
+VECHO = :
+else
+VECHO = echo " "
+ARFLAGS = rc
+.SILENT:
+endif
+
+NODEPTARGETS = clean
+ifeq ($(MAKECMDGOALS),)
+DEPTARGETS = all
+else
+DEPTARGETS = $(filter-out $(NODEPTARGETS),$(MAKECMDGOALS))
+endif
+
+all: dtc ftdump libfdt tests
+
+STD_CLEANFILES = *~ *.o *.d *.a *.i *.s core a.out
+
+clean: libfdt_clean tests_clean
+ @$(VECHO) CLEAN
+ rm -f $(STD_CLEANFILES)
+ rm -f *.tab.[ch] lex.yy.c *.output vgcore.*
+ rm -f $(BIN)
+
+#
+# General rules
+#
+
+%.o: %.c
+ @$(VECHO) CC $@
+ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
+
+%.o: %.S
+ @$(VECHO) AS $@
+ $(CC) $(CPPFLAGS) $(AFLAGS) -D__ASSEMBLY__ -o $@ -c $<
-DEPFILES = $(DTC_OBJS:.o=.d)
+%.d: %.c
+ $(CC) $(CPPFLAGS) -MM -MG -MT "$*.o $@" $< > $@
-.PHONY: libfdt tests
+%.i: %.c
+ @$(VECHO) CPP $@
+ $(CC) $(CPPFLAGS) -E $< > $@
-all: $(TARGETS) tests libfdt
+%.s: %.c
+ @$(VECHO) CC -S $@
+ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -S $<
-dtc: $(DTC_OBJS)
- $(LINK.c) -o $@ $^
+%.a:
+ @$(VECHO) AR $@
+ $(AR) $(ARFLAGS) $@ $^
-ftdump: ftdump.o
+$(BIN): %:
+ @$(VECHO) LD $@
$(LINK.c) -o $@ $^
-libfdt:
- cd libfdt && $(MAKE) all
+
+#
+# Rules for dtc proper
+#
+DTC_PROGS = dtc ftdump
+DTC_OBJS = dtc.o flattree.o fstree.o data.o livetree.o \
+ srcpos.o treesource.o \
+ dtc-parser.tab.o lex.yy.o
+DTC_DEPFILES = $(DTC_OBJS:%.o=%.d)
dtc-parser.tab.c dtc-parser.tab.h dtc-parser.output: dtc-parser.y
+ @$(VECHO) BISON $@
$(BISON) -d $<
lex.yy.c: dtc-lexer.l
+ @$(VECHO) LEX $@
$(LEX) $<
-lex.yy.o: lex.yy.c dtc-parser.tab.h
-
-tests: tests/all
-
-tests/%: libfdt
- $(MAKE) -C tests $*
-
-check: all
- cd tests; ./run_tests.sh
+BIN += dtc ftdump
-checkv: all
- cd tests; ./run_tests.sh -v
+dtc: $(DTC_OBJS)
-func: all
- cd tests; ./run_tests.sh -t func
+ftdump: ftdump.o
-funcv: all
- cd tests; ./run_tests.sh -t func -v
+ifneq ($(DEPTARGETS),)
+-include $(DTC_DEPFILES)
+endif
-stress: all
- cd tests; ./run_tests.sh -t stress
+#
+# Rules for libfdt
+#
+LIBFDT_PREFIX = libfdt/
+include libfdt/Makefile.libfdt
-stressv: all
- cd tests; ./run_tests.sh -t stress -v
+.PHONY: libfdt
+libfdt: $(LIBFDT_LIB)
-clean:
- rm -f *~ *.o a.out core $(TARGETS)
- rm -f *.tab.[ch] lex.yy.c
- rm -f *.i *.output vgcore.*
- rm -f *.d
- $(MAKE) -C libfdt clean
- $(MAKE) -C tests clean
+libfdt_clean:
+ @$(VECHO) CLEAN "(libfdt)"
+ rm -f $(LIBFDT_CLEANFILES)
-%.d: %.c
- $(CC) $(CPPFLAGS) -MM -MG -MT "$*.o $@" $< > $@
+ifneq ($(DEPTARGETS),)
+-include $(LIBFDT_DEPFILES)
+endif
--include $(DEPFILES)
+#
+# Testsuite rules
+#
+TESTS_PREFIX=tests/
+include tests/Makefile.tests