Makefile-ccan 2.7 KB

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