Makefile-ccan 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. # Normal modules: no external dependencies, just a header:
  8. MODS_NORMAL_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. # No external dependencies, with C code:
  25. MODS_NORMAL_WITH_SRC := antithread \
  26. antithread/alloc \
  27. asort \
  28. asprintf \
  29. autodata \
  30. avl \
  31. bdelta \
  32. block_pool \
  33. btree \
  34. ccan_tokenizer \
  35. charset \
  36. ciniparser \
  37. crc \
  38. crcsync \
  39. daemonize \
  40. daemon_with_notify \
  41. dgraph \
  42. err \
  43. failtest \
  44. foreach \
  45. grab_file \
  46. hash \
  47. htable \
  48. idtree \
  49. ilog \
  50. isaac \
  51. iscsi \
  52. json \
  53. lbalance \
  54. likely \
  55. list \
  56. md4 \
  57. net \
  58. noerr \
  59. opt \
  60. ptr_valid \
  61. rbtree \
  62. read_write_all \
  63. rfc822 \
  64. sparse_bsearch \
  65. str \
  66. stringmap \
  67. strmap \
  68. strset \
  69. str_talloc \
  70. take \
  71. tal \
  72. talloc \
  73. talloc_link \
  74. tally \
  75. tap \
  76. time \
  77. ttxml
  78. MODS_NORMAL:=$(MODS_NORMAL_WITH_SRC) $(MODS_NORMAL_NO_SRC)
  79. # Modules which require external dependencies, thus may not pass check.
  80. MODS_EXTERNAL_NO_SRC:=
  81. MODS_EXTERNAL_WITH_SRC:=jmap \
  82. jset \
  83. nfs \
  84. ogg_to_pcm \
  85. wwviaudio
  86. MODS_EXTERNAL:=$(MODS_EXTERNAL_NO_SRC) $(MODS_EXTERNAL_WITH_SRC)
  87. MODS:=$(MODS_EXTERNAL) $(MODS_NORMAL)
  88. default: libccan.a
  89. # Automatic dependency generation: makes ccan/*/*.d files.
  90. DEPGEN=-MD
  91. -include ccan/*/*.d
  92. # Anything with C files needs building; dir leaves / on, sort uniquifies
  93. DIRS=$(patsubst %/, %, $(sort $(foreach m, $(MODS_NORMAL_WITH_SRC), $(dir $(wildcard ccan/$m/*.c)))))
  94. # Generate everyone's separate Makefiles.
  95. -include $(foreach dir, $(DIRS), $(dir)-Makefile)
  96. ccan/%-Makefile:
  97. @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
  98. @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
  99. # We compile all the ccan/foo/*.o files together into ccan/foo.o
  100. OBJFILES=$(DIRS:=.o)
  101. # We create all the .o files and link them together.
  102. $(OBJFILES): %.o:
  103. $(LD) -r -o $@ $^
  104. libccan.a: $(OBJFILES)
  105. $(AR) r $@ $(OBJFILES)