chiark / gitweb /
air-hockey-puck: wip
[reprap-play.git] / reprap-objects.make
1 # reprap-objects Makefile, reuseable parts
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 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; $(PLAY)/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: %.scad
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                 rm -f /media/sd/JOB.* /media/sd/job.*
69                 cp $^ /media/sd/JOB.G
70                 sleep 0.5
71                 umount /media/sd
72
73 %:              %.cpp
74                 cpp -nostdinc -P <$< >$@.tmp && mv -f $@.tmp $@
75
76 funcs.scad:
77
78 #%.gcode:       %.stl
79 #               $(SKEINFORGE) $<
80
81 %.gcode:        manual-gcode-generator %.m-g
82                 $(PLAY)/$^ >$@.tmp && mv -f $@.tmp $@
83
84 %.dxf:          %.eps
85                 pstoedit -dt -f "dxf: -polyaslines -mm" $< $@
86
87 %:              %.pl
88                 ./$< >$@.tmp && mv -f $@.tmp $@
89
90 %:              %.m4
91                 $(M4) -P >$@.tmp $< && mv -f $@.tmp $@
92
93 .PRECIOUS: %.auto.scad
94 %.auto.scad: $(PLAY)/toplevel-make Makefile $(PLAY)/toplevel-find
95                 @echo ' write $@'
96                 $< $@ >$@.tmp
97                 @mv -f $@.tmp $@
98
99 .PRECIOUS:      %.stl %.gcode %.eps %.dxf
100
101 clean:
102                 rm -f *~ *.stl *.auto.scad *.gcode .*.d $(AUTO_INCS)
103