Makefile-ccan 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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/str \
  101. tal/talloc \
  102. talloc \
  103. tally \
  104. tap \
  105. time \
  106. timer \
  107. ttxml \
  108. wwviaudio
  109. MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
  110. default: libccan.a
  111. # Automatic dependency generation: makes ccan/*/*.d files.
  112. DEPGEN=-MD
  113. -include ccan/*/*.d
  114. # Anything with C files needs building; dir leaves / on, sort uniquifies
  115. DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
  116. # Generate everyone's separate Makefiles.
  117. -include $(foreach dir, $(DIRS), $(dir)-Makefile)
  118. ccan/%-Makefile:
  119. @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
  120. @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
  121. # We compile all the ccan/foo/*.o files together into ccan/foo.o
  122. OBJFILES=$(DIRS:=.o)
  123. # We create all the .o files and link them together.
  124. $(OBJFILES): %.o:
  125. $(LD) -r -o $@ $^
  126. libccan.a: $(OBJFILES)
  127. $(AR) r $@ $(OBJFILES)