views:

158

answers:

1

I have been tooling around with autotools for the past couple of days, and finally have made significant progress. One problem I am having is that I have two libraries that need to be compiled before the main application code. I'm not quite sure how to do this. My directory structure is below and a snippet from my configure.ac as well.

AC_CONFIG_FILES([Makefile
      src/Makefile
      gtkworkbook/Makefile
      csv/Makefile])
AC_OUTPUT

I need the csv/Makefile and gtkworkbook/Makefile to both be compiled before src/Makefile; is there any way to specify this? Right now I am getting an error about the library (csv) not existing during the application compile process.

+3  A: 

The order of items in AC_CONFIG_FILES() does not affect the build order. If you're using automake, which I assume you are, it will traverse your directory tree in the order that you list directories in each Makefile.am's SUBDIRS list.

That being said, you should have the order of items in AC_CONFIG_FILES() mirror the build order, for consistency/maintainability.

Example of how your toplevel Makefile.am's SUBDIRS to build in the desired order:

SUBDIRS = csv gtkworkbook src

Also, for this simple case you don't need both AC_CONFIG_FILES() and AC_OUTPUT(). You can pass your list directory to AC_OUTPUT():

AC_OUTPUT([
    Makefile
    src/Makefile
    gtkworkbook/Makefile
    csv/Makefile
])
anthony
i.e. you need SUBDIRS=csv gtkworkbook src(yes I was typing an answer as anthony did his!)
dajobe
I did this but it does not to seem have worked. Makefile.am in the top directory has the same subdirs, and the AC_OUTPUT was changed too. Any suggestions?
John Bellone
Are you sure the changes from your Makefile.am have propagated to your Makefile? GNU make attempts to do this automatically for cases it can detect but sometimes a regen is required after editing your configure.in. Rerun your autogen script.
anthony
it typically only adds the appropriate rules for regeneration to the output Makefiles if you configure --enable-maintainer-mode. otherwise as anthony says, regen if top level Makefile has the wrong SUBDIRS.
dajobe