Makefile-ccan 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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/shachain \
  44. crypto/siphash24 \
  45. daemonize \
  46. daemon_with_notify \
  47. darray \
  48. deque \
  49. dgraph \
  50. endian \
  51. eratosthenes \
  52. err \
  53. failtest \
  54. foreach \
  55. generator \
  56. grab_file \
  57. hash \
  58. heap \
  59. htable \
  60. idtree \
  61. ilog \
  62. invbloom \
  63. io \
  64. isaac \
  65. iscsi \
  66. jacobson_karels \
  67. jmap \
  68. jset \
  69. json \
  70. lbalance \
  71. likely \
  72. list \
  73. lpq \
  74. lqueue \
  75. lstack \
  76. md4 \
  77. mem \
  78. minmax \
  79. net \
  80. nfs \
  81. noerr \
  82. ntdb \
  83. objset \
  84. ogg_to_pcm \
  85. opt \
  86. order \
  87. permutation \
  88. pipecmd \
  89. pr_log \
  90. ptrint \
  91. ptr_valid \
  92. pushpull \
  93. rbtree \
  94. rbuf \
  95. read_write_all \
  96. rfc822 \
  97. rszshm \
  98. short_types \
  99. siphash \
  100. sparse_bsearch \
  101. str \
  102. str/hex \
  103. strgrp \
  104. stringbuilder \
  105. stringmap \
  106. strmap \
  107. strset \
  108. structeq \
  109. take \
  110. tal \
  111. tal/grab_file \
  112. tal/link \
  113. tal/path \
  114. tal/stack \
  115. tal/str \
  116. tal/talloc \
  117. talloc \
  118. tally \
  119. tap \
  120. tcon \
  121. time \
  122. timer \
  123. tlist \
  124. tlist2 \
  125. ttxml \
  126. typesafe_cb \
  127. version \
  128. wwviaudio \
  129. xstring
  130. # Anything with C files needs building; dir leaves / on, sort uniquifies
  131. MODS_WITH_SRC = $(patsubst ccan/%/, %, $(sort $(foreach m, $(MODS), $(dir $(wildcard ccan/$m/*.c)))))
  132. default: libccan.a
  133. # Automatic dependency generation: makes ccan/*/*.d files.
  134. DEPGEN=-MMD
  135. -include $(foreach m, $(MODS), ccan/$(m)/*.d)
  136. DIRS=$(patsubst %, ccan/%, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)))
  137. # Generate everyone's separate Makefiles.
  138. -include $(foreach dir, $(DIRS), $(dir)-Makefile)
  139. ccan/%-Makefile:
  140. @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
  141. @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
  142. # We compile all the ccan/foo/*.o files together into ccan/foo.o
  143. OBJFILES=$(DIRS:=.o)
  144. # We create all the .o files and link them together.
  145. $(OBJFILES): %.o:
  146. $(LD) -r -o $@ $^
  147. libccan.a: $(OBJFILES)
  148. $(AR) r $@ $(OBJFILES)