Makefile-ccan 2.6 KB

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