From b4ad263e58f8c2e74751df098904fc5bf7eb5a09 Mon Sep 17 00:00:00 2001
From: Henrik Uhrenholt <henrik.uhrenholt.gpl@gmail.com>
Date: Thu, 27 Jan 2011 11:49:54 -0800
Subject: [PATCH] Macro AX_PROG_SPLINT

---
 m4/ax_prog_splint.m4 |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 100 insertions(+), 0 deletions(-)
 create mode 100644 m4/ax_prog_splint.m4

diff --git a/m4/ax_prog_splint.m4 b/m4/ax_prog_splint.m4
new file mode 100644
index 0000000..fcbdc30
--- /dev/null
+++ b/m4/ax_prog_splint.m4
@@ -0,0 +1,100 @@
+# ===========================================================================
+#    http://www.gnu.org/software/autoconf-archive/ax_prog_splint.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_PROG_SPLINT([AX_SPLINTFLAGS])
+#
+# DESCRIPTION
+#
+#   Check for program splint.
+#
+#   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 1
+
+dnl Copyright (C) 2011 Henrik Uhrenholt
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.  This file is offered as-is,
+dnl without any warranty.
+
+
+AC_DEFUN([AX_PROG_SPLINT],
+[
+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))
+SPLINTFILES=\$(addsuffix _splint.log,\$(SPLINT_LIB) \$(SPLINT_BIN))
+
+splint-check: all \$(SPLINTFILES)
+
+\$(foreach bin, \$(SPLINT_BIN) \$(SPLINT_LIB),\$(eval \$(call splint_rules,\$(bin))))
+
+
+
+
+endif
+
+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
+])
+])
-- 
1.7.0.4

