Where to put compiler options?

W. Tasin tasin at e-technik.fh-muenchen.de
Fri Mar 17 17:41:19 GMT 2000


Matthias Duesterhoeft wrote:
> 
> Hello,

Hi Matthias, Jacek, Ralf,

due to your posting I want to put this in the list, what I found out
about this:

> 
> I've just finished an application which uses threads. Each source file
> must be compiled with "_REENTRANT" definied. This is no problem in
> KDevelop, but when I create the source tar ball, KDevelop forgets to put
> the additional compiler option into the Makefile.

Hmmmm... "KDevelop forgets"?? ...
Depending the point of view and every case could be a different one...
But this is another subject :-)

> 
> I don't know autoconf etc. very well, so here's my question: In what file
> need I write the compiler option -D_REENTRANT ?

One version:
add to acconfig.h the following line:

#undef _REENTRANT

and insert in the configure.in, after the macro call
AC_CONFIG_HEADER(config.h):

AC_DEFINE_UNQUOTED(_REENTRANT)

(So it will be defined in config.h)
Requirements:
  AC_CONFIG_HEADER(config.h)
and
  in the sources a 

  #include <config.h>

  before the other includes will be done...
  

----

I personally think DEFINES should be published by config.h (or by the
shell/make variable $DEFS) and not as supposed inside the CXXFLAGS.
Unfortunately automake 1.4 has a bug, so something like DEFS += won't
work anymore :-((
(look also at http://lists.kde.org/?l=kde-devel&m=91908521503903&w=2 )
and we would need to _add_ the desired -D_REENTRANT to the already
existing values of $DEFS

The following solutions lack for this named semantical reason!!
But they will work, so here they are:

Another method to define it, is directly inside the configure.in - like
Jacek posted:
Here is a similiar method:
Insert the following in configure.in (I think a good position would be
after AC_CHECK_COMPILERS... take care of it, because another position
may change the results):

CXXFLAGS="$CXXFLAGS -D_REENTRANT"

(Jacek... I think AC_SUBST(CXXFLAGS) isn't necessary here - because it
is an "internal variable", is it??!!)

(N.B: look at the configure.in of the kdevelop sources there it is used
for the -frtti flag)

----
Quite another method to define this only for a section of modules (i.e.
the sources of a certain project-subdirectory):

insert the following in the Makefile.am of the project-subdir (e.g.
myprj/myprj/Makefile.am):
AM_CXXFLAGS=-D_REENTRANT

Requirements:
automake 1.4 and in the toplevel Makefile.am there should be
"1.4" added to the AUTOMAKE_OPTIONS.
e.g. 
AUTOMAKE_OPTIONS = foreign 1.4

So only the named project subdirectory will be compiled with this
switch...
(NB: these AM_CXXFLAGS will be set _before_ the "original" CXXFLAGS - in
this case it does no harm, but it may... look at the next part of my
mail)

----
Ralf, here some other stuff which would be maybe also relevant on this
subject (so it would be great if you could insert this also in the
documentation):

If you want to toggle an already made switch and you are using the
acinclude.m4/am_edit from KDE you should read this:
By default -fno-rtti and -fno-exceptions and -fno_check_news are set in
the new source templates... 
There are already some variables defined by the acinclude.m4.in which
can switch these back:
$(USE_RTTI)=-frtti
$(USE_EXCEPTIONS)=-fexceptions
(these are set to empty, if the compiler doesn't support these options
and it means that no -fno-rtti or -fno-exceptions was made)

so if you want to override a switch like -fno-rtti, the option -frtti
must occur _after_ the -fno-rtti switch (in the compiler call). To do
this use the following...

1) for the complete project:
in configure.in
CXXFLAGS="$CXXFLAGS $USE_RTTI"

2) for only a project-section:
   insert the following in the Makefile.am of the desired project
subdirectory:

KDE_CXXFLAGS=$(USE_RTTI)

(It works only for newer acinclude.m4 & am_edit, I think they must be
younger than 12-09-1999, formerly it was known as APPEND_CXXFLAGS)

> 
> Tschüss
>    Matthias
> 

Hope I didn´t make a grave error and it would be complete, but I don't
think so ;-)

Bye

Walter

--
oohhh sveglia.... il mondo e' ammalato, ma x colpa di chi.........
(Zucchero)
:-------W. Tasin, FB 04,
FHM-------------------PGP-KeyID:0x7961A645----------:
<Key-Fingerprint: 1610 835F 0080 32F4 6140  6CF7 A7D0 44CD 7961A645>
<http://wwwkeys.pgp.net:11371/pks/lookup?op=index&search=0x7961A645&fingerprint=on>




More information about the KDevelop mailing list