Makefile-ccan 2.3 KB

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