0

I am using autotools to create Makefiles for a project in Fortran. I would like to direct compiler to place all objects it creates (*.o) in a sub-directory called "Obj".

My configure.ac looks like this:

AC_INIT([Driver],[0.1])
AM_INIT_AUTOMAKE
AC_PROG_FC
AC_PROG_RANLIB
AC_OUTPUT( 
  Makefile
)

and Makefile.am like:

bin_PROGRAMS = SFS
SFS_SOURCES = Driver.f90
INCLUDE = -I@top_srcdir@/

To the best of my knowledge, a directive such as

OBJDIR = Obj

Should somehow penetrate the final Makefile, but have no idea how to direct autotools to do it.

Any hint would be appreciated.

Bojan Niceno
  • 113
  • 1
  • 1
  • 11
  • If you want fine control over where intermediate targets are built then you probably want to write your Makefiles directly, or perhaps with Autoconf alone, rather than letting Automake do it. Automake does not play well with that kind of thing. Why is it important to you where the intermediate targets are built? – John Bollinger Oct 11 '17 at 18:01
  • Thanks for your answer John. The reason? I am not working alone but in a small team with three other researchers. They don't want to see object files among the sources, and since they outvoted me on that issue (3:1) I am trying to find a workaround. Would you maybe know how to direct Autoconf to place object files in a separate directory? – Bojan Niceno Oct 12 '17 at 06:43
  • I sympathize. Please allow me to suggest that if you're colleagues do not want to see object files among the sources, then a better solution -- available out-of-the-box from an Automake-derived build system -- is to use only [out-of-source (a.k.a. VPATH) builds](https://www.gnu.org/software/automake/manual/html_node/VPATH-Builds.html). – John Bollinger Oct 12 '17 at 13:42
  • If out-of-source building is also unsatisfactory then I'm afraid your team might have a lot of work cut out for them. As I was trying to tell you at the beginning, there is no simple switch to flip. Autoconf, if you continue to use it, simply helps you gather system information and plug data into file templates. Especially Makefile templates. You need to provide appropriate templates, and that's where Automake comes in, but you don't like the templates that Automake makes. So you'll need to write your own templates -- more-or-less complete Makefiles that do as you want. – John Bollinger Oct 12 '17 at 13:48
  • Thanks a lot John, highly appreciated :-) – Bojan Niceno Oct 12 '17 at 14:04
  • Possible duplicate of [Automake generating binaries to bin/ instead of in src/](https://stackoverflow.com/questions/2139854/automake-generating-binaries-to-bin-instead-of-in-src) – ptomato Oct 31 '17 at 02:45

0 Answers0