Skip to content
Snippets Groups Projects
Verified Commit 3a5a7b33 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Support for native relibc compilation of tests

parent d6d01e56
No related branches found
No related tags found
No related merge requests found
SYSROOT?=../sysroot
# Binaries that should generate the same output every time # Binaries that should generate the same output every time
EXPECT_NAMES=\ EXPECT_NAMES=\
alloca \ alloca \
...@@ -130,14 +128,14 @@ all: $(BINS) ...@@ -130,14 +128,14 @@ all: $(BINS)
clean: clean:
rm -rf bins gen *.out rm -rf bins gen *.out
run: | $(SYSROOT) $(BINS) run: | $(BINS)
for name in $(NAMES); \ for name in $(NAMES); \
do \ do \
echo "# $${name} #"; \ echo "# $${name} #"; \
"bins/$${name}" test args || exit $$?; \ "bins/$${name}" test args || exit $$?; \
done done
expected: | $(SYSROOT) $(EXPECT_BINS) expected: | $(EXPECT_BINS)
rm -rf expected rm -rf expected
mkdir -p expected mkdir -p expected
for name in $(EXPECT_NAMES); \ for name in $(EXPECT_NAMES); \
...@@ -147,7 +145,7 @@ expected: | $(SYSROOT) $(EXPECT_BINS) ...@@ -147,7 +145,7 @@ expected: | $(SYSROOT) $(EXPECT_BINS)
"bins/$${name}" test args > "expected/$${name}.stdout" 2> "expected/$${name}.stderr" || exit $$?; \ "bins/$${name}" test args > "expected/$${name}.stdout" 2> "expected/$${name}.stderr" || exit $$?; \
done done
verify: | $(SYSROOT) $(EXPECT_BINS) verify: | $(EXPECT_BINS)
rm -rf gen rm -rf gen
mkdir -p gen mkdir -p gen
for name in $(EXPECT_NAMES); \ for name in $(EXPECT_NAMES); \
...@@ -167,22 +165,31 @@ CFLAGS=\ ...@@ -167,22 +165,31 @@ CFLAGS=\
-Wall \ -Wall \
-pedantic \ -pedantic \
-g \ -g \
-nostdinc \
-nostdlib \
-isystem $(SYSROOT)/include \
-I . -I .
HEADLIBS=\ LIBS=
$(SYSROOT)/lib/crt0.o \
$(SYSROOT)/lib/crti.o
TAILLIBS=\ NATIVE_RELIBC?=0
$(SYSROOT)/lib/libc.a \ ifeq ($(NATIVE_RELIBC),0)
$(SYSROOT)/lib/crtn.o CFLAGS+=\
-nostdinc \
-nostdlib \
-isystem ../sysroot/include \
../sysroot/lib/crt0.o \
../sysroot/lib/crti.o
LIBS=\
../sysroot/lib/libc.a \
../sysroot/lib/crtn.o
../sysroot: ../sysroot:
$(MAKE) -C .. sysroot $(MAKE) -C .. sysroot
bins/%: %.c $(SYSROOT) bins/%: %.c ../sysroot
mkdir -p "$$(dirname "$@")"
$(CC) $(CFLAGS) "$<" $(LIBS) -o "$@"
else
bins/%: %.c
mkdir -p "$$(dirname "$@")" mkdir -p "$$(dirname "$@")"
$(CC) $(CFLAGS) $(HEADLIBS) "$<" $(TAILLIBS) -o "$@" $(CC) $(CFLAGS) "$<" $(LIBS) -o "$@"
endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment