bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wget compilation spammed with warnings and notes


From: Tim Ruehsen
Subject: Re: Wget compilation spammed with warnings and notes
Date: Wed, 15 Jun 2016 12:26:35 +0200
User-agent: KMail/4.14.10 (Linux/4.6.0-1-amd64; KDE/4.14.20; x86_64; ; )

On Tuesday 14 June 2016 13:05:53 Paul Eggert wrote:
> On 06/14/2016 11:54 AM, Tim Rühsen wrote:
> > mmm, you (or anyone else) don't know a way to use special CFLAGS just
> > for gnulib / lib directory (or in general: a subdirectory) ?
> 
> Yes, that's reasonably common. See coreutils configure.ac for an
> example; look for "We use a slightly smaller set of warning options for
> lib/."

Paul, thank you so much for this valuable hint.

Just for the record:

I had to create a custom Makefile.am in lib/ and add --makefile-name=gnulib.mk 
to the gnulib-tool invocation. To include gnulib.mk I needed the Makefile.am 
to look like this:
####
MOSTLYCLEANFILES =
noinst_LTLIBRARIES =
EXTRA_DIST =
BUILT_SOURCES =
MOSTLYCLEANDIRS =
CLEANFILES =
SUFFIXES =

AM_CFLAGS = $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)

include gnulib.mk
####

In configure.ac, using gl_MANYWARN_COMPLEMENT (=remove warn options) alone was 
not enough. Some options like -Wsign-compare are implicitly added by -Wextra 
and/or -W. These have to be disabled by e.g. gl_WARN_ADD([-Wno-sign-compare]).
gl_WARN_ADD changes $WARN_CFLAGS, which is not what I want for the non-gnulib 
flags. Backing up and restoring $WARN_FLAGS is working.

#### Snippet from configure.ac ####
  # We use a slightly smaller set of warning options for lib/.
  # Remove the following and save the result in GNULIB_WARN_CFLAGS.
  # Removing is not enough if these switches are implicitly set by other
  #  flags like -Wall or -Wextra. We have to explicitely unset them
  #  with -Wno-....
  nw=
  nw="$nw -Wpedantic"
  nw="$nw -Wunused-macros"
  nw="$nw -Wsign-compare"
  nw="$nw -Wunused-parameter"
  nw="$nw -Wswitch-default"
  nw="$nw -Wformat-nonliteral"
  bak="$WARN_CFLAGS"
  # disable options implicitly set by other options
  gl_WARN_ADD([-Wno-sign-compare])
  gl_WARN_ADD([-Wno-unused-parameter])
  gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
  AC_SUBST([GNULIB_WARN_CFLAGS])
  WARN_CFLAGS="$bak"
####

Regards, Tim

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]