Makefile-ccan 2.4 KB

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