Compiling without gcc and AM_CFLAGS

137 views
Skip to first unread message

Deron Meranda

unread,
Aug 12, 2010, 1:24:20 PM8/12/10
to jansso...@googlegroups.com
I'm trying to compile the jansson 1.3 on a Unix using a compiler
other than gcc, and was getting an error because the
src/Makefile.in sets the automake variable

AM_CFLAGS = -Wall -Wextra -Werror

Those compiler flags are specific to gcc and do not work
under some other C compilers.

It's somewhat easy to override this, but thought it might
be best to fix the configure script to either not set these
here; or to conditionally do it based on whether gcc is
being used. BTW, configure doesn't support --without-gcc,
thought forcing $CC and $CFLAGS does seem to work.

--
Deron Meranda
http://deron.meranda.us/

Petri Lehtinen

unread,
Aug 12, 2010, 2:07:09 PM8/12/10
to jansso...@googlegroups.com
Deron Meranda wrote:
> I'm trying to compile the jansson 1.3 on a Unix using a compiler
> other than gcc, and was getting an error because the
> src/Makefile.in sets the automake variable
>
> AM_CFLAGS = -Wall -Wextra -Werror
>
> Those compiler flags are specific to gcc and do not work
> under some other C compilers.
>
> It's somewhat easy to override this, but thought it might
> be best to fix the configure script to either not set these
> here; or to conditionally do it based on whether gcc is
> being used.

I fixed it so that those flags are set only if gcc is detected. It's
in the 1.3 branch:

git> commit f71eb7fe1749836ac45cc6c0015dd6d2aec4bef9
git> Author: Petri Lehtinen <pe...@digip.org>
git> Date: Thu Aug 12 20:59:48 2010 +0300
git>
git> Check for gcc before setting gcc specific CFLAGS
git>
git> configure.ac | 1 +
git> src/Makefile.am | 3 +++
git> 2 files changed, 4 insertions(+), 0 deletions(-)


> BTW, configure doesn't support --without-gcc,
> thought forcing $CC and $CFLAGS does seem to work.

I've never heard of this flag. Is it supposed to change the order in
which configure searches for C compiler so that gcc isn't searched
first?

Petri

Deron Meranda

unread,
Aug 12, 2010, 2:35:43 PM8/12/10
to jansso...@googlegroups.com
>> BTW, configure doesn't support --without-gcc,
>> thought forcing $CC and $CFLAGS does seem to work.
>
> I've never heard of this flag. Is it supposed to change the order in
> which configure searches for C compiler so that gcc isn't searched
> first?

I'm certainly not an autoconfigure/automake expert,
but lots of other OSS packages provide that configure flag.

It essentially will ignore any gcc* it finds in the path
and will look for other (native) compilers instead.
I don't know how it works or how to activate it.

It's not terribly important as long as you can force a
compiler by setting CC; such as

CC=xlc ./configure ...

but it can still be convenient for those of us mucking
with proprietary Unixes.

Petri Lehtinen

unread,
Aug 12, 2010, 3:32:18 PM8/12/10
to jansso...@googlegroups.com
Deron Meranda wrote:
> >> BTW, configure doesn't support --without-gcc,
> >> thought forcing $CC and $CFLAGS does seem to work.
> >
> > I've never heard of this flag. Is it supposed to change the order in
> > which configure searches for C compiler so that gcc isn't searched
> > first?
>
> I'm certainly not an autoconfigure/automake expert,
> but lots of other OSS packages provide that configure flag.

Do you happen to remember any package that has the flag? I could have
a look on how it's implemented. Reading through Autoconf docs doesn't
give an obvious answer.

> It essentially will ignore any gcc* it finds in the path
> and will look for other (native) compilers instead.
> I don't know how it works or how to activate it.
>
> It's not terribly important as long as you can force a
> compiler by setting CC; such as
>
> CC=xlc ./configure ...
>
> but it can still be convenient for those of us mucking
> with proprietary Unixes.

Can you reveal on which architectures you are mucking with? It would
be interesting to know just how portable Jansson is right now :)

Petri

Deron Meranda

unread,
Aug 12, 2010, 4:03:36 PM8/12/10
to jansso...@googlegroups.com
On Thu, Aug 12, 2010 at 3:32 PM, Petri Lehtinen <pe...@digip.org> wrote:
> Do you happen to remember any package that [--without-gcc] has the flag? I could have

> a look on how it's implemented. Reading through Autoconf docs doesn't
> give an obvious answer.

First is I think there's a pattern for allowing anything like
--without-xyz to be treated as if it were --with-xyz=no
and generally it allows any package name to be used in
the flag.


I know that both Python and Ruby use that flag; though I
don't think they are particularly "standard" configure-based
packages.

Emacs used to support it; though it was seemingly removed
as of version 23.1.

I seem to remember a lot more packages using that than
I can find now. Perhaps it's going out of favor in support
of just setting the $CC variable ??? I may be showing my age.


I wouldn't spend a lot of time on it unless you just want to.
Setting CC works for jansson to keep it from picking up an
unwanted gcc.


> Can you reveal on which architectures you are mucking with? It would
> be interesting to know just how portable Jansson is right now :)

Other than Linux, which is easy, mostly several versions of
both AIX (PowerPC) and HP-UX (both PA-RISC and Itanium).

Petri Lehtinen

unread,
Aug 13, 2010, 1:27:27 AM8/13/10
to jansso...@googlegroups.com
Deron Meranda wrote:
> On Thu, Aug 12, 2010 at 3:32 PM, Petri Lehtinen <pe...@digip.org> wrote:
> > Do you happen to remember any package that [--without-gcc] has the flag? I could have
> > a look on how it's implemented. Reading through Autoconf docs doesn't
> > give an obvious answer.
>
> First is I think there's a pattern for allowing anything like
> --without-xyz to be treated as if it were --with-xyz=no
> and generally it allows any package name to be used in
> the flag.
>
>
> I know that both Python and Ruby use that flag; though I
> don't think they are particularly "standard" configure-based
> packages.

Both Python and Ruby seem to just set CC=cc if --without-gcc is used.
Furthermore, Python has special cases for AIX (CC=cc_r) and BeOS
(CC=mwcc). So...

> I wouldn't spend a lot of time on it unless you just want to.
> Setting CC works for jansson to keep it from picking up an
> unwanted gcc.

... I believe those users who know that they don't want gcc are also
able to set CC to a correct value before running ./configure :)

Reply all
Reply to author
Forward
0 new messages