Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #
  2. # Copyright (C) 2011-2017 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. TOP_DIR := ../../..
  32. include $(TOP_DIR)/buildenv.mk
  33. CFLAGS += -Werror $(ENCLAVE_CFLAGS)
  34. CXXFLAGS += -Werror $(ENCLAVE_CXXFLAGS)
  35. INCLUDE += -I$(COMMON_DIR) \
  36. -I$(COMMON_DIR)/inc/tlibc \
  37. -I$(SGX_IPP_INC) \
  38. -I$(LINUX_PSW_DIR)/ae/inc \
  39. -I$(LINUX_PSW_DIR)/ae/inc/internal \
  40. -I$(TOP_DIR)/common/inc \
  41. -I$(TOP_DIR)/common/inc/internal
  42. TSERVICE_SIM_LIB := libsgx_tservice_sim.a
  43. TAE_SERVICE_SIM_LIB := libtae_service_sim.a
  44. EDLFILE := $(TOP_DIR)/common/inc/sgx_tae_service.edl
  45. TSEAL_LIB_DIR := $(LINUX_SDK_DIR)/tseal/linux
  46. TSEAL_LIB := $(TSEAL_LIB_DIR)/libtSeal.a
  47. SE_LIB_DIR := $(LINUX_SDK_DIR)/selib/linux
  48. SE_LIB := $(SE_LIB_DIR)/libselib.a
  49. EC_DH_LIB_DIR := $(LINUX_SDK_DIR)/ec_dh_lib
  50. EC_DH_LIB := $(EC_DH_LIB_DIR)/libsgx_dh.a
  51. EDGER8R_DIR := $(LINUX_SDK_DIR)/edger8r/linux
  52. EDGER8R := $(EDGER8R_DIR)/_build/Edger8r.native
  53. SRC := $(wildcard *.cpp)
  54. SRC += $(TOP_DIR)/common/src/dh.cpp
  55. OBJS := $(sort $(SRC:.cpp=.o))
  56. .PHONY: all
  57. all: $(TSERVICE_SIM_LIB) | $(BUILD_DIR)
  58. $(CP) $^ $|
  59. $(TAE_SERVICE_SIM_LIB): $(OBJS)
  60. $(AR) rcsD $@ $(OBJS)
  61. $(TSERVICE_SIM_LIB): $(TAE_SERVICE_SIM_LIB) $(EC_DH_LIB) $(TSEAL_LIB) $(SE_LIB)
  62. @$(MKDIR) $(BUILD_DIR)/.tservice_sim
  63. @$(RM) -f $(BUILD_DIR)/.tservice_sim/*
  64. cd $(BUILD_DIR)/.tservice_sim && $(AR) x $(EC_DH_LIB)
  65. cd $(BUILD_DIR)/.tservice_sim && $(AR) x $(TSEAL_LIB)
  66. cd $(BUILD_DIR)/.tservice_sim && $(AR) x $(SE_LIB)
  67. cp $(TAE_SERVICE_SIM_LIB) $@
  68. $(AR) rsD $@ $(BUILD_DIR)/.tservice_sim/*.o
  69. @$(RM) -rf $(BUILD_DIR)/.tservice_sim
  70. sgx_tae_service_t.h: $(EDLFILE) $(EDGER8R)
  71. $(EDGER8R) --trusted --header-only --search-path $(TOP_DIR)/common/inc $<
  72. $(OBJS): %.o: %.cpp sgx_tae_service_t.h
  73. $(CXX) $(CXXFLAGS) -fno-exceptions -fno-rtti $(INCLUDE) $(DEFINES) -c $< -o $@
  74. $(EDGER8R):
  75. $(MAKE) -C $(EDGER8R_DIR)
  76. $(EC_DH_LIB):
  77. $(MAKE) -C $(EC_DH_LIB_DIR)
  78. $(TSEAL_LIB):
  79. $(MAKE) -C $(TSEAL_LIB_DIR)
  80. $(SE_LIB):
  81. $(MAKE) -C $(SE_LIB_DIR)
  82. $(BUILD_DIR):
  83. @$(MKDIR) $@
  84. .PHONY: clean
  85. clean:
  86. $(MAKE) -C $(EDGER8R_DIR) clean
  87. $(MAKE) -C $(EC_DH_LIB_DIR) clean
  88. $(MAKE) -C $(TSEAL_LIB_DIR) clean
  89. $(MAKE) -C $(SE_LIB_DIR) clean
  90. @$(RM) *.o $(TSERVICE_SIM_LIB) $(TAE_SERVICE_SIM_LIB) $(BUILD_DIR)/$(TSERVICE_SIM_LIB)
  91. @$(RM) $(COMMON_DIR)/src/*.o
  92. @$(RM) sgx_tae_service_*.c
  93. @$(RM) sgx_tae_service_*.h
  94. .PHONY: rebuild
  95. rebuild:
  96. $(MAKE) clean
  97. $(MAKE) all