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
|
2011-05-08 21:45:39 +02:00
|
|
|
PATCHLEVEL = 3
|
2007-07-07 20:52:25 +02:00
|
|
|
SUBLEVEL = 0
|
2008-07-25 23:17:04 +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
|
2010-03-09 00:49:33 +01:00
|
|
|
WARNINGS = -Werror -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
|
2010-04-30 07:27:32 +02:00
|
|
|
-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls
|
2010-03-09 00:49:33 +01:00
|
|
|
CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
|
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
|
|
|
|
2009-05-26 20:07:26 +02:00
|
|
|
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
|
|
|
|
sed -e 's/\(cygwin\).*/cygwin/')
|
|
|
|
|
|
|
|
ifeq ($(HOSTOS),darwin)
|
|
|
|
SHAREDLIB_EXT=dylib
|
|
|
|
SHAREDLIB_LINK_OPTIONS=-dynamiclib -Wl,-install_name -Wl,
|
|
|
|
else
|
|
|
|
SHAREDLIB_EXT=so
|
|
|
|
SHAREDLIB_LINK_OPTIONS=-shared -Wl,--version-script=$(LIBFDT_version) -Wl,-soname,
|
|
|
|
endif
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#
|
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
|
|
|
|
2008-10-03 17:49:22 +02:00
|
|
|
include Makefile.convert-dtsv0
|
2007-10-04 07:37:43 +02:00
|
|
|
include Makefile.dtc
|
2008-10-03 17:49:22 +02:00
|
|
|
include Makefile.ftdump
|
2007-10-04 07:37:43 +02:00
|
|
|
|
2008-10-03 17:49:22 +02:00
|
|
|
BIN += convert-dtsv0
|
2007-10-04 07:37:43 +02:00
|
|
|
BIN += dtc
|
2008-10-03 17:49:22 +02:00
|
|
|
BIN += ftdump
|
2007-10-04 07:37:43 +02:00
|
|
|
|
2010-11-09 23:51:09 +01:00
|
|
|
SCRIPTS = dtdiff
|
2005-06-08 09:18:34 +02:00
|
|
|
|
2008-10-03 17:49:22 +02:00
|
|
|
all: $(BIN) libfdt
|
|
|
|
|
2007-06-14 07:05:55 +02:00
|
|
|
|
2007-10-04 07:37:43 +02:00
|
|
|
ifneq ($(DEPTARGETS),)
|
|
|
|
-include $(DTC_OBJS:%.o=%.d)
|
2008-10-03 17:49:22 +02:00
|
|
|
-include $(CONVERT_OBJS:%.o=%.d)
|
|
|
|
-include $(FTDUMP_OBJS:%.o=%.d)
|
2007-10-04 07:37:43 +02:00
|
|
|
endif
|
|
|
|
|
2007-06-14 07:05:55 +02:00
|
|
|
|
2008-05-15 08:39:12 +02:00
|
|
|
|
2007-06-26 04:45:51 +02:00
|
|
|
#
|
|
|
|
# Rules for libfdt
|
|
|
|
#
|
2007-10-04 07:37:43 +02:00
|
|
|
LIBFDT_objdir = libfdt
|
|
|
|
LIBFDT_srcdir = libfdt
|
2009-01-02 14:20:34 +01:00
|
|
|
LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
|
2011-04-26 12:45:27 +02:00
|
|
|
LIBFDT_lib = $(LIBFDT_objdir)/libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT)
|
2008-07-23 17:20:53 +02:00
|
|
|
LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
|
2009-01-02 14:20:34 +01:00
|
|
|
LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
|
2008-07-23 17:20:53 +02:00
|
|
|
|
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
|
2009-01-02 14:20:34 +01:00
|
|
|
libfdt: $(LIBFDT_archive) $(LIBFDT_lib)
|
2005-06-08 09:18:34 +02:00
|
|
|
|
2009-01-02 14:20:34 +01:00
|
|
|
$(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
|
2008-05-16 05:20:41 +02: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))
|
2009-01-02 14:20:34 +01:00
|
|
|
rm -f $(LIBFDT_objdir)/*.so
|
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
|
|
|
|
2008-10-03 17:49:22 +02:00
|
|
|
# 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) $(CONVERT_GEN_SRCS)
|
|
|
|
|
2010-11-09 23:51:09 +01:00
|
|
|
install: all $(SCRIPTS)
|
2008-10-03 17:49:22 +02:00
|
|
|
@$(VECHO) INSTALL
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(BINDIR)
|
2010-11-09 23:51:09 +01:00
|
|
|
$(INSTALL) $(BIN) $(SCRIPTS) $(DESTDIR)$(BINDIR)
|
2008-10-03 17:49:22 +02:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
2009-02-17 20:43:40 +01:00
|
|
|
$(INSTALL) $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
|
2011-04-26 12:45:27 +02:00
|
|
|
ln -sf $(notdir $(LIBFDT_lib)) $(DESTDIR)$(LIBDIR)/$(LIBFDT_soname)
|
|
|
|
ln -sf $(LIBFDT_soname) $(DESTDIR)$(LIBDIR)/libfdt.$(SHAREDLIB_EXT)
|
2009-02-17 20:43:40 +01:00
|
|
|
$(INSTALL) -m 644 $(LIBFDT_archive) $(DESTDIR)$(LIBDIR)
|
2008-10-03 17:49:22 +02:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)
|
|
|
|
$(INSTALL) -m 644 $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR)
|
|
|
|
|
|
|
|
$(VERSION_FILE): Makefile FORCE
|
|
|
|
$(call filechk,version)
|
|
|
|
|
|
|
|
|
|
|
|
dtc: $(DTC_OBJS)
|
|
|
|
|
|
|
|
convert-dtsv0: $(CONVERT_OBJS)
|
|
|
|
@$(VECHO) LD $@
|
|
|
|
$(LINK.c) -o $@ $^
|
|
|
|
|
|
|
|
ftdump: $(FTDUMP_OBJS)
|
|
|
|
|
|
|
|
|
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
|
|
|
|
#
|
2011-04-26 12:45:27 +02:00
|
|
|
STD_CLEANFILES = *~ *.o *.$(SHAREDLIB_EXT) *.d *.a *.i *.s core a.out vgcore.* \
|
2007-10-04 07:37:43 +02:00
|
|
|
*.tab.[ch] *.lex.c *.output
|
2007-07-07 21:18:02 +02:00
|
|
|
|
|
|
|
clean: libfdt_clean tests_clean
|
|
|
|
@$(VECHO) CLEAN
|
2008-05-20 06:50:50 +02:00
|
|
|
rm -f $(STD_CLEANFILES)
|
2007-10-04 07:37:43 +02:00
|
|
|
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 $@" $< > $@
|
|
|
|
|
2007-11-12 23:52:58 +01:00
|
|
|
%.d: %.S
|
|
|
|
@$(VECHO) DEP $<
|
|
|
|
$(CC) $(CPPFLAGS) -MM -MG -MT "$*.o $@" $< > $@
|
|
|
|
|
2007-07-07 21:18:02 +02:00
|
|
|
%.i: %.c
|
|
|
|
@$(VECHO) CPP $@
|
|
|
|
$(CC) $(CPPFLAGS) -E $< > $@
|
|
|
|
|
|
|
|
%.s: %.c
|
|
|
|
@$(VECHO) CC -S $@
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -S $<
|
|
|
|
|
|
|
|
%.a:
|
|
|
|
@$(VECHO) AR $@
|
|
|
|
$(AR) $(ARFLAGS) $@ $^
|
|
|
|
|
2009-01-02 14:20:34 +01:00
|
|
|
$(LIBFDT_lib):
|
|
|
|
@$(VECHO) LD $@
|
2011-04-26 12:45:27 +02:00
|
|
|
$(CC) $(LDFLAGS) -fPIC $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
|
2009-01-02 14:20:34 +01:00
|
|
|
|
2007-10-04 07:37:43 +02:00
|
|
|
%.lex.c: %.l
|
|
|
|
@$(VECHO) LEX $@
|
2007-12-06 03:07:50 +01:00
|
|
|
$(LEX) -o$@ $<
|
2007-10-04 07:37:43 +02:00
|
|
|
|
|
|
|
%.tab.c %.tab.h %.output: %.y
|
|
|
|
@$(VECHO) BISON $@
|
|
|
|
$(BISON) -d $<
|
|
|
|
|
2007-07-07 20:52:25 +02:00
|
|
|
FORCE:
|