Makefile-ccan 2.5 KB

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