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