Makefile-ccan 2.6 KB

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