Makefile-ccan 2.3 KB

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