Makefile-ccan 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. ptrint \
  89. ptr_valid \
  90. pushpull \
  91. rbtree \
  92. rbuf \
  93. read_write_all \
  94. rfc822 \
  95. siphash \
  96. sparse_bsearch \
  97. str \
  98. str/hex \
  99. stringbuilder \
  100. stringmap \
  101. strmap \
  102. strset \
  103. take \
  104. tal \
  105. tal/grab_file \
  106. tal/link \
  107. tal/path \
  108. tal/stack \
  109. tal/str \
  110. tal/talloc \
  111. talloc \
  112. tally \
  113. tap \
  114. time \
  115. timer \
  116. ttxml \
  117. wwviaudio
  118. MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
  119. default: libccan.a
  120. # Automatic dependency generation: makes ccan/*/*.d files.
  121. DEPGEN=-MD
  122. -include ccan/*/*.d
  123. # Anything with C files needs building; dir leaves / on, sort uniquifies
  124. DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
  125. # Generate everyone's separate Makefiles.
  126. -include $(foreach dir, $(DIRS), $(dir)-Makefile)
  127. ccan/%-Makefile:
  128. @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
  129. @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
  130. # We compile all the ccan/foo/*.o files together into ccan/foo.o
  131. OBJFILES=$(DIRS:=.o)
  132. # We create all the .o files and link them together.
  133. $(OBJFILES): %.o:
  134. $(LD) -r -o $@ $^
  135. libccan.a: $(OBJFILES)
  136. $(AR) r $@ $(OBJFILES)