Reputation: 553
I want to include another makefile after running a particular command because the first command generates that makefile. I tried this
debug2:
cd bench/${BENCH}; verilator --cc top.v
include ${BENCH_DIR}/Vtop_classes.mk
In this case make doesn't recognize the include command and gives an error "make: include: Command not found"
if I try to include without tab then it includes before the previous command is executed and so generates error of no such file
debug2:
cd bench/${BENCH}; verilator --cc top.v
include ${BENCH_DIR}/Vtop_classes.mk
Upvotes: 2
Views: 823
Reputation: 65
INCLUDED-FILES=MakeA MakeB
-include $(INCLUDED-FILES)
# alternatively use sinclude
generate-makefile:
touch MakeA
touch MakeB
clean: generate-makefile
if [ -a MakeA ]; then make clean-A; else echo "No file: MakeA. Run make again."; fi;
if [ -a MakeB ]; then make clean-B; else echo "No file: MakeB. Run make again."; fi;
GNU make will not report errors because of -include
. When make runs the deferred rules and the included files do not exist the shell prints a message "Run make again". The deferred rules in the example call make a second time, so no error is reported.
Because -include
does not report errors, make
can run the generation rule on the first run. The dependencies are resolved for the second run.
Upvotes: 0