Makefile-ccan 2.3 KB

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