Makefile-ccan 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. version
  25. # No external dependencies, with C code:
  26. MODS_NORMAL_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. json \
  54. lbalance \
  55. likely \
  56. list \
  57. md4 \
  58. net \
  59. noerr \
  60. opt \
  61. ptr_valid \
  62. rbtree \
  63. rbuf \
  64. read_write_all \
  65. rfc822 \
  66. siphash \
  67. sparse_bsearch \
  68. str \
  69. stringmap \
  70. strmap \
  71. strset \
  72. str_talloc \
  73. take \
  74. tal \
  75. tal/link \
  76. tal/path \
  77. tal/str \
  78. talloc \
  79. talloc_link \
  80. tally \
  81. tap \
  82. time \
  83. ttxml
  84. MODS_NORMAL:=$(MODS_NORMAL_WITH_SRC) $(MODS_NORMAL_NO_SRC)
  85. # Modules which require external dependencies, thus may not pass check.
  86. MODS_EXTERNAL_NO_SRC:=
  87. MODS_EXTERNAL_WITH_SRC:=jmap \
  88. jset \
  89. nfs \
  90. ogg_to_pcm \
  91. tal/talloc \
  92. wwviaudio
  93. MODS_EXTERNAL:=$(MODS_EXTERNAL_NO_SRC) $(MODS_EXTERNAL_WITH_SRC)
  94. MODS:=$(MODS_EXTERNAL) $(MODS_NORMAL)
  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, $(MODS_NORMAL_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)