Where to put compiler options?
tasin at e-technik.fh-muenchen.de
Fri Mar 17 17:41:19 UTC 2000
Matthias Duesterhoeft wrote:
Hi Matthias, Jacek, Ralf,
due to your posting I want to put this in the list, what I found out
> 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 ?
add to acconfig.h the following line:
and insert in the configure.in, after the macro call
(So it will be defined in config.h)
in the sources a
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
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):
(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.
automake 1.4 and in the toplevel Makefile.am there should be
"1.4" added to the AUTOMAKE_OPTIONS.
AUTOMAKE_OPTIONS = foreign 1.4
So only the named project subdirectory will be compiled with this
(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
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
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:
(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:
2) for only a project-section:
insert the following in the Makefile.am of the desired project
(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)
Hope I didn´t make a grave error and it would be complete, but I don't
think so ;-)
oohhh sveglia.... il mondo e' ammalato, ma x colpa di chi.........
:-------W. Tasin, FB 04,
<Key-Fingerprint: 1610 835F 0080 32F4 6140 6CF7 A7D0 44CD 7961A645>
More information about the KDevelop