I would like to know if it's possible to pass a makefile target's dependency as an argument. And if it's possible, how to do it.
For example, imagine I have an application which builds from several dependencies
target_full : dep1.o dep2.o dep3.o
commands
dep1.o : file1 file2
commands
dep2.o : file3 file4
commands
dep3.o : file5 file6
commands
I would like to be able to pass an already compiled dependency as argument.
So if I run make all it will generate dep1.o dep2.o dep3.o from files but if I run make all dep1-file=myDep.o it will generate only dep2.o and dep3.o and use the given dependency WITHOUT recompiling dep1.o from file1 and file2.
In fact I don't want the the first dependency target to be called at all
I imagined something like
ifndef(dep1-file)
dep1=dep1.o
else
dep1=${dep1-file}
endif
target_full : ${dep1} dep2.o dep3.o
commands
${dep1} : file1 file2
commands
dep2.o : file3 file4
commands
dep3.o : file5 file6
commands
However make keep compiling dep1.o from file1 and file2. Maybe it's because of modification dates but I also would like this to NOT be taken in count as I don't care if file1 and file2 are more recent than my custom dependency or not.
EDIT : I should have precised that I have a working solution but it's really ugly though so I'm not fully satisfied with it, I think a better way to do it exist.
However I paste it here so it may facilitate the uderstanding of my issue.
ifndef dep1-file
dep1=dep1.o
else
dep1=${dep1-file}
endif
target_full : ${dep1} dep2.o dep3.o
commands
ifndef dep1-file
${dep1} : file1 file2
commands
endif
dep2.o : file3 file4
commands
dep3.o : file5 file6
commands
I would be glad to have some help to resolve this problem. Thanks in advance