chiark / gitweb /
air-hockey-puck: wip
[reprap-play.git] / diziet-utils / reprap-objects.make
1 # reprap-objects Makefile, reuseable parts
2 #
3 # Build scripts for various 3D designs
4 #
5 # Copyright 2012-2023 Ian Jackson
6 #
7 # This work is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This work is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this work.  If not, see <http://www.gnu.org/licenses/>.
19
20
21 M4=m4
22
23 CWD := $(shell pwd)
24 DUTILS ?= $(CWD)/diziet-utils
25 PLAY ?= $(CWD) # deprecated, for compatibility only
26
27 AUTO_TOPLEVELS := $(foreach m,$(USING_AUTOS),$(shell $(DUTILS)/toplevel-find $m))
28
29 AUTO_INCS += funcs.scad
30
31 default:        autoincs scads
32
33 $(shell set -xe; $(DUTILS)/commitid.scad.pl >commitid.scad.tmp; cmp commitid.scad.tmp commitid.scad || mv -f commitid.scad.tmp commitid.scad )
34
35 autoincs:       $(AUTO_INCS) $(AUTO_STLS_INCS)
36 scads:          $(addsuffix .auto.scad, $(AUTO_TOPLEVELS))
37 stls:           $(addsuffix .auto.stl, $(AUTO_TOPLEVELS))
38
39 %.auto.scads: %.scad
40         $(MAKE) $(addsuffix .auto.scad, $(shell $(DUTILS)/toplevel-find $*))
41 %.auto.stls:
42         $(MAKE) $(addsuffix .auto.stl, $(shell $(DUTILS)/toplevel-find $*))
43
44 i=mv -f $@.tmp $@
45 o= >$@.tmp && $i
46
47 -include .*.d
48
49 %.stl:          %.scad $(AUTO_INCS)
50                 openscad -d .$@.d.tmp -o $*.tmp.stl $<
51                 @rm -f $@
52                 @sed -e 's/\.tmp\.stl:/.stl:/' <.$@.d.tmp >.$@.d
53                 @rm .$@.d.tmp
54                 mv -f $*.tmp.stl $@
55
56 AUTOBASE=$(shell echo $(1) | perl -pe 's/,\w+\.auto$$//')
57
58 %:              %.cpp
59                 cpp -nostdinc -P <$< $o
60
61 funcs.scad:     diziet-utils/funcs.scad.cpp
62                 cpp -nostdinc -P $< $o
63
64 %.gcode:        manual-gcode-generator %.m-g
65                 $(CWD)/$^ $o
66
67 %.dxf:          %.eps
68                 pstoedit -dt -f "dxf: -polyaslines -mm" $< $@
69
70 %:              %.pl
71                 ./$< $o
72
73 %:              %.m4
74                 $(M4) -P >$@.tmp $< && $i
75
76 .PRECIOUS: %.auto.scad
77 %.auto.scad: $(DUTILS)/toplevel-make Makefile $(DUTILS)/toplevel-find
78                 @echo ' write $@'
79                 $< $@ >$@.tmp
80                 @$i
81
82 .PRECIOUS:      %.stl %.gcode %.eps %.dxf
83
84 clean:
85                 rm -f *~ *.stl *.auto.scad *.gcode .*.d $(AUTO_INCS)
86