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