Explorar o código

[Makefile, Pal/Linux-SGX] Calculate dependencies for *.manifest.sgx

Isaku Yamahata %!s(int64=4) %!d(string=hai) anos
pai
achega
9af27a82b0
Modificáronse 4 ficheiros con 34 adicións e 21 borrados
  1. 6 0
      LibOS/shim/test/Makefile
  2. 5 0
      Pal/regression/Makefile
  3. 16 20
      Pal/src/host/Linux-SGX/Makefile.Test
  4. 7 1
      Pal/test/Makefile

+ 6 - 0
LibOS/shim/test/Makefile

@@ -27,6 +27,8 @@ CFLAGS-libos = -I$(SHIMDIR)/../include -L$(SHIMDIR)/../../glibc-build/libos
 .PHONY: default
 default: all
 
+include $(level)../../../Makefile.configs
+include $(level)../../../Makefile.rules
 include $(PALDIR)/Makefile.Test
 
 .PHONY: all
@@ -75,6 +77,10 @@ manifest: manifest.template
 	@echo [ $@ ]
 	sed $(manifest_rules) $< > $@
 
+ifeq ($(SGX), 1)
+include $(addsuffix .manifest.sgx.d,$(patsubst %.manifest,%,$(exec_target)))
+endif
+
 .PHONY: clean
 clean: $(clean-extra) $(if $(level),,clean-subdirs)
 	rm -rf pal_loader $(call expand_target,$(exec_target)) $(target) $(wildcard *.d)

+ 5 - 0
Pal/regression/Makefile

@@ -15,6 +15,8 @@ pal_lib = ../../Runtime/libpal-$(PAL_HOST).so
 
 .PHONY: default
 default: all
+include ../../Makefile.configs
+include ../../Makefile.rules
 include ../src/Makefile.Test
 
 RUNTIME_DIR = $(CURDIR)/../../Runtime
@@ -60,6 +62,9 @@ $(executables): %: %.c ../src/user_start.o \
 	@$(CC) -MD -MP $(CFLAGS) $(filter-out %.h,$^) -o $@
 
 include $(wildcard *.d)
+ifeq ($(SGX), 1)
+include $(addsuffix .manifest.sgx.d,$(executables))
+endif
 
 .lib/host_endian.h: ../src/host/$(PAL_HOST)/host_endian.h
 	@mkdir -p .lib

+ 16 - 20
Pal/src/host/Linux-SGX/Makefile.Test

@@ -11,37 +11,33 @@ ifeq ($(SGX_RUN),1)
 expand_target = $(foreach t,$(filter-out manifest,$(1)),$(patsubst %.manifest,%,$(t)).token)
 
 %.token: %.sig
-	@echo [ Token: $(patsubst %.token,%,$@) ]
-	@$(SGX_GET_TOKEN) -output $@ -sig $(patsubst %.token,%.sig,$@)
+	$(call cmd,sgx_get_token)
 
 else
 
 expand_target = $(1) $(foreach t,$(filter-out manifest,$(1)), \
-		$(patsubst %.manifest,%,$(t)).manifest.sgx) *.sig *.token
+		$(patsubst %.manifest,%,$(t)).manifest.sgx)
 
 $(SGX_SIGNER_KEY):
 	$(error "Cannot find any enclave key. Generate $(abspath $(SGX_SIGNER_KEY)) or specify 'SGX_SIGNER_KEY=' with make")
 
-prerequisite = \
-	for f in `sed -e 's/\#.*//g' $(1) | grep -Po 'sgx.trusted_children.[^\\s=]+\\s*=\\s*file:\\K\\S+'`; do \
-		$(MAKE) $${f%.sig}.manifest.sgx; \
-	done
+%.sig %.manifest.sgx: %.manifest % $(LIBPAL) $(SGX_SIGNER_KEY) %.manifest.sgx.d
+	$(call cmd,sgx_sign_manifest)
 
-find_manifest = $(patsubst %.template,%,$(if $(wildcard $(1).manifest.template),$(1).manifest.template,manifest.template))
+%.sig %.manifest.sgx: manifest % $(LIBPAL) $(SGX_SIGNER_KEY) %.manifest.sgx.d
+	$(call cmd,sgx_sign_manifest)
 
-%.manifest.sgx: % $(LIBPAL) $(SGX_SIGNER_KEY)
-	$(eval $@-manifest := $(call find_manifest,$<))
-	@$(MAKE) $($@-manifest)
-	$(call prerequisite,$($@-manifest))
-	@echo [ $@ ]
-	$(SGX_SIGN) -output $@ -exec $< -manifest $($@-manifest)
+%.sig %.manifest.sgx: %.manifest $(LIBPAL) $(SGX_SIGNER_KEY) %.manifest.sgx.d
+	$(call cmd,sgx_sign)
 
-%.manifest.sgx: %.manifest $(LIBPAL) $(SGX_SIGNER_KEY)
-	$(call prerequisite,$<)
-	@$(MAKE) $<
-	@echo [ $@ ]
-	$(SGX_SIGN) -output $@ -manifest $<
+.PRECIOUS: %.manifest.sgx.d
 
-*.sig *.token nothing:
+%.manifest.sgx.d: %.manifest
+	$(call cmd,sgx_manifest_dependency)
+
+%.manifest.sgx.d: manifest
+	$(call cmd,sgx_manifest_dependency)
+
+*.token nothing:
 
 endif

+ 7 - 1
Pal/test/Makefile

@@ -6,6 +6,8 @@ CFLAGS	= -Wall -O2 -std=c11 -fno-builtin -nostdlib -no-pie \
 
 .PHONY: default
 default: all
+include ../../Makefile.configs
+include ../../Makefile.rules
 include ../src/Makefile.Test
 
 executables = HelloWorld File Failure Thread Fork Event Process Exception \
@@ -50,6 +52,9 @@ $(executables): %: %.c $(graphene_lib) $(pal_lib) ../src/user_start.o
 
 $(graphene_lib): .lib/host_endian.h
 	$(MAKE) -C ../lib target=$(abspath .lib)/
+ifeq ($(SGX), 1)
+include $(addsuffix .manifest.sgx.d,$(executables))
+endif
 else
 .IGNORE: $(executables)
 $(executables):
@@ -61,4 +66,5 @@ endif
 clean:
 	rm -rf pal_loader $(call expand_target,$(target)) .lib *.cached \
 	       $(addsuffix .d, $(executables)) $(addsuffix .i.d, $(executables)) \
-	       $(addsuffix .s.d, $(executables))
+	       $(addsuffix .s.d, $(executables)) \
+	       $(addsuffix .manifest.sgx.d,$(executables))