Makefile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. SOURCE = $(shell find . -maxdepth 1 ! -name version.h -a -name '*.[h]')
  5. SOURCE += *.c Makefile
  6. NODEPTARGETS=<clean>
  7. CPPFLAGS = -I.
  8. CFLAGS = -Wall -g
  9. LIBDIR = $(PREFIX)/$(LIB32)
  10. EXTRA_DIST = \
  11. README \
  12. HOWTO \
  13. LGPL-2.1
  14. ifdef V
  15. VECHO = :
  16. else
  17. VECHO = echo " "
  18. ARFLAGS = rc
  19. .SILENT:
  20. endif
  21. DEPFILES = $(LIBOBJS:%.o=%.d)
  22. all: libs tests
  23. .PHONY: tests libs
  24. libs: $(TARGETLIBS)
  25. tests: tests/all
  26. tests/%: libs
  27. $(MAKE) -C tests $*
  28. check: all
  29. cd tests; ./run_tests.sh
  30. checkv: all
  31. cd tests; ./run_tests.sh -v
  32. func: all
  33. cd tests; ./run_tests.sh -t func
  34. funcv: all
  35. cd tests; ./run_tests.sh -t func -v
  36. stress: all
  37. cd tests; ./run_tests.sh -t stress
  38. stressv: all
  39. cd tests; ./run_tests.sh -t stress -v
  40. %.o: %.c
  41. @$(VECHO) CC $@
  42. $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
  43. libfdt.a: $(LIBOBJS)
  44. @$(VECHO) AR $@
  45. $(AR) $(ARFLAGS) $@ $^
  46. %.i: %.c
  47. @$(VECHO) CPP $@
  48. $(CC) $(CPPFLAGS) -E $< > $@
  49. %.s: %.c
  50. @$(VECHO) CC -S $@
  51. $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -S $<
  52. clean:
  53. @$(VECHO) CLEAN
  54. rm -f *~ *.o *.so *.a *.d *.i *.s core a.out $(VERSION)
  55. $(MAKE) -C tests clean
  56. %.d: %.c
  57. @$(CC) $(CPPFLAGS) -MM -MT "$*.o $@" $< > $@
  58. # Workaround: Don't build dependencies for certain targets
  59. # When the include below is executed, make will use the %.d target above to
  60. # generate missing files. For certain targets (clean, version.h, etc) we don't
  61. # need or want these dependency files, so don't include them in this case.
  62. ifeq (,$(findstring <$(MAKECMDGOALS)>,$(NODEPTARGETS)))
  63. -include $(DEPFILES)
  64. endif