summaryrefslogtreecommitdiff
path: root/libguile/lightening/tests/Makefile
blob: 2a048501db9e93515ed76ef56e435fc0a68ba07f (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
TESTS=$(sort $(basename $(wildcard *.c)))
TARGETS=native ia32 aarch64
ALL_TARGETS=$(TARGETS) armv7

# Suitable values of cross-compiler variables for Debian:
#
#   make test CC_IA32=i668-linux-gnu-gcc CC_AARCH64=aarch64-linux-gnu-gcc
#
# The relevant packages that you need to run this:
#
#   dpkg --add-architecture i386
#   dpkg --add-architecture arm64
#   apt-get update -qq
#   apt-get install -y \
#     libc6-dev:amd64 gcc make \
#     qemu binfmt-support qemu-user-static \
#     gcc-i686-linux-gnu libc6-dev-i386-cross libc6:i386 \
#     gcc-aarch64-linux-gnu libc6-dev-arm64-cross libc6:arm64
#
CC = gcc
CC_IA32=guix environment --pure -s i686-linux --ad-hoc gcc-toolchain glibc -- gcc
CC_AARCH64=guix environment --pure -s aarch64-linux --ad-hoc gcc-toolchain glibc -- gcc
CC_ARMv7=guix environment --pure -s armhf-linux --ad-hoc gcc-toolchain glibc -- gcc
CFLAGS = -Wall -O0 -g

all: $(foreach TARGET,$(TARGETS),$(addprefix test-$(TARGET)-,$(TESTS)))

check: $(addprefix test-$(TARGET),$(TARGETS))

test-%: $(addprefix test-%-,$(TESTS))
	@echo "Running unit tests..."
	@set -e; for test in $?; do \
	  echo "Testing: $$test"; \
	  ./$$test; \
	done
	@echo "Success."

.PHONY: test check

lightening-%.o: ../lightening.h ../lightening/*.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ -c ../lightening/lightening.c

test-native-%: %.c lightening-native.o test.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ lightening-native.o $<

test-ia32-%: CC = $(CC_IA32)
test-ia32-%: %.c lightening-ia32.o test.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ lightening-ia32.o $<

test-aarch64-%: CC = $(CC_AARCH64)
test-aarch64-%: %.c lightening-aarch64.o test.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ lightening-aarch64.o $<

test-armv7-%: CC = $(CC_ARMv7)
test-armv7-%: %.c lightening-armv7.o test.h
	$(CC) $(CFLAGS) $(CPPFLAGS) -I.. -o $@ lightening-armv7.o $<

.PRECIOUS: $(foreach TARGET,$(ALL_TARGETS),$(addprefix test-$(TARGET)-,$(TESTS)))
.PRECIOUS: $(foreach TARGET,$(ALL_TARGETS),lightening-$(TARGET).o)

clean:
	rm -f $(foreach TARGET,$(ALL_TARGETS),$(addprefix test-$(TARGET)-,$(TESTS)))
	rm -f $(foreach TARGET,$(ALL_TARGETS),lightening-$(TARGET).o)