Makefile-ccan 2.5 KB

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