-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#146) Rework Makefile-rules to use auto-variables $@, $< more widely
This commit refactors existing Makefile-rules to replace hard-coded file-names (e.g. "certifier_proofs.cc") to instead use Make-provided automatic variables (such as $@ and $<). In a few places, use: - '$(<D)' to name the directory of the 1st pre-requisite - '$(@d)' to name the directory of the target With this change, much of the rules become more compact and follow a pattern consistent with Make-suggested usage of variables. Refactor few mak-files to define common_objs list; remove redundant definitions of CFLAGS and other unused symbols / make-rules.
- Loading branch information
Showing
16 changed files
with
520 additions
and
527 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ I= $(SRC_DIR)/include | |
INCLUDE= -I$(I) -I$(LIBSRC)/sev-snp -I/usr/local/opt/[email protected]/include/ | ||
|
||
CFLAGS=$(INCLUDE) -O3 -g -Wall -std=c++11 -Wno-unused-variable -D X64 -D DEBUG -Wno-deprecated-declarations | ||
CFLAGS1=$(INCLUDE) -O1 -g -Wall -std=c++11 -Wno-unused-variable -D X64 -D DEBUG -Wno-deprecated-declarations | ||
CC=g++ | ||
LINK=g++ | ||
# PROTO=/usr/local/bin/protoc | ||
|
@@ -44,13 +43,18 @@ AR=ar | |
#export LD_LIBRARY_PATH=/usr/local/lib | ||
LDFLAGS= -L $(LOCAL_LIB) -lprotobuf -lgtest -lgflags -lpthread -L/usr/local/opt/[email protected]/lib/ -lcrypto -lssl | ||
|
||
dobj= $(O)/app_service.o $(O)/certifier.pb.o $(O)/certifier.o $(O)/certifier_proofs.o $(O)/support.o \ | ||
$(O)/simulated_enclave.o $(O)/application_enclave.o $(O)/cc_helpers.o $(O)/cc_useful.o \ | ||
$(O)/sev_support.o $(O)/sev_report.o | ||
dobj = $(O)/app_service.o $(O)/certifier.pb.o $(O)/certifier.o \ | ||
$(O)/certifier_proofs.o $(O)/support.o $(O)/simulated_enclave.o \ | ||
$(O)/application_enclave.o $(O)/cc_helpers.o $(O)/cc_useful.o \ | ||
$(O)/sev_support.o $(O)/sev_report.o | ||
|
||
user_dobj= $(O)/test_user.o $(O)/certifier.pb.o $(O)/certifier.o $(O)/certifier_proofs.o $(O)/support.o \ | ||
$(O)/simulated_enclave.o $(O)/application_enclave.o $(O)/cc_helpers.o $(O)/cc_useful.o | ||
user_dobj = $(O)/test_user.o $(O)/certifier.pb.o $(O)/certifier.o \ | ||
$(O)/certifier_proofs.o $(O)/support.o $(O)/simulated_enclave.o \ | ||
$(O)/application_enclave.o $(O)/cc_helpers.o $(O)/cc_useful.o | ||
|
||
send_req_dobj = $(O)/send_request.o $(O)/certifier.pb.o $(O)/certifier.o \ | ||
$(O)/support.o $(O)/application_enclave.o \ | ||
$(O)/simulated_enclave.o $(O)/certifier_proofs.o | ||
|
||
all: app_service.exe hello_world.exe send_request.exe test_user.exe | ||
|
||
|
@@ -62,83 +66,82 @@ clean: | |
@echo "removing executable file" | ||
rm -rf $(EXE_DIR)/app_service.exe | ||
|
||
hello_world.exe: hello_world.cc | ||
@echo "hello_world.cc" | ||
$(CC) $(CFLAGS) -o $(O)/hello_world.exe $(S)/hello_world.cc | ||
hello_world.exe: $(S)/hello_world.cc | ||
@echo "compiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
send_request.exe: $(O)/send_request.o $(O)/certifier.pb.o $(O)/certifier.o $(O)/support.o $(O)/application_enclave.o $(O)/simulated_enclave.o $(O)/certifier_proofs.o | ||
@echo "send_request.exe" | ||
$(LINK) -o $(EXE_DIR)/send_request.exe $(O)/send_request.o $(O)/certifier.pb.o \ | ||
$(O)/certifier.o $(O)/certifier_proofs.o $(O)/support.o $(O)/application_enclave.o $(O)/simulated_enclave.o $(LDFLAGS) | ||
$(EXE_DIR)/send_request.exe: $(send_req_dobj) | ||
@echo "linking executable $@" | ||
$(LINK) $(send_req_dobj) $(LDFLAGS) -o $(@D)/$@ | ||
|
||
$(O)/send_request.o: $(S)/send_request.cc | ||
@echo "send_request.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/send_request.o $(S)/send_request.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
app_service.exe: $(dobj) | ||
@echo "linking executable files" | ||
$(LINK) -o $(EXE_DIR)/app_service.exe $(dobj) $(LDFLAGS) | ||
$(EXE_DIR)/app_service.exe: $(dobj) | ||
@echo "linking executable $@" | ||
$(LINK) $(dobj) $(LDFLAGS) -o $(@D)/$@ | ||
|
||
test_user.exe: $(user_dobj) | ||
@echo "linking executable files" | ||
$(LINK) -o $(EXE_DIR)/test_user.exe $(user_dobj) $(LDFLAGS) | ||
$(EXE_DIR)/test_user.exe: $(user_dobj) | ||
@echo "linking executable $@" | ||
$(LINK) $(user_dobj) $(LDFLAGS) -o $(@D)/$@ | ||
|
||
$(I)/certifier.pb.h: $(US)/certifier.pb.cc | ||
$(US)/certifier.pb.cc: $(CP)/certifier.proto | ||
$(PROTO) --proto_path=$(CP) --cpp_out=$(US) $< | ||
mv certifier.pb.h $(I) | ||
$(PROTO) --proto_path=$(<D) --cpp_out=$(@D) $< | ||
mv $(@D)/certifier.pb.h $(I) | ||
|
||
$(O)/app_service.o: $(S)/app_service.cc $(S)/certifier.pb.cc | ||
@echo "compiling app_service.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/app_service.o $(S)/app_service.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/certifier.pb.o: $(US)/certifier.pb.cc $(I)/certifier.pb.h | ||
@echo "compiling certifier.pb.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/certifier.pb.o $(US)/certifier.pb.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/certifier.o: $(LIBSRC)/certifier.cc $(I)/certifier.pb.h $(I)/certifier.h | ||
@echo "compiling certifier.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/certifier.o $(LIBSRC)/certifier.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/certifier_proofs.o: $(LIBSRC)/certifier_proofs.cc $(I)/certifier.pb.h $(I)/certifier.h | ||
@echo "compiling certifier_proofs.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/certifier_proofs.o $(LIBSRC)/certifier_proofs.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/support.o: $(LIBSRC)/support.cc $(I)/support.h | ||
@echo "compiling support.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/support.o $(LIBSRC)/support.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/cc_helpers.o: $(LIBSRC)/cc_helpers.cc $(I)/cc_helpers.h | ||
@echo "compiling cc_helpers.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/cc_helpers.o $(LIBSRC)/cc_helpers.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/cc_useful.o: $(LIBSRC)/cc_useful.cc $(I)/cc_useful.h | ||
@echo "compiling cc_useful.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/cc_useful.o $(LIBSRC)/cc_useful.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/simulated_enclave.o: $(LIBSRC)/simulated_enclave.cc $(I)/simulated_enclave.h | ||
@echo "compiling simulated_enclave.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/simulated_enclave.o $(LIBSRC)/simulated_enclave.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/application_enclave.o: $(LIBSRC)/application_enclave.cc $(I)/application_enclave.h | ||
@echo "compiling application_enclave.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/application_enclave.o $(LIBSRC)/application_enclave.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/test_user.o: $(S)/test_user.cc $(S)/certifier.pb.cc | ||
@echo "compiling test_user.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/test_user.o $(S)/test_user.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
SEV_S=$(LIBSRC)/sev-snp | ||
|
||
$(O)/sev_support.o: $(SEV_S)/sev_support.cc \ | ||
$(I)/certifier.h $(I)/support.h $(SEV_S)/attestation.h $(SEV_S)/sev_guest.h \ | ||
$(SEV_S)/snp_derive_key.h | ||
@echo "compiling sev_support.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/sev_support.o $(SEV_S)/sev_support.cc | ||
$(I)/certifier.h $(I)/support.h \ | ||
$(SEV_S)/attestation.h $(SEV_S)/sev_guest.h \ | ||
$(SEV_S)/snp_derive_key.h | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/sev_report.o: $(SEV_S)/sev_report.cc \ | ||
$(I)/certifier.h $(I)/support.h $(SEV_S)/attestation.h $(SEV_S)/sev_guest.h \ | ||
$(SEV_S)/snp_derive_key.h | ||
@echo "compiling sev_report.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/sev_report.o $(SEV_S)/sev_report.cc | ||
|
||
$(I)/certifier.h $(I)/support.h $(SEV_S)/attestation.h \ | ||
$(SEV_S)/sev_guest.h $(SEV_S)/snp_derive_key.h | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ I= $(SRC_DIR)/include | |
INCLUDE= -I$(I) -I/usr/local/opt/[email protected]/include/ -I$(S)/sev-snp/ | ||
|
||
CFLAGS=$(INCLUDE) -O3 -g -Wall -std=c++11 -Wno-unused-variable -D X64 -Wno-deprecated-declarations | ||
CFLAGS1=$(INCLUDE) -O1 -g -Wall -std=c++11 -Wno-unused-variable -D X64 -Wno-deprecated-declarations | ||
CC=g++ | ||
LINK=g++ | ||
#PROTO=/usr/local/bin/protoc | ||
|
@@ -43,12 +42,13 @@ LDFLAGS= -L $(LOCAL_LIB) -lprotobuf -lgtest -lgflags -lpthread -L/usr/local/opt/ | |
|
||
# Note: You can omit all the files below in d_obj except $(O)/example_app.o, | ||
# if you link in the certifier library certifier.a. | ||
dobj= $(O)/service_example_app.o $(O)/certifier.pb.o $(O)/certifier.o $(O)/certifier_proofs.o \ | ||
$(O)/support.o $(O)/simulated_enclave.o $(O)/application_enclave.o $(O)/cc_helpers.o $(O)/cc_useful.o | ||
|
||
sp_dobj=$(O)/start_program.o $(O)/certifier.pb.o $(O)/certifier.o $(O)/certifier_proofs.o $(O)/support.o \ | ||
$(O)/simulated_enclave.o $(O)/application_enclave.o $(O)/cc_helpers.o $(O)/cc_useful.o | ||
dobj = $(O)/service_example_app.o $(O)/certifier.pb.o $(O)/certifier.o \ | ||
$(O)/certifier_proofs.o $(O)/support.o $(O)/simulated_enclave.o \ | ||
$(O)/application_enclave.o $(O)/cc_helpers.o $(O)/cc_useful.o | ||
|
||
sp_dobj = $(O)/start_program.o $(O)/certifier.pb.o $(O)/certifier.o \ | ||
$(O)/certifier_proofs.o $(O)/support.o $(O)/simulated_enclave.o \ | ||
$(O)/application_enclave.o $(O)/cc_helpers.o $(O)/cc_useful.o | ||
|
||
all: service_example_app.exe start_program.exe | ||
clean: | ||
|
@@ -59,56 +59,55 @@ clean: | |
@echo "removing executable file" | ||
rm -rf $(EXE_DIR)/service_example_app.exe | ||
|
||
service_example_app.exe: $(dobj) | ||
@echo "linking executable files" | ||
$(LINK) -o $(EXE_DIR)/service_example_app.exe $(dobj) $(LDFLAGS) | ||
$(EXE_DIR)/service_example_app.exe: $(dobj) | ||
@echo "\nlinking executable $@" | ||
$(LINK) $(dobj) $(LDFLAGS) -o $(@D)/$@ | ||
|
||
$(I)/certifier.pb.h: $(US)/certifier.pb.cc | ||
$(US)/certifier.pb.cc: $(CP)/certifier.proto | ||
$(PROTO) --proto_path=$(CP) --cpp_out=$(US) $< | ||
mv $(US)/certifier.pb.h $(I) | ||
$(PROTO) --proto_path=$(<D) --cpp_out=$(@D) $< | ||
mv $(@D)/certifier.pb.h $(I) | ||
|
||
$(O)/certifier.pb.o: $(US)/certifier.pb.cc $(I)/certifier.pb.h | ||
@echo "compiling certifier.pb.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/certifier.pb.o $(US)/certifier.pb.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
start_program.exe: $(sp_dobj) | ||
@echo "start_program.exe" | ||
$(LINK) -o $(EXE_DIR)/start_program.exe $(sp_dobj) $(LDFLAGS) | ||
$(EXE_DIR)/start_program.exe: $(sp_dobj) | ||
@echo "\nlinking executable $@" | ||
$(LINK) $(sp_dobj) $(LDFLAGS) -o $(@D)/$@ | ||
|
||
$(O)/start_program.o: start_program.cc | ||
@echo "start_program.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/start_program.o $(US)/start_program.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/service_example_app.o: $(US)/service_example_app.cc $(I)/certifier.h $(US)/certifier.pb.cc | ||
@echo "compiling service_example_app.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/service_example_app.o $(US)/service_example_app.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/certifier.o: $(S)/certifier.cc $(I)/certifier.pb.h $(I)/certifier.h | ||
@echo "compiling certifier.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/certifier.o $(S)/certifier.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/certifier_proofs.o: $(S)/certifier_proofs.cc $(I)/certifier.pb.h $(I)/certifier.h | ||
@echo "compiling certifier_proofs.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/certifier_proofs.o $(S)/certifier_proofs.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/support.o: $(S)/support.cc $(I)/support.h | ||
@echo "compiling support.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/support.o $(S)/support.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/simulated_enclave.o: $(S)/simulated_enclave.cc $(I)/simulated_enclave.h | ||
@echo "compiling simulated_enclave.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/simulated_enclave.o $(S)/simulated_enclave.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/application_enclave.o: $(S)/application_enclave.cc $(I)/application_enclave.h | ||
@echo "compiling application_enclave.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/application_enclave.o $(S)/application_enclave.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/cc_helpers.o: $(S)/cc_helpers.cc $(I)/certifier.h $(US)/certifier.pb.cc | ||
@echo "compiling cc_helpers.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/cc_helpers.o $(S)/cc_helpers.cc | ||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< | ||
|
||
$(O)/cc_useful.o: $(S)/cc_useful.cc $(I)/cc_useful.h | ||
@echo "compiling cc_useful.cc" | ||
$(CC) $(CFLAGS) -c -o $(O)/cc_useful.o $(S)/cc_useful.cc | ||
|
||
@echo "\ncompiling $<" | ||
$(CC) $(CFLAGS) -o $(@D)/$@ -c $< |
Oops, something went wrong.