1#
2# SPDX-License-Identifier: ISC
3#
4# Copyright (c) 2021 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 the link stage
44LDFLAGS = @LDFLAGS@
45
46# Flags to pass to libtool
47LTFLAGS = @LT_STATIC@
48
49# Libraries
50LT_LIBS =
51LIBS = $(LT_LIBS)
52
53# Address sanitizer flags
54ASAN_CFLAGS = @ASAN_CFLAGS@
55ASAN_LDFLAGS = @ASAN_LDFLAGS@
56
57# PIE flags
58PIE_CFLAGS = @PIE_CFLAGS@
59PIE_LDFLAGS = @PIE_LDFLAGS@
60
61# Stack smashing protection flags
62SSP_CFLAGS = @SSP_CFLAGS@
63SSP_LDFLAGS = @SSP_LDFLAGS@
64
65# cppcheck options, usually set in the top-level Makefile
66CPPCHECK_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
67
68# splint options, usually set in the top-level Makefile
69SPLINT_OPTS = -D__restrict= -checks
70
71# PVS-studio options
72PVS_CFG = $(top_srcdir)/PVS-Studio.cfg
73PVS_IGNORE = 'V707,V011,V002,V536'
74PVS_LOG_OPTS = -a 'GA:1,2' -e -t errorfile -d $(PVS_IGNORE)
75
76# Set to non-empty for development mode
77DEVEL = @DEVEL@
78
79#### End of system configuration section. ####
80
81SHELL = @SHELL@
82
83LIBFUZZSTUB_OBJS = fuzzstub.lo
84
85IOBJS = $(LIBFUZZSTUB_OBJS:.lo=.i)
86
87POBJS = $(IOBJS:.i=.plog)
88
89all: libsudo_fuzzstub.la
90
91pvs-log-files: $(POBJS)
92
93pvs-studio: $(POBJS)
94	plog-converter $(PVS_LOG_OPTS) $(POBJS)
95
96depend:
97	$(scriptdir)/mkdep.pl --srcdir=$(abs_top_srcdir) \
98	    --builddir=$(abs_top_builddir) lib/fuzzstub/Makefile.in
99	cd $(top_builddir) && ./config.status --file lib/fuzzstub/Makefile
100
101Makefile: $(srcdir)/Makefile.in
102	cd $(top_builddir) && ./config.status --file lib/fuzzstub/Makefile
103
104.SUFFIXES: .c .h .i .lo .plog
105
106.c.lo:
107	$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $<
108
109.c.i:
110	$(CC) -E -o $@ $(CPPFLAGS) $<
111
112.i.plog:
113	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 $@
114
115libsudo_fuzzstub.la: $(LIBFUZZSTUB_OBJS)
116	$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(LIBFUZZSTUB_OBJS) $(LT_LIBS)
117
118pre-install:
119
120install:
121
122install-binaries:
123
124install-includes:
125
126install-doc:
127
128install-plugin:
129
130install-fuzzer:
131
132uninstall:
133
134splint:
135	splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c
136
137cppcheck:
138	cppcheck $(CPPCHECK_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c
139
140pvs-log-files: $(POBJS)
141
142fuzz:
143
144check-fuzzer:
145
146check: check-fuzzer
147
148clean:
149	-$(LIBTOOL) $(LTFLAGS) --mode=clean rm -f *.lo *.o *.la
150	-rm -f *.i *.plog stamp-* core *.core core.*
151
152mostlyclean: clean
153
154distclean: clean
155	-rm -rf Makefile .libs
156
157clobber: distclean
158
159realclean: distclean
160	rm -f TAGS tags
161
162cleandir: realclean
163
164.PHONY: clean mostlyclean distclean cleandir clobber realclean
165
166# Autogenerated dependencies, do not modify
167fuzzstub.lo: $(srcdir)/fuzzstub.c $(incdir)/compat/stdbool.h \
168             $(incdir)/sudo_compat.h $(incdir)/sudo_util.h \
169             $(top_builddir)/config.h
170	$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/fuzzstub.c
171fuzzstub.i: $(srcdir)/fuzzstub.c $(incdir)/compat/stdbool.h \
172             $(incdir)/sudo_compat.h $(incdir)/sudo_util.h \
173             $(top_builddir)/config.h
174	$(CC) -E -o $@ $(CPPFLAGS) $<
175fuzzstub.plog: fuzzstub.i
176	rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/fuzzstub.c --i-file $< --output-file $@
177