0

I'm creating a software project and I wanted to use autotools to do the makefile and etc. script generation for me, I manually created Makefile.am and configure.in files, and I'm using the autogen.sh script from here. The problem comes when attempting to build the project in a separate 'build' directory, e.g. if I go:

mkdir build
cd build
../configure
make

The configure step works fine, but when running make I get:

make  all-recursive
Making all in src
/bin/sh: line 0: cd: src: No such file or directory
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Any tips to get this working? Or should I give up and try something simpler/different. I plan for this to be a reasonably simple C++ project, and the only dependency I plan to have is on the boost unit testing framework, and to do most development in Eclipse IDE.

Adam M-W
  • 3,509
  • 9
  • 49
  • 69
  • 1
    this seems to be a problem with your Makefile.am's. it would be great if you could post them (at least the Makefile.am in your project's root and src (assuming that src/ is directly in the project-root) – umläute Sep 10 '12 at 09:28
  • Sorry.. Here they are https://gist.github.com/3690227 – Adam M-W Sep 10 '12 at 10:39

1 Answers1

1

there's a bug in your src/Makefile.am, line#17:

swin-adventure_SOURCES = src/main.cc

should really read:

swin-adventure_SOURCES = main.cc

since you are already in the src/ directory (unless there's a src/src/ subfolder)

there's another bug, as you are using special characters in your _SOURCES variabes: swin-adventure_SOURCES has the forbidden - character; try to normalize that to swin_adventure_SOURCES

finally, you are trying to assign a value to bin_PROGRAMS multiple times (and each time the same value), try to avoid that.

something like:

## Additional flags to pass to aclocal when it is invoked automatically at
## make time. The ${ACLOCAL_FLAGS} variable is picked up from the environment
## to provide a way for the user to supply additional arguments.
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}

## Define an executable target "swin-adventure", which will be installed into the
## directory named by the predefined variable $(bindir).
bin_PROGRAMS = swin-adventure

## Define the list of source files for the "swin-adventure" target. The file 
## extension .cc is recognized by Automake, and causes it to produce rules 
## which invoke the C++ compiler to produce an object file (.o) from each 
## source file. The ## header files (.h) do not result in object files by 
## themselves, but will be included in distribution archives of the project.
swin_adventure_SOURCES = main.cc
umläute
  • 28,885
  • 9
  • 68
  • 122
  • Thanks. You've been a real help. Is there a way to move where the generated binary is created (i.e. create it in the root directory rather than the src directory?) – Adam M-W Sep 10 '12 at 14:18
  • usually you don't :-). if you absolutely need it to be in the root directory you could either add all the build-info into your root Makefile.am (rather than src/Makefile.am), this time using `src/main.cc` (isn't this where we came in?); or you add a post-build hook that copies/symlinks the resulting binary to the place you want – umläute Sep 26 '12 at 09:14