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