2010-02-28 21:57:35 +00: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
|
2014-01-27 19:37:35 +00:00
|
|
|
PATCHLEVEL = 4
|
2010-02-28 21:57:35 +00:00
|
|
|
SUBLEVEL = 0
|
|
|
|
EXTRAVERSION =
|
|
|
|
LOCAL_VERSION =
|
|
|
|
CONFIG_LOCALVERSION =
|
|
|
|
|
2012-07-24 16:29:33 +00:00
|
|
|
CPPFLAGS = -I libfdt -I .
|
|
|
|
WARNINGS = -Werror -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
|
|
|
|
-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls
|
|
|
|
CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
|
2010-02-28 21:57:35 +00:00
|
|
|
|
|
|
|
BISON = bison
|
|
|
|
LEX = flex
|
|
|
|
|
|
|
|
INSTALL = /usr/bin/install
|
|
|
|
DESTDIR =
|
|
|
|
PREFIX = $(HOME)
|
|
|
|
BINDIR = $(PREFIX)/bin
|
|
|
|
LIBDIR = $(PREFIX)/lib
|
|
|
|
INCLUDEDIR = $(PREFIX)/include
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#
|
|
|
|
# Overall rules
|
|
|
|
#
|
|
|
|
ifdef V
|
|
|
|
VECHO = :
|
|
|
|
else
|
|
|
|
VECHO = echo " "
|
2012-12-06 01:31:25 +00:00
|
|
|
ARFLAGS ?= rc
|
2010-02-28 21:57:35 +00:00
|
|
|
.SILENT:
|
|
|
|
endif
|
|
|
|
|
|
|
|
NODEPTARGETS = clean
|
|
|
|
ifeq ($(MAKECMDGOALS),)
|
|
|
|
DEPTARGETS = all
|
|
|
|
else
|
|
|
|
DEPTARGETS = $(filter-out $(NODEPTARGETS),$(MAKECMDGOALS))
|
|
|
|
endif
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules for versioning
|
|
|
|
#
|
|
|
|
|
|
|
|
DTC_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
|
|
|
|
VERSION_FILE = version_gen.h
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
include Makefile.convert-dtsv0
|
|
|
|
include Makefile.dtc
|
2012-07-24 16:29:33 +00:00
|
|
|
include Makefile.utils
|
2010-02-28 21:57:35 +00:00
|
|
|
|
|
|
|
BIN += convert-dtsv0
|
|
|
|
BIN += dtc
|
2012-07-24 16:29:33 +00:00
|
|
|
BIN += fdtdump
|
|
|
|
BIN += fdtget
|
|
|
|
BIN += fdtput
|
2010-02-28 21:57:35 +00:00
|
|
|
|
2012-07-24 16:29:33 +00:00
|
|
|
SCRIPTS = dtdiff
|
2010-02-28 21:57:35 +00:00
|
|
|
|
|
|
|
all: $(BIN) libfdt
|
|
|
|
|
|
|
|
|
|
|
|
ifneq ($(DEPTARGETS),)
|
|
|
|
-include $(DTC_OBJS:%.o=%.d)
|
|
|
|
-include $(CONVERT_OBJS:%.o=%.d)
|
2012-07-24 16:29:33 +00:00
|
|
|
-include $(FDTDUMP_OBJS:%.o=%.d)
|
|
|
|
-include $(FDTGET_OBJS:%.o=%.d)
|
|
|
|
-include $(FDTPUT_OBJS:%.o=%.d)
|
2010-02-28 21:57:35 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Rules for libfdt
|
|
|
|
#
|
|
|
|
LIBFDT_objdir = libfdt
|
|
|
|
LIBFDT_srcdir = libfdt
|
|
|
|
LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
|
2012-07-24 16:29:33 +00:00
|
|
|
LIBFDT_lib = $(LIBFDT_objdir)/libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT)
|
2010-02-28 21:57:35 +00:00
|
|
|
LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
|
|
|
|
LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
|
|
|
|
|
|
|
|
include $(LIBFDT_srcdir)/Makefile.libfdt
|
|
|
|
|
|
|
|
.PHONY: libfdt
|
|
|
|
libfdt: $(LIBFDT_archive) $(LIBFDT_lib)
|
|
|
|
|
|
|
|
$(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
|
|
|
|
$(LIBFDT_lib): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
|
|
|
|
|
|
|
|
libfdt_clean:
|
|
|
|
@$(VECHO) CLEAN "(libfdt)"
|
|
|
|
rm -f $(addprefix $(LIBFDT_objdir)/,$(STD_CLEANFILES))
|
|
|
|
rm -f $(LIBFDT_objdir)/*.so
|
|
|
|
|
|
|
|
ifneq ($(DEPTARGETS),)
|
|
|
|
-include $(LIBFDT_OBJS:%.o=$(LIBFDT_objdir)/%.d)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2014-01-27 19:37:35 +00:00
|
|
|
install-bin: all $(SCRIPTS)
|
|
|
|
@$(VECHO) INSTALL-BIN
|
2010-02-28 21:57:35 +00:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(BINDIR)
|
2012-07-24 16:29:33 +00:00
|
|
|
$(INSTALL) $(BIN) $(SCRIPTS) $(DESTDIR)$(BINDIR)
|
2014-01-27 19:37:35 +00:00
|
|
|
|
|
|
|
install-lib: all
|
|
|
|
@$(VECHO) INSTALL-LIB
|
2010-02-28 21:57:35 +00:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
|
|
|
$(INSTALL) $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
|
2012-07-24 16:29:33 +00:00
|
|
|
ln -sf $(notdir $(LIBFDT_lib)) $(DESTDIR)$(LIBDIR)/$(LIBFDT_soname)
|
|
|
|
ln -sf $(LIBFDT_soname) $(DESTDIR)$(LIBDIR)/libfdt.$(SHAREDLIB_EXT)
|
2010-02-28 21:57:35 +00:00
|
|
|
$(INSTALL) -m 644 $(LIBFDT_archive) $(DESTDIR)$(LIBDIR)
|
2014-01-27 19:37:35 +00:00
|
|
|
|
|
|
|
install-includes:
|
|
|
|
@$(VECHO) INSTALL-INC
|
2010-02-28 21:57:35 +00:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)
|
|
|
|
$(INSTALL) -m 644 $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR)
|
|
|
|
|
2014-01-27 19:37:35 +00:00
|
|
|
install: install-bin install-lib install-includes
|
|
|
|
|
2010-02-28 21:57:35 +00:00
|
|
|
$(VERSION_FILE): Makefile FORCE
|
|
|
|
$(call filechk,version)
|
|
|
|
|
|
|
|
|
|
|
|
dtc: $(DTC_OBJS)
|
|
|
|
|
|
|
|
convert-dtsv0: $(CONVERT_OBJS)
|
|
|
|
@$(VECHO) LD $@
|
|
|
|
$(LINK.c) -o $@ $^
|
|
|
|
|
2012-07-24 16:29:33 +00:00
|
|
|
fdtdump: $(FDTDUMP_OBJS)
|
|
|
|
|
|
|
|
fdtget: $(FDTGET_OBJS) $(LIBFDT_archive)
|
|
|
|
|
|
|
|
fdtput: $(FDTPUT_OBJS) $(LIBFDT_archive)
|
2010-02-28 21:57:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Testsuite rules
|
|
|
|
#
|
|
|
|
TESTS_PREFIX=tests/
|
2012-07-24 16:29:33 +00:00
|
|
|
|
|
|
|
TESTS_BIN += dtc
|
|
|
|
TESTS_BIN += convert-dtsv0
|
|
|
|
TESTS_BIN += fdtput
|
|
|
|
TESTS_BIN += fdtget
|
|
|
|
|
2010-02-28 21:57:35 +00:00
|
|
|
include tests/Makefile.tests
|
|
|
|
|
|
|
|
#
|
|
|
|
# Clean rules
|
|
|
|
#
|
2012-07-24 16:29:33 +00:00
|
|
|
STD_CLEANFILES = *~ *.o *.$(SHAREDLIB_EXT) *.d *.a *.i *.s core a.out vgcore.* \
|
2010-02-28 21:57:35 +00:00
|
|
|
*.tab.[ch] *.lex.c *.output
|
|
|
|
|
|
|
|
clean: libfdt_clean tests_clean
|
|
|
|
@$(VECHO) CLEAN
|
|
|
|
rm -f $(STD_CLEANFILES)
|
|
|
|
rm -f $(VERSION_FILE)
|
|
|
|
rm -f $(BIN)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generic compile rules
|
|
|
|
#
|
|
|
|
%: %.o
|
|
|
|
@$(VECHO) LD $@
|
|
|
|
$(LINK.c) -o $@ $^
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
@$(VECHO) CC $@
|
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
|
|
|
%.o: %.S
|
|
|
|
@$(VECHO) AS $@
|
|
|
|
$(CC) $(CPPFLAGS) $(AFLAGS) -D__ASSEMBLY__ -o $@ -c $<
|
|
|
|
|
|
|
|
%.d: %.c
|
|
|
|
@$(VECHO) DEP $<
|
|
|
|
$(CC) $(CPPFLAGS) -MM -MG -MT "$*.o $@" $< > $@
|
|
|
|
|
|
|
|
%.d: %.S
|
|
|
|
@$(VECHO) DEP $<
|
|
|
|
$(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) $@ $^
|
|
|
|
|
|
|
|
$(LIBFDT_lib):
|
|
|
|
@$(VECHO) LD $@
|
2012-07-24 16:29:33 +00:00
|
|
|
$(CC) $(LDFLAGS) -fPIC $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
|
2010-02-28 21:57:35 +00:00
|
|
|
|
|
|
|
%.lex.c: %.l
|
|
|
|
@$(VECHO) LEX $@
|
|
|
|
$(LEX) -o$@ $<
|
|
|
|
|
|
|
|
%.tab.c %.tab.h %.output: %.y
|
|
|
|
@$(VECHO) BISON $@
|
|
|
|
$(BISON) -d $<
|
|
|
|
|
|
|
|
FORCE:
|