2007-07-07 20:52:25 +02:00
|
|
|
#
|
|
|
|
# Device Tree Compiler
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Version information will be constructed in this order:
|
|
|
|
# EXTRAVERSION might be "-rc", for example.
|
|
|
|
# LOCAL_VERSION is likely from command line.
|
|
|
|
# CONFIG_LOCALVERSION from some future config system.
|
|
|
|
#
|
|
|
|
VERSION = 1
|
|
|
|
PATCHLEVEL = 0
|
|
|
|
SUBLEVEL = 0
|
2007-08-10 02:31:32 +02:00
|
|
|
EXTRAVERSION =
|
2007-07-07 20:52:25 +02:00
|
|
|
LOCAL_VERSION =
|
2007-09-18 03:44:04 +02:00
|
|
|
CONFIG_LOCALVERSION =
|
2007-07-07 20:52:25 +02:00
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
CPPFLAGS = -I libfdt
|
2007-08-31 08:21:23 +02:00
|
|
|
CFLAGS = -Wall -g -Os
|
2005-06-08 09:18:34 +02:00
|
|
|
|
2005-06-16 06:36:37 +02:00
|
|
|
BISON = bison
|
2007-10-04 07:37:43 +02:00
|
|
|
LEX = flex
|
2005-06-16 06:36:37 +02:00
|
|
|
|
2007-06-29 16:53:23 +02:00
|
|
|
INSTALL = /usr/bin/install
|
|
|
|
DESTDIR =
|
dtc: Improve the make install target
This patch makes various improvements to dtc's make install target:
- libfdt is also installed. Specifically, libfdt.a and the
two export relevant header files, fdt.h and libfdt.h are installed.
- ftdump is no longer installed. It was only ever a
development debugging tool and may well go away at some point.
- In keeping with normal conventions, there is now a PREFIX
variable, allowing control of where things are installed (in /usr,
/usr/local, /opt, etc.).
- By default, installed into the user's home directory,
instead of /usr. This is friendlier for self-installers, package
builders can easily override PREFIX to restore the old behaviour.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-07-24 07:14:52 +02:00
|
|
|
PREFIX = $(HOME)
|
|
|
|
BINDIR = $(PREFIX)/bin
|
|
|
|
LIBDIR = $(PREFIX)/lib
|
|
|
|
INCLUDEDIR = $(PREFIX)/include
|
2007-06-29 16:53:23 +02:00
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2007-10-04 07:37:43 +02:00
|
|
|
install: all
|
|
|
|
@$(VECHO) INSTALL
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(BINDIR)
|
|
|
|
$(INSTALL) -m 755 dtc $(DESTDIR)$(BINDIR)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
|
|
|
$(INSTALL) -m 644 $(LIBFDT_LIB) $(DESTDIR)$(LIBDIR)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)
|
2007-11-02 16:26:15 +01:00
|
|
|
$(INSTALL) -m 644 $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES)) $(DESTDIR)$(INCLUDEDIR)
|
2007-10-04 07:37:43 +02:00
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
#
|
2007-10-04 07:37:43 +02:00
|
|
|
# Rules for versioning
|
2007-06-26 04:45:51 +02:00
|
|
|
#
|
2007-06-14 07:05:55 +02:00
|
|
|
|
2007-10-04 07:37:43 +02:00
|
|
|
DTC_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
|
|
|
|
VERSION_FILE = version_gen.h
|
2007-07-07 21:18:02 +02:00
|
|
|
|
2007-10-04 07:37:43 +02:00
|
|
|
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
|
|
|
|
else if [ -x /bin/bash ]; then echo /bin/bash; \
|
|
|
|
else echo sh; fi ; fi)
|
|
|
|
|
|
|
|
nullstring :=
|
|
|
|
space := $(nullstring) # end of line
|
|
|
|
|
|
|
|
localver_config = $(subst $(space),, $(string) \
|
|
|
|
$(patsubst "%",%,$(CONFIG_LOCALVERSION)))
|
|
|
|
|
|
|
|
localver_cmd = $(subst $(space),, $(string) \
|
|
|
|
$(patsubst "%",%,$(LOCALVERSION)))
|
|
|
|
|
|
|
|
localver_scm = $(shell $(CONFIG_SHELL) ./scripts/setlocalversion)
|
|
|
|
localver_full = $(localver_config)$(localver_cmd)$(localver_scm)
|
|
|
|
|
|
|
|
dtc_version = $(DTC_VERSION)$(localver_full)
|
|
|
|
|
|
|
|
# Contents of the generated version file.
|
|
|
|
define filechk_version
|
|
|
|
(echo "#define DTC_VERSION \"DTC $(dtc_version)\""; )
|
|
|
|
endef
|
|
|
|
|
|
|
|
define filechk
|
|
|
|
set -e; \
|
|
|
|
echo ' CHK $@'; \
|
|
|
|
mkdir -p $(dir $@); \
|
|
|
|
$(filechk_$(1)) < $< > $@.tmp; \
|
|
|
|
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
|
|
|
|
rm -f $@.tmp; \
|
|
|
|
else \
|
|
|
|
echo ' UPD $@'; \
|
|
|
|
mv -f $@.tmp $@; \
|
|
|
|
fi;
|
|
|
|
endef
|
2005-06-08 09:18:34 +02:00
|
|
|
|
2007-07-07 20:52:25 +02:00
|
|
|
$(VERSION_FILE): Makefile FORCE
|
|
|
|
$(call filechk,version)
|
|
|
|
|
2007-10-04 07:37:43 +02:00
|
|
|
#
|
|
|
|
# Rules for dtc proper
|
|
|
|
#
|
|
|
|
include Makefile.dtc
|
|
|
|
|
|
|
|
BIN += dtc
|
|
|
|
|
|
|
|
# This stops make from generating the lex and bison output during
|
|
|
|
# auto-dependency computation, but throwing them away as an
|
|
|
|
# intermediate target and building them again "for real"
|
|
|
|
.SECONDARY: $(DTC_GEN_SRCS)
|
2005-06-08 09:18:34 +02:00
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
dtc: $(DTC_OBJS)
|
2007-06-14 07:05:55 +02:00
|
|
|
|
2007-10-04 07:37:43 +02:00
|
|
|
ifneq ($(DEPTARGETS),)
|
|
|
|
-include $(DTC_OBJS:%.o=%.d)
|
|
|
|
endif
|
|
|
|
#
|
|
|
|
# Rules for ftdump
|
|
|
|
#
|
|
|
|
BIN += ftdump
|
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
ftdump: ftdump.o
|
2007-06-14 07:05:55 +02:00
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
ifneq ($(DEPTARGETS),)
|
2007-10-04 07:37:43 +02:00
|
|
|
-include ftdump.d
|
2007-06-26 04:45:51 +02:00
|
|
|
endif
|
|
|
|
#
|
|
|
|
# Rules for libfdt
|
|
|
|
#
|
2007-10-04 07:37:43 +02:00
|
|
|
LIBFDT_objdir = libfdt
|
|
|
|
LIBFDT_srcdir = libfdt
|
2007-11-02 16:26:15 +01:00
|
|
|
include $(LIBFDT_srcdir)/Makefile.libfdt
|
2007-06-14 07:05:55 +02:00
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
.PHONY: libfdt
|
|
|
|
libfdt: $(LIBFDT_LIB)
|
2005-06-08 09:18:34 +02:00
|
|
|
|
2007-11-02 16:26:15 +01:00
|
|
|
$(LIBFDT_LIB): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
|
2007-10-04 07:37:43 +02:00
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
libfdt_clean:
|
|
|
|
@$(VECHO) CLEAN "(libfdt)"
|
2007-11-02 16:26:15 +01:00
|
|
|
rm -f $(addprefix $(LIBFDT_objdir)/,$(STD_CLEANFILES))
|
|
|
|
rm -f $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_CLEANFILES))
|
2005-06-08 09:18:34 +02:00
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
ifneq ($(DEPTARGETS),)
|
2007-10-04 07:37:43 +02:00
|
|
|
-include $(LIBFDT_OBJS:%.o=$(LIBFDT_objdir)/%.d)
|
2007-06-26 04:45:51 +02:00
|
|
|
endif
|
2005-07-11 08:29:25 +02:00
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
#
|
|
|
|
# Testsuite rules
|
|
|
|
#
|
|
|
|
TESTS_PREFIX=tests/
|
|
|
|
include tests/Makefile.tests
|
2007-06-29 16:53:23 +02:00
|
|
|
|
2007-10-04 07:37:43 +02:00
|
|
|
#
|
|
|
|
# Clean rules
|
|
|
|
#
|
|
|
|
STD_CLEANFILES = *~ *.o *.d *.a *.i *.s core a.out vgcore.* \
|
|
|
|
*.tab.[ch] *.lex.c *.output
|
2007-07-07 21:18:02 +02:00
|
|
|
|
|
|
|
clean: libfdt_clean tests_clean
|
|
|
|
@$(VECHO) CLEAN
|
2007-10-04 07:37:43 +02:00
|
|
|
rm -f $(STD_CLEANFILES) $(DTC_CLEANFILES)
|
|
|
|
rm -f $(VERSION_FILE)
|
2007-07-07 21:18:02 +02:00
|
|
|
rm -f $(BIN)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generic compile rules
|
|
|
|
#
|
2007-08-31 08:04:27 +02:00
|
|
|
%: %.o
|
|
|
|
@$(VECHO) LD $@
|
|
|
|
$(LINK.c) -o $@ $^
|
|
|
|
|
2007-07-07 21:18:02 +02:00
|
|
|
%.o: %.c
|
|
|
|
@$(VECHO) CC $@
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
|
|
|
%.o: %.S
|
|
|
|
@$(VECHO) AS $@
|
|
|
|
$(CC) $(CPPFLAGS) $(AFLAGS) -D__ASSEMBLY__ -o $@ -c $<
|
|
|
|
|
|
|
|
%.d: %.c
|
2007-10-04 07:37:43 +02:00
|
|
|
@$(VECHO) DEP $<
|
2007-07-07 21:18:02 +02:00
|
|
|
$(CC) $(CPPFLAGS) -MM -MG -MT "$*.o $@" $< > $@
|
|
|
|
|
|
|
|
%.i: %.c
|
|
|
|
@$(VECHO) CPP $@
|
|
|
|
$(CC) $(CPPFLAGS) -E $< > $@
|
|
|
|
|
|
|
|
%.s: %.c
|
|
|
|
@$(VECHO) CC -S $@
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -S $<
|
|
|
|
|
|
|
|
%.a:
|
|
|
|
@$(VECHO) AR $@
|
|
|
|
$(AR) $(ARFLAGS) $@ $^
|
|
|
|
|
2007-10-04 07:37:43 +02:00
|
|
|
%.lex.c: %.l
|
|
|
|
@$(VECHO) LEX $@
|
|
|
|
$(LEX) -o $@ $<
|
|
|
|
|
|
|
|
%.tab.c %.tab.h %.output: %.y
|
|
|
|
@$(VECHO) BISON $@
|
|
|
|
$(BISON) -d $<
|
|
|
|
|
2007-07-07 20:52:25 +02:00
|
|
|
FORCE:
|