aboutsummaryrefslogtreecommitdiffstats
path: root/test/Makefile
blob: f037cea64dd5a7449bfe6c0e857f0432bb38fdc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
CC ?= gcc
VERICERT ?= vericert
VERICERT_OPTS ?= -O0 -finline -fschedule -fif-conv -drtl -dgblseq -dgblpar
IVERILOG ?= iverilog
IVERILOG_OPTS ?=

TESTS := $(patsubst %.c,%.check,$(wildcard *.c))

all: $(TESTS)

%.gcc.out: %.gcc
	@./$< ; echo "$$?" >$@

%.o: %.c
	@$(CC) $(CFLAGS) -c -o $@ $<

%.gcc: %.o
	@$(CC) $(CFLAGS) -o $@ $<

%.sv: %.c
	$(VERICERT) $(VERICERT_OPTS) -o $@ $<

%.iver: %.sv
	@$(IVERILOG) $(IVERILOG_OPTS) -o $@ -- $<

%.veri.out: %.iver
	@./$< | tail -n1 | sed -r -e 's/[^0-9]*([0-9]+)/\1/' >$@

%.check: %.gcc.out %.veri.out
	@diff $^ >$@
	@printf "\033[0;36mOK\033[0m\t$(patsubst %.check,%,$@)\n"

clean:
	rm -f *.check *.gcc *.gcc.out *.o *.sv *.iver *.veri.out