Makefile-ccan 2.4 KB

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