chiark / gitweb /
do not include out-of-layer platforms, or layerkind s
[trains.git] / layout / Makefile
1 include ../cprogs.make
2 include ../common.make
3
4 M4INCS=         parts.i4
5
6 E_TRACK=        ArsCLMNo
7 LAYOUTOPTS_ALL= -ep=*Cm
8 LAYOUTOPTS=     -E=*$(E_TRACK) $(LAYOUTOPTS_ALL)
9 LAYOUTOPTS_PHYS= -S1.0 $(LAYOUTOPTS) '-e*A'
10 LAYOUTOPTS_PS=  -e'[sp]=*rm' -e'p=5C'
11 XLAYOUTOPTS_LAYER= -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l' \
12                 $(LAYOUTOPTS_PS)
13
14 LAYOUTOPTS_SEGS= '-e*=*rm'
15
16 LAYERS_LS=      0 4 10 26 30
17 LAYERS_PS=      $(addsuffix .ps, $(LAYERS_LS))
18 LAYERS_L=       $(addprefix ours-l, $(LAYERS_PS))
19 LAYERS_E=       $(addprefix ours-e, $(LAYERS_PS))
20 LAYERS_M=       $(addprefix ours-m, $(LAYERS_PS))
21 LAYERS=         $(LAYERS_L) $(LAYERS_E) $(LAYERS_M)
22
23 LPAGES=  $(foreach x, 0 1 2 3 4 5 6, $(foreach y, 1 2 3 4 5, ours-p4-$xx$y.ps))
24
25 CPROGS=         subseg2display compose-segenco
26
27 default:        $(CPROGS) for-test-ui layers extras
28 all:            default lpages
29 for-pic:        ours+pindata.asm
30 recurse:        $(CPROGS) for-pic for-test-ui
31 for-test-ui:    ours.graph.c ours.redactgraph ours.raw.neato.ps \
32                 ours.redacted.neato.ps ours.layout-data.o \
33                 ours.dgram-bot.segcmap ours.dgram-bot.plandata.c \
34                 ours.dgram-bot.plandata.o
35
36 layers:         $(LAYERS)
37 lpages:         $(LPAGES)
38 extras:         ours-a.ps ours-al.ps dualjn-a.ps parts.ps
39
40 include ours.dgram.m
41 include segencolayers.m
42
43 NETPBM =        -lnetpbm
44 ifeq (,$(shell test -f /usr/lib/libppm.so || echo no))
45 NETPBM +=       -lppm
46 endif
47
48 REDACT=         consistency movfeatsplitedges   \
49                 consistency movfeatrmstubs      \
50                 consistency movfeatsplitnodes   \
51                 consistency trivpairnodes       \
52                 consistency trivnullnodes
53
54 subseg2display: subseg2display.o
55                 $(LINK) $(NETPBM) -lpub -lm
56
57 compose-segenco: compose-segenco.o
58                 $(LINK) $(NETPBM)
59
60 %.neato.ps:     %.neato
61                 neato -Tps <$< $o
62
63 %.raw.neato:    %.redactgraph
64                 ./$< consistency printforneato $o
65
66 %.redacted.neato: %.redactgraph
67                 ./$< $(REDACT) consistency printforneato $o
68
69 %.redacted.forsafety: %.redactgraph
70                 ./$< $(REDACT) consistency printforforsafety $o
71
72 %.layout-data.c: data2safety %.wiring %.redacted.forsafety \
73                         reversers.pin-info detectors.pin-info
74                 ./$(filter-out %.pin-info, $^) $o
75
76 %+pindata.asm:  %.layout-data.c
77                 @:
78
79 %.pin-info:     pin-info-gen ../pcb/%.net
80                 ./$< $* $o
81
82 %.redactgraph:  %.graph.o redactgraph.o
83                 $(LINK)
84
85 %.d4:           %.m4 $(M4INCS) Makefile
86                 m4 -s $< $o
87
88 %-a.ps:         %.d4 layout
89                 ./layout <$< $(LAYOUTOPTS) '-E*lD' $o
90
91 %-al.ps:        %.d4 layout
92                 ./layout <$< $(LAYOUTOPTS) '-e*C' '-ep=rm' $o
93
94 %-ap.ps:        %.d4 layout
95                 ./layout -S1.0 <$< $(LAYOUTOPTS) '-e*A' '-ep=rm' $o
96
97 %.segcmapreq:   %.run-layout
98                 ./$< $(LAYOUTOPTS_SEGS) -GR $o
99
100 %.segcmap:      %.segcmapreq segcmapassign segcmap.h
101                 ./segcmapassign <$< $o
102
103 %.dgram.m:      %.dgram-list make-dgram-make
104                 ./make-dgram-make <$< $* $o
105
106 %.m:            %.gen-make
107                 ./$< $o
108
109 %.segenco.ppm:  %.segenco.ps Makefile
110                 gs -dNOPAUSE -dBATCH -dSAFER -q \
111                         -sDEVICE=ppmraw -r72 -g595x842 \
112                         -sOutputFile=$@.new $< && mv -f $@.new $@
113
114 ours.graph.c:   extractgraph ours.dgram-bot.p0.segenco.ps
115                 ./$^ $o
116 # Strictly, this is wrong as it only uses layer 0.  When we have more
117 # layers, should put them all in same segenco specially for extractgraph
118
119 ours-l%.ps:     ours.d4 layout
120                 ./layout <$< -l$* $(LAYOUTOPTS) $(XLAYOUTOPTS_LAYER) $o
121
122 ours-m%.ps:     ours.d4 layout
123                 ./layout <$< -l$* -E'=*aRsclDmno' \
124                         -E'=5RNLDA' -E'*~=5rCdsml' $(LAYOUTOPTS_PS) $o
125
126 ours-e%.ps:     ours.d4 layout
127                 ./layout <$< -l$* -E'=*aRsclMno' \
128                         -e'=5RN' -E'*~=5rsm' -e'p~=5r' -e'*=*l' \
129                         -e'[sp]=*rm' $o
130
131 ours-p%.ps:     ours.d4 layout
132                 ./layout <$< -l$$(printf %s "$*" | sed -e 's/-/ -P/') \
133                         $(LAYOUTOPTS_PHYS) $(XLAYOUTOPTS_LAYER) $o
134
135 test-p%.ps:     test.d4 layout
136                 ./layout <$< -l$$(printf %s "$*" | sed -e 's/-/ -P/') \
137                         $(LAYOUTOPTS_PHYS) $(XLAYOUTOPTS_LAYER) $o
138
139 parts.ps:       showlib.d4 layout
140                 ./layout <$< $(LAYOUTOPTS_ALL) $o
141
142 # test case
143 t.ppm:          ours.dgram-bot.pa.segenco.ppm x.gdb subseg2display
144                 gdb -x x.gdb
145
146 ui-plan-%.ppm:  ours.dgram-%.pa.segenco.ppm Makefile
147                 pnmcrop <$< >$@.1.new
148                 pnmflip <$@.1.new -ccw >$@.2.new
149                 pnmpad <$@.2.new -white -l5 -r5 -t5 -b5 $o
150
151 subseg2display.o compose-segenco.o: segcmap.h
152
153 clean:
154                 -rm -f -- *.d4 *~ t.* *.m *.new core
155                 -rm -f ours.*.ps ours-*.ps parts.ps *.neato.ps ours.*.neato
156                 -rm -f dualjn-*.ps
157                 -rm -f *.pin-info *+pindata.asm
158                 -rm -f *.redacted.forsafety *.redacted.forneato
159                 -rm -f *.oprint-*.ps *.run-layout
160                 -rm -f *.segcmap *.segcmapreq
161                 -rm -f *.dgram-*.p*.segenco.ps *.dgram-*.p*.segenco.ppm
162                 -rm -f *.dgram-*.plandata.c ours.graph.c ours.layout-data.c
163                 -rm -f $(CPROGS) *.o *.d ours.redactgraph
164                 -rm -f tmp.* ui-plan-*.ppm
165
166 .PRECIOUS:      $(OPRINTS)
167 .PRECIOUS:      %.segcmap %.segcmapreq %.segenco.ppm %.d4 %.neato %.raw.neato
168 .PRECIOUS:      %.redactgraph %.redacted.forsafety %.redacted.neato
169 .PRECIOUS:      %.layout-data.c %.pin-info
170
171 include $(wildcard *.d)