diff options
author | Michael Schwarz <michi.schwarz@gmail.com> | 2015-07-31 16:27:21 +0200 |
---|---|---|
committer | Michael Schwarz <michi.schwarz@gmail.com> | 2015-08-06 16:32:59 +0200 |
commit | 4a103f6dba4c20ef13475e553d6a6f5328a7f340 (patch) | |
tree | 994283189577b99051cfd36018688a20ff12c0d7 | |
parent | e2d477640ffef84011860f00694a58374e7c3a29 (diff) | |
download | pogojig-4a103f6dba4c20ef13475e553d6a6f5328a7f340.tar.gz pogojig-4a103f6dba4c20ef13475e553d6a6f5328a7f340.tar.bz2 pogojig-4a103f6dba4c20ef13475e553d6a6f5328a7f340.zip |
Integrated Asymptote compilation into makefile.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 32 |
2 files changed, 25 insertions, 8 deletions
@@ -3,4 +3,5 @@ /src/**/*.dxf /src/**/*.stl +/src/**/*.pdf /src/**/*.d @@ -2,16 +2,18 @@ INKSCAPE := inkscape OPENSCAD := openscad PYTHON := python2 +ASYMPTOTE := asy # Settings affecting the compiled results. You can overwrite these in a file called settings.mk in the same directory as this makefile. See readme.creole. DXF_FLATNESS := 0.1 FLAT_SCAD_FILES := +ASY_SVG_FILES := # Non-file goals. -.PHONY: all clean generated dxf stl +.PHONY: all clean generated dxf stl asy pdf # 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 +all: generated dxf stl asy pdf # Include the configuration files. -include config.mk settings.mk @@ -26,14 +28,11 @@ PYTHON_CMD := PYTHONPATH="support:$$PYTHONPATH" $(PYTHON) GENERATED_FILES := $(addsuffix .scad,$(basename $(shell ./generate_sources.sh))) # 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 \)) +SRC_FILES := $(GENERATED_FILES) $(shell find src -type f -not \( \( -name '.*' -or -name '* *' \) -prune \)) # 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 := $(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),$(filter %.scad,$(COMPILED_SRC_FILES)))) @@ -41,7 +40,15 @@ SCAD_STL_FILES := $(patsubst %.scad,%.stl,$(filter-out $(FLAT_SCAD_FILES),$(filt 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,$(filter %.svg,$(COMPILED_SRC_FILES)))) +SVG_DXF_FILES := $(filter-out $(SCAD_DXF_FILES),$(patsubst %.svg,%.dxf,$(filter %.svg,$(filter-out $(ASY_SVG_FILES),$(COMPILED_SRC_FILES))))) + +SVG_ASY_FILES := $(patsubst %.svg,%.asy,$(filter %.svg,$(filter $(ASY_SVG_FILES),$(COMPILED_SRC_FILES)))) + +# PDF files which can be generated from Asymptote files. We exclude SVG_ASY_FILES because they don't contain any drawing primitives and thus won't produce a PDF. +ASY_PDF_FILES := $(patsubst %.asy,%.pdf,$(filter %.asy,$(filter-out $(SVG_ASY_FILES), $(COMPILED_SRC_FILES)))) + +# Makefiles which are generated while compiling to record dependencies. +DEPENDENCY_FILES := $(foreach i,.scad,$(patsubst %$i,%.d,$(filter %$i,$(COMPILED_SRC_FILES)))) # Files that may be used from OpenSCAD files and thus must exist before OpenSCAD is called. SCAD_ORDER_DEPS := $(filter %.scad %.dxf,$(GENERATED_FILES)) $(SVG_DXF_FILES) @@ -51,17 +58,22 @@ GLOBAL_DEPS := Makefile $(wildcard config.mk settings.mk) # 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) $(SVG_ASY_FILES) $(ASY_PDF_FILES) $(DEPENDENCY_FILES) # Goals to build the project up to a specific step. generated: $(GENERATED_FILES) dxf: $(SVG_DXF_FILES) $(SCAD_DXF_FILES) stl: $(SCAD_STL_FILES) +pdf: $(ASY_PDF_FILES) +asy: $(SVG_ASY_FILES) # Rule to convert an SVG file to a DXF file. $(SVG_DXF_FILES): %.dxf: %.svg $(GLOBAL_DEPS) $(PYTHON_CMD) -m inkscape $< $@ +$(SVG_ASY_FILES): %.asy: %.svg $(GLOBAL_DEPS) + $(PYTHON_CMD) -m inkscape $< $@ + # Rule to compile an OpenSCAD file to a DXF file. $(SCAD_DXF_FILES): %.dxf: %.scad $(GLOBAL_DEPS) | $(SCAD_ORDER_DEPS) $(PYTHON_CMD) -m openscad $< $@ $*.d @@ -70,6 +82,10 @@ $(SCAD_DXF_FILES): %.dxf: %.scad $(GLOBAL_DEPS) | $(SCAD_ORDER_DEPS) $(SCAD_STL_FILES): %.stl: %.scad $(GLOBAL_DEPS) | $(SCAD_ORDER_DEPS) $(PYTHON_CMD) -m openscad $< $@ $*.d +# Rule to export an SVG file to an Asymptote file. +$(ASY_PDF_FILES): %.pdf: %.asy $(GLOBAL_DEPS) $(COMPILED_SRC_FILES) $(SVG_ASY_FILES) + ASYMPTOTE_DIR=$$(dirname $@) $(ASYMPTOTE) -f pdf -o $@ $< + # Rule for automaticaly generated OpenSCAD files. $(GENERATED_FILES): generate_sources.sh $(GLOBAL_DEPS) ./generate_sources.sh $@ |