Makefile-ccan 2.7 KB

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