chiark / gitweb /
commitid.scad.pl: Provide _M mirrored versions of everything (nfc for existing uses)
[reprap-play.git] / Makefile
1 # reprap-objects Makefile
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 HRR=/home/reprap
21 SLIC3R=$(HRR)/Slic3r/bin/slic3r
22 SKEINFORGE=python $(HRR)/reprappro-software.git/skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py
23
24 CWD := $(shell pwd)
25 PLAY ?= $(CWD)
26
27 CONFIG=$(PLAY)/slic3r-config.ini
28
29 USING_AUTOS ?= filamentspool xeno-drivebay-bracket dungeonquest-cone anke-gps-bracket cable-hole-trunking-cover anglepoise-neck crossbar-computer-led-mount wardrobe-hook knifeblock pandemic-counter pattress-boxes-3-cover
30 AUTO_TOPLEVELS := $(foreach m,$(USING_AUTOS),$(shell $(PLAY)/toplevel-find $m))
31
32 AUTO_INCS = funcs.scad
33
34 default:        autoincs scads
35
36 $(shell set -xe; ./commitid.scad.pl >commitid.scad.tmp; cmp commitid.scad.tmp commitid.scad || mv -f commitid.scad.tmp commitid.scad )
37
38 autoincs:       $(AUTO_INCS)
39 scads:          $(addsuffix .auto.scad, $(AUTO_TOPLEVELS))
40 stls:           $(addsuffix .auto.stl, $(AUTO_TOPLEVELS))
41
42 %.auto.scads:
43         $(MAKE) $(addsuffix .auto.scad, $(shell $(PLAY)/toplevel-find $*))
44 %.auto.stls:
45         $(MAKE) $(addsuffix .auto.stl, $(shell $(PLAY)/toplevel-find $*))
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 %.gcode:        %.stl $(CONFIG)
59                 $(SLIC3R) --load $(CONFIG) \
60                         --ignore-nonexistent-config \
61                         --load $(call AUTOBASE,$*).slic3r \
62                         --load $*.slic3r \
63                         --output $@.tmp $<
64                 @mv -f $@.tmp $@
65
66 %.gcode-sd:     %.gcode
67                 mount /media/sd
68                 cp $^ /media/sd/JOB.G
69                 sleep 0.5
70                 umount /media/sd
71
72 %:              %.cpp
73                 cpp -nostdinc -P <$< >$@.tmp && mv -f $@.tmp $@
74
75 funcs.scad:
76
77 #%.gcode:       %.stl
78 #               $(SKEINFORGE) $<
79
80 %.gcode:        manual-gcode-generator %.m-g
81                 $(PLAY)/$^ >$@.tmp && mv -f $@.tmp $@
82
83 dovecliptest.stl: doveclip.scad $(AUTO_INCS)
84
85 KNIFEBLOCK_KNIVES= 0 1 2
86 KNIFEBLOCK_TEMPLATES= bl hl
87 KNIFEBLOCK_TEMPLATE_FILES=\
88         $(foreach k,$(KNIFEBLOCK_KNIVES), \
89         $(foreach t,$(KNIFEBLOCK_TEMPLATES), \
90         knifeblock-knives-t$k$t.dxf))
91
92 knifeblock-knives-templates knifeblock.stl: $(KNIFEBLOCK_TEMPLATE_FILES)
93
94 .PRECIOUS: knifeblock-knives-t%.dxf
95 knifeblock-knives-t%.dxf: knifeblock-knives-filter knifeblock-knives-trace.fig
96                 ./$< $(notdir $*) <$(filter %.fig, $^) >$@.tmp.fig
97                 fig2dev -D -30 -L eps <$@.tmp.fig >$@.tmp.eps
98                 pstoedit -dt -f "dxf: -polyaslines -mm" $@.tmp.eps $@
99
100 PANDEMICCOUNTER_LETTERS=30 31 32 33 34 35
101 PANDEMICCOUNTER_DXFS=$(foreach l,$(PANDEMICCOUNTER_LETTERS), \
102         pandemic-counter-l$l.dxf)
103
104 pandemic-counter-letters: $(PANDEMICCOUNTER_DXFS)
105 pandemic-counter%.stl: $(PANDEMICCOUNTER_DXFS)
106
107 .PRECIOUS: pandemic-counter-l%.eps
108 pandemic-counter-l%.eps: pandemic-counter-letters.fig
109                 fig2dev -D +$(notdir $*) -L eps <$< >$@.tmp
110                 @mv -f $@.tmp $@
111
112 PANDEMICQUARANTINES_NUMBERS=1 2
113 PANDEMICQUARANTINES_DXFS=$(foreach l,$(PANDEMICQUARANTINES_NUMBERS), \
114         pandemic-quarantine-l$l.dxf)
115
116 pandemic-quarantine-numbers: $(PANDEMICQUARANTINES_DXFS)
117 pandemic-quarantine%.stl: $(PANDEMICQUARANTINES_DXFS)
118
119 .PRECIOUS: pandemic-quarantine-l%.eps
120 pandemic-quarantine-l%.eps: pandemic-quarantine-numbers.fig
121                 fig2dev -D +$(notdir $*) -L eps <$< >$@.tmp
122                 @mv -f $@.tmp $@
123
124 SCREWRECESSTEST_SIZES= 2 3 4 5 6
125 SCREWRECESSTEST_DXFS=$(foreach s,$(SCREWRECESSTEST_SIZES), \
126         screw-recess-test-number-s$s.dxf)
127
128 screw-recess-test-number-s%.fig: screw-recess-test-number.fig.pl
129         ./$< $* >$@.tmp && mv -f $@.tmp $@
130
131 screw-recess-test-number-s%.eps: screw-recess-test-number-s%.fig
132                 fig2dev -L eps <$< >$@.tmp
133                 @mv -f $@.tmp $@
134
135 screw-recess-test-numbers screw-recess-test.stl: $(SCREWRECESSTEST_DXFS)
136
137 question-question.eps: question-question.fig
138                 fig2dev -L eps <$< >$@.tmp
139                 @mv -f $@.tmp $@
140
141 question-token.stl: question-question.dxf
142
143 lemon-stand.stl: lemon-stand.scad
144
145 .PRECIOUS: $(SCREWRECESSTEST_DXFS) $(SCREWRECESSTEST_DXFS) \
146         $(foreach s,$(SCREWRECESSTEST_SIZES), \
147                 screw-recess-test-number-s$s.fig \
148                 screw-recess-test-number-s$s.eps)
149
150 %.dxf:          %.eps
151                 pstoedit -dt -f "dxf: -polyaslines -mm" $< $@
152
153 %:              %.pl
154                 ./$< >$@.tmp && mv -f $@.tmp $@
155
156 .PRECIOUS: %.auto.scad
157 %.auto.scad: $(PLAY)/toplevel-make Makefile $(PLAY)/toplevel-find
158                 @echo ' write $@'
159                 $< $@ >$@.tmp
160                 @mv -f $@.tmp $@
161
162 .PRECIOUS:      %.stl %.gcode %.eps %.dxf
163
164 clean:
165                 rm -f *~ *.stl *.auto.scad *.gcode .*.d $(AUTO_INCS)