Makefile-ccan 2.4 KB

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