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