2 # Copyright (c) 2011-2018 Todd C. Miller <Todd.Miller@sudo.ws>
4 # Permission to use, copy, modify, and distribute this software for any
5 # purpose with or without fee is hereby granted, provided that the above
6 # copyright notice and this permission notice appear in all copies.
8 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #### Start of system configuration section. ####
23 top_builddir = @top_builddir@
24 top_srcdir = @top_srcdir@
25 incdir = $(top_srcdir)/include
26 cross_compiling = @CROSS_COMPILING@
28 # Compiler & tools to use
34 # Our install program supports extra flags...
35 INSTALL = $(SHELL) $(top_srcdir)/install-sh -c
36 INSTALL_OWNER = -o $(install_uid) -g $(install_gid)
37 INSTALL_BACKUP = @INSTALL_BACKUP@
40 LIBS = $(top_builddir)/lib/util/libsudo_util.la
42 # C preprocessor flags
43 CPPFLAGS = -I$(incdir) -I$(top_builddir) -I$(top_srcdir) @CPPFLAGS@
45 # Usually -O and/or -g
48 # Flags to pass to the link stage
50 LT_LDFLAGS = @LT_LDFLAGS@ @LT_LDEXPORTS@
52 # Flags to pass to libtool
53 LTFLAGS = --tag=disable-static
55 # Address sanitizer flags
56 ASAN_CFLAGS = @ASAN_CFLAGS@
57 ASAN_LDFLAGS = @ASAN_LDFLAGS@
60 PIE_CFLAGS = @PIE_CFLAGS@
61 PIE_LDFLAGS = @PIE_LDFLAGS@
63 # Stack smashing protection flags
64 SSP_CFLAGS = @SSP_CFLAGS@
65 SSP_LDFLAGS = @SSP_LDFLAGS@
67 # cppcheck options, usually set in the top-level Makefile
68 CPPCHECK_OPTS = -q --force --enable=warning,performance,portability --suppress=constStatement --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
70 # splint options, usually set in the top-level Makefile
71 SPLINT_OPTS = -D__restrict= -checks
74 PVS_CFG = $(top_srcdir)/PVS-Studio.cfg
75 PVS_IGNORE = 'V707,V011,V002,V536'
76 PVS_LOG_OPTS = -a 'GA:1,2' -e -t errorfile -d $(PVS_IGNORE)
78 # Where to install things...
80 exec_prefix = @exec_prefix@
83 sysconfdir = @sysconfdir@
84 libexecdir = @libexecdir@
85 datarootdir = @datarootdir@
86 localstatedir = @localstatedir@
87 plugindir = @PLUGINDIR@
89 # File mode and map file to use for shared libraries/objects
90 shlib_enable = @SHLIB_ENABLE@
91 shlib_mode = @SHLIB_MODE@
92 shlib_exp = $(srcdir)/sample_plugin.exp
93 shlib_map = sample_plugin.map
94 shlib_opt = sample_plugin.opt
96 # User and group ids the installed files should be "owned" by
100 #### End of system configuration section. ####
104 OBJS = sample_plugin.lo
106 LIBOBJDIR = $(top_builddir)/@ac_config_libobj_dir@/
108 VERSION = @PACKAGE_VERSION@
110 all: sample_plugin.la
112 Makefile: $(srcdir)/Makefile.in
113 cd $(top_builddir) && ./config.status --file plugins/sample/Makefile
115 .SUFFIXES: .c .h .i .lo .plog
118 $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $<
121 $(CC) -E -o $@ $(CPPFLAGS) $<
124 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 $@
126 $(shlib_map): $(shlib_exp)
127 @$(AWK) 'BEGIN { print "{\n\tglobal:" } { print "\t\t"$$0";" } END { print "\tlocal:\n\t\t*;\n};" }' $(shlib_exp) > $@
129 $(shlib_opt): $(shlib_exp)
130 @$(SED) 's/^/+e /' $(shlib_exp) > $@
132 sample_plugin.la: $(OBJS) @LT_LDDEP@
133 $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) $(LDFLAGS) $(ASAN_LDFLAGS) $(SSP_LDFLAGS) $(LT_LDFLAGS) -o $@ $(OBJS) $(LIBS) -module -avoid-version -rpath $(plugindir) -shrext .so
137 install: install-plugin
140 $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(plugindir)
148 install-plugin: install-dirs sample_plugin.la
149 if [ X"$(shlib_enable)" = X"yes" ]; then \
150 INSTALL_BACKUP='$(INSTALL_BACKUP)' $(LIBTOOL) $(LTFLAGS) --mode=install $(INSTALL) $(INSTALL_OWNER) -m $(shlib_mode) sample_plugin.la $(DESTDIR)$(plugindir); \
154 -$(LIBTOOL) $(LTFLAGS) --mode=uninstall rm -f $(DESTDIR)$(plugindir)/sample_plugin.la
155 -test -z "$(INSTALL_BACKUP)" || \
156 rm -f $(DESTDIR)$(plugindir)/sample_plugin.so$(INSTALL_BACKUP)
159 splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c
162 cppcheck $(CPPCHECK_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c
164 pvs-log-files: $(POBJS)
167 plog-converter $(PVS_LOG_OPTS) $(POBJS)
172 -$(LIBTOOL) $(LTFLAGS) --mode=clean rm -f *.lo *.o *.la *.a *.i *.plog \
173 stamp-* core *.core core.*
178 -rm -rf Makefile .libs $(shlib_map) $(shlib_opt)
187 # Autogenerated dependencies, do not modify
188 sample_plugin.lo: $(srcdir)/sample_plugin.c $(incdir)/compat/stdbool.h \
189 $(incdir)/sudo_compat.h $(incdir)/sudo_plugin.h \
190 $(incdir)/sudo_util.h $(top_builddir)/config.h \
191 $(top_builddir)/pathnames.h
192 $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/sample_plugin.c
193 sample_plugin.i: $(srcdir)/sample_plugin.c $(incdir)/compat/stdbool.h \
194 $(incdir)/sudo_compat.h $(incdir)/sudo_plugin.h \
195 $(incdir)/sudo_util.h $(top_builddir)/config.h \
196 $(top_builddir)/pathnames.h
197 $(CC) -E -o $@ $(CPPFLAGS) $<
198 sample_plugin.plog: sample_plugin.i
199 rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/sample_plugin.c --i-file $< --output-file $@