Browse Source

[Pal] Introduce common Makefile.manifest and remove Pal/src/Makefile.Test

Isaku Yamahata 4 years ago
parent
commit
419b5c5a11

+ 1 - 8
Pal/regression/Makefile

@@ -1,7 +1,6 @@
 include ../../Scripts/Makefile.configs
 include ../src/Makefile.Host
 include ../../Scripts/Makefile.rules
-include ../src/Makefile.Test
 
 CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib \
 	  -I../include/pal -I../lib -I../src
@@ -43,6 +42,7 @@ manifests   = manifest $(patsubst %.manifest.template,%.manifest,$(wildcard *.ma
 
 target = $(executables) $(manifests)
 
+include ../../Scripts/Makefile.manifest
 graphene_lib = .lib/graphene-lib.a
 pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
 
@@ -80,12 +80,6 @@ manifest_rules = \
 	-e 's:\$$(RA_CLIENT_LINKABLE):$(if $(RA_CLIENT_LINKABLE),$(RA_CLIENT_LINKABLE),0):g' \
 	$(extra_rules)
 
-manifest: manifest.template
-	$(call cmd,manifest,$(manifest_rules))
-
-%.manifest: %.manifest.template $(executables) $(pal_lib)
-	$(call cmd,manifest,$(manifest_rules))
-
 ../src/user_shared_start.o ../src/user_start.o: ../src/user_start.S
 	$(MAKE) -C ../src $(notdir $@)
 
@@ -117,7 +111,6 @@ ifeq ($(SGX), 1)
 # rule defined in Pal/src/host/Linux-SGX/Makefile.Test.
 Bootstrap5.manifest.sgx.d: %.manifest.sgx.d: %.manifest
 	$(call cmd,sgx_sign_depend)
-include $(addsuffix .manifest.sgx.d,$(executables))
 endif
 endif
 

+ 0 - 7
Pal/src/Makefile.Test

@@ -1,7 +0,0 @@
-DIR := $(dir $(lastword $(MAKEFILE_LIST)))
-
-ifeq ($(PAL_HOST),)
-include $(DIR)/Makefile.Host
-endif
-
--include $(DIR)/host/$(PAL_HOST)/Makefile.Test

+ 0 - 2
Pal/src/host/Linux-SGX/Makefile.Test

@@ -1,2 +0,0 @@
-SGX_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
-include $(SGX_DIR)/Makefile.manifest

+ 8 - 0
Pal/src/host/Linux-SGX/Makefile.manifest

@@ -41,3 +41,11 @@ $(SGX_SIGNER_KEY):
 # use static pattern rules in the corresponding Makefiles (e.g., in Pal/regression).
 # %.manifest.sgx.d: %.manifest
 # 	$(call cmd,sgx_sign_depend)
+
+ifeq ($(filter %clean,$(MAKECMDGOALS)),)
+ifeq ($(target),)
+$(error define "target" variable for manifest.sgx dependency calculation)
+endif
+include $(addsuffix .manifest.sgx.d,$(call drop_manifest_suffix,$(target)))
+endif
+

+ 2 - 12
Pal/test/Makefile

@@ -1,7 +1,6 @@
 include ../../Scripts/Makefile.configs
 include ../src/Makefile.Host
 include ../../Scripts/Makefile.rules
-include ../src/Makefile.Test
 
 CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib -no-pie \
 	  -I../include/pal -I../lib
@@ -16,6 +15,8 @@ manifests = manifest
 
 target = $(executables) $(manifests)
 
+include ../../Scripts/Makefile.manifest
+
 graphene_lib = .lib/graphene-lib.a
 pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
 
@@ -36,12 +37,6 @@ endif
 pal_loader:
 	ln -sf ../../Runtime/pal_loader
 
-manifest: manifest.template
-	$(call cmd,manifest)
-
-%.manifest: %.manifest.template
-	$(call cmd,manifest)
-
 ifeq ($(findstring x86_64,$(SYS))$(findstring linux,$(SYS)),x86_64linux)
 CFLAGS-Pie = -fPIC -pie
 LDLIBS = $(graphene_lib) $(pal_lib) ../src/user_start.o
@@ -54,11 +49,6 @@ $(executables): %: %.c $(LDLIBS)
 
 $(graphene_lib): .lib/host_endian.h
 	$(MAKE) -C ../lib target=$(abspath .lib)/
-ifeq ($(filter %clean,$(MAKECMDGOALS)),)
-ifeq ($(SGX), 1)
-include $(addsuffix .manifest.sgx.d,$(executables))
-endif
-endif
 else
 .IGNORE: $(executables)
 $(executables):

+ 1 - 7
Scripts/Makefile.Test

@@ -8,7 +8,7 @@ RUNTIME = $(abspath $(SCRIPTS_DIR)/../Runtime)
 include $(SCRIPTS_DIR)/Makefile.configs
 include $(PALDIR)/Makefile.Host
 include $(SCRIPTS_DIR)/Makefile.rules
-include $(PALDIR)/Makefile.Test
+include $(SCRIPTS_DIR)/Makefile.manifest
 
 ifeq ($(SGX),1)
 PAL_LOADER = pal_loader SGX
@@ -65,12 +65,6 @@ endif
 pal_loader:
 	ln -sf $(RUNTIME)/pal_loader
 
-%.manifest: %.manifest.template
-	$(call cmd,manifest,$(manifest_rules))
-
-manifest: manifest.template
-	$(call cmd,manifest,$(manifest_rules))
-
 ifeq ($(filter %clean,$(MAKECMDGOALS)),)
 ifeq ($(SGX),1)
 include $(addsuffix .manifest.sgx.d,$(patsubst %.manifest,%,$(exec_target)))

+ 13 - 0
Scripts/Makefile.manifest

@@ -0,0 +1,13 @@
+ifeq ($(PAL_HOST),)
+$(error include Makefile.configs before including Makefile.manifest)
+endif
+
+MAKEFILE_MANIFEST_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+
+%.manifest: %.manifest.template
+	$(call cmd,manifest,$(manifest_rules))
+
+manifest: manifest.template
+	$(call cmd,manifest,$(manifest_rules))
+
+-include $(MAKEFILE_MANIFEST_DIR)/../Pal/src/host/$(PAL_HOST)/Makefile.manifest