Makefile-ccan 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. # Example makefile which makes a "libccan.a" of everything under ccan/.
  2. # For simple projects you could just do:
  3. # SRCFILES += $(wildcard ccan/*/*.c)
  4. #CCAN_CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -Wundef -DCCAN_STR_DEBUG=1
  5. CCAN_CFLAGS=-g3 -ggdb -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -Wundef -DCCAN_STR_DEBUG=1
  6. CFLAGS = $(CCAN_CFLAGS) -I. $(DEPGEN)
  7. # Normal modules: no external dependencies, just a header:
  8. MODS_NORMAL_NO_SRC := alignof \
  9. array_size \
  10. asearch \
  11. build_assert \
  12. bytestring \
  13. cast \
  14. check_type \
  15. compiler \
  16. container_of \
  17. darray \
  18. endian \
  19. objset \
  20. short_types \
  21. tcon \
  22. tlist \
  23. typesafe_cb
  24. # No external dependencies, with C code:
  25. MODS_NORMAL_WITH_SRC := antithread \
  26. antithread/alloc \
  27. asort \
  28. asprintf \
  29. autodata \
  30. avl \
  31. bdelta \
  32. block_pool \
  33. btree \
  34. ccan_tokenizer \
  35. charset \
  36. ciniparser \
  37. crc \
  38. crcsync \
  39. daemonize \
  40. daemon_with_notify \
  41. dgraph \
  42. err \
  43. failtest \
  44. foreach \
  45. grab_file \
  46. hash \
  47. htable \
  48. idtree \
  49. ilog \
  50. isaac \
  51. iscsi \
  52. json \
  53. lbalance \
  54. likely \
  55. list \
  56. md4 \
  57. net \
  58. noerr \
  59. opt \
  60. ptr_valid \
  61. rbtree \
  62. rbuf \
  63. read_write_all \
  64. rfc822 \
  65. sparse_bsearch \
  66. str \
  67. stringmap \
  68. strmap \
  69. strset \
  70. str_talloc \
  71. take \
  72. tal \
  73. tal/link \
  74. tal/path \
  75. tal/str \
  76. talloc \
  77. talloc_link \
  78. tally \
  79. tap \
  80. time \
  81. ttxml
  82. MODS_NORMAL:=$(MODS_NORMAL_WITH_SRC) $(MODS_NORMAL_NO_SRC)
  83. # Modules which require external dependencies, thus may not pass check.
  84. MODS_EXTERNAL_NO_SRC:=
  85. MODS_EXTERNAL_WITH_SRC:=jmap \
  86. jset \
  87. nfs \
  88. ogg_to_pcm \
  89. wwviaudio
  90. MODS_EXTERNAL:=$(MODS_EXTERNAL_NO_SRC) $(MODS_EXTERNAL_WITH_SRC)
  91. MODS:=$(MODS_EXTERNAL) $(MODS_NORMAL)
  92. default: libccan.a
  93. # Automatic dependency generation: makes ccan/*/*.d files.
  94. DEPGEN=-MD
  95. -include ccan/*/*.d
  96. # Anything with C files needs building; dir leaves / on, sort uniquifies
  97. DIRS=$(patsubst %/, %, $(sort $(foreach m, $(MODS_NORMAL_WITH_SRC), $(dir $(wildcard ccan/$m/*.c)))))
  98. # Generate everyone's separate Makefiles.
  99. -include $(foreach dir, $(DIRS), $(dir)-Makefile)
  100. ccan/%-Makefile:
  101. @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
  102. @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
  103. # We compile all the ccan/foo/*.o files together into ccan/foo.o
  104. OBJFILES=$(DIRS:=.o)
  105. # We create all the .o files and link them together.
  106. $(OBJFILES): %.o:
  107. $(LD) -r -o $@ $^
  108. libccan.a: $(OBJFILES)
  109. $(AR) r $@ $(OBJFILES)