Makefile 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #
  2. # Copyright (C) 2011-2018 Intel Corporation. All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions
  6. # are met:
  7. #
  8. # * Redistributions of source code must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. # * Redistributions in binary form must reproduce the above copyright
  11. # notice, this list of conditions and the following disclaimer in
  12. # the documentation and/or other materials provided with the
  13. # distribution.
  14. # * Neither the name of Intel Corporation nor the names of its
  15. # contributors may be used to endorse or promote products derived
  16. # from this software without specific prior written permission.
  17. #
  18. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. #
  30. #
  31. # PCL library makefile
  32. include ../../buildenv.mk
  33. ifndef $(VERBOSE)
  34. VERBOSE := @
  35. endif
  36. ifeq ($(ARCH), x86)
  37. $(error x86 build is not supported, only x64!!)
  38. endif
  39. # output dir for simulation build objects
  40. SIM_DIR := simulation/
  41. SIM_OBJ_DIR := $(SIM_DIR)
  42. PCL_SIM_LIB := libsgx_pclsim.a
  43. PCL_LIB := libsgx_pcl.a
  44. # source files
  45. PCL_ASM_FILES := crypto/pcl_vpaes-x86_64.s \
  46. crypto/pcl_ghash-x86_64.s
  47. PCL_CPP_FILES := pcl_entry.cpp \
  48. pcl_mem.cpp \
  49. crypto/pcl_crypto.cpp \
  50. unseal/pcl_tSeal.cpp \
  51. unseal/pcl_sgx_get_key.cpp \
  52. unseal/pcl_tSeal_util.cpp \
  53. unseal/pcl_tSeal_internal.cpp
  54. PCL_C_FILES := crypto/pcl_sha256.c \
  55. crypto/pcl_gcm128.c
  56. # files for simulation mode
  57. PCL_SIM_C_FILES := $(PCL_C_FILES) crypto/pcl_cmac.c
  58. PCL_SIM_CPP_FILES := $(PCL_CPP_FILES) unseal/sim/pcl_deriv.cpp unseal/sim/pcl_t_instructions.cpp
  59. # object files
  60. PCL_CPP_OBJECTS := $(PCL_CPP_FILES:%.cpp=%.o)
  61. PCL_C_OBJECTS := $(PCL_C_FILES:%.c=%.o)
  62. PCL_ASM_OBJECTS := $(PCL_ASM_FILES:%.s=%.o)
  63. # simulation objects
  64. PCL_SIM_CPP_OBJECTS := $(PCL_SIM_CPP_FILES:%.cpp=$(SIM_OBJ_DIR)%.o)
  65. PCL_SIM_C_OBJECTS := $(PCL_SIM_C_FILES:%.c=$(SIM_OBJ_DIR)%.o)
  66. # build flags
  67. PCL_INCLUDE_PATH := -I$(COMMON_DIR)/inc \
  68. -I$(COMMON_DIR)/inc/tlibc \
  69. -I$(COMMON_DIR)/inc/internal \
  70. -I./crypto \
  71. -I./unseal \
  72. -I/usr/include/x86_64-linux-gnu \
  73. -I/usr/include \
  74. -I./
  75. TCFLAGS := $(filter-out -ffunction-sections -fdata-sections, $(CFLAGS))
  76. TCXXFLAGS := $(filter-out -ffunction-sections -fdata-sections, $(CXXFLAGS))
  77. PCL_LIB_C_FLAGS := $(TCFLAGS) $(ENCLAVE_CFLAGS) $(PCL_INCLUDE_PATH)
  78. PCL_LIB_CPP_FLAGS := $(TCXXFLAGS) $(ENCLAVE_CXXFLAGS) $(PCL_INCLUDE_PATH)
  79. PCL_SIM_LIB_C_FLAGS := $(TCFLAGS) $(ENCLAVE_CFLAGS) -DSE_SIM=1 $(PCL_INCLUDE_PATH) -I$(LINUX_SDK_DIR)/simulation/tinst
  80. PCL_SIM_LIB_CPP_FLAGS := $(TCXXFLAGS) $(ENCLAVE_CXXFLAGS) -DSE_SIM=1 $(PCL_INCLUDE_PATH) -I$(LINUX_SDK_DIR)/simulation/tinst
  81. # targets
  82. .PHONY: all
  83. all: | $(BUILD_DIR)
  84. $(VERBOSE)$(MAKE) $(PCL_LIB)
  85. $(VERBOSE)$(MAKE) $(PCL_SIM_LIB)
  86. $(VERBOSE)$(CP) $(PCL_LIB) $|
  87. $(VERBOSE)$(CP) $(PCL_SIM_LIB) $|
  88. $(BUILD_DIR):
  89. $(VERBOSE)$(MKDIR) $@
  90. .PHONY: $(PCL_LIB)
  91. $(PCL_LIB):$(PCL_CPP_OBJECTS) $(PCL_ASM_OBJECTS) $(PCL_C_OBJECTS)
  92. @echo "library build with DEBUG =" $(DEBUG)
  93. $(VERBOSE)$(AR) -rc $@ $^
  94. @echo "AR <= $@"
  95. .PHONY: $(PCL_SIM_LIB)
  96. $(PCL_SIM_LIB):$(PCL_SIM_CPP_OBJECTS) $(PCL_ASM_OBJECTS) $(PCL_SIM_C_OBJECTS)
  97. @echo "library build with DEBUG =" $(DEBUG)
  98. $(VERBOSE)$(AR) -rc $@ $^
  99. @echo "AR <= $@"
  100. %.o: %.s
  101. $(VERBOSE)mkdir -p $(@D)
  102. $(VERBOSE)$(CXX) $(PCL_LIB_C_FLAGS) -c $< -o $@
  103. $(VERBOSE)$(OBJCOPY) $@ --rename-section .text=$(NIPX)
  104. $(VERBOSE)$(OBJCOPY) $@ --rename-section .data=$(NIPD)
  105. $(VERBOSE)$(OBJCOPY) $@ --rename-section .rodata=$(NIPRODT)
  106. @echo "CXX <= $<"
  107. %.o: %.c
  108. $(VERBOSE)mkdir -p $(@D)
  109. $(VERBOSE)$(CXX) $(PCL_LIB_C_FLAGS) -c $< -o $@
  110. $(VERBOSE)$(OBJCOPY) $@ --rename-section .text=$(NIPX)
  111. $(VERBOSE)$(OBJCOPY) $@ --rename-section .data=$(NIPD)
  112. $(VERBOSE)$(OBJCOPY) $@ --rename-section .rodata=$(NIPRODT)
  113. @echo "CXX <= $<"
  114. %.o: %.cpp
  115. $(VERBOSE)mkdir -p $(@D)
  116. $(VERBOSE)$(CXX) $(PCL_LIB_CPP_FLAGS) -c $< -o $@
  117. $(VERBOSE)$(OBJCOPY) $@ --rename-section .text=$(NIPX)
  118. $(VERBOSE)$(OBJCOPY) $@ --rename-section .data=$(NIPD)
  119. $(VERBOSE)$(OBJCOPY) $@ --rename-section .rodata=$(NIPRODT)
  120. @echo "CXX <= $<"
  121. # Simulation objects
  122. $(SIM_OBJ_DIR)%.o: %.s
  123. $(VERBOSE)mkdir -p $(@D)
  124. $(VERBOSE)$(CXX) $(PCL_SIM_LIB_C_FLAGS) -c $< -o $@
  125. $(VERBOSE)$(OBJCOPY) $@ --rename-section .text=$(NIPX)
  126. $(VERBOSE)$(OBJCOPY) $@ --rename-section .data=$(NIPD)
  127. $(VERBOSE)$(OBJCOPY) $@ --rename-section .rodata=$(NIPRODT)
  128. @echo "CXX <= $<"
  129. $(SIM_OBJ_DIR)%.o: %.c
  130. $(VERBOSE)mkdir -p $(@D)
  131. $(VERBOSE)$(CXX) $(PCL_SIM_LIB_C_FLAGS) -c $< -o $@
  132. $(VERBOSE)$(OBJCOPY) $@ --rename-section .text=$(NIPX)
  133. $(VERBOSE)$(OBJCOPY) $@ --rename-section .data=$(NIPD)
  134. $(VERBOSE)$(OBJCOPY) $@ --rename-section .rodata=$(NIPRODT)
  135. @echo "CXX <= $<"
  136. $(SIM_OBJ_DIR)%.o: %.cpp
  137. $(VERBOSE)mkdir -p $(@D)
  138. $(VERBOSE)$(CXX) $(PCL_SIM_LIB_CPP_FLAGS) -c $< -o $@
  139. $(VERBOSE)$(OBJCOPY) $@ --rename-section .text=$(NIPX)
  140. $(VERBOSE)$(OBJCOPY) $@ --rename-section .data=$(NIPD)
  141. $(VERBOSE)$(OBJCOPY) $@ --rename-section .rodata=$(NIPRODT)
  142. @echo "CXX <= $<"
  143. .PHONY: clean
  144. clean:
  145. $(VERBOSE)$(RM) $(PCL_LIB) $(PCL_SIM_LIB) $(PCL_CPP_OBJECTS) $(PCL_ASM_OBJECTS) $(PCL_C_OBJECTS) $(PCL_SIM_CPP_OBJECTS) $(PCL_SIM_C_OBJECTS)
  146. $(VERBOSE)rm -rf $(SIM_DIR) $(BUILD_DIR)/$(PCL_LIB) $(BUILD_DIR)/$(PCL_SIM_LIB)
  147. .PHONY: rebuild
  148. rebuild:
  149. $(MAKE) clean
  150. $(MAKE) all