Re: Turn off C compiler warnings in automake

2015-06-30 Thread Alex Vong
於 二,2015-06-30 於 09:37 +0200,Thomas Jahns 提到:
> On 06/29/15 17:31, Alex Vong wrote:
> > Thanks for telling me there is no portable flag for doing so.
> > I am now using AC_SUBST() to set the value of STREAM and append `
> > $(STREAM)>/dev/null' to every make command. If the user configure with
> > --enable-verbose-compiler, then STREAM will be set to 0, otherwise
> > STREAM will be set to 2. This keeps the flexibility. Does it sound
> > reasonable?
> 
> I'm not sure if an output redirection on stdin is portable. But I think given 
> the way you are going about this you could easily set a Makefile variable to 
> the 
> full redirection (or none), i.e. lose the >/dev/null and instead make STREAM 
> be 
> either '2>/dev/null' or the empty string ''?
> 
> Regards, Thomas
Hi Thomas,
I tried substituting `2>/dev/null' before but without success. However,
I try again just now and find out that if I add a pair of single quotes,
then it will work just fine. In short, the following code will work

AS_IF([test "x$enable_verbose_compiler" != "xyes"],
[AC_SUBST([REDIRECTION], ['2>/dev/null'])]
)

Thanks for the suggestion!

Cheers,
Alex





Re: Turn off C compiler warnings in automake

2015-06-30 Thread Thomas Jahns

On 06/29/15 17:31, Alex Vong wrote:

Thanks for telling me there is no portable flag for doing so.
I am now using AC_SUBST() to set the value of STREAM and append `
$(STREAM)>/dev/null' to every make command. If the user configure with
--enable-verbose-compiler, then STREAM will be set to 0, otherwise
STREAM will be set to 2. This keeps the flexibility. Does it sound
reasonable?


I'm not sure if an output redirection on stdin is portable. But I think given 
the way you are going about this you could easily set a Makefile variable to the 
full redirection (or none), i.e. lose the >/dev/null and instead make STREAM be 
either '2>/dev/null' or the empty string ''?


Regards, Thomas
--
Thomas Jahns
HD(CP)^2
Abteilung Anwendungssoftware

Deutsches Klimarechenzentrum GmbH
Bundesstraße 45a • D-20146 Hamburg • Germany

Phone:  +49 40 460094-151
Fax:+49 40 460094-270
Email:  Thomas Jahns 
URL:www.dkrz.de

Geschäftsführer: Prof. Dr. Thomas Ludwig
Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 39784



smime.p7s
Description: S/MIME Cryptographic Signature


Re: Turn off C compiler warnings in automake

2015-06-29 Thread Alex Vong
於 一,2015-06-29 於 10:00 +0200,Thomas Jahns 提到:
> Hi Alex,
> 
> On 06/28/15 16:21, Alex Vong wrote:
> > Besides, the code base is quite old and as we know compilers always
> > add new warnings. I have asked upstream about fixing the warnings, but
> > it seems there is no easy way to fix all of them. So I want to know is
> > there a portable way to silent all compiler warnings? Since there are
> > lots of warnings even without '-Wall -Wextra'. I want to know how do
> > you think about it.
> 
> since you are using gcc, there are -fsyntax-only and -w which should provide 
> less verbose builds. But there are only very few portable compiler options 
> (like 
> -I, -D) and to my knowledge none address warnings.
> 
> You could of course redirect all compiler stderr output to /dev/null and thus 
> get rid of it, i.e. add 2>/dev/null to your make calls. But this will make 
> debugging build failures harder later on.
> 
> Regards, Thomas
> 
> 
Hi Thomas,

Thanks for telling me there is no portable flag for doing so.
I am now using AC_SUBST() to set the value of STREAM and append `
$(STREAM)>/dev/null' to every make command. If the user configure with
--enable-verbose-compiler, then STREAM will be set to 0, otherwise
STREAM will be set to 2. This keeps the flexibility. Does it sound
reasonable?

Cheers,
Alex





Re: Turn off C compiler warnings in automake

2015-06-29 Thread Thomas Jahns

Hi Alex,

On 06/28/15 16:21, Alex Vong wrote:

Besides, the code base is quite old and as we know compilers always
add new warnings. I have asked upstream about fixing the warnings, but
it seems there is no easy way to fix all of them. So I want to know is
there a portable way to silent all compiler warnings? Since there are
lots of warnings even without '-Wall -Wextra'. I want to know how do
you think about it.


since you are using gcc, there are -fsyntax-only and -w which should provide 
less verbose builds. But there are only very few portable compiler options (like 
-I, -D) and to my knowledge none address warnings.


You could of course redirect all compiler stderr output to /dev/null and thus 
get rid of it, i.e. add 2>/dev/null to your make calls. But this will make 
debugging build failures harder later on.


Regards, Thomas




smime.p7s
Description: S/MIME Cryptographic Signature


Re: Re: Turn off C compiler warnings in automake

2015-06-28 Thread Alex Vong
Hi Thomas,

Sorry I forget to subscript to the mailing list so I cannot reply, but
now I can.

May be I should clarify why I want to silent those warnings. Actually,
I am working on packaging a GPLed software for a distro. (I am new in
both packaging and autotools.) The software does not use a Makefile
but provides different compilation flags for different targets. This
is of cource inconvienient for end users, so I try to use autotools to
guess the host environment and apply the set of suitable compilation
flags.

Besides, the code base is quite old and as we know compilers always
add new warnings. I have asked upstream about fixing the warnings, but
it seems there is no easy way to fix all of them. So I want to know is
there a portable way to silent all compiler warnings? Since there are
lots of warnings even without '-Wall -Wextra'. I want to know how do
you think about it.

Thanks,
Alex



Re: Turn off C compiler warnings in automake

2015-06-22 Thread Thomas Jahns

Hello,

On 06/22/15 15:44, Alex Vong wrote:

Is there any easy way to turn off c compiler warnings (those printed
to stderr) portably?


From my point of view, the easy way is to write portable code which does not 
generate warnings. This is also the preferred and recommended way.


But automake is quite agnostic in this regard: no part of it (at least that I 
know of) makes the compiler generate more warnings than the code produces anyway 
with the selected compiler warning flags.


I think you are trying to handle something that is quite external to automake 
within, which can only lead to problems later on.


Please clarify under what circumstances you get unwelcome warnings. If a user of 
some package builds it with e.g. gcc -Wall, said user is in my opinion entitled 
to all the warnings that gives.


Regards, Thomas



smime.p7s
Description: S/MIME Cryptographic Signature


Turn off C compiler warnings in automake

2015-06-22 Thread Alex Vong
Hi everyone,

Is there a portable way to silent C compiler warnings in automake? I
think of 2 ways of doing it but both ways have serious limitations.

1. hand-craft automake rules with `2>/dev/null' appended on the command
limitation: tedious, defeat the purpose of using automake (not _auto_ enough)

2. add `-w' to myprog_CFLAGS
limitation: it is GCC-specific and not portable (c99 does not specify
this switch)

Currently, I am using method 1 (hand-crafting) to achieve per-object
flags. However, I learnt that I can use convience library to simulate
per-object flags so I rewrite my Makefile.am to use convience library,
It looks much cleaner!

Is there any easy way to turn off c compiler warnings (those printed
to stderr) portably?

Thanks all!
Alex