Gerald Van Baren | c0577a6 | 2007-03-31 11:59:59 -0400 | [diff] [blame^] | 1 | PREFIX = /usr/local |
| 2 | TARGETLIBS = libfdt.a |
| 3 | LIBOBJS = fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o fdt_strerror.o |
| 4 | |
| 5 | SOURCE = $(shell find . -maxdepth 1 ! -name version.h -a -name '*.[h]') |
| 6 | SOURCE += *.c Makefile |
| 7 | NODEPTARGETS=<clean> |
| 8 | |
| 9 | CPPFLAGS = -I. |
| 10 | CFLAGS = -Wall -g |
| 11 | |
| 12 | LIBDIR = $(PREFIX)/$(LIB32) |
| 13 | |
| 14 | EXTRA_DIST = \ |
| 15 | README \ |
| 16 | HOWTO \ |
| 17 | LGPL-2.1 |
| 18 | |
| 19 | ifdef V |
| 20 | VECHO = : |
| 21 | else |
| 22 | VECHO = echo " " |
| 23 | ARFLAGS = rc |
| 24 | .SILENT: |
| 25 | endif |
| 26 | |
| 27 | DEPFILES = $(LIBOBJS:%.o=%.d) |
| 28 | |
| 29 | all: libs tests |
| 30 | |
| 31 | .PHONY: tests libs |
| 32 | |
| 33 | libs: $(TARGETLIBS) |
| 34 | |
| 35 | tests: tests/all |
| 36 | |
| 37 | tests/%: libs |
| 38 | $(MAKE) -C tests $* |
| 39 | |
| 40 | check: all |
| 41 | cd tests; ./run_tests.sh |
| 42 | |
| 43 | checkv: all |
| 44 | cd tests; ./run_tests.sh -v |
| 45 | |
| 46 | func: all |
| 47 | cd tests; ./run_tests.sh -t func |
| 48 | |
| 49 | funcv: all |
| 50 | cd tests; ./run_tests.sh -t func -v |
| 51 | |
| 52 | stress: all |
| 53 | cd tests; ./run_tests.sh -t stress |
| 54 | |
| 55 | stressv: all |
| 56 | cd tests; ./run_tests.sh -t stress -v |
| 57 | |
| 58 | %.o: %.c |
| 59 | @$(VECHO) CC $@ |
| 60 | $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< |
| 61 | |
| 62 | libfdt.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 | |
| 74 | clean: |
| 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. |
| 86 | ifeq (,$(findstring <$(MAKECMDGOALS)>,$(NODEPTARGETS))) |
| 87 | -include $(DEPFILES) |
| 88 | endif |