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