[PATCH util-macros] XORG_WITH_LINT: rework and extend platform coverage

Gaetan Nadon memsize at videotron.ca
Mon May 17 10:07:32 PDT 2010


On Mon, 2010-05-17 at 08:07 -0700, Alan Coopersmith wrote:

> Gaetan Nadon wrote:
> > Guess the lint program name by platform.
> > Use ARG variable for user input values.
> > Provide default flags per platform.
> 
> So when I want to check with sparse on Solaris, instead of --with-lint=sparse
> now I have to do --with-lint LINT=SPARSE ?   I guess I can learn to type that.

Correct, if the sparse executable is uppercase, otherwise it would be
LINT=sparse or LINT=/somewhere/sparse if the program is not on the path.
If using lint, nothing to type. AC_PATH_PROG will search for lint prog
in PATH and set LINT. If you set LINT on the command line as above, then
AC_PROG_PATH let it pass through without intervening. 

These are free functions we get from autoconf macros with little code to
write. The same has been done for all the non-deprecated doc tools. It
should be fairly consistent now and it is in line with the semantic of
the "with" option:


        Optional Packages:
          --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
          --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)

There would be nothing wrong in having a --with-sparse option if it is a
common scenario.  


> Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> 
> > Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
> > ---
> >  xorg-macros.m4.in |   77 +++++++++++++++++++++++++++++++++++++----------------
> >  1 files changed, 54 insertions(+), 23 deletions(-)
> > 
> > diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
> > index 0feab01..8b82b29 100644
> > --- a/xorg-macros.m4.in
> > +++ b/xorg-macros.m4.in
> > @@ -855,38 +855,69 @@ AC_SUBST([XTMALLOC_ZERO_CFLAGS])
> >  # ----------------
> >  # Minimum version: 1.1.0
> >  #
> > -# Sets up flags for source checkers such as lint and sparse if --with-lint
> > -# is specified.   (Use --with-lint=sparse for sparse.)
> > -# Sets $LINT to name of source checker passed with --with-lint (default: lint)
> > -# Sets $LINT_FLAGS to flags to pass to source checker
> > -# Sets LINT automake conditional if enabled (default: disabled)
> > +# This macro enables the use of a tool that flags some suspicious and
> > +# non-portable constructs (likely to be bugs) in C language source code.
> > +# It will attempt to locate the tool and use appropriate options.
> > +# There are various lint type tools on different platforms.
> > +#
> > +# Interface to module:
> > +# LINT:		returns the path to the tool found on the platform
> > +#		or the value set to LINT on the configure cmd line
> > +#		also an Automake conditional
> > +# LINT_FLAGS:	an Automake variable with appropriate flags
> > +#
> > +# --with-lint:	'yes' user instructs the module to use lint
> > +#		'no' user instructs the module not to use lint (default)
> > +#
> > +# If the user sets the value of LINT, AC_PATH_PROG skips testing the path.
> > +# If the user sets the value of LINT_FLAGS, they are used verbatim.
> >  #
> >  AC_DEFUN([XORG_WITH_LINT],[
> >  
> > -# Allow checking code with lint, sparse, etc.
> > +AC_ARG_VAR([LINT], [Path to a lint-style command])
> > +AC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command])
> >  AC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
> >  		[Use a lint-style source code checker (default: disabled)])],
> >  		[use_lint=$withval], [use_lint=no])
> > -if test "x$use_lint" = "xyes" ; then
> > -	LINT="lint"
> > +
> > +# Obtain platform specific info like program name and options
> > +# The lint program on FreeBSD and NetBSD is different from the one on Solaris
> > +case $host_os in
> > +  *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*)
> > +	lint_name=splint
> > +	lint_options="-badflag"
> > +	;;
> > +  *freebsd* | *netbsd*)
> > +	lint_name=lint
> > +	lint_options="-u -b"
> > +	;;
> > +  *solaris*)
> > +	lint_name=lint
> > +	lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
> > +	;;
> > +esac
> > +
> > +# Test for the presence of the program (either guessed by the code or spelled out by the user)
> > +if test "x$use_lint" = x"yes" ; then
> > +   AC_PATH_PROG([LINT], [$lint_name])
> > +   if test "x$LINT" = "x"; then
> > +        AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH])
> > +   fi
> > +elif test "x$use_lint" = x"no" ; then
> > +   if test "x$LINT" != "x"; then
> > +      AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified])
> > +   fi
> >  else
> > -	LINT="$use_lint"
> > -fi
> > -if test "x$LINT_FLAGS" = "x" -a "x$LINT" != "xno" ; then
> > -    case $LINT in
> > -	lint|*/lint)
> > -	    case $host_os in
> > -		solaris*)
> > -			LINT_FLAGS="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2"
> > -			;;
> > -	    esac
> > -	    ;;
> > -    esac
> > +   AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.])
> > +fi
> > +
> > +# User supplied flags override default flags
> > +if test "x$LINT_FLAGS" != "x"; then
> > +   lint_options=$LINT_FLAGS
> >  fi
> >  
> > -AC_SUBST(LINT)
> > -AC_SUBST(LINT_FLAGS)
> > -AM_CONDITIONAL(LINT, [test x$LINT != xno])
> > +AC_SUBST([LINT_FLAGS],[$lint_options])
> > +AM_CONDITIONAL(LINT, [test "x$LINT" != x])
> >  
> >  ]) # XORG_WITH_LINT
> >  
> 
> 
> -- 
> 	-Alan Coopersmith-        alan.coopersmith at oracle.com
> 	 Oracle Solaris Platform Engineering: X Window System
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100517/677e553a/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100517/677e553a/attachment.pgp>


More information about the xorg-devel mailing list