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