diff --git a/Makefile b/Makefile index 7e0ba91763..fea8a8ca7f 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ CARGOFLAGS?=$(CARGO_COMMON_FLAGS) RUSTCFLAGS?= export OBJCOPY?=objcopy -BUILD="target/$(TARGET)" +BUILD?="$(shell pwd)/target/$(TARGET)" CARGOFLAGS+="--target=$(TARGET)" ifeq ($(TARGET),aarch64-unknown-linux-gnu) @@ -51,7 +51,7 @@ SRC=\ BUILTINS_VERSION=0.1.70 -.PHONY: all clean fmt install install-headers libs submodules test +.PHONY: all clean fmt install install-libs install-headers install-tests libs submodules test all: | libs @@ -96,6 +96,11 @@ install-libs: libs $(AR) -rcs "$(DESTDIR)/lib/libdl.a" $(AR) -rcs "$(DESTDIR)/lib/librt.a" +install-tests: tests + $(MAKE) -C tests + mkdir -p "$(DESTDIR)/bin/relibc-tests" + cp -vr tests/bins_static/* "$(DESTDIR)/bin/relibc-tests/" + install: install-headers install-libs submodules: @@ -113,6 +118,7 @@ sysroot: all test: sysroot # TODO: Fix SIGILL when running cargo test # $(CARGO_TEST) test + # TODO: $(MAKE) -C tests run? $(MAKE) -C tests verify # Debug targets diff --git a/tests/Makefile b/tests/Makefile index 4c08211820..1e6fae921d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -122,6 +122,8 @@ EXPECT_NAMES=\ # mkfifo # netdb/netdb \ +BUILD?=. + DYNAMIC_ONLY_NAMES=\ dlfcn @@ -148,15 +150,20 @@ NAMES=\ unistd/pathconf \ unistd/setid \ unistd/stat \ - unistd/sysconf + unistd/sysconf \ + pthread/main \ + pthread/cleanup \ + pthread/extjoin \ + pthread/once \ + pthread/customstack # resource/getrusage # time/times #TODO: dynamic tests currently broken -BINS=$(patsubst %,bins_static/%,$(NAMES)) +BINS=$(patsubst %,$(BUILD)/bins_static/%,$(NAMES)) #BINS+=$(patsubst %,bins_dynamic/%,$(NAMES)) #BINS+=$(patsubst %,bins_dynamic/%,$(DYNAMIC_ONLY_NAMES)) -EXPECT_BINS=$(patsubst %,bins_static/%,$(EXPECT_NAMES)) +EXPECT_BINS=$(patsubst %,$(BUILD)/bins_static/%,$(EXPECT_NAMES)) #EXPECT_BINS+=$(patsubst %,bins_dynamic/%,$(EXPECT_NAMES)) #EXPECT_BINS+=$(patsubst %,bins_dynamic/%,$(DYNAMIC_ONLY_NAMES)) @@ -239,18 +246,18 @@ DYNAMIC_FLAGS+=\ -Wl,-rpath=\$$ORIGIN endif -bins_static/%: %.c $(DEPS) +$(BUILD)/bins_static/%: %.c $(DEPS) mkdir -p "$$(dirname "$@")" $(CC) "$<" -o "$@" $(FLAGS) $(STATIC_FLAGS) -bins_dynamic/%.so: %.c $(DEPS) +$(BUILD)/bins_dynamic/%.so: %.c $(DEPS) mkdir -p "$$(dirname "$@")" $(CC) "$<" -o "$@" -shared -fpic $(FLAGS) $(DYNAMIC_FLAGS) -bins_dynamic/dlfcn: dlfcn.c bins_dynamic/sharedlib.so $(DEPS) +$(BUILD)/bins_dynamic/dlfcn: dlfcn.c $(BUILD)/bins_dynamic/sharedlib.so $(DEPS) mkdir -p "$$(dirname "$@")" $(CC) "$<" -o "$@" $(FLAGS) $(DYNAMIC_FLAGS) -bins_dynamic/%: %.c $(DEPS) +$(BUILD)/bins_dynamic/%: %.c $(DEPS) mkdir -p "$$(dirname "$@")" $(CC) "$<" -o "$@" $(FLAGS) $(DYNAMIC_FLAGS)