I'm working on modifying a huge recursive makefile project that has 6000+ source files. All of which are clearcase controlled. Since I don't want to copy the whole source tree, I'm trying to create a new project only containing the modified source files and thus pull the source from the original tree if they don't exist in my modified tree.
I have already modified the makefile in ModDir
to check if each folder exists locally and execute make in that folder if it does. Otherwise it executes make in the sourceDir
. My issue lies in the subdir makefiles.
Each subdir makefile contains a list of all of the source files needed for that module. I need to find a way to build the file locally if it exists, else build the file from SourceDir/subdir
.
I.e. in my image, the Dir1
makefile needs to build F1
from ModDir/Dir1/F1
, and build the other files from SourceDir/Dir1/F2-F3
.
I tried to use VPATH to tell make to locate the source files in both locations (ModDir
first of course) which works beautifully. However, since make assumes the object files are in the ModDir
, it can't find any of the object files built in SourceDir
.
I also tried making a pre-build rule to modify the make file list with bash, but I don't know if that's even possible.
How do I use make to build from one directory if the source file exists (ModDir
), otherwise build from another (SourceDir
)?
The easiest way will be to put your "if ... then ... else" logic in an external bash or batch (whichever OS you use) script and swap makefile
s before calling make
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With