build: Fix and clean up the gen.mk.
[gfxprim.git] / gen.mk
blob58cd612aa9d6942c66328a8eb72d8eca1265fb50
2 # This is makefile rule for generating C sources from python generators
4 ifndef LIBNAME
5 $(error LIBNAME not defined, fix your library Makefile)
6 endif
8 ifndef GENHEADERS
9 GENHEADERS=
10 endif
12 ifndef GENSOURCES
13 GENSOURCES=
14 endif
17 # Generate genfiles for generated sources
19 CSOURCES+=$(GENSOURCES)
22 # Make the genrated headers actually build
24 all: $(GENHEADERS) $(GENSOURCES)
27 # Base common templates location
29 TEMPLATE_DIR=$(TOPDIR)/pylib/templates/
32 # ALL templates and potential generated files (not generated automatically)
33 # NOTE: Currently unused
35 ALL_TEMPLATES=$(shell find $(TOPDIR) -name '*.t')
36 ALL_GENERATED=$(basename $(ALL_TEMPLATES))
39 # And clean them
41 CLEAN+=$(GENSOURCES) $(GENHEADERS)
44 # Add templates as dependencies
46 PYTHON_FILES=$(shell find $(TEMPLATE_DIR) -name '*.t')
47 $(GENSOURCES) $(GENHEADERS): $(PYTHON_FILES)
50 # Generated files depend on python generators and the template
52 $(GENSOURCES) $(GENHEADERS): %: %.t
53 ifdef VERBOSE
54 ${PYTHON} ${TOPDIR}/pylib/bin/generate_file.py -t $(TEMPLATE_DIR) "$@.t" "$@"
55 else
56 @echo "GEN $@"
57 @${PYTHON} ${TOPDIR}/pylib/bin/generate_file.py -t $(TEMPLATE_DIR) "$@.t" "$@"
58 endif