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