Debian Codegraph @

libguile/lightening/tests/Makefile

raw
1 TESTS ?= $(sort $(basename $(wildcard *.c)))
2 TARGETS ?= native ia32 aarch64 armv7 riscv
3
4 # Suitable values of cross-compiler variables for Debian:
5 #
6 # make test CC_IA32=i668-linux-gnu-gcc CC_AARCH64=aarch64-linux-gnu-gcc
7 #
8 # The relevant packages that you need to run this:
9 #
10 # dpkg --add-architecture i386
11 # dpkg --add-architecture arm64
12 # apt-get update -qq
13 # apt-get install -y \
14 # libc6-dev:amd64 gcc make \
15 # qemu binfmt-support qemu-user-static \
16 # gcc-i686-linux-gnu libc6-dev-i386-cross libc6:i386 \
17 # gcc-aarch64-linux-gnu libc6-dev-arm64-cross libc6:arm64\
18 # gcc-riscv64-linux-gnu libc6-dev-riscv64-cross libc6:riscv64
19 #
20 CC = gcc
21 CC_IA32 ?= guix environment --pure -s i686-linux --ad-hoc gcc-toolchain -- gcc
22 CC_AARCH64 ?= guix environment --pure -s aarch64-linux --ad-hoc gcc-toolchain -- gcc
23 CC_ARMv7 ?= guix environment --pure -s armhf-linux --ad-hoc gcc-toolchain -- gcc
24 CC_RISCV ?= guix environment --pure -s riscv64-linux --ad-hoc gcc-toolchain -- gcc
25 CFLAGS ?= -Wall -O0 -g
26
27 all: $(foreach TARGET,$(TARGETS),$(addprefix test-$(TARGET)-,$(TESTS)))
28
29 check: $(addprefix test-$(TARGET),$(TARGETS))
30
31 test-%: $(addprefix test-%-,$(TESTS))
32 @echo "Running unit tests..."
33 @set -e; for test in $?; do \
34 echo "Testing: $$test"; \
35 ./$$test; \
36 done
37 @echo "Success."
38
39 .PHONY: test check
40
41 lightening-%.o: ../lightening.h ../lightening/*.c
42 $(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ -c ../lightening/lightening.c
43
44 test-native-%: %.c lightening-native.o test.h
45 $(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ lightening-native.o $<
46
47 test-ia32-%: CC = $(CC_IA32)
48 test-ia32-%: %.c lightening-ia32.o test.h
49 $(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ lightening-ia32.o $<
50
51 test-aarch64-%: CC = $(CC_AARCH64)
52 test-aarch64-%: %.c lightening-aarch64.o test.h
53 $(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ lightening-aarch64.o $<
54
55 test-armv7-%: CC = $(CC_ARMv7)
56 test-armv7-%: %.c lightening-armv7.o test.h
57 $(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ lightening-armv7.o $<
58
59 test-riscv-%: CC = $(CC_RISCV)
60 test-riscv-%: %.c lightening-riscv.o test.h
61 $(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ lightening-riscv.o $<
62
63 .PRECIOUS: $(foreach TARGET,$(TARGETS),$(addprefix test-$(TARGET)-,$(TESTS)))
64 .PRECIOUS: $(foreach TARGET,$(TARGETS),lightening-$(TARGET).o)
65
66 clean:
67 rm -f $(foreach TARGET,$(TARGETS),$(addprefix test-$(TARGET)-,$(TESTS)))
68 rm -f $(foreach TARGET,$(TARGETS),lightening-$(TARGET).o)