Ask Your Question
1

Automake to compile objects in a specific directory

asked 2011-12-12 11:06:25 -0500

shaiton gravatar image

updated 2011-12-12 12:02:23 -0500

Hi,

How could I get automake to compile object in an object directory, and not in the source folder?

Here is what I have so far:

|-- configure.ac
|-- include
|   |-- header1.h
|   |-- header2.h
|   `-- Makefile.am
|-- Makefile.am
|-- obj
|   `--  
`-- src
    |-- Makefile.am
    |-- main.cc
    |-- snd.cc
    |-- Makefile.am
    `-- USBdiscovery.cc

I've read things about "AUTOMAKE_OPTIONS = subdir-objects" (to include in a Makefile.am?) but I don't know how to tell that I want my .o files in obj/.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2011-12-13 03:58:59 -0500

shaiton gravatar image

What I found so far is the Parallel Build Trees (a.k.a. VPATH Builds).

We just have to run our default configure script in a subdirectory, that will create a new tree. We would then have the sources tree and the build tree.

If configure is executed in its own directory, the source and build trees are combined: derived files are constructed in the same directories as their sources.

I new where to create object files in my own makefile, now it is more convenient to create the build tree.

My tree is like above, with the empied obj dir (we should not create it obj as BSD don't like that)

cd obj
../configure
make

That's it, I now have a clean source tree and a build tree completly out of my repo.

.
|-- configure.ac
|-- include
|   |-- header1.h
|   |-- header2.h
|   `-- Makefile.am
|-- Makefile.am
|-- obj
|   `-- config.log
|   |-- config.status
|   |-- include
|   |   `-- Makefile
|   |-- Makefile
|   `-- src
|       |-- main.o
|       |-- snd.o
|       `-- Makefile
`-- src
    |-- Makefile.am
    |-- main.cc
    |-- snd.cc
    |-- Makefile.am
    `-- USBdiscovery.cc
edit flag offensive delete link more
0

answered 2011-12-12 23:25:05 -0500

SoumyaC gravatar image

Not sure if this is what you want, but probably if yes you can use pathsubst() function to store your object files (.o files) in obj. You can refer below link for description -

Storing *.o in obj

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-12-12 11:06:25 -0500

Seen: 2,820 times

Last updated: Dec 13 '11