I have a script which generates some source files for my c++ project. The script itself looks like this:
echo "total args: $#"
if [ $# -eq 7 ]; then
echo "in if"
$1/../tools/xsde [...]
fi
It is executed from a makefile when target smt_response_files is run and file .xsd.files.make does not exists or it is older than .xsd file.
$(smt_path) ?= .
$(smt_build) ?= $(smt_path)/build
$(common_build) ?= ../build
-include $(smt_build)/$(smt_gen_response_xsd).files.make
smt_response_files : | $(smt_build)/$(smt_gen_response_xsd).files.make
@:
$(smt_build)/$(smt_gen_response_xsd).files.make : $(smt_gen_response_path)/$(smt_gen_response_xsd)
@$(common_build)/generate_xml.sh $(smt_path) $(smt_gen_response_path) $(smt_gen_response_xsd) xml::$(smt_gen_response_class) make_list $(smt_build)/$(smt_gen_response_xsd).files.make smt_response_files
The problem: after I clean up my project and delete *.xsd.files.make they are recreated when makefiles are parsed (I've translated the output from Russian):
Reading make-files...
total args: 7
in if
...
total: 2193
Updating makefile goals...
File `smt_clean' does not exist.
... (and a normal clean proccess goes next)
The autogenerated files are removed by the clean target, but I don't like that they are created in the process.
The only way to do this, as far as I know is to exclude the rules for recreating *.xsd.files.make which are included as makefiles:
inc_gen ?= true
ifeq ($(MAKECMDGOALS),clean)
inc_gen := false
endif
# ... other excluded targets here (smt_clean, etc.)
ifeq ($(inc_gen),true)
$(smt_build)/$(smt_gen_response_xsd).files.make : $(smt_gen_response_path)/$(smt_gen_response_xsd)
@$(common_build)/generate_xml.sh $(smt_path) $(smt_gen_response_path) $(smt_gen_response_xsd) xml::$(smt_gen_response_class) make_list $(smt_build)/$(smt_gen_response_xsd).files.make smt_response_files
endif
Is there other ways to solve my problem? Maybe some more general approach exists?
Thanks everyone in advance.