Makefile-ccan 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. # Modules which are just a header:
  8. MODS_NO_SRC := alignof \
  9. argcheck \
  10. array_size \
  11. asearch \
  12. bitmap \
  13. build_assert \
  14. cast \
  15. check_type \
  16. compiler \
  17. container_of \
  18. darray \
  19. endian \
  20. minmax \
  21. objset \
  22. short_types \
  23. structeq \
  24. tcon \
  25. tlist \
  26. typesafe_cb \
  27. version
  28. # No external dependencies, with C code:
  29. MODS_WITH_SRC := antithread \
  30. antithread/alloc \
  31. asort \
  32. asprintf \
  33. autodata \
  34. avl \
  35. base64 \
  36. bdelta \
  37. block_pool \
  38. breakpoint \
  39. btree \
  40. bytestring \
  41. ccan_tokenizer \
  42. cdump \
  43. charset \
  44. ciniparser \
  45. crc \
  46. crcsync \
  47. cpuid \
  48. crypto/ripemd160 \
  49. crypto/sha256 \
  50. crypto/shachain \
  51. daemonize \
  52. daemon_with_notify \
  53. dgraph \
  54. eratosthenes \
  55. err \
  56. failtest \
  57. foreach \
  58. grab_file \
  59. hash \
  60. heap \
  61. htable \
  62. idtree \
  63. ilog \
  64. invbloom \
  65. io \
  66. isaac \
  67. iscsi \
  68. jacobson_karels \
  69. jmap \
  70. json \
  71. jset \
  72. lbalance \
  73. likely \
  74. list \
  75. lqueue \
  76. lstack \
  77. md4 \
  78. mem \
  79. net \
  80. nfs \
  81. noerr \
  82. ntdb \
  83. ogg_to_pcm \
  84. opt \
  85. order \
  86. ptrint \
  87. ptr_valid \
  88. pushpull \
  89. rbtree \
  90. rbuf \
  91. read_write_all \
  92. rfc822 \
  93. siphash \
  94. sparse_bsearch \
  95. str \
  96. str/hex \
  97. stringbuilder \
  98. stringmap \
  99. strmap \
  100. strset \
  101. take \
  102. tal \
  103. tal/grab_file \
  104. tal/link \
  105. tal/path \
  106. tal/stack \
  107. tal/str \
  108. tal/talloc \
  109. talloc \
  110. tally \
  111. tap \
  112. time \
  113. timer \
  114. ttxml \
  115. wwviaudio
  116. MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
  117. default: libccan.a
  118. # Automatic dependency generation: makes ccan/*/*.d files.
  119. DEPGEN=-MD
  120. -include ccan/*/*.d
  121. # Anything with C files needs building; dir leaves / on, sort uniquifies
  122. DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
  123. # Generate everyone's separate Makefiles.
  124. -include $(foreach dir, $(DIRS), $(dir)-Makefile)
  125. ccan/%-Makefile:
  126. @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
  127. @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
  128. # We compile all the ccan/foo/*.o files together into ccan/foo.o
  129. OBJFILES=$(DIRS:=.o)
  130. # We create all the .o files and link them together.
  131. $(OBJFILES): %.o:
  132. $(LD) -r -o $@ $^
  133. libccan.a: $(OBJFILES)
  134. $(AR) r $@ $(OBJFILES)