automake
[Top][All Lists]
Advanced

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

Re: Change a flag for a specific file


From: Ralf Wildenhues
Subject: Re: Change a flag for a specific file
Date: Mon, 7 Aug 2006 15:39:34 +0200
User-agent: Mutt/1.5.11

Hello Sylvestre,

* Sylvestre Ledru wrote on Mon, Aug 07, 2006 at 03:17:56PM CEST:
> 
> A quick question, I would like to be able to change one compilation flag
> for one file.
> I have a few fortran files which don't work (but can be compiled) with
> the optimisation flag (-O).
> Thus, I would like to disable the -O flag just fort those files. Is it
> possible to do that with automake ?

You can use per-target flags for this, if you have to.
(I say "if you have to", because in general it's easier to let the user
just do
  ./configure FFLAGS=-O0 FCFLAGS=-O0
and be done with it.  Why?  Your users will have compilers that do not
understand '-O0' even; so by hardcoding it, you will make it less fun
for them).

But anyway, here's a quick example Makefile.am:
  bin_PROGRAMS = foo
  foo_SOURCES = foo.f bar.f

now add:
  foo_FCFLAGS = -O0

(if you use AC_PROG_FC; for the F77 Fortran interface the variable to
use is foo_FFLAGS instead).  If you only build one program anyway, you
can just use the AM_FCFLAGS variable and be done with it.

If it is even important to you to have _only_ one file compiled with
this flag, say bar.f, while all the others do not get this flag, you
could make the compilation of bar.f special by putting it in a (not
installed) library.  For example:
  bin_PROGRAMS = foo
  foo_SOURCES = foo.f
  foo_LDADD = libdummy.a
  noinst_LIBRARIES = libdummy.a
  libdummy_a_SOURCES = bar.f
  libdummy_a_FCFLAGS = -O0

(remember to add AC_PROG_RANLIB to configure.ac if you do not use it
yet; if instead you are already using Libtool, use a convenience archive
  noinst_LTLIBRARIES = libdummy.la
instead).

Hope that helps.

Cheers,
Ralf




reply via email to

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