ソースを参照

[LibOS/shim/test] Copy Makefile to Makefile.Test and use it

LibOS/shim/test/Makefile has confusion. It's makefile for test/ directory
and common functions for each test directory.
As a first step to untangle the confusion, copy Makefile.Test for
common functions and have test directories to use it.
Later once grapene-tests is updated, LibOS/shim/test/Makefile
will have only submake rules.
Isaku Yamahata 4 年 前
コミット
353f1f609f

+ 94 - 0
LibOS/shim/test/Makefile.Test

@@ -0,0 +1,94 @@
+subdirs = native
+
+SYS ?= $(shell gcc -dumpmachine)
+export SYS
+
+PALDIR  = $(level)../../../Pal/src
+SHIMDIR = $(level)../src
+RUNTIME = $(level)../../../Runtime
+
+ifeq ($(SGX),1)
+PAL_LOADER = pal_loader SGX
+else
+PAL_LOADER = pal_loader
+endif
+
+CC = gcc
+CXX = g++
+CFLAGS 	= -Wall -std=gnu99
+CFLAGS-debug = -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib
+CXXFLAGS = -Wall -std=c++14
+CXXFLAGS-debug = -I$(SHIMDIR)/../include -I$(PALDIR)/../include/pal -I$(PALDIR)/../lib
+LDFLAGS	=
+LDFLAGS-debug = -L$(SHIMDIR) -L$(PALDIR) -Wl,-rpath-link=$(abspath $(RUNTIME))
+
+CFLAGS-libos = -I$(SHIMDIR)/../include -L$(SHIMDIR)/../../glibc-build/libos
+
+.PHONY: default
+default: all
+
+include $(PALDIR)/Makefile.Test
+
+.PHONY: all
+all: pal_loader $(target) $(if $(level),,build-subdirs) | $(call expand_target,$(exec_target))
+
+ifeq ($(DEBUG),1)
+CC += -g
+CXX += -g
+endif
+export DEBUG
+
+ifeq ($(WERROR),1)
+CFLAGS += -Werror
+endif
+
+ifeq ($(ABSPATH_IN_MANIFEST),yes)
+manifest_rules = \
+	-e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
+	-e 's:\$$(PWD):$(PWD):g' \
+	-e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
+	-e 's:\$$(SHIMPATH):$(abspath $(RUNTIME))/libsysdb.so:g' \
+	-e 's:\$$(LIBCDIR):$(abspath $(RUNTIME)):g' \
+	$(extra_rules)
+else
+manifest_rules= \
+	-e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
+	-e 's:\$$(PWD):$(PWD):g' \
+	-e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
+	-e 's:\$$(SHIMPATH):'$$RELDIR'$(RUNTIME)/libsysdb.so:g' \
+	-e 's:\$$(LIBCDIR):'$$RELDIR'$(RUNTIME):g' \
+	$(extra_rules)
+endif
+
+pal_loader:
+	ln -sf $(RUNTIME)/pal_loader
+
+relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")
+
+%manifest: %manifest.template
+	@echo [ $@ ]
+	RELDIR=$(filter-out ./,$(call relative-to,$(dir $@),$(shell pwd))/) && \
+	sed $(manifest_rules) $< > $@
+	(grep -q '^#!' $@ && chmod +x $@) || true
+
+manifest: manifest.template
+	@echo [ $@ ]
+	sed $(manifest_rules) $< > $@
+
+ifneq ($(MAKECMDGOALS),clean)
+ifeq ($(SGX),1)
+include $(addsuffix .manifest.sgx.d,$(exec_target))
+endif
+endif
+
+.PHONY: clean
+clean: $(clean-extra) $(if $(level),,clean-subdirs)
+	rm -rf pal_loader $(call expand_target,$(exec_target)) $(target) $(wildcard *.d)
+
+.PHONY: build-subdirs
+build-subdirs:
+	for f in $(subdirs); do (cd $$f; $(MAKE); cd ..); done
+
+.PHONY: clean-subdirs
+clean-subdirs:
+	for f in $(subdirs); do (cd $$f; $(MAKE) clean; cd ..); done

+ 1 - 1
LibOS/shim/test/benchmark/Makefile

@@ -7,7 +7,7 @@ target = $(c_executables) $(cxx_executables) \
 level = ../
 include ../../../../Makefile.configs
 include ../../../../Makefile.rules
-include ../Makefile
+include ../Makefile.Test
 
 CFLAGS-libos = -L../../../glibc-build/libos -I../../include
 

+ 1 - 1
LibOS/shim/test/inline/Makefile

@@ -10,7 +10,7 @@ default: all
 level = ../
 include ../../../../Makefile.configs
 include ../../../../Makefile.rules
-include ../Makefile
+include ../Makefile.Test
 
 CFLAGS-debug += -fno-builtin -nostdlib
 

+ 1 - 1
LibOS/shim/test/native/Makefile

@@ -8,7 +8,7 @@ target = $(exec_target) $(manifests)
 level = ../
 include ../../../../Makefile.configs
 include ../../../../Makefile.rules
-include ../Makefile
+include ../Makefile.Test
 
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
 

+ 1 - 1
LibOS/shim/test/regression/Makefile

@@ -13,7 +13,7 @@ default: all
 level = ../
 include ../../../../Makefile.configs
 include ../../../../Makefile.rules
-include ../Makefile
+include ../Makefile.Test
 
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)