blob: c8240bba3a77e058964fafc4ac6fef60ca49472e [file] [log] [blame]
Gerald Van Barenc0577a62007-03-31 11:59:59 -04001PREFIX = /usr/local
2TARGETLIBS = libfdt.a
3LIBOBJS = fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o fdt_strerror.o
4
5SOURCE = $(shell find . -maxdepth 1 ! -name version.h -a -name '*.[h]')
6SOURCE += *.c Makefile
7NODEPTARGETS=<clean>
8
9CPPFLAGS = -I.
10CFLAGS = -Wall -g
11
12LIBDIR = $(PREFIX)/$(LIB32)
13
14EXTRA_DIST = \
15 README \
16 HOWTO \
17 LGPL-2.1
18
19ifdef V
20VECHO = :
21else
22VECHO = echo " "
23ARFLAGS = rc
24.SILENT:
25endif
26
27DEPFILES = $(LIBOBJS:%.o=%.d)
28
29all: libs tests
30
31.PHONY: tests libs
32
33libs: $(TARGETLIBS)
34
35tests: tests/all
36
37tests/%: libs
38 $(MAKE) -C tests $*
39
40check: all
41 cd tests; ./run_tests.sh
42
43checkv: all
44 cd tests; ./run_tests.sh -v
45
46func: all
47 cd tests; ./run_tests.sh -t func
48
49funcv: all
50 cd tests; ./run_tests.sh -t func -v
51
52stress: all
53 cd tests; ./run_tests.sh -t stress
54
55stressv: all
56 cd tests; ./run_tests.sh -t stress -v
57
58%.o: %.c
59 @$(VECHO) CC $@
60 $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
61
62libfdt.a: $(LIBOBJS)
63 @$(VECHO) AR $@
64 $(AR) $(ARFLAGS) $@ $^
65
66%.i: %.c
67 @$(VECHO) CPP $@
68 $(CC) $(CPPFLAGS) -E $< > $@
69
70%.s: %.c
71 @$(VECHO) CC -S $@
72 $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -S $<
73
74clean:
75 @$(VECHO) CLEAN
76 rm -f *~ *.o *.so *.a *.d *.i *.s core a.out $(VERSION)
77 $(MAKE) -C tests clean
78
79%.d: %.c
80 @$(CC) $(CPPFLAGS) -MM -MT "$*.o $@" $< > $@
81
82# Workaround: Don't build dependencies for certain targets
83# When the include below is executed, make will use the %.d target above to
84# generate missing files. For certain targets (clean, version.h, etc) we don't
85# need or want these dependency files, so don't include them in this case.
86ifeq (,$(findstring <$(MAKECMDGOALS)>,$(NODEPTARGETS)))
87-include $(DEPFILES)
88endif