diff options
author | Michael Schwarz <michi.schwarz@gmail.com> | 2014-11-26 16:24:08 +0100 |
---|---|---|
committer | Michael Schwarz <michi.schwarz@gmail.com> | 2014-11-27 18:18:27 +0100 |
commit | 16d3e4a963d7fd299042ba27778744e0bd7da037 (patch) | |
tree | 9148c097353b3241c6895c6c74fe3f583ca85c6e /Makefile | |
download | pogojig-16d3e4a963d7fd299042ba27778744e0bd7da037.tar.gz pogojig-16d3e4a963d7fd299042ba27778744e0bd7da037.tar.bz2 pogojig-16d3e4a963d7fd299042ba27778744e0bd7da037.zip |
First version of the template project.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..37a6547 --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +INKSCAPE ?= inkscape +OPENSCAD ?= openscad + +# Used by dxf_export/main.sh +export INKSCAPE + +# 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))) +GENERATED_SVG_FILES := $(filter %.svg, $(GENERATED_FILES)) +GENERATED_SCAD_FILES := $(filter %.scad, $(GENERATED_FILES)) + +# Source SVG 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)) + +# 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. +all: $(STL_FILES) + +# Everything^-1. +clean: + rm -rf $(DXF_FILES) $(STL_FILES) $(GENERATED_SCAD_FILES) + +# Needs to be included after target all has been defined. +-include config.mk + +# 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)))) + +# Rule to convert an SVG file to a DXF file. +%.dxf: %.svg + dxf_export/main.sh $< $@ + +# Rule to compile an OpenSCAD file to an STL file. +%.stl: %.scad + $(OPENSCAD) -o $@ $< + +# Rule for automaticlaly generated OpenSCAD files. +$(GENERATED_FILES): generate_sources.sh + ./generate_sources.sh $@ > $@ |