Browse Source

[Pal/Linux-SGX] Add rule `cmulti` to build executable from multiple .o files

Isaku Yamahata 4 years ago
parent
commit
86afe662f3
2 changed files with 12 additions and 7 deletions
  1. 8 7
      Pal/src/host/Linux-SGX/Makefile
  2. 4 0
      Scripts/Makefile.rules

+ 8 - 7
Pal/src/host/Linux-SGX/Makefile

@@ -62,9 +62,10 @@ $(addsuffix .o,$(enclave-objs)): quote/generated-cacert.h
 %.s: %.S
 	$(call cmd,cpp_s_S)
 
+CFLAGS-pal-sgx = -Wl,-z,relro,-z,now -pie
+LDLIBS-pal-sgx += -lprotobuf-c
 pal-sgx: $(addsuffix .o,$(urts-objs) $(urts-asm-objs)) $(graphene_lib)
-	@echo [ host/Linux-SGX/$@ ]
-	@$(CC) $(CFLAGS) -Wl,-z,relro,-z,now -pie $^ -lc -lprotobuf-c -o $@
+	$(call cmd,cmulti)
 
 quote/aesm.pb-c.o: quote/aesm.pb-c.c quote/aesm.pb-c.h
 quote/aesm.pb-c.c quote/aesm.pb-c.h: quote/aesm.proto
@@ -78,10 +79,10 @@ quote/generated-cacert.h: $(ias_cert_file)
 $(ias_cert_file):
 	@../../../../Scripts/download --output $@ --url $(ias_cert_url) --sha256 $(ias_cert_sha256)
 
-debugger/sgx_gdb.so: debugger/sgx_gdb.c debugger/sgx_gdb.h sgx_arch.h
-	@echo [ host/Linux-SGX/$@ ]
-	$(CC) -MD -MP -Wall -fPIC -O2 -std=c11 -c debugger/sgx_gdb.c -o debugger/sgx_gdb.o
-	$(LD) -shared debugger/sgx_gdb.o -o debugger/sgx_gdb.so -lc
+debugger/sgx_gdb.so: CFLAGS =
+CFLAGS-debugger/sgx_gdb.so = -shared -Wall -fPIC -O2 -std=c11
+debugger/sgx_gdb.so: debugger/sgx_gdb.c
+	$(call cmd,csingle)
 
 enclave_entry.o sgx_entry.o: asm-offsets.h
 
@@ -95,7 +96,7 @@ endif
 include ../../../../Scripts/Makefile.rules
 
 CLEAN_FILES += $(notdir $(pal_static) $(pal_lib) $(pal_loader))
-CLEAN_FILES += debugger/sgx_gdb.o
+CLEAN_FILES += debugger/sgx_gdb.so
 CLEAN_FILES += quote/aesm.pb-c.c quote/aesm.pb-c.h quote/aesm.pb-c.d quote/aesm.pb-c.o
 CLEAN_FILES += quote/generated-cacert.h
 

+ 4 - 0
Scripts/Makefile.rules

@@ -123,6 +123,10 @@ quiet_cmd_csingle = [ $@ ]
 quiet_cmd_cxxsingle = [ $@ ]
       cmd_cxxsingle = $(CXX) -MD -MP $(CXXFLAGS) $(CXXFLAGS-$@) -o $@ $< $(LDLIBS) $(LDLIBS-$@)
 
+# multiple .o => executable
+quiet_cmd_cmulti = [ $@ ]
+      cmd_cmulti = $(CC) -MD -MP $(CFLAGS) $(CFLAGS-$@) -o $@ $^ $(LDLIBS) $(LDLIBS-$@)
+
 # sgx sign
 quiet_cmd_sgx_sign_exec = [ $*.{sig, manifest.sgx} ]
       cmd_sgx_sign_exec = $(SGX_SIGN) -output $*.manifest.sgx -exec $* -manifest $< > .output.sgx_sign.$*