1#
2# SPDX-License-Identifier: ISC
3#
4# Copyright (c) 2019-2020 Todd C. Miller <Todd.Miller@sudo.ws>
5#
6# Permission to use, copy, modify, and distribute this software for any
7# purpose with or without fee is hereby granted, provided that the above
8# copyright notice and this permission notice appear in all copies.
9#
10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17#
18# @configure_input@
19#
20
21#### Start of system configuration section. ####
22
23srcdir = @srcdir@
24abs_srcdir = @abs_srcdir@
25top_srcdir = @top_srcdir@
26abs_top_srcdir = @abs_top_srcdir@
27top_builddir = @top_builddir@
28abs_top_builddir = @abs_top_builddir@
29devdir = @devdir@
30scriptdir = $(top_srcdir)/scripts
31incdir = $(top_srcdir)/include
32
33# Compiler & tools to use
34CC = @CC@
35LIBTOOL = @LIBTOOL@
36
37# C preprocessor flags
38CPPFLAGS = -I$(incdir) -I$(top_builddir) -I$(srcdir) -I$(top_srcdir) @CPPFLAGS@
39
40# Usually -O and/or -g
41CFLAGS = @CFLAGS@
42
43# Flags to pass to libtool
44LTFLAGS = @LT_STATIC@
45
46# Address sanitizer flags
47ASAN_CFLAGS = @ASAN_CFLAGS@
48ASAN_LDFLAGS = @ASAN_LDFLAGS@
49
50# PIE flags
51PIE_CFLAGS = @PIE_CFLAGS@
52PIE_LDFLAGS = @PIE_LDFLAGS@
53
54# Stack smashing protection flags
55SSP_CFLAGS = @SSP_CFLAGS@
56SSP_LDFLAGS = @SSP_LDFLAGS@
57
58# cppcheck options, usually set in the top-level Makefile
59CPPCHECK_OPTS = -q --enable=warning,performance,portability --suppress=constStatement --suppress=compareBoolExpressionWithInt --error-exitcode=1 --inline-suppr -Dva_copy=va_copy -U__cplusplus -UQUAD_MAX -UQUAD_MIN -UUQUAD_MAX -U_POSIX_HOST_NAME_MAX -U_POSIX_PATH_MAX -U__NBBY -DNSIG=64
60
61# splint options, usually set in the top-level Makefile
62SPLINT_OPTS = -D__restrict= -checks
63
64# PVS-studio options
65PVS_CFG = $(top_srcdir)/PVS-Studio.cfg
66PVS_IGNORE = 'V707,V011,V002,V536'
67PVS_LOG_OPTS = -a 'GA:1,2' -e -t errorfile -d $(PVS_IGNORE)
68
69# Set to non-empty for development mode
70DEVEL = @DEVEL@
71
72#### End of system configuration section. ####
73
74SHELL = @SHELL@
75
76LIBPROTOBUF_C_OBJS = protobuf-c.lo
77
78IOBJS = $(LIBPROTOBUF_C_OBJS:.lo=.i)
79
80POBJS = $(IOBJS:.i=.plog)
81
82all: libprotobuf-c.la
83
84pvs-log-files: $(POBJS)
85
86pvs-studio: $(POBJS)
87	plog-converter $(PVS_LOG_OPTS) $(POBJS)
88
89depend:
90	$(scriptdir)/mkdep.pl --srcdir=$(abs_top_srcdir) \
91	    --builddir=$(abs_top_builddir) lib/protobuf-c/Makefile.in
92	cd $(top_builddir) && ./config.status --file lib/protobuf-c/Makefile
93
94Makefile: $(srcdir)/Makefile.in
95	cd $(top_builddir) && ./config.status --file lib/protobuf-c/Makefile
96
97.SUFFIXES: .c .h .i .lo .plog
98
99.c.lo:
100	$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $<
101
102.c.i:
103	$(CC) -E -o $@ $(CPPFLAGS) $<
104
105.i.plog:
106	ifile=$<; rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $${ifile%i}c --i-file $< --output-file $@
107
108$(devdir)/log_server.pb-c.c: $(srcdir)/log_server.proto
109	@if [ -n "$(DEVEL)" ]; then \
110	    cmd='protoc-c --c_out=$(devdir) --proto_path=$(srcdir) $(srcdir)/log_server.proto'; \
111	    echo "$$cmd"; eval $$cmd; \
112	    cmd='$(scriptdir)/unanon $(devdir)/log_server.pb-c.h $(devdir)/log_server.pb-c.c'; \
113	    echo "$$cmd"; eval $$cmd; \
114	    if [ "$(devdir)" == "$(srcdir)" ]; then \
115		cmd='mv -f $(devdir)/log_server.pb-c.h $(incdir)/log_server.pb-c.h'; \
116	    else \
117		cmd='mv -f $(devdir)/log_server.pb-c.h $(top_builddir)/log_server.pb-c.h'; \
118	    fi; \
119	    echo "$$cmd"; eval $$cmd; \
120	fi
121
122libprotobuf-c.la: $(LIBPROTOBUF_C_OBJS)
123	$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(LIBPROTOBUF_C_OBJS)
124
125pre-install:
126
127install:
128
129install-binaries:
130
131install-includes:
132
133install-doc:
134
135install-plugin:
136
137install-fuzzer:
138
139uninstall:
140
141splint:
142	splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c
143
144cppcheck:
145	cppcheck $(CPPCHECK_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c
146
147pvs-log-files: $(POBJS)
148
149fuzz:
150
151check-fuzzer:
152
153check: check-fuzzer
154
155clean:
156	-$(LIBTOOL) $(LTFLAGS) --mode=clean rm -f *.lo *.o *.la
157	-rm -f *.i *.plog stamp-* core *.core core.*
158
159mostlyclean: clean
160
161distclean: clean
162	-rm -rf Makefile .libs
163
164clobber: distclean
165
166realclean: distclean
167	rm -f TAGS tags
168
169cleandir: realclean
170
171.PHONY: clean mostlyclean distclean cleandir clobber realclean
172
173# Autogenerated dependencies, do not modify
174protobuf-c.lo: $(srcdir)/protobuf-c.c $(incdir)/protobuf-c/protobuf-c.h \
175               $(top_builddir)/config.h
176	$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/protobuf-c.c
177protobuf-c.i: $(srcdir)/protobuf-c.c $(incdir)/protobuf-c/protobuf-c.h \
178               $(top_builddir)/config.h
179	$(CC) -E -o $@ $(CPPFLAGS) $<
180protobuf-c.plog: protobuf-c.i
181	rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/protobuf-c.c --i-file $< --output-file $@
182