summaryrefslogtreecommitdiff
path: root/m4/ax_prog_splint.m4
blob: 931b745fc9352a8c7729d248c79966805991f2ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# ===========================================================================
#      https://www.gnu.org/software/autoconf-archive/ax_prog_splint.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_PROG_SPLINT([AX_SPLINTFLAGS])
#
# DESCRIPTION
#
#   Check for program splint, the static C code checking tool. The splint
#   URL is given by http://www.splint.org. This macro should be use together
#   with automake.
#
#   Enables following environment variables:
#
#     SPLINT
#     SPLINTFLAGS
#
#   and AX_SPLINTFLAGS is given by AC_SUBST. If AX_SPLINTFLAGS is not given
#   by AX_PROG_SPLINT it defaults to "-weak".
#
#   Enables the following make target:
#
#     splint-check
#
#   which runs splint per PROGRAMS and LIBRARIES. Output from splint run is
#   collected in file ***_splint.log where *** is given by the PROGRAMS or
#   LIBRARIES name.
#
#   The following line is required in Makefile.am:
#
#     include aminclude_static.am
#
# LICENSE
#
#   Copyright (c) 2011 Henrik Uhrenholt
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved. This file is offered as-is, without any
#   warranty.

#serial 3

AC_DEFUN([AX_PROG_SPLINT],
[
AC_REQUIRE([AX_ADD_AM_MACRO_STATIC])
AC_ARG_VAR([SPLINT], [splint executable])
AC_ARG_VAR([SPLINTFLAGS], [splint flags])
if test "x$SPLINT" = "x"; then
   AC_CHECK_PROGS([SPLINT], [splint])
fi
if test "x$SPLINT" != "x"; then
   ax_splintflags=$1
   if test "x$1" = "x"; then
      ax_splintflags=-weak
   fi
   AC_SUBST([AX_SPLINTFLAGS], [$ax_splintflags])
   ax_prog_splint_enable=yes
else
   AC_MSG_WARN([splint support disabled])
   ax_prog_splint_enable=no
fi
AM_CONDITIONAL([ax_prog_splint_enable], [test x"$ax_prog_splint_enable" = x"yes"])

AX_ADD_AM_MACRO_STATIC([
if ax_prog_splint_enable

define splint_rules
\$(1)_splint.log: \$${AX_DOLLAR}(\$(1)_OBJECTS)
	-\$(SPLINT) \$(AX_SPLINTFLAGS) \$(SPLINTFLAGS)  \$(AM_SPLINTFLAGS) \$(DEFAULT_INCLUDES) \$(AM_CPPFLAGS) +error-stream-stdout +warning-stream-stdout \$${AX_DOLLAR}(addprefix \$(srcdir)/,\$${AX_DOLLAR}(\$(1)_SOURCES)) > \$${AX_DOLLAR}@
endef


SPLINT_BIN=\$(subst /,_,\$(PROGRAMS:\$(EXEEXT)=))
SPLINT_LIB=\$(subst /,_,\$(LIBRARIES:.a=_a))
SPLINT_LTLIB=\$(subst /,_,\$(LTLIBRARIES:.la=_la))
SPLINTFILES=\$(addsuffix _splint.log,\$(SPLINT_LIB) \$(SPLINT_BIN) \$(SPLINT_LTLIB))

splint-check: all \$(SPLINTFILES)

\$(foreach bin, \$(SPLINT_BIN) \$(SPLINT_LIB) \$(SPLINT_LTLIB),\$(eval \$(call splint_rules,\$(bin))))




endif

.PHONY: clean-local-splint distclean-local-splint
clean-local: clean-local-splint
clean-local-splint:
	-test -z \"\$(SPLINTFILES)\" || rm -f \$(SPLINTFILES)

distclean-local: distclean-local-splint
distclean-local-splint: clean-local-splint
])
])