Reputation: 239
I code some C++ software and manage the whole project with the GNU autotools.
I have some part of the C++ code which is really verbose so I have made a script "generator.rb" which generate it automatically in a file "generated.cpp".
I have a build target "generated.cpp" that construct "generated.cpp" from "object_list.txt"
Up to this point everything works correctly.
Now I want to #include this "generated.cpp" file in another one "handwritten.cpp".
Since automake is said to automaticaly compute the dependencies on included files, I expect it to :
rebuild "generated.cpp" when building "handwritten.o", if it does not exist or is not up-to-date
trigger a new "handwritten.o" build each time object_list.txt has changed
So how can I do that ?
Remark : My source tree is like that :
./
\_src/
| \_handwritten.cpp
|_design/
| \_object_list.txt
\_tools/
\_generator.rb
Remark : My build tree is like that :
build/
\_gcc_debug/
|_src/
| \_handwritten.o
\_design/
\_generated.cpp
Upvotes: 1
Views: 225
Reputation: 22519
Since automake is said to automaticaly compute the dependencies on included files
Because Automake-generated Makefiles generate dependencies as a side effect of compilation, a file that is created as part of the build needs special treatment. You have to tell Automake to build such a file before it tries any of the normal compilations. This is done using BUILT_SOURCES, like:
BUILT_SOURCES = generated.cpp
... followed by writing the rules you need to create generated.cpp
.
Upvotes: 1