From 7a1f69c47414ac181b1713f46d658ef546d079e5 Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Wed, 5 Aug 2015 15:24:38 +0200 Subject: Simplified makefile. --- Makefile | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9b1f796..1bde859 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,12 @@ PYTHON := python2 DXF_FLATNESS := 0.1 FLAT_SCAD_FILES := +# Non-file goals. +.PHONY: all clean generated dxf stl + +# Goal to build Everything. Also generates files which aren't compiled to anything else. Deined here to make it the default goal. +all: generated dxf stl + # Include the configuration files. -include config.mk settings.mk @@ -18,50 +24,34 @@ PYTHON_CMD := PYTHONPATH="support:$$PYTHONPATH" $(PYTHON) # 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)) - -# All visible files in the src directory. Ignore files whose names contain spaces. Also ignore generated files. -SRC_FILES := $(filter-out $(GENERATED_FILES),$(shell find src -not \( \( -name '.*' -or -name '* *' \) -prune \))) -SRC_SCAD_FILES := $(filter %.scad,$(SRC_FILES)) -SRC_SVG_FILES := $(filter %.svg,$(SRC_FILES)) -# Source SVG files. -SVG_FILES := $(SRC_SVG_FILES) $(GENERATED_SVG_FILES) +# All visible files in the src directory that either exist or can be generated. Ignore files whose names contain spaces. +SRC_FILES := $(GENERATED_FILES) $(shell find src -not \( \( -name '.*' -or -name '* *' \) -prune \)) -# Only OpenSCAD files whose names do not start with `_' are compiled to STL. -COMPILED_SCAD_FILES := $(foreach i, $(SRC_SCAD_FILES) $(GENERATED_SCAD_FILES),$(if $(filter-out _%,$(notdir $(i))),$(i))) +# Source files whose names start with `_' are not compiled directly but may be used from other source files. +COMPILED_SRC_FILES := $(foreach i,$(SRC_FILES),$(if $(filter-out _%,$(notdir $(i))),$(i))) # Makefiles which are generated while compiling to record dependencies. -DEPENDENCY_FILES := $(patsubst %.scad,%.d,$(COMPILED_SCAD_FILES)) +DEPENDENCY_FILES := $(foreach i,.scad,$(patsubst %$i,%.d,$(filter %$i,$(COMPILED_SRC_FILES)))) # STL files produced from OpenSCAD files. -SCAD_STL_FILES := $(patsubst %.scad,%.stl,$(filter-out $(FLAT_SCAD_FILES),$(COMPILED_SCAD_FILES))) +SCAD_STL_FILES := $(patsubst %.scad,%.stl,$(filter-out $(FLAT_SCAD_FILES),$(filter %.scad,$(COMPILED_SRC_FILES)))) # DXF files produced from OpenSCAD fiels. Ignore non-OpenSCAD files in FLAT_SCAD_FILES. -SCAD_DXF_FILES := $(patsubst %.scad,%.dxf,$(filter $(FLAT_SCAD_FILES),$(COMPILED_SCAD_FILES))) +SCAD_DXF_FILES := $(patsubst %.scad,%.dxf,$(filter %.scad,$(filter $(FLAT_SCAD_FILES),$(COMPILED_SRC_FILES)))) # DXF files produced from SVG files. Ignore an SVG file if the same DXF file can also be produced from an OpenSCAD file. This is just to get reproducable builds without aborting it. -SVG_DXF_FILES := $(filter-out $(SCAD_DXF_FILES),$(patsubst %.svg,%.dxf,$(SVG_FILES))) +SVG_DXF_FILES := $(filter-out $(SCAD_DXF_FILES),$(patsubst %.svg,%.dxf,$(filter %.svg,$(COMPILED_SRC_FILES)))) # Files that may be used from OpenSCAD files and thus must exist before OpenSCAD is called. -SCAD_ORDER_DEPS := $(SVG_DXF_FILES) $(GENERATED_FILES) +SCAD_ORDER_DEPS := $(filter %.scad %.dxf,$(GENERATED_FILES)) $(SVG_DXF_FILES) # Dependencies which may affect the result of all build products. GLOBAL_DEPS := Makefile $(wildcard config.mk settings.mk) -# Make the next goal (`all`) the default goal. -.DEFAULT_GOAL := - -# Non-file goals. -.PHONY: all clean generated dxf stl - -# Goal to build Everything. Also generates files which aren't compiled to anything else. -all: generated dxf stl - # Everything^-1. clean: - rm -rf $(GENERATED_FILES) $(SVG_DXF_FILES) $(SCAD_DXF_FILES) $(SCAD_STL_FILES) $(DEPENDENCY_FILES) + rm -rf $(GENERATED_FILES) $(SVG_DXF_FILES) $(SCAD_DXF_FILES) $(SCAD_STL_FILES) $() $(DEPENDENCY_FILES) # Goals to build the project up to a specific step. generated: $(GENERATED_FILES) -- cgit