Makefile-ccan 2.3 KB

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