Makefile-ccan 2.5 KB

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