Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automake Variables to tidy up Makefile.am

I have a directory /src containing all of my source files, and /bin to store all binary after running make command. The directory is something like below:

/BuildDirectory
- - /src
- - /bin
- - configure
- - Makefile.am
- - configure.ac 
- - ... 

Now in Makefile.am, I have to specified:

bin_PROGRAMS = bin/x bin/y bin/z bin/k ...

bin_x_SOURCES = src/x.cpp
bin_y_SOURCES = src/y.cpp
bin_z_SOURCES = src/z.cpp

Is there any variable that can help to get rid of all "bin/" and "src/" ? For example I just specify:

$BIN = bin
$SRC = src 

And they will look for the correct files in correct folders and compile it to the correct places.

Thanks

like image 543
w00d Avatar asked Jun 24 '11 04:06

w00d


2 Answers

You could take advantage of remote building. Place this makefile in the bin dir:

VPATH = ../src
bin_PROGRAMS = x y z k ...

x_SOURCES = x.cpp
y_SOURCES = y.cpp
z_SOURCES = z.cpp

Now replace the current Makefile.am with this one:

SUBDIRS = bin

Now tweak your configure.ac to also generate bin/Makefile

AC_CONFIG_FILES([Makefile
        bin/Makefile])

and you should be set for life.

like image 157
DipSwitch Avatar answered Nov 15 '22 17:11

DipSwitch


Not to my knowledge. If you're looking to separate your compiled files from your source files, remember that you can build outside of the tree:

$ cd foo-1.2.3
$ mkdir build
$ cd build
$ ../configure
$ make
$ make install

If this is what you're looking to do, you can make the Makefile.am simpler by creating binaries without a directory prefix (and still referencing things in src/ by hand).

like image 30
Jack Kelly Avatar answered Nov 15 '22 16:11

Jack Kelly