chiark / gitweb /
undo broken deletion
[trains.git] / pcb / Makefile
1
2 default:        all
3 recurse:        all
4 for-pic:        netlists
5 all:            for-pic panel3.pcb
6
7 o=>$@.new && mv -f $@.new $@
8
9 netlists:       reversers.net detectors.net \
10                 reversers.hole-rep detectors.hole-rep \
11                 both.hole-rep panel3.hole-rep
12
13 # print from pcb(1) as follows:
14 #   File / Print Layout / ...
15 #      select media and offsets: A4
16 #      rotate
17 #      ok
18 #    (If `... exists, use anyway?', Sequence OK)
19 #
20 # then
21 #   make {reversers,detectors}.oprints{-l,-lpr}
22 #   for f in *.oprint-*.ps; do gv -scale -1 -media A4 $f; done
23 #   etc.
24
25 OPRINTS=        %.oprint-copper.ps              \
26                 %.pcb.output_fab.ps             \
27                 %.pcb.output_frontsilk.ps       \
28                 %.oprint-assembly.ps
29
30 %.hole-rep:     %.pcb hole-report.pl
31                 ./hole-report.pl <$< $o
32
33 include reversers.layers.dep
34 include detectors.layers.dep
35 include panel3.layers.dep
36
37 %.zip:          layers.txt.tmpl Makefile
38                 rm -rf $@.d; mkdir -p $@.d
39                 set -e; exec <$<; cd $@.d; perl -pe '                   \
40                         m/^(\S+)\s+(\w+)\s+(\w+)\s+(\S.*)$$/ or die;    \
41                         system "cp ../$*.pcb.output_$$1.$$3 $$2.$$3";   \
42                         die $$? if $$?;                                 \
43                         $$_= sprintf "%-20s %s\n", "$$2.$$3", $$4;      \
44                 ' >readme.txt;                                          \
45                 zip -l ../$@.new *
46                 mv -f $@.new $@
47                 unzip -v $@
48
49 PANEL3_PCBS=    reversers.pcb detectors.pcb detectors.pcb
50
51 panel3.pcb:     pcb-panelise $(PANEL3_PCBS) Makefile
52                 ./$< -g100 $(PANEL3_PCBS) $o
53
54 $*.zip: $*.pcb.output_$$1.$$2/ or die' \
55
56 %.out-ps.tar:
57                 GZIP=-9v tar zvcf $@.gz $*.pcb.output_*.ps
58
59 %.layers.dep:   layers.txt.tmpl Makefile
60                 perl -pe \
61         's/^(\S+)\s+\w+\s+(\w+)\s.*/$*.zip: $*.pcb.output_$$1.$$2/ or die' \
62                         <$< $o
63
64 both.hole-rep:  hole-report.pl reversers.pcb detectors.pcb
65                 ./$^ $o
66
67 %.oprints:      $(OPRINTS)
68                         echo $^ >$@-l-tmp
69
70 %.oprints-l:    $(OPRINTS) %.oprints Makefile
71                         cp $@-tmp $@
72
73 pcboprints:     reversers.oprints-l detectors.oprints-l
74
75 %.oprints-lpr:  %.oprints-l
76                 set -ex; for f in `cat $^`; do lpr $$f; done
77
78 %.distilled.ps: %.ps
79                 ps2ps $< $@
80
81 %.oprint-copper.ps:     %.pcb.output_back.distilled.ps \
82                         %.pcb.output_front.distilled.ps
83                 cat $^ >$@.tmp
84                 ps2ps $@.tmp $@-2.tmp
85                 pstops '2:0(-50mm,0mm)+1(50mm,0mm)' <$@-2.tmp $o
86
87 %.oprint-copper.ps:     Makefile
88
89 %.oprint-assembly.ps:   %.pcb.output_assembly.ps Makefile
90                 pstops -pa4 '0@2(-109mm,-290mm)' <$< $o
91
92 %.net:          %.net-info
93                 sed -e '/^\#/d' <$< $o
94
95 %.net-info:     %.net-spec netlist-expand
96                 ./netlist-expand $< $o
97
98 %.net-spec:     generate-netspec.pl
99                 ./$< $@ $o
100
101 clean:
102                 -rm -f -- *~ *.new
103                 -rm -f *.hole-rep *.net *.net-info *.net-spec
104                 -rm -f *.layers.dep panel3.pcb
105
106 .PRECIOUS:      %.net-info %.net-spec
107 .PRECIOUS:      $(OPRINTS)