chiark / gitweb /
m% does not include loc labels and bars
[trains.git] / layout / Makefile
index f63091b7788801c52bb2c90cbe6e723274d7b5b6..38149353601110a9e4bfa5e099f5dc83f95d624e 100644 (file)
@@ -1,3 +1,5 @@
+include ../cprogs.make
+include ../common.make
 
 M4INCS=                parts.i4
 
@@ -7,29 +9,82 @@ LAYOUTOPTS=   -E=*$(E_TRACK) $(LAYOUTOPTS_ALL)
 LAYOUTOPTS_PHYS= -S1.0 $(LAYOUTOPTS) '-e*A'
 XLAYOUTOPTS_LAYER= -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l'
 
-LAYOUTOPTS_SEGS= '-e*=*r' '-e=5G'
+LAYOUTOPTS_SEGS= '-e*=*rm'
 
 LAYERS_LS=     0 10 20
 LAYERS_PS=     $(addsuffix .ps, $(LAYERS_LS))
 LAYERS_L=      $(addprefix ours-l, $(LAYERS_PS))
 LAYERS_E=      $(addprefix ours-e, $(LAYERS_PS))
-LAYERS=                $(LAYERS_L) $(LAYERS_E)
+LAYERS_M=      $(addprefix ours-m, $(LAYERS_PS))
+LAYERS=                $(LAYERS_L) $(LAYERS_E) $(LAYERS_M)
 
 LPAGES=         $(foreach x, 0 1 2 3 4 5 6, $(foreach y, 1 2 3 4 5, ours-p0-$xx$y.ps))
 
-default:       layers
+CPROGS=                subseg2display compose-segenco
+
+default:       $(CPROGS) for-test-ui layers extras
 all:           default lpages
+for-pic:       ours+pindata.asm
+recurse:       $(CPROGS) for-pic for-test-ui
+for-test-ui:   ours.graph.c ours.redactgraph ours.raw.neato.ps \
+               ours.redacted.neato.ps ours.layout-data.o \
+               ours.dgram-bot.segcmap ours.dgram-bot.plandata.c \
+               ours.dgram-bot.plandata.o
 
 layers:                $(LAYERS)
 lpages:                $(LPAGES)
+extras:                ours-a.ps ours-al.ps dualjn-a.ps parts.ps
+
+include ours.dgram.m
+include segencolayers.m
+
+NETPBM =       -lnetpbm
+ifeq (,$(shell test -f /usr/lib/libppm.so || echo no))
+NETPBM +=      -lppm
+endif
+
+REDACT=                consistency movfeatsplitedges   \
+               consistency movfeatrmstubs      \
+               consistency movfeatsplitnodes   \
+               consistency trivpairnodes       \
+               consistency trivnullnodes
+
+subseg2display:        subseg2display.o
+               $(LINK) $(NETPBM) -lpub -lm
+
+compose-segenco: compose-segenco.o
+               $(LINK) $(NETPBM)
+
+%.neato.ps:    %.neato
+               neato -Tps <$< $o
+
+%.raw.neato:   %.redactgraph
+               ./$< consistency printforneato $o
+
+%.redacted.neato: %.redactgraph
+               ./$< $(REDACT) consistency printforneato $o
+
+%.redacted.forsafety: %.redactgraph
+               ./$< $(REDACT) consistency printforforsafety $o
+
+%.layout-data.c: data2safety %.wiring %.redacted.forsafety \
+                       reversers.pin-info detectors.pin-info
+               ./$(filter-out %.pin-info, $^) $o
 
-o=>$@.new && mv -f $@.new $@
+%+pindata.asm: %.layout-data.c
+               @:
+
+%.pin-info:    pin-info-gen ../pcb/%.net
+               ./$< $* $o
+
+%.redactgraph: %.graph.o redactgraph.o
+               $(LINK)
 
 %.d4:          %.m4 $(M4INCS) Makefile
-               m4 -s <$< $o
+               m4 -s $< $o
 
 %-a.ps:                %.d4 layout
-               ./layout <$< $(LAYOUTOPTS) '-E*l' $o
+               ./layout <$< $(LAYOUTOPTS) '-E*lD' $o
 
 %-al.ps:       %.d4 layout
                ./layout <$< $(LAYOUTOPTS) '-e*C' '-ep=rm' $o
