Makefile-ccan 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. CFLAGS_FORCE_C_SOURCE = -x c
  8. MODS := a_star \
  9. aga \
  10. agar \
  11. alignof \
  12. altstack \
  13. antithread \
  14. antithread/alloc \
  15. argcheck \
  16. array_size \
  17. asearch \
  18. asort \
  19. asprintf \
  20. autodata \
  21. avl \
  22. base64 \
  23. bdelta \
  24. bitmap \
  25. block_pool \
  26. breakpoint \
  27. btree \
  28. build_assert \
  29. bytestring \
  30. cast \
  31. ccan_tokenizer \
  32. cdump \
  33. charset \
  34. check_type \
  35. ciniparser \
  36. compiler \
  37. container_of \
  38. cppmagic \
  39. cpuid \
  40. crc \
  41. crcsync \
  42. crypto/ripemd160 \
  43. crypto/sha256 \
  44. crypto/sha512 \
  45. crypto/shachain \
  46. crypto/siphash24 \
  47. daemonize \
  48. daemon_with_notify \
  49. darray \
  50. deque \
  51. dgraph \
  52. endian \
  53. eratosthenes \
  54. err \
  55. failtest \
  56. foreach \
  57. generator \
  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. jset \
  71. json \
  72. lbalance \
  73. likely \
  74. list \
  75. lpq \
  76. lqueue \
  77. lstack \
  78. md4 \
  79. mem \
  80. minmax \
  81. net \
  82. nfs \
  83. noerr \
  84. ntdb \
  85. objset \
  86. ogg_to_pcm \
  87. opt \
  88. order \
  89. permutation \
  90. pipecmd \
  91. pr_log \
  92. ptrint \
  93. ptr_valid \
  94. pushpull \
  95. rbtree \
  96. rbuf \
  97. read_write_all \
  98. rfc822 \
  99. rszshm \
  100. short_types \
  101. siphash \
  102. sparse_bsearch \
  103. str \
  104. str/hex \
  105. strgrp \
  106. stringbuilder \
  107. stringmap \
  108. strmap \
  109. strset \
  110. structeq \
  111. take \
  112. tal \
  113. tal/grab_file \
  114. tal/link \
  115. tal/path \
  116. tal/stack \
  117. tal/str \
  118. tal/talloc \
  119. talloc \
  120. tally \
  121. tap \
  122. tcon \
  123. time \
  124. timer \
  125. tlist \
  126. tlist2 \
  127. ttxml \
  128. typesafe_cb \
  129. version \
  130. wwviaudio \
  131. xstring
  132. # Anything with C files needs building; dir leaves / on, sort uniquifies
  133. MODS_WITH_SRC = $(patsubst ccan/%/, %, $(sort $(foreach m, $(MODS), $(dir $(wildcard ccan/$m/*.c)))))
  134. default: libccan.a
  135. # Automatic dependency generation: makes ccan/*/*.d files.
  136. DEPGEN=-MMD
  137. -include $(foreach m, $(MODS), ccan/$(m)/*.d)
  138. DIRS=$(patsubst %, ccan/%, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)))
  139. # Generate everyone's separate Makefiles.
  140. -include $(foreach dir, $(DIRS), $(dir)-Makefile)
  141. ccan/%-Makefile:
  142. @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
  143. @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
  144. # We compile all the ccan/foo/*.o files together into ccan/foo.o
  145. OBJFILES=$(DIRS:=.o)
  146. # We create all the .o files and link them together.
  147. $(OBJFILES): %.o:
  148. $(LD) -r -o $@ $^
  149. libccan.a: $(OBJFILES)
  150. $(AR) r $@ $(OBJFILES)