Makefile-ccan 2.4 KB

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