1 # Nathan's generic Makefile -*- mode:Makefile -*-
2 # Copyright (C) 2019-2020 Nathan Sidwell, nathan@acm.org
7 exec_prefix := @
exec_prefix@
10 includedir := @
includedir@
15 # We have to place the -I paths last, so that building will see -I paths to us
16 CXX
:= $(filter-out -I
%,@CXX@
)
19 INSTALL
:= $(srcdir)/build-aux
/install-sh
21 # C++ compiler options
22 CXXFLAGS
:= @CXXFLAGS@
23 CXXINC
:= $(filter -I
%,@CXX@
)
24 CXXOPTS
:= $(CXXFLAGS
) @PICFLAG@
26 ifneq (@EXCEPTIONS@
,yes
)
27 CXXOPTS
+= -fno-exceptions
-fno-rtti
31 CXXOPTS
+= $(filter-out -DHAVE_CONFIG_H
,@DEFS@
) -include config.h
34 LDFLAGS
:= @LDFLAGS@ @LD_PICFLAG@
37 # Per-source & per-directory compile flags (warning: recursive)
38 SRC_CXXFLAGS
= $(CXXFLAGS
$(patsubst $(srcdir)%,%,$1)) \
39 $(if
$(filter-out $(srcdir)/,$1),\
40 $(call
$0,$(dir $(patsubst %/,%,$1))))
42 ifneq ($(MAINTAINER
),)
43 override MAINTAINER
+= $1
45 ifeq (@MAINTAINER@
,yes
)
48 MAINTAINER
= \
# --enable-maintainer-mode to rebuild $1, or make MAINTAINER=touch
58 $(CXX
) $(strip $(CXXOPTS
) $(call SRC_CXXFLAGS
,$<) $(CXXINC
)) \
59 -MMD
-MP
-MF
${@
:.o
=.d
} -c
-o
$@
$<
68 revision.stamp
: $(srcdir)/.
69 @revision
=`git -C $(srcdir) rev-parse HEAD 2>/dev/null` ;\
70 if
test -n
"$$revision" ;\
71 then revision
=git-
$$revision ;\
72 if git
-C
$(srcdir) status
--porcelain
2>/dev
/null | grep
-vq
'^ ' ;\
73 then revision
=$${revision}M
;\
75 else revision
=unknown
;\
79 revision
: revision.stamp
80 @cmp
-s
$< $@ || cp
-f
$< $@
85 rm -f revision.stamp revision
88 rm -f config.log config.status
90 $(srcdir)/configure
: $(srcdir)/configure.ac
$(srcdir)/config.m4
91 $(call MAINTAINER
,$@
,cd
$(@D
) && autoconf
-W
all,error
)
93 $(srcdir)/config.h.in
: $(srcdir)/configure.ac
$(srcdir)/config.m4
94 $(call MAINTAINER
,$@
,cd
$(@D
) && autoheader
-f
-W
all,error
)
96 config.h
: config.status config.h.in
100 ifeq ($(filter %clean,$(MAKECMDGOALS
)),)
101 Makefile
: config.status Makefile.in
106 config.status
: $(srcdir)/configure
$(srcdir)/config.h.in
107 if
test -x
$@
; then .
/$@
-recheck
; else $< @configure_args@
; fi
112 rm -f
$(shell find
$(srcdir) -name
'*~')
117 maintainer-clean
:: distclean
118 rm -f
$(srcdir)/config.h.in
120 .PHONY
: all check clean distclean maintainer-clean
mostlyclean
122 CXXFLAGS
/ := -I
$(srcdir)
123 LIBCODY.O
:= buffer.o client.o fatal.o netclient.o netserver.o \
124 resolver.o packet.o server.o
128 libcody.a
: $(LIBCODY.O
)
135 rm -f
$(LIBCODY.O
) $(LIBCODY.O
:.o
=.d
)
138 CXXFLAGS
/fatal.
cc = -DSRCDIR
='"$(srcdir)"'
140 fatal.o
: Makefile revision
143 $(INSTALL
) -d
$(libdir) $(includedir)
144 $(INSTALL
) libcody.a
$(libdir)
145 $(INSTALL
) $(srcdir)/cody.hh
$(includedir)
147 ifeq ($(filter clean%,$(MAKECMDGOALS
)),)
148 -include $(LIBCODY.O
:.o
=.d
)