Makefile-ccan 2.7 KB

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