Fixed up s51 autodetect
[fw/sdcc] / support / regression / ports / mcs51 / spec.mk
index 8485e3ecde76c631e90f83479b42fb8c0c976ae4..d2d05045c133dc05dad58d5ea307f3e0dec28438 100644 (file)
@@ -1,17 +1,22 @@
 # Port specification for the mcs51 port running with uCsim
+#
+# model small
 
-S51 = ../../sim/ucsim/s51.src/s51
+# path to uCsim
+S51A = $(SDCC_DIR)/sim/ucsim/s51.src/s51
+S51B = $(SDCC_DIR)/bin/s51
 
-SDCCFLAGS += --lesspedantic -DREENTRANT=reentrant --stack-after-data
+S51 = $(shell if [ -f $(S51A) ]; then echo $(S51A); else echo $(S51B); fi)
+
+SDCCFLAGS +=--lesspedantic -DREENTRANT=reentrant --stack-after-data
 
 OBJEXT = .rel
 EXEEXT = .ihx
 
-# Needs parts of gbdk-lib, namely the internal mul/div/mod functions.
-EXTRAS = fwk/lib/testfwk$(OBJEXT) ports/$(PORT)/support$(OBJEXT)
+EXTRAS = fwk/lib/testfwk$(OBJEXT) $(PORTS_DIR)/$(PORT)/support$(OBJEXT)
 
 # Rule to link into .ihx
-%.ihx: %$(OBJEXT) $(EXTRAS)
+%$(EXEEXT): %$(OBJEXT) $(EXTRAS)
        $(SDCC) $(SDCCFLAGS) $(EXTRAS) $<
        mv fwk/lib/testfwk.ihx $@
        mv fwk/lib/testfwk.map $(@:.ihx=.map)
@@ -19,8 +24,16 @@ EXTRAS = fwk/lib/testfwk$(OBJEXT) ports/$(PORT)/support$(OBJEXT)
 %$(OBJEXT): %.c
        $(SDCC) $(SDCCFLAGS) -c $<
 
-# PENDING: Path to sdcc-extra
-%.out: %$(EXEEXT)
+# run simulator with 10 seconds timeout
+%.out: %$(EXEEXT) fwk/lib/timeout
        mkdir -p `dirname $@`
-       $(S51) -t32 -S in=$(shell tty),out=$@ $< < ports/mcs51/uCsim.cmd >/dev/null 2>&1
+       -fwk/lib/timeout 10 $(S51) -t32 -S in=/dev/null,out=$@ $< < $(PORTS_DIR)/mcs51/uCsim.cmd >/dev/null \
+         || echo -e --- FAIL: \"timeout, simulation killed\" in $(<:.ihx=.c)"\n"--- Summary: 1/1/1: timeout >> $@
        -grep -n FAIL $@ /dev/null || true
+
+fwk/lib/timeout: fwk/lib/timeout.c
+
+_clean:
+       rm -f fwk/lib/timeout fwk/lib/timeout.exe $(PORTS_DIR)/$(PORT)/*.rel $(PORTS_DIR)/$(PORT)/*.rst \
+             $(PORTS_DIR)/$(PORT)/*.lst $(PORTS_DIR)/$(PORT)/*.sym $(PORTS_DIR)/$(PORT)/*.asm temp.lnk
+