Makefile-ccan 2.7 KB

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