6df802ca70f785d101daf2f7a7303fc5930aa3f3
[fw/sdcc] / support / regression / ports / mcs51 / spec.mk
1 # Port specification for the mcs51 port running with uCsim
2 #
3 # model small
4
5 # path to uCsim
6 S51A = $(SDCC_DIR)/sim/ucsim/s51.src/s51
7 S51B = $(SDCC_DIR)/bin/s51
8
9 S51 = $(shell if [ -f $(S51A) ]; then echo $(S51A); else echo $(S51B); fi)
10
11 SDCCFLAGS +=--nostdinc --less-pedantic -DREENTRANT=reentrant -I$(INC_DIR)/mcs51
12 LINKFLAGS = --nostdlib
13 LINKFLAGS += mcs51.lib libsdcc.lib liblong.lib libint.lib libfloat.lib
14 LIBDIR = $(SDCC_DIR)/device/lib/build/small
15
16 OBJEXT = .rel
17 EXEEXT = .ihx
18
19 EXTRAS = $(PORTS_DIR)/$(PORT)/testfwk$(OBJEXT) $(PORTS_DIR)/$(PORT)/support$(OBJEXT)
20 FWKLIB = $(PORTS_DIR)/$(PORT)/T2_isr$(OBJEXT)
21
22 # Rule to link into .ihx
23 %$(EXEEXT): %$(OBJEXT) $(EXTRAS) $(FWKLIB) $(PORTS_DIR)/$(PORT)/fwk.lib
24         $(SDCC) $(SDCCFLAGS) $(LINKFLAGS) -L $(LIBDIR) $(EXTRAS) $(PORTS_DIR)/$(PORT)/fwk.lib $< -o $@
25
26 %$(OBJEXT): %.c
27         $(SDCC) $(SDCCFLAGS) -c $< -o $@
28
29 $(PORTS_DIR)/$(PORT)/testfwk$(OBJEXT): fwk/lib/testfwk.c
30         $(SDCC) $(SDCCFLAGS) -c $< -o $@
31
32 $(PORTS_DIR)/$(PORT)/fwk.lib:
33         cp $(PORTS_DIR)/mcs51/fwk.lib $(PORTS_DIR)/$(PORT)/fwk.lib
34
35 # run simulator with 30 seconds timeout
36 %.out: %$(EXEEXT) fwk/lib/timeout
37         mkdir -p `dirname $@`
38         -fwk/lib/timeout 30 $(S51) -t32 -S in=/dev/null,out=$@ $< < $(PORTS_DIR)/mcs51/uCsim.cmd > $(@:.out=.sim) \
39           || echo -e --- FAIL: \"timeout, simulation killed\" in $(<:$(EXEEXT)=.c)"\n"--- Summary: 1/1/1: timeout >> $@
40         python get_ticks.py < $(@:.out=.sim) >> $@
41         -grep -n FAIL $@ /dev/null || true
42
43 fwk/lib/timeout: fwk/lib/timeout.c
44
45
46 _clean:
47         rm -f fwk/lib/timeout fwk/lib/timeout.exe $(PORTS_DIR)/$(PORT)/*.rel $(PORTS_DIR)/$(PORT)/*.rst \
48               $(PORTS_DIR)/$(PORT)/*.lst $(PORTS_DIR)/$(PORT)/*.sym $(PORTS_DIR)/$(PORT)/*.asm \
49               $(PORTS_DIR)/$(PORT)/*.lnk $(PORTS_DIR)/$(PORT)/*.map $(PORTS_DIR)/$(PORT)/*.mem