Makefile-ccan 2.3 KB

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