|
1 # |
|
2 # Device Tree Compiler |
|
3 # |
|
4 |
|
5 # |
|
6 # Version information will be constructed in this order: |
|
7 # EXTRAVERSION might be "-rc", for example. |
|
8 # LOCAL_VERSION is likely from command line. |
|
9 # CONFIG_LOCALVERSION from some future config system. |
|
10 # |
|
11 VERSION = 1 |
|
12 PATCHLEVEL = 2 |
|
13 SUBLEVEL = 0 |
|
14 EXTRAVERSION = |
|
15 LOCAL_VERSION = |
|
16 CONFIG_LOCALVERSION = |
|
17 |
|
18 CPPFLAGS = -I libfdt |
|
19 CFLAGS = -Wall -g -Os -Wpointer-arith -Wcast-qual |
|
20 |
|
21 BISON = bison |
|
22 LEX = flex |
|
23 |
|
24 INSTALL = /usr/bin/install |
|
25 DESTDIR = |
|
26 PREFIX = $(HOME) |
|
27 BINDIR = $(PREFIX)/bin |
|
28 LIBDIR = $(PREFIX)/lib |
|
29 INCLUDEDIR = $(PREFIX)/include |
|
30 |
|
31 # |
|
32 # Overall rules |
|
33 # |
|
34 ifdef V |
|
35 VECHO = : |
|
36 else |
|
37 VECHO = echo " " |
|
38 ARFLAGS = rc |
|
39 .SILENT: |
|
40 endif |
|
41 |
|
42 NODEPTARGETS = clean |
|
43 ifeq ($(MAKECMDGOALS),) |
|
44 DEPTARGETS = all |
|
45 else |
|
46 DEPTARGETS = $(filter-out $(NODEPTARGETS),$(MAKECMDGOALS)) |
|
47 endif |
|
48 |
|
49 all: dtc ftdump convert-dtsv0 libfdt |
|
50 |
|
51 install: all |
|
52 @$(VECHO) INSTALL |
|
53 $(INSTALL) -d $(DESTDIR)$(BINDIR) |
|
54 $(INSTALL) -m 755 dtc $(DESTDIR)$(BINDIR) |
|
55 $(INSTALL) -d $(DESTDIR)$(LIBDIR) |
|
56 $(INSTALL) -m 644 $(LIBFDT_lib) $(DESTDIR)$(LIBDIR) |
|
57 $(INSTALL) -d $(DESTDIR)$(INCLUDEDIR) |
|
58 $(INSTALL) -m 644 $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR) |
|
59 |
|
60 # |
|
61 # Rules for versioning |
|
62 # |
|
63 |
|
64 DTC_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) |
|
65 VERSION_FILE = version_gen.h |
|
66 |
|
67 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ |
|
68 else if [ -x /bin/bash ]; then echo /bin/bash; \ |
|
69 else echo sh; fi ; fi) |
|
70 |
|
71 nullstring := |
|
72 space := $(nullstring) # end of line |
|
73 |
|
74 localver_config = $(subst $(space),, $(string) \ |
|
75 $(patsubst "%",%,$(CONFIG_LOCALVERSION))) |
|
76 |
|
77 localver_cmd = $(subst $(space),, $(string) \ |
|
78 $(patsubst "%",%,$(LOCALVERSION))) |
|
79 |
|
80 localver_scm = $(shell $(CONFIG_SHELL) ./scripts/setlocalversion) |
|
81 localver_full = $(localver_config)$(localver_cmd)$(localver_scm) |
|
82 |
|
83 dtc_version = $(DTC_VERSION)$(localver_full) |
|
84 |
|
85 # Contents of the generated version file. |
|
86 define filechk_version |
|
87 (echo "#define DTC_VERSION \"DTC $(dtc_version)\""; ) |
|
88 endef |
|
89 |
|
90 define filechk |
|
91 set -e; \ |
|
92 echo ' CHK $@'; \ |
|
93 mkdir -p $(dir $@); \ |
|
94 $(filechk_$(1)) < $< > $@.tmp; \ |
|
95 if [ -r $@ ] && cmp -s $@ $@.tmp; then \ |
|
96 rm -f $@.tmp; \ |
|
97 else \ |
|
98 echo ' UPD $@'; \ |
|
99 mv -f $@.tmp $@; \ |
|
100 fi; |
|
101 endef |
|
102 |
|
103 $(VERSION_FILE): Makefile FORCE |
|
104 $(call filechk,version) |
|
105 |
|
106 # |
|
107 # Rules for dtc proper |
|
108 # |
|
109 include Makefile.dtc |
|
110 |
|
111 BIN += dtc |
|
112 |
|
113 # This stops make from generating the lex and bison output during |
|
114 # auto-dependency computation, but throwing them away as an |
|
115 # intermediate target and building them again "for real" |
|
116 .SECONDARY: $(DTC_GEN_SRCS) |
|
117 |
|
118 dtc: $(DTC_OBJS) |
|
119 |
|
120 ifneq ($(DEPTARGETS),) |
|
121 -include $(DTC_OBJS:%.o=%.d) |
|
122 endif |
|
123 # |
|
124 # Rules for ftdump & convert-dtsv0 |
|
125 # |
|
126 BIN += ftdump convert-dtsv0 |
|
127 |
|
128 ftdump: ftdump.o |
|
129 |
|
130 convert-dtsv0: convert-dtsv0-lexer.lex.o srcpos.o |
|
131 @$(VECHO) LD $@ |
|
132 $(LINK.c) -o $@ $^ |
|
133 |
|
134 ifneq ($(DEPTARGETS),) |
|
135 -include ftdump.d |
|
136 endif |
|
137 # |
|
138 # Rules for libfdt |
|
139 # |
|
140 LIBFDT_objdir = libfdt |
|
141 LIBFDT_srcdir = libfdt |
|
142 LIBFDT_lib = $(LIBFDT_objdir)/libfdt.a |
|
143 LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES)) |
|
144 |
|
145 include $(LIBFDT_srcdir)/Makefile.libfdt |
|
146 |
|
147 .PHONY: libfdt |
|
148 libfdt: $(LIBFDT_lib) |
|
149 |
|
150 $(LIBFDT_lib): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS)) |
|
151 |
|
152 libfdt_clean: |
|
153 @$(VECHO) CLEAN "(libfdt)" |
|
154 rm -f $(addprefix $(LIBFDT_objdir)/,$(STD_CLEANFILES)) |
|
155 |
|
156 ifneq ($(DEPTARGETS),) |
|
157 -include $(LIBFDT_OBJS:%.o=$(LIBFDT_objdir)/%.d) |
|
158 endif |
|
159 |
|
160 # |
|
161 # Testsuite rules |
|
162 # |
|
163 TESTS_PREFIX=tests/ |
|
164 include tests/Makefile.tests |
|
165 |
|
166 # |
|
167 # Clean rules |
|
168 # |
|
169 STD_CLEANFILES = *~ *.o *.d *.a *.i *.s core a.out vgcore.* \ |
|
170 *.tab.[ch] *.lex.c *.output |
|
171 |
|
172 clean: libfdt_clean tests_clean |
|
173 @$(VECHO) CLEAN |
|
174 rm -f $(STD_CLEANFILES) |
|
175 rm -f $(VERSION_FILE) |
|
176 rm -f $(BIN) |
|
177 |
|
178 # |
|
179 # Generic compile rules |
|
180 # |
|
181 %: %.o |
|
182 @$(VECHO) LD $@ |
|
183 $(LINK.c) -o $@ $^ |
|
184 |
|
185 %.o: %.c |
|
186 @$(VECHO) CC $@ |
|
187 $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< |
|
188 |
|
189 %.o: %.S |
|
190 @$(VECHO) AS $@ |
|
191 $(CC) $(CPPFLAGS) $(AFLAGS) -D__ASSEMBLY__ -o $@ -c $< |
|
192 |
|
193 %.d: %.c |
|
194 @$(VECHO) DEP $< |
|
195 $(CC) $(CPPFLAGS) -MM -MG -MT "$*.o $@" $< > $@ |
|
196 |
|
197 %.d: %.S |
|
198 @$(VECHO) DEP $< |
|
199 $(CC) $(CPPFLAGS) -MM -MG -MT "$*.o $@" $< > $@ |
|
200 |
|
201 %.i: %.c |
|
202 @$(VECHO) CPP $@ |
|
203 $(CC) $(CPPFLAGS) -E $< > $@ |
|
204 |
|
205 %.s: %.c |
|
206 @$(VECHO) CC -S $@ |
|
207 $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -S $< |
|
208 |
|
209 %.a: |
|
210 @$(VECHO) AR $@ |
|
211 $(AR) $(ARFLAGS) $@ $^ |
|
212 |
|
213 %.lex.c: %.l |
|
214 @$(VECHO) LEX $@ |
|
215 $(LEX) -o$@ $< |
|
216 |
|
217 %.tab.c %.tab.h %.output: %.y |
|
218 @$(VECHO) BISON $@ |
|
219 $(BISON) -d $< |
|
220 |
|
221 FORCE: |