chiark / gitweb /
Add a build system.
[scad] / Makefile
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..2e4f2f1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,53 @@
+### -*-makefile-gmake-*-
+###
+### Build OpenSCAD models
+###
+### (c) 2022 Mark Wooding
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This program is free software: you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation; either version 3 of the License, or (at
+### your option) any later version.
+###
+### This program is distributed in the hope that it will be useful, but
+### WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+### General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+all:
+
+## `Silent-rules' machinery.
+V                       = 0
+V_AT                    = $(V_AT).$V
+V_AT.0                  = @
+v-tag                   = $(call v-tag.$V,$1)
+v-tag.0                         = @printf "  %-8s %s\n" "$1" "$@";
+
+## Other configuration.
+OPENSCAD                = openscad
+
+## Main list of models.
+MODELS                 += discpick-collar.scad
+
+## Building models.
+CLEANFILES             += *.stl
+%.stl: %.scad
+       $(call v-tag,SCAD)$(OPENSCAD) -o$@ -d$*.dep $<
+STLS                    = $(MODELS:.scad=.stl)
+all: $(STLS)
+
+## Dependency file management.
+CLEANFILES             += *.dep
+DEPS                   += $(MODELS:.scad=.dep)
+-include $(DEPS)
+
+## Cleaning up.
+clean:; rm -f $(CLEANFILES)
+
+###----- That's all, folks --------------------------------------------------