chiark / gitweb /
fixes from live bessar
[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 makesubmakefile
44 set -e; d=.submakefile.new; rm -f $$d; for f in "$$@";do echo "$$f" >>$$d; done
45 --
46 $(foreach prog, $(PROGRAMS), $(call define_prog,$(prog)))
47 $(foreach da, idlocs% config %+morse %+pindata blank%,
48    $(call define_directasm,$(da)))
49 endef
50
51 .submakefile:   $(CEBPIC)manypics.make Makefile
52                 : $(shell $(makesubmakefile)) ... generate .submakefile
53                 @mv -f $@.new $@
54
55 ifneq ($(MAKECMDGOALS),clean)
56 include .submakefile
57 endif
58
59 blank0.asm blank2.asm blank4.asm blank6.asm: blank%.asm: $(CEBPIC)manypics.make
60                 echo >$@.new " org 0x$*000"
61                 echo >>$@.new " nop"
62                 echo >>$@.new " end"
63                 mv -f $@.new $@
64
65 #---------- targets ----------
66
67 all: $(TARGETS)
68
69 noncode%.hex:   $(HEXMERGER) idlocs%.hex config.hex
70                 $(MERGEHEX)
71
72 morse+auto.inc: $(CEBPIC)morse-generator morse.messages
73                 ./$^ inc $o
74
75 %+vars.inc:     %.asm $(CEBPIC)manypics.make
76                 perl -ne '                                      \
77                         BEGIN { print "; autogenerated - do not edit\n"; } \
78                         next unless m/^\w+\s+equ\s+/;           \
79                         print $$_ or die $$!;                   \
80                 ' <$< $o
81
82 %+vars.fin:     %.asm $(CEBPIC)manypics.make
83                 perl -ne '                                              \
84                         BEGIN { print "; autogenerated - do not edit\n"; } \
85                         next unless m/^(\w+)\s/;                        \
86                         next if m/^\w+\s+(?:equ|udata|udata_acs)\s+/;   \
87                         print "  extern $$1\n" or die $$!;              \
88                 ' <$< $o
89
90 %+morse.asm:    $(CEBPIC)morse-generator morse.messages %+program.map
91                 ./$^ asm -I$(MORSE_INCLUDE) $o
92
93 %.map:          %.hex
94                 @:
95
96 idlocs%.asm:    $(CEBPIC)make-idlocs ../layout/ours.wiring
97                 ./$^ $* >$@.new && mv -f $@.new $@
98
99 ours+pindata.asm: ../layout/ours+pindata.asm
100                 cp $< $@
101
102 manypic-clean:  pic-clean
103                 rm -f idlocs*.asm *+morse.* morse+auto.inc blank[0246].*
104
105 .PRECIOUS:      idlocs%.asm morse+auto.inc %+morse.asm %+morse.hex %.map
106 .PRECIOUS:      %+vars.inc %+vars.fin