chiark / gitweb /
do stuff with panel3
[trains.git] / pic.make
1
2 M4INCS=         parts.i4
3
4 E_TRACK=        ArsCLMNo
5 LAYOUTOPTS_ALL= -ep=*Cm
6 LAYOUTOPTS=     -E=*$(E_TRACK) $(LAYOUTOPTS_ALL)
7 LAYOUTOPTS_PHYS= -S1.0 $(LAYOUTOPTS) '-e*A'
8 XLAYOUTOPTS_LAYER= -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l'
9
10 LAYERS_LS=      0 10 20
11 LAYERS_PS=      $(addsuffix .ps, $(LAYERS_LS))
12 LAYERS_L=       $(addprefix ours-l, $(LAYERS_PS))
13 LAYERS_E=       $(addprefix ours-e, $(LAYERS_PS))
14 LAYERS=         $(LAYERS_L) $(LAYERS_E)
15
16 LPAGES=  $(foreach x, 0 1 2 3 4 5 6, $(foreach y, 1 2 3 4 5, ours-p0-$xx$y.ps))
17
18 default:        netlists picprogs
19 layers:         $(LAYERS)
20 lpages:         $(LPAGES)
21
22 all:            default layers bulkres.bom divider-tables \
23                 picprogs netlists panel3.pcb
24
25 o=>$@.new && mv -f $@.new $@
26
27 CIRCUITPARTS=   control.partlist circuit.partlist
28 BULKRESPARTS=   bulkres-select.partlist bulkres-items.partlist
29
30 picprogs:       flasher.hex flash-all.hex
31
32 netlists:       reversers.net detectors.net \
33                 reversers.hole-rep detectors.hole-rep \
34                 both.hole-rep panel3.hole-rep
35
36 # print from pcb(1) as follows:
37 #   File / Print Layout / ...
38 #      select media and offsets: A4
39 #      rotate
40 #      ok
41 #    (If `... exists, use anyway?', Sequence OK)
42 #
43 # then
44 #   make {reversers,detectors}.oprints{-l,-lpr}
45 #   for f in *.oprint-*.ps; do gv -scale -1 -media A4 $f; done
46 #   etc.
47
48 OPRINTS=        %.oprint-copper.ps              \
49                 %.pcb.output_fab.ps             \
50                 %.pcb.output_frontsilk.ps       \
51                 %.oprint-assembly.ps
52
53 %.hole-rep:     %.pcb hole-report.pl
54                 ./hole-report.pl <$< $o
55
56 include reversers.layers.dep
57 include detectors.layers.dep
58 include panel3.layers.dep
59
60 %.zip:          layers.txt.tmpl Makefile
61                 rm -rf $@.d; mkdir -p $@.d
62                 set -e; exec <$<; cd $@.d; perl -pe '                   \
63                         m/^(\S+)\s+(\w+)\s+(\w+)\s+(\S.*)$$/ or die;    \
64                         system "cp ../$*.pcb.output_$$1.$$3 $$2.$$3";   \
65                         die $$? if $$?;                                 \
66                         $$_= sprintf "%-20s %s\n", $$2.$$3, $$4;        \
67                 ' >readme.txt;                                          \
68                 zip -l ../$@.new *
69                 mv -f $@.new $@
70                 unzip -v $@
71
72 PANEL3_PCBS=    reversers.pcb detectors.pcb detectors.pcb
73
74 panel3.pcb:     pcb-panelise $(PANEL3_PCBS) Makefile
75                 ./$< -g100 $(PANEL3_PCBS) $o
76
77 $*.zip: $*.pcb.output_$$1.$$2/ or die' \
78
79 %.layers.dep:   layers.txt.tmpl Makefile
80                 perl -pe \
81         's/^(\S+)\s+\w+\s+(\w+)\s.*/$*.zip: $*.pcb.output_$$1.$$2/ or die' \
82                         <$< $o
83
84 both.hole-rep:  hole-report.pl reversers.pcb detectors.pcb
85                 ./$^ $o
86
87 %.oprints:      $(OPRINTS)
88                         echo $^ >$@-l-tmp
89
90 %.oprints-l:    $(OPRINTS) %.oprints Makefile
91                         cp $@-tmp $@
92
93 pcboprints:     reversers.oprints-l detectors.oprints-l
94
95 %.oprints-lpr:  %.oprints-l
96                 set -ex; for f in `cat $^`; do lpr $$f; done
97
98 %.distilled.ps: %.ps
99                 ps2ps $< $@
100
101 %.oprint-copper.ps:     %.pcb.output_back.distilled.ps \
102                         %.pcb.output_front.distilled.ps
103                 cat $^ >$@.tmp
104                 ps2ps $@.tmp $@-2.tmp
105                 pstops '2:0(-50mm,0mm)+1(50mm,0mm)' <$@-2.tmp $o
106
107 %.oprint-copper.ps:     Makefile
108
109 %.oprint-assembly.ps:   %.pcb.output_assembly.ps Makefile
110                 pstops -pa4 '0@2(-109mm,-290mm)' <$< $o
111
112 %.net:          %.net-info
113                 sed -e '/^\#/d' <$< $o
114
115 %.net-info:     %.net-spec netlist-expand
116                 ./netlist-expand $< $o
117
118 %.net-spec:     generate-netspec.pl
119                 ./$< $@ $o
120
121 %.hex:          %.asm
122                 gpasm -p 18f458 $<
123
124 circuit.bom:    farnell-find $(CIRCUITPARTS)
125                 ./farnell-find bom $(CIRCUITPARTS) $o
126
127 bulkres.bom:    farnell-find $(BULKRESPARTS)
128                 ./farnell-find bom $(BULKRESPARTS) $o
129
130 bulkres-select.partlist:        bulkres-select-gen.pl
131                 ./$^ $o
132
133 bulkres-items.suggest:
134                 cat bulkres-searchout*[0-9] | ./farnell-resistor-convert.pl $o
135
136 bulkres-items.descs:    bulkres-items.suggest
137                 xargs ./farnell-find describe <$< $o
138
139 bulkres-items.partlist:
140                 ./farnell-resistor-convert.pl <bulkres-items.descs MRS25 std $o
141
142 divider-table.txt:      divider-table.pl
143                 ./$< $o
144
145 divider-tables:         divider-table.ps divider-table.txt
146
147 divider-table.ps:       divider-table.txt Makefile
148                 a2ps -o- -R -1 --borders no -B -L"$$(wc -l <$<)" -l158 \
149                  --center-title='E24 resistor ratios and logarithms' <$< $o
150
151 %.d4:           %.m4 $(M4INCS) Makefile
152                 m4 -s <$< $o
153
154 %-a.ps:         %.d4 layout
155                 ./layout <$< $(LAYOUTOPTS) '-E*l' $o
156
157 %-al.ps:        %.d4 layout
158                 ./layout <$< $(LAYOUTOPTS) '-e*C' '-ep=rm' $o
159
160 %-ap.ps:        %.d4 layout
161                 ./layout -S1.0 <$< $(LAYOUTOPTS) '-e*A' '-ep=rm' $o
162
163 ours-l%.ps:     ours.d4 layout
164                 ./layout <$< -l$* $(LAYOUTOPTS) $(XLAYOUTOPTS_LAYER) $o
165
166 ours-e%.ps:     ours.d4 layout
167                 ./layout <$< -l$* -E'=*aRsclMno' \
168                         -e'p=*rm' -e'=5RN' -E'*~=5rsm' -e'p~=5r' -e'*=*l' $o
169
170 ours-p%.ps:     ours.d4 layout
171                 ./layout <$< -l$$(printf %s "$*" | sed -e 's/-/ -P/') \
172                         $(LAYOUTOPTS_PHYS) $(XLAYOUTOPTS_LAYER) $o
173
174 parts.ps:       showlib.d4 layout
175                 ./layout <$< $(LAYOUTOPTS_ALL) $o
176
177 clean:
178                 -rm -f -- *.d4 farn.* *~ *.new
179                 -rm -f bulkres-*.partlist bulkres-items.suggest *.bom
180                 -rm -f t,*.gnuplot-data t,*.gnuplot-cmd t,gnuplot-fifo
181                 -rm -f t,gnuplots.sh reversers.net reversers.net-info
182                 -rm -f flasher.hex flasher.cod flasher.lst
183                 -rm -f ours-*.ps parts.ps
184                 -rm -f *.oprint-*.ps
185
186 .PRECIOUS:      %.net-info %.net-spec
187 .PRECIOUS:      $(OPRINTS)