chiark / gitweb /
segment labelling work-in-progress - yet to do are labels and graph colouring
[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)) ours-e20.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 else
47 ifeq (,$(shell test -f /usr/lib/libnetpbm.so || echo no))
48 NETPBM +=       -lnetpbm
49 endif
50 endif
51
52 REDACT=         consistency movfeatsplitedges   \
53                 consistency movfeatrmstubs      \
54                 consistency movfeatsplitnodes   \
55                 consistency trivpairnodes       \
56                 consistency trivnullnodes
57
58 subseg2display: subseg2display.o
59                 $(LINK) $(NETPBM) -lpub -lm
60
61 compose-segenco: compose-segenco.o
62                 $(LINK) $(NETPBM)
63
64 %.neato.ps:     %.neato
65                 neato -Tps <$< $o
66
67 %.raw.neato:    %.redactgraph
68                 ./$< consistency printforneato $o
69
70 %.redacted.neato: %.redactgraph
71                 ./$< $(REDACT) consistency printforneato $o
72
73 %.redacted.forsafety: %.redactgraph
74                 ./$< $(REDACT) consistency printforforsafety $o
75
76 %.redacted.segjoins: %.redactgraph
77                 ./$< $(REDACT) consistency printforlayoutsegjoins $o
78
79 %.layout-data.c: data2safety %.wiring %.redacted.forsafety \
80                         reversers.pin-info detectors.pin-info
81                 ./$(filter-out %.pin-info, $^) $o
82
83 %+pindata.asm:  %.layout-data.c
84                 @:
85
86 %.pin-info:     pin-info-gen ../pcb/%.net
87                 ./$< $* $o
88
89 %.redactgraph:  %.graph.o redactgraph.o
90                 $(LINK)
91
92 %.d4:           %.m4 $(M4INCS) Makefile
93                 m4 -s $< $o
94
95 %-a.ps:         %.d4 layout
96                 ./layout <$< $(LAYOUTOPTS) '-E*lD' $o
97
98 %-al.ps:        %.d4 layout
99                 ./layout <$< $(LAYOUTOPTS) '-e*C' '-ep=rm' $o
100
101 %-ap.ps:        %.d4 layout
102                 ./layout -S1.0 <$< $(LAYOUTOPTS) '-e*A' '-ep=rm' $o
103
104 %.segcmapreq:   %.run-layout
105                 ./$< $(LAYOUTOPTS_SEGS) -GR $o
106
107 %.segcmap:      %.segcmapreq segcmapassign segcmap.h
108                 ./segcmapassign <$< $o
109
110 %.dgram.m:      %.dgram-list make-dgram-make
111                 ./make-dgram-make <$< $* $o
112
113 %.m:            %.gen-make
114                 ./$< $o
115
116 %.segenco.ppm:  %.segenco.ps Makefile
117                 gs -dNOPAUSE -dBATCH -dSAFER -q \
118                         -sDEVICE=ppmraw -r72 -g595x842 \
119                         -sOutputFile=$@.new $< && mv -f $@.new $@
120
121 ours.graph.c:   extractgraph ours.dgram-bot.p0.segenco.ps
122                 ./$^ $o
123 # Strictly, this is wrong as it only uses layer 0.  When we have more
124 # layers, should put them all in same segenco specially for extractgraph
125
126 ours-l%.ps:     ours.d4 layout
127                 ./layout <$< -l$* $(LAYOUTOPTS) $(XLAYOUTOPTS_LAYER) $o
128
129 ours-s%.ps:     layout ours.redacted.segjoins ours.d4
130                 ./layout -l$* -e'*=*rldm' -E'=5Q' -e'segjoin=5M' \
131                         $(filter-out layout, $^) $o
132
133 ours-m%.ps:     ours.d4 layout
134                 ./layout <$< -l$* -E'=*aRsclDmno' \
135                         -E'=5RNLDA' -E'*~=5rCdsml' $(LAYOUTOPTS_PS) $o
136
137 ours-e%.ps:     ours.d4 layout
138                 ./layout <$< -l$* -E'=*aRsclMno' \
139                         -e'=5RN' -E'*~=5rsm' -e'p~=5r' -e'*=*l' \
140                         -e'[sp]=*rm' $o
141
142 ours-p%.ps:     ours.d4 layout
143                 ./layout <$< -l$$(printf %s "$*" | sed -e 's/-/ -P/') \
144                         $(LAYOUTOPTS_PHYS) $(XLAYOUTOPTS_LAYER) $o
145
146 test-p%.ps:     test.d4 layout
147                 ./layout <$< -l$$(printf %s "$*" | sed -e 's/-/ -P/') \
148                         $(LAYOUTOPTS_PHYS) $(XLAYOUTOPTS_LAYER) $o
149
150 parts.ps:       showlib.d4 layout
151                 ./layout <$< $(LAYOUTOPTS_ALL) $o
152
153 # test case
154 t.ppm:          ours.dgram-bot.pa.segenco.ppm x.gdb subseg2display
155                 gdb -x x.gdb
156
157 ui-plan-%.ppm:  ours.dgram-%.pa.segenco.ppm Makefile
158                 pnmcrop <$< >$@.1.new
159                 pnmflip <$@.1.new -ccw >$@.2.new
160                 pnmpad <$@.2.new -white -l5 -r5 -t5 -b5 $o
161
162 subseg2display.o compose-segenco.o: segcmap.h
163
164 clean:
165                 -rm -f -- *.d4 *~ t.* *.m *.new core *.d
166                 -rm -f ours.*.ps ours-*.ps parts.ps *.neato.ps ours.*.neato
167                 -rm -f dualjn-*.ps
168                 -rm -f *.pin-info *+pindata.asm
169                 -rm -f *.redacted.forsafety *.redacted.forneato
170                 -rm -f *.oprint-*.ps *.run-layout
171                 -rm -f *.segcmap *.segcmapreq
172                 -rm -f *.dgram-*.p*.segenco.ps *.dgram-*.p*.segenco.ppm
173                 -rm -f *.dgram-*.plandata.c ours.graph.c ours.layout-data.c
174                 -rm -f $(CPROGS) *.o *.d ours.redactgraph *.segjoins
175                 -rm -f tmp.* ui-plan-*.ppm
176
177 .PRECIOUS:      $(OPRINTS)
178 .PRECIOUS:      %.segcmap %.segcmapreq %.segenco.ppm %.d4 %.neato %.raw.neato
179 .PRECIOUS:      %.redactgraph %.redacted.forsafety %.redacted.neato
180 .PRECIOUS:      %.layout-data.c %.pin-info %.segjoins
181
182 include $(wildcard *.d)