diff options
author | Michael Schwarz <michi.schwarz@gmail.com> | 2014-12-12 18:07:28 +0100 |
---|---|---|
committer | Michael Schwarz <michi.schwarz@gmail.com> | 2014-12-12 18:07:28 +0100 |
commit | 88fef813b0d1013e90c9aa4156cbc836481377a3 (patch) | |
tree | 128b26f48b4a5abfbb803d85ecae48237cb0a238 /Makefile | |
parent | c02392b65243b3842e273cec36468e21ee376787 (diff) | |
parent | b69003800917a93c5c2b240ede6f83b80f1095cc (diff) | |
download | pogojig-88fef813b0d1013e90c9aa4156cbc836481377a3.tar.gz pogojig-88fef813b0d1013e90c9aa4156cbc836481377a3.tar.bz2 pogojig-88fef813b0d1013e90c9aa4156cbc836481377a3.zip |
Merge branch 'master' into no-examples
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -1,8 +1,11 @@ INKSCAPE ?= inkscape OPENSCAD ?= openscad +PYTHON ?= python2 + +PYTHON_CMD := PYTHONPATH="support:$$PYTHONPATH" $(PYTHON) # Used by dxf_export/main.sh -export INKSCAPE +export INKSCAPE OPENSCAD # Run generate_scad.sh to get the names of all OpenSCAD files that should be generated using that same script. GENERATED_FILES := $(addsuffix .scad,$(basename $(shell ./generate_sources.sh))) @@ -13,34 +16,32 @@ GENERATED_SCAD_FILES := $(filter %.scad, $(GENERATED_FILES)) SVG_FILES := $(shell find src -name '*.svg') $(GENERATED_SVG_FILES) # Only OpenSCAD files whose names do not start with `_' are compiled to STL. -SCAD_FILES := $(shell find src -name '*.scad') $(GENERATED_SCAD_FILES) -LIBRARY_SCAD_FILES := $(foreach i,$(SCAD_FILES),$(if $(filter _%,$(notdir $(i))),$(i))) -COMPILED_SCAD_FILES := $(filter-out $(LIBRARY_SCAD_FILES),$(SCAD_FILES)) +COMPILED_SCAD_FILES := $(foreach i,$(shell find src -name '*.scad') $(GENERATED_SCAD_FILES),$(if $(filter-out _%,$(notdir $(i))),$(i))) + +# Makefiles which are generated while compiling to record dependencies. +DEPENDENCY_FILES := $(patsubst %.scad,%.d,$(COMPILED_SCAD_FILES)) # All files that may be generated from the source files. STL_FILES := $(patsubst %.scad,%.stl,$(COMPILED_SCAD_FILES)) DXF_FILES := $(patsubst %.svg,%.dxf,$(SVG_FILES)) # Everything. Also generates files which aren't compiled to anything else. -all: $(STL_FILES) $(GENERATED_FILES) +all: $(GENERATED_FILES) $(DXF_FILES) $(STL_FILES) # Everything^-1. clean: - rm -rf $(DXF_FILES) $(STL_FILES) $(GENERATED_FILES) - -# Needs to be included after target all has been defined. --include config.mk + rm -rf $(GENERATED_FILES) $(DXF_FILES) $(STL_FILES) $(DEPENDENCY_FILES) -# Assume that any compiled OpenSCAD file may depend on any non-compiled OpenSCAD file in the same directory. -$(foreach i,$(COMPILED_SCAD_FILES),$(eval $(i): $(filter $(dir $(i))%,$(LIBRARY_SCAD_FILES) $(DXF_FILES)))) +# Include the local configuration file and the dependency files. Needs to be included after the `all' target has been defined. +-include config.mk $(DEPENDENCY_FILES) # Rule to convert an SVG file to a DXF file. %.dxf: %.svg - python2 dxf_export $< $@ + $(PYTHON_CMD) -m dxf_export $< $@ -# Rule to compile an OpenSCAD file to an STL file. -%.stl: %.scad - $(OPENSCAD) -o $@ $< +# Rule to compile an OpenSCAD file to an STL file. We require all DXF files to exist before an OpenSCAD file can be used to generate an STL file. Additional dependencies are read from the included makefiles generated during compiling. +%.stl: %.scad | $(DXF_FILES) + $(PYTHON_CMD) -m openscad $< $@ $*.d # Rule for automaticlaly generated OpenSCAD files. $(GENERATED_FILES): generate_sources.sh |