chiark / gitweb /
sleepphone-cable-box: introduce wall_bot, nfc
[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 M4=m4
23 SKEINFORGE=python $(HRR)/reprappro-software.git/skeinforge/skeinforge_application/skeinforge_utilities/skeinforge_craft.py
24
25 CWD := $(shell pwd)
26 PLAY ?= $(CWD)
27
28 CONFIG=$(PLAY)/slic3r-config.ini
29
30 FILAMENTSPOOL_AUTOS = filamentspool filamentspool-lt filamentspool-sm
31 FILAMENTSPOOL_AUTOS += filamentspool-storarm3
32
33 USING_AUTOS ?= $(FILAMENTSPOOL_AUTOS) 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 bike-lipo-box earring-stand bike-stalk-led-mount sewing-table sewing-table-test sewing-table-jig maglite-holder poster-tube-lid fairphone-case
34
35 AUTO_TOPLEVELS := $(foreach m,$(USING_AUTOS),$(shell $(PLAY)/toplevel-find $m))
36
37 AUTO_INCS += funcs.scad sealing-box.scad sewing-table.scad \
38              poster-tube-lid-parametric.scad
39
40 default:        autoincs scads
41
42 $(shell set -xe; $(PLAY)/commitid.scad.pl >commitid.scad.tmp; cmp commitid.scad.tmp commitid.scad || mv -f commitid.scad.tmp commitid.scad )
43
44 autoincs:       $(AUTO_INCS)
45 scads:          $(addsuffix .auto.scad, $(AUTO_TOPLEVELS))
46 stls:           $(addsuffix .auto.stl, $(AUTO_TOPLEVELS))
47
48 %.auto.scads: %.scad
49         $(MAKE) $(addsuffix .auto.scad, $(shell $(PLAY)/toplevel-find $*))
50 %.auto.stls:
51         $(MAKE) $(addsuffix .auto.stl, $(shell $(PLAY)/toplevel-find $*))
52
53 -include .*.d
54
55 %.stl:          %.scad $(AUTO_INCS)
56                 openscad -d .$@.d.tmp -o $*.tmp.stl $<
57                 @rm -f $@
58                 @sed -e 's/\.tmp\.stl:/.stl:/' <.$@.d.tmp >.$@.d
59                 @rm .$@.d.tmp
60                 mv -f $*.tmp.stl $@
61
62 AUTOBASE=$(shell echo $(1) | perl -pe 's/,\w+\.auto$$//')
63
64 %.gcode:        %.stl $(CONFIG)
65                 $(SLIC3R) --load $(CONFIG) \
66                         --ignore-nonexistent-config \
67                         --load $(call AUTOBASE,$*).slic3r \
68                         --load $*.slic3r \
69                         --output $@.tmp $<
70                 @mv -f $@.tmp $@
71
72 %.gcode-sd:     %.gcode
73                 mount /media/sd
74                 rm -f /media/sd/JOB.* /media/sd/job.*
75                 cp $^ /media/sd/JOB.G
76                 sleep 0.5
77                 umount /media/sd
78
79 %:              %.cpp
80                 cpp -nostdinc -P <$< >$@.tmp && mv -f $@.tmp $@
81
82 funcs.scad:
83
84 #%.gcode:       %.stl
85 #               $(SKEINFORGE) $<
86
87 %.gcode:        manual-gcode-generator %.m-g
88                 $(PLAY)/$^ >$@.tmp && mv -f $@.tmp $@
89
90 dovecliptest.stl: doveclip.scad $(AUTO_INCS)
91
92 KNIFEBLOCK_KNIVES= 0 1 2
93 KNIFEBLOCK_TEMPLATES= bl hl
94 KNIFEBLOCK_TEMPLATE_FILES=\
95         $(foreach k,$(KNIFEBLOCK_KNIVES), \
96         $(foreach t,$(KNIFEBLOCK_TEMPLATES), \
97         knifeblock-knives-t$k$t.dxf))
98
99 knifeblock-knives-templates knifeblock.stl: $(KNIFEBLOCK_TEMPLATE_FILES)
100
101 .PRECIOUS: knifeblock-knives-t%.dxf
102 knifeblock-knives-t%.dxf: knifeblock-knives-filter knifeblock-knives-trace.fig
103                 ./$< $(notdir $*) <$(filter %.fig, $^) >$@.tmp.fig
104                 fig2dev -D -30 -L eps <$@.tmp.fig >$@.tmp.eps
105                 pstoedit -dt -f "dxf: -polyaslines -mm" $@.tmp.eps $@
106
107 PANDEMICCOUNTER_LETTERS=30 31 32 33 34 35
108 PANDEMICCOUNTER_DXFS=$(foreach l,$(PANDEMICCOUNTER_LETTERS), \
109         pandemic-counter-l$l.dxf)
110
111 pandemic-counter-letters: $(PANDEMICCOUNTER_DXFS)
112 pandemic-counter%.stl: $(PANDEMICCOUNTER_DXFS)
113
114 .PRECIOUS: pandemic-counter-l%.eps
115 pandemic-counter-l%.eps: pandemic-counter-letters.fig
116                 fig2dev -D +$(notdir $*) -L eps <$< >$@.tmp
117                 @mv -f $@.tmp $@
118
119 .PRECIOUS: maglite-holder-torch-curve.eps
120 maglite-holder-torch-curve.eps: maglite-holder-torch.fig
121                 fig2dev -D +1:70 -L eps <$< >$@.tmp
122                 @mv -f $@.tmp $@
123
124 maglite-holder-torch-curve.dxf: maglite-holder-torch-curve.eps
125                 pstoedit -dt -flat 0.05 -f "dxf: -polyaslines -mm" $< $@
126
127
128 PANDEMICQUARANTINES_NUMBERS=1 2
129 PANDEMICQUARANTINES_DXFS=$(foreach l,$(PANDEMICQUARANTINES_NUMBERS), \
130         pandemic-quarantine-l$l.dxf)
131
132 pandemic-quarantine-numbers: $(PANDEMICQUARANTINES_DXFS)
133 pandemic-quarantine%.stl: $(PANDEMICQUARANTINES_DXFS)
134
135 .PRECIOUS: pandemic-quarantine-l%.eps
136 pandemic-quarantine-l%.eps: pandemic-quarantine-numbers.fig
137                 fig2dev -D +$(notdir $*) -L eps <$< >$@.tmp
138                 @mv -f $@.tmp $@
139
140 FILAMENTSPOOL_NUMBERS=$(shell seq 300 100 1500)
141 filamentspool-number-n%.eps:    filamentspool-number.eps.pl
142         ./$< $* >$@.tmp && mv -f $@.tmp $@
143
144 FILAMENTSPOOL_DXFS=$(foreach n,$(FILAMENTSPOOL_NUMBERS), \
145         filamentspool-number-n$n.dxf)
146
147 $(addsuffix .auto.stl, $(foreach f,$(FILAMENTSPOOL_AUTOS),$(shell \
148         $(PLAY)/toplevel-find $(PLAY)/$f))): $(FILAMENTSPOOL_DXFS)
149
150 filamentspool-numbers filamentspool.stl: $(FILAMENTSPOOL_DXFS)
151
152 SCREWRECESSTEST_SIZES= 2 3 4 5 6
153 SCREWRECESSTEST_DXFS=$(foreach s,$(SCREWRECESSTEST_SIZES), \
154         screw-recess-test-number-s$s.dxf)
155
156 screw-recess-test-number-s%.fig: screw-recess-test-number.fig.pl
157         ./$< $* >$@.tmp && mv -f $@.tmp $@
158
159 screw-recess-test-number-s%.eps: screw-recess-test-number-s%.fig
160                 fig2dev -L eps <$< >$@.tmp
161                 @mv -f $@.tmp $@
162
163 screw-recess-test-numbers screw-recess-test.stl: $(SCREWRECESSTEST_DXFS)
164
165 question-question.eps: question-question.fig
166                 fig2dev -L eps <$< >$@.tmp
167                 @mv -f $@.tmp $@
168
169 sewing-table%.stl: sewing-table-rear-profile.dxf
170 sewing-table%.stl: sewing-table-front-profile.dxf
171 sewing-table%.stl: sewing-table-end-profile.dxf
172
173 sewing-table-%-profile.eps: sewing-table-%-profile.fig
174                 fig2dev -L eps -D +40 <$< >$@.tmp
175                 @mv -f $@.tmp $@
176
177 question-token.stl: question-question.dxf
178
179 lemon-stand.stl: lemon-stand.scad
180
181 electron-token.stl: electron-token.scad
182
183 .PRECIOUS: $(SCREWRECESSTEST_DXFS) $(SCREWRECESSTEST_DXFS) \
184         $(foreach s,$(SCREWRECESSTEST_SIZES), \
185                 screw-recess-test-number-s$s.fig \
186                 screw-recess-test-number-s$s.eps)
187
188 %.dxf:          %.eps
189                 pstoedit -dt -f "dxf: -polyaslines -mm" $< $@
190
191 %:              %.pl
192                 ./$< >$@.tmp && mv -f $@.tmp $@
193
194 %:              %.m4
195                 $(M4) -P >$@.tmp $< && mv -f $@.tmp $@
196
197 .PRECIOUS: %.auto.scad
198 %.auto.scad: $(PLAY)/toplevel-make Makefile $(PLAY)/toplevel-find
199                 @echo ' write $@'
200                 $< $@ >$@.tmp
201                 @mv -f $@.tmp $@
202
203 .PRECIOUS:      %.stl %.gcode %.eps %.dxf
204
205 clean:
206                 rm -f *~ *.stl *.auto.scad *.gcode .*.d $(AUTO_INCS)