Makefile-ccan 2.8 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. # 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. cppmagic \
  19. darray \
  20. endian \
  21. lqueue \
  22. lstack \
  23. minmax \
  24. objset \
  25. short_types \
  26. structeq \
  27. tcon \
  28. tlist \
  29. typesafe_cb \
  30. version
  31. # No external dependencies, with C code:
  32. MODS_WITH_SRC := a_star \
  33. aga \
  34. agar \
  35. altstack \
  36. antithread \
  37. antithread/alloc \
  38. asort \
  39. asprintf \
  40. autodata \
  41. avl \
  42. base64 \
  43. bdelta \
  44. block_pool \
  45. breakpoint \
  46. btree \
  47. bytestring \
  48. ccan_tokenizer \
  49. cdump \
  50. charset \
  51. ciniparser \
  52. crc \
  53. crcsync \
  54. cpuid \
  55. crypto/ripemd160 \
  56. crypto/sha256 \
  57. crypto/shachain \
  58. daemonize \
  59. daemon_with_notify \
  60. deque \
  61. dgraph \
  62. eratosthenes \
  63. err \
  64. failtest \
  65. foreach \
  66. generator \
  67. grab_file \
  68. hash \
  69. heap \
  70. htable \
  71. idtree \
  72. ilog \
  73. invbloom \
  74. io \
  75. isaac \
  76. iscsi \
  77. jacobson_karels \
  78. jmap \
  79. json \
  80. jset \
  81. lbalance \
  82. likely \
  83. list \
  84. lpq \
  85. md4 \
  86. mem \
  87. net \
  88. nfs \
  89. noerr \
  90. ntdb \
  91. ogg_to_pcm \
  92. opt \
  93. order \
  94. permutation \
  95. pipecmd \
  96. pr_log \
  97. ptrint \
  98. ptr_valid \
  99. pushpull \
  100. rbtree \
  101. rbuf \
  102. read_write_all \
  103. rfc822 \
  104. rszshm \
  105. siphash \
  106. sparse_bsearch \
  107. str \
  108. str/hex \
  109. stringbuilder \
  110. stringmap \
  111. strgrp \
  112. strmap \
  113. strset \
  114. take \
  115. tal \
  116. tal/grab_file \
  117. tal/link \
  118. tal/path \
  119. tal/stack \
  120. tal/str \
  121. tal/talloc \
  122. talloc \
  123. tally \
  124. tap \
  125. time \
  126. timer \
  127. ttxml \
  128. wwviaudio \
  129. xstring
  130. MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
  131. default: libccan.a
  132. # Automatic dependency generation: makes ccan/*/*.d files.
  133. DEPGEN=-MMD
  134. -include $(foreach m, $(MODS), ccan/$(m)/*.d)
  135. # Anything with C files needs building; dir leaves / on, sort uniquifies
  136. DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
  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)