Makefile.in 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # Nathan's generic Makefile -*- mode:Makefile -*-
  2. # Copyright (C) 2019-2020 Nathan Sidwell, nathan@acm.org
  3. # License: Apache v2.0
  4. srcdir := @srcdir@
  5. prefix := @prefix@
  6. exec_prefix := @exec_prefix@
  7. bindir := @bindir@
  8. libdir := @libdir@
  9. includedir := @includedir@
  10. # Linker options
  11. LDFLAGS := @LDFLAGS@
  12. LIBS := @LIBS@
  13. # We have to place the -I paths last, so that building will see -I paths to us
  14. CXX := $(filter-out -I%,@CXX@)
  15. AR := @AR@
  16. RANLIB := @RANLIB@
  17. INSTALL := $(srcdir)/build-aux/install-sh
  18. # C++ compiler options
  19. CXXFLAGS := @CXXFLAGS@
  20. CXXINC := $(filter -I%,@CXX@)
  21. CXXOPTS := $(CXXFLAGS) @PICFLAG@
  22. ifneq (@EXCEPTIONS@,yes)
  23. CXXOPTS += -fno-exceptions -fno-rtti
  24. endif
  25. # Config
  26. CXXOPTS += $(filter-out -DHAVE_CONFIG_H,@DEFS@) -include config.h
  27. # Linker options
  28. LDFLAGS := @LDFLAGS@
  29. LIBS := @LIBS@
  30. # Per-source & per-directory compile flags (warning: recursive)
  31. SRC_CXXFLAGS = $(CXXFLAGS$(patsubst $(srcdir)%,%,$1)) \
  32. $(if $(filter-out $(srcdir)/,$1),\
  33. $(call $0,$(dir $(patsubst %/,%,$1))))
  34. ifneq ($(MAINTAINER),)
  35. override MAINTAINER += $1
  36. endif
  37. ifeq (@MAINTAINER@,yes)
  38. MAINTAINER = $2
  39. else
  40. MAINTAINER = \# --enable-maintainer-mode to rebuild $1, or make MAINTAINER=touch
  41. endif
  42. vpath %.in $(srcdir)
  43. vpath %.cc $(srcdir)
  44. .SUFFIXES: .o .cc
  45. %.o: %.cc
  46. @mkdir -p $(dir $@)
  47. $(CXX) $(strip $(CXXOPTS) $(call SRC_CXXFLAGS,$<) $(CXXINC)) \
  48. -MMD -MP -MF ${@:.o=.d} -c -o $@ $<
  49. all:: Makefile
  50. mostlyclean::
  51. clean:: Makefile
  52. # FIXME: Delete
  53. revision.stamp: $(srcdir)/.
  54. @revision=$$(git -C $(srcdir) rev-parse HEAD 2>/dev/null) ;\
  55. if test -n "$$revision" ;\
  56. then revision=git-$$revision ;\
  57. if git -C $(srcdir) status --porcelain 2>/dev/null | grep -vq '^ ' ;\
  58. then revision+=M ;\
  59. fi ;\
  60. else revision=unknown ;\
  61. fi ;\
  62. echo $$revision > $@
  63. revision: revision.stamp
  64. @cmp -s $< $@ || cp -f $< $@
  65. mostlyclean::
  66. clean:: mostlyclean
  67. rm -f revision.stamp revision
  68. distclean:: clean
  69. rm -f config.log config.status
  70. $(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/config.m4
  71. $(call MAINTAINER,$@,cd $(@D) && autoconf -W all,error)
  72. $(srcdir)/config.h.in: $(srcdir)/configure.ac $(srcdir)/config.m4
  73. $(call MAINTAINER,$@,cd $(@D) && autoheader -f -W all,error)
  74. config.h: config.status config.h.in
  75. ./$< --header=$@
  76. touch $@
  77. ifeq ($(filter %clean,$(MAKECMDGOALS)),)
  78. Makefile: config.status Makefile.in
  79. ./$< --file=$@
  80. touch $@
  81. endif
  82. config.status: $(srcdir)/configure $(srcdir)/config.h.in
  83. if test -x $@; then ./$@ -recheck; else $< @configure_args@; fi
  84. mostlyclean::
  85. clean:: mostlyclean
  86. rm -f $(shell find $(srcdir) -name '*~')
  87. distclean:: clean
  88. rm -f config.h
  89. maintainer-clean:: distclean
  90. rm -f $(srcdir)/config.h.in
  91. .PHONY: all check clean distclean maintainer-clean mostlyclean
  92. CXXFLAGS/ := -I$(srcdir)
  93. LIBCODY.O := buffer.o client.o fatal.o netclient.o netserver.o \
  94. resolver.o packet.o server.o
  95. all:: libcody.a
  96. libcody.a: $(LIBCODY.O)
  97. $(AR) -cr $@ $^
  98. $(RANLIB) $@
  99. mostlyclean::
  100. clean:: mostlyclean
  101. rm -f $(LIBCODY.O) $(LIBCODY.O:.o=.d)
  102. rm -f libcody.a
  103. CXXFLAGS/fatal.cc = -DSRCDIR='"$(srcdir)"'
  104. fatal.o: Makefile revision
  105. install::
  106. $(INSTALL) -d $(libdir) $(includedir)
  107. $(INSTALL) libcody.a $(libdir)
  108. $(INSTALL) $(srcdir)/cody.hh $(includedir)
  109. ifeq ($(filter clean%,$(MAKECMDGOALS)),)
  110. -include $(LIBCODY.O:.o=.d)
  111. endif