Makefile-ccan 2.3 KB

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