1

I have a script that generates c++ source files of previousy unknown number and name which then need to be compiled into one library. So far, I do this with a simple (shell) for loop in my Makefile:

compile:
        for f in `ls -1 *.cpp` ; do g++ -c ...
        ...

There will be no other c++ sources in the directory, so I just compile everything that's there.

Now I want to change my build system to autoconf/automake and I'm wondering what the 'right' way of doing this would be. The tutorials I've found only cover the case where you know the number and names of the sources that will be generated.

Is there, for example, a way to access the compiler name and all the flags that autoconf/automake put together for me, so that I can insert them in my own compile command?

Thanks in advance.

Martin Wiebusch
  • 1,681
  • 2
  • 11
  • 15

3 Answers3

2

I would change the script to generate a Makefile.am listing all these files explicitly.

adl
  • 15,627
  • 6
  • 51
  • 65
  • But I already have a Makefile.am that's responsible for running the script and generating the sources. The script depends on other input files and needs to be re-run whenever they change. (I guess I should have mentioned that.) – Martin Wiebusch Apr 16 '12 at 18:04
0

So you have something like:

FOO_SCRIPT=script.sh
libfoo_la_SOURCES=foo.cpp bar.cpp baz.cpp

foo.cpp : foo.input
        $(FOO_SCRIPT) $<

bar.cpp baz.cpp : bar.input
        $(FOO_SCRIPT) $<
ldav1s
  • 15,885
  • 2
  • 53
  • 56
0
SRC= $(wildcard *.cpp)
OBJ= $(SRC:.cpp=.o)
[...]
target: $(OBJ)
tomato
  • 747
  • 5
  • 11