chiark / gitweb /
realtime: print all movpos positions on entering Run
[trains.git] / cebpic / manypics.make
1
2 default: all
3
4 #---------- general definitions etc. ----------
5
6 TARGETS += $(foreach i, $(PICNOS), idlocs$i.hex noncode$i.hex)
7 MORSE_INCLUDE ?= common.inc
8 INCLUDES += ../iwjpictest/insn-aliases.inc morse+auto.inc
9
10 INCLUDES += $(addsuffix +vars.fin, $(VARSFILES))
11 INCLUDES += $(addsuffix +vars.inc, $(VARSFILES))
12
13 include ../common.make
14 include ../pic.make
15
16 #---------- bizarre macro arrangements for $(PROGRAMS) ----------
17
18 define define_prog
19
20 TARGETS += $(1)+code.hex $(1)+program.hex $(1)+program.map $(1)+program.disasm
21 TARGETS += $$(foreach i, $$(PICNOS), $(1)+entire$$i.hex)
22
23 $(1)_CODEHEX= $$(foreach panel, $$(XCODEN_$(1)), $(1)+$$(panel).hex) \
24                 $$(foreach panel, $$(XCODE1_$(1)), $$(panel).hex)
25
26 $(1)+code.hex:  $$(HEXMERGER) $(1)+program.hex $$($(1)_CODEHEX)
27                 $$(MERGEHEX)
28
29 $(1)+entire%.hex: $$(HEXMERGER) $(1)+program.hex $$($(1)_CODEHEX) idlocs%.hex config.hex
30                 $$(MERGEHEX)
31
32 $(1)+program.hex: $(1).o $$(OBJS_$(prog)) $$(LIBS)
33                 $$(LINK)
34
35 endef
36
37 define define_directasm
38
39 $(1).hex:       $(1).asm $$(INCLUDES)
40                 $$(ASSEMBLE) $$<
41 endef
42
43 define submakefiletext
44 $(foreach prog, $(PROGRAMS), $(call define_prog,$(prog)))
45 $(foreach da, idlocs% config %+morse %+pindata blank%,
46    $(call define_directasm,$(da)))
47 endef
48 export submakefiletext
49
50 $(eval $(submakefiletext))
51
52 blank0.asm blank2.asm blank4.asm blank6.asm: blank%.asm: $(CEBPIC)manypics.make
53                 echo >$@.new " org 0x$*000"
54                 echo >>$@.new " nop"
55                 echo >>$@.new " end"
56                 mv -f $@.new $@
57
58 #---------- targets ----------
59
60 all: $(TARGETS)
61
62 noncode%.hex:   $(HEXMERGER) idlocs%.hex config.hex
63                 $(MERGEHEX)
64
65 morse+auto.inc: $(CEBPIC)morse-generator morse.messages
66                 ./$^ inc $o
67
68 %+vars.inc:     %.asm $(CEBPIC)manypics.make
69                 perl -n                                         \
70                 -e '    BEGIN { print "; autogenerated - do not edit\n"; } '\
71                 -e '    next unless m/^\w+\s+equ\s+/;           '\
72                 -e '    print $$_ or die $$!;                   '\
73                 <$< $o
74
75 %+vars.fin:     %.asm $(CEBPIC)manypics.make
76                 perl -n                                                 \
77                 -e '    BEGIN { print "; autogenerated - do not edit\n"; } '\
78                 -e '    next unless m/^(\w+)\s/;                        '\
79                 -e '    next if m/^\w+\s+(?:equ|udata|udata_acs)\s+/;   '\
80                 -e '    print "  extern $$1\n" or die $$!;              '\
81                  <$< $o
82
83 %+morse.asm:    $(CEBPIC)morse-generator morse.messages %+program.map
84                 ./$^ asm -I$(MORSE_INCLUDE) $o
85
86 %.map:          %.hex
87                 @:
88
89 idlocs%.asm:    $(CEBPIC)make-idlocs ../layout/ours.wiring
90                 ./$^ $* >$@.new && mv -f $@.new $@
91
92 ours+pindata.asm: ../layout/ours+pindata.asm
93                 cp $< $@
94
95 manypic-clean:  pic-clean
96                 rm -f idlocs*.asm *+morse.* morse+auto.inc blank[0246].*
97
98 .PRECIOUS:      idlocs%.asm morse+auto.inc %+morse.asm %+morse.hex %.map
99 .PRECIOUS:      %+vars.inc %+vars.fin