@@ -37,18 +92,35 @@ o=>$@.new && mv -f $@.new $@
 %-ap.ps:       %.d4 layout
                ./layout -S1.0 <$< $(LAYOUTOPTS) '-e*A' '-ep=rm' $o
 
-ours-g%.ps:    ours.d4 ours-g%.segcmap layout
-               ./layout <$< -l$* $(LAYOUTOPTS_SEGS) -GLours-g$*.segcmap $o
+%.segcmapreq:  %.run-layout
+               ./$< $(LAYOUTOPTS_SEGS) -GR $o
 
-ours-g%.segcmap: ours-g%.segcmapreq segcmapassign
+%.segcmap:     %.segcmapreq segcmapassign segcmap.h
                ./segcmapassign <$< $o
 
-ours-g%.segcmapreq: ours.d4 layout
-               ./layout <$< -l$* $(LAYOUTOPTS_SEGS) -GR $o
+%.dgram.m:     %.dgram-list make-dgram-make
+               ./make-dgram-make <$< $* $o
+
+%.m:           %.gen-make
+               ./$< $o
+
+%.segenco.ppm: %.segenco.ps Makefile
+               gs -dNOPAUSE -dBATCH -dSAFER -q \
+                       -sDEVICE=ppmraw -r72 -g595x842 \
+                       -sOutputFile=$@.new $< && mv -f $@.new $@
+
+ours.graph.c:  extractgraph ours.dgram-bot.p0.segenco.ps
+               ./$^ $o
+# Strictly, this is wrong as it only uses layer 0.  When we have more
+# layers, should put them all in same segenco specially for extractgraph
 
 ours-l%.ps:    ours.d4 layout
                ./layout <$< -l$* $(LAYOUTOPTS) $(XLAYOUTOPTS_LAYER) $o
 
+ours-m%.ps:    ours.d4 layout
+               ./layout <$< -l$* -E'=*aRsclDmno' \
+                       -e'p=*rm' -E'=5RNlDA' -E'*~=5rCdsml' $o
+
 ours-e%.ps:    ours.d4 layout
                ./layout <$< -l$* -E'=*aRsclMno' \
                        -e'p=*rm' -e'=5RN' -E'*~=5rsm' -e'p~=5r' -e'*=*l' $o
@@ -60,9 +132,33 @@ ours-p%.ps: ours.d4 layout
 parts.ps:      showlib.d4 layout
                ./layout <$< $(LAYOUTOPTS_ALL) $o
 
+# test case
+t.ppm:         ours.dgram-bot.pa.segenco.ppm x.gdb subseg2display
+               gdb -x x.gdb
+
+ui-plan-%.ppm: ours.dgram-%.pa.segenco.ppm Makefile
+               pnmcrop <$< >$@.1.new
+               pnmflip <$@.1.new -ccw >$@.2.new
+               pnmpad <$@.2.new -white -l5 -r5 -t5 -b5 $o
+
+subseg2display.o compose-segenco.o: segcmap.h
+
 clean:
-               -rm -f -- *.d4 *~ *.new
-               -rm -f ours-*.ps parts.ps
-               -rm -f *.oprint-*.ps
+               -rm -f -- *.d4 *~ t.* *.m *.new core
+               -rm -f ours.*.ps ours-*.ps parts.ps *.neato.ps ours.*.neato
+               -rm -f dualjn-*.ps
+               -rm -f *.pin-info *+pindata.asm
+               -rm -f *.redacted.forsafety *.redacted.forneato
+               -rm -f *.oprint-*.ps *.run-layout
+               -rm -f *.segcmap *.segcmapreq
+               -rm -f *.dgram-*.p*.segenco.ps *.dgram-*.p*.segenco.ppm
+               -rm -f *.dgram-*.plandata.c ours.graph.c ours.layout-data.c
+               -rm -f $(CPROGS) *.o *.d ours.redactgraph
+               -rm -f tmp.* ui-plan-*.ppm
 
 .PRECIOUS:     $(OPRINTS)
+.PRECIOUS:     %.segcmap %.segcmapreq %.segenco.ppm %.d4 %.neato %.raw.neato
+.PRECIOUS:     %.redactgraph %.redacted.forsafety %.redacted.neato
+.PRECIOUS:     %.layout-data.c %.pin-info
+
+include $(wildcard *.d)