chiark / gitweb /
working on data2safety
[trains.git] / layout / Makefile
1 #include ../cprogs.make
2
3 M4INCS=         parts.i4
4
5 E_TRACK=        ArsCLMNo
6 LAYOUTOPTS_ALL= -ep=*Cm
7 LAYOUTOPTS=     -E=*$(E_TRACK) $(LAYOUTOPTS_ALL)
8 LAYOUTOPTS_PHYS= -S1.0 $(LAYOUTOPTS) '-e*A'
9 XLAYOUTOPTS_LAYER= -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l'
10
11 LAYOUTOPTS_SEGS= '-e*=*rm'
12
13 LAYERS_LS=      0 10 20
14 LAYERS_PS=      $(addsuffix .ps, $(LAYERS_LS))
15 LAYERS_L=       $(addprefix ours-l, $(LAYERS_PS))
16 LAYERS_E=       $(addprefix ours-e, $(LAYERS_PS))
17 LAYERS=         $(LAYERS_L) $(LAYERS_E)
18
19 LPAGES=  $(foreach x, 0 1 2 3 4 5 6, $(foreach y, 1 2 3 4 5, ours-p0-$xx$y.ps))
20
21 CPROGS=         subseg2display compose-segenco
22
23 default:        $(CPROGS) for-test-ui
24 all:            default lpages layers extras
25 for-test-ui:    ours.graph.c ours.redactgraph ours.raw.neato.ps \
26                 ours.redacted.neato.ps ours.safety.c \
27                 ours.dgram-bot.segcmap subseg2display ui-plan-bot.ppm
28
29 layers:         $(LAYERS)
30 lpages:         $(LPAGES)
31 extras:         dualjn-a.ps parts.ps
32
33 include ours.dgram.m
34 include segencolayers.m
35
36 o=>$@.new && mv -f $@.new $@
37
38 CFLAGS=         -Wall -Wwrite-strings -Wpointer-arith \
39                 -Wstrict-prototypes -Wmissing-prototypes \
40                 -Wmissing-declarations -Werror $(OPTIMISE)
41 OPTIMISE=       -O2 -g
42 CPPFLAGS=       -D_GNU_SOURCE
43 LINK=           $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS)
44 NETPBM=         -lnetpbm
45 # -lppm
46
47 REDACT=         consistency movfeatsplitedges   \
48                 consistency movfeatrmstubs      \
49                 consistency movfeatsplitnodes   \
50                 consistency trivpairnodes       \
51                 consistency trivnullnodes
52
53 subseg2display: subseg2display.o
54                 $(LINK) $(NETPBM) -lpub -lm
55
56 compose-segenco: compose-segenco.o
57                 $(LINK) $(NETPBM)
58
59 %.neato.ps:     %.neato
60                 neato -Tps <$< $o
61
62 %.raw.neato:    %.redactgraph
63                 ./$< consistency printforneato $o
64
65 %.redacted.neato: %.redactgraph
66                 ./$< $(REDACT) consistency printforneato $o
67
68 %.redacted.forsafety: %.redactgraph
69                 ./$< $(REDACT) consistency printforforsafety $o
70
71 %.safety.c:     data2safety %.wiring %.redacted.forsafety
72                 ./$^ $o
73
74 %.redactgraph:  %.graph.o redactgraph.o
75                 $(LINK)
76
77 %.d4:           %.m4 $(M4INCS) Makefile
78                 m4 -s <$< $o
79
80 %-a.ps:         %.d4 layout
81                 ./layout <$< $(LAYOUTOPTS) '-E*l' $o
82
83 %-al.ps:        %.d4 layout
84                 ./layout <$< $(LAYOUTOPTS) '-e*C' '-ep=rm' $o
85
86 %-ap.ps:        %.d4 layout
87                 ./layout -S1.0 <$< $(LAYOUTOPTS) '-e*A' '-ep=rm' $o
88
89 %.segcmapreq:   %.run-layout
90                 ./$< $(LAYOUTOPTS_SEGS) -GR $o
91
92 %.segcmap:      %.segcmapreq segcmapassign segcmap.h
93                 ./segcmapassign <$< $o
94
95 %.dgram.m:      %.dgram-list make-dgram-make
96                 ./make-dgram-make <$< $* $o
97
98 %.m:            %.gen-make
99                 ./$< $o
100
101 %.segenco.ppm:  %.segenco.ps Makefile
102                 gs -dNOPAUSE -dBATCH -dSAFER -q \
103                         -sDEVICE=ppmraw -r72 -g595x842 \
104                         -sOutputFile=$@.new $< && mv -f $@.new $@
105
106 ours.graph.c:   extractgraph ours.dgram-bot.p0.segenco.ps
107                 ./$^ $o
108 # Strictly, this is wrong as it only uses layer 0.  When we have more
109 # layers, should put them all in same segenco specially for extractgraph
110
111 ours-l%.ps:     ours.d4 layout
112                 ./layout <$< -l$* $(LAYOUTOPTS) $(XLAYOUTOPTS_LAYER) $o
113
114 ours-e%.ps:     ours.d4 layout
115                 ./layout <$< -l$* -E'=*aRsclMno' \
116                         -e'p=*rm' -e'=5RN' -E'*~=5rsm' -e'p~=5r' -e'*=*l' $o
117
118 ours-p%.ps:     ours.d4 layout
119                 ./layout <$< -l$$(printf %s "$*" | sed -e 's/-/ -P/') \
120                         $(LAYOUTOPTS_PHYS) $(XLAYOUTOPTS_LAYER) $o
121
122 parts.ps:       showlib.d4 layout
123                 ./layout <$< $(LAYOUTOPTS_ALL) $o
124
125 # test case
126 t.ppm:          ours.dgram-bot.pa.segenco.ppm x.gdb subseg2display
127                 gdb -x x.gdb
128
129 ui-plan-%.ppm:  ours.dgram-%.pa.segenco.ppm Makefile
130                 pnmcrop <$< >$@.1.new
131                 pnmflip <$@.1.new -ccw >$@.2.new
132                 pnmpad <$@.2.new -white -l5 -r5 -t5 -b5 $o
133
134 subseg2display.o compose-segenco.o: segcmap.h
135
136 clean:
137                 -rm -f -- *.d4 *~ t.* *.m *.new core
138                 -rm -f ours-*.ps parts.ps
139                 -rm -f *.oprint-*.ps *.run-layout
140                 -rm -f *.segcmap *.segcmapreq
141                 -rm -f *.dgram-*.p*.segenco.ps *.dgram-*.p*.segenco.ppm
142                 -rm -f $(CPROGS) *.o
143
144 .PRECIOUS:      $(OPRINTS)
145 .PRECIOUS:      %.segcmap %.segcmapreq %.segenco.ppm %.d4 %.neato
146 .PRECIOUS:      %.redactgraph %.redacted.forsafety