Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #
  2. # Copyright (C) 2011-2016 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. include ../../../../buildenv.mk
  32. CPPFLAGS += -I$(COMMON_DIR)/inc/ \
  33. -I$(COMMON_DIR)/inc/tlibc/ \
  34. -I$(COMMON_DIR)/inc/internal \
  35. -I$(LINUX_SDK_DIR)/trts/
  36. CFLAGS += $(ENCLAVE_CFLAGS)
  37. ASFLAGS := -DSE_SIM -Werror $(CFLAGS)
  38. CFLAGS += -DSE_SIM -Werror -fasynchronous-unwind-tables
  39. CXXFLAGS += -DSE_SIM -Werror $(ENCLAVE_CXXFLAGS)\
  40. -fno-exceptions -fno-rtti
  41. SIM_DIR := $(CUR_DIR)/../..
  42. # The sources from tRTS - shared by both Sim/HW mode
  43. TRTS_DIR := $(LINUX_SDK_DIR)/trts/
  44. # The sources for SE0 instruction simulation
  45. TINST_DIR := $(SIM_DIR)/tinst/
  46. # The sources for low-level API used by instruction simulation
  47. LOWLIB_DIR := $(SIM_DIR)/assembly/linux/
  48. # The sources for TLS support
  49. TLS_DIR := $(SIM_DIR)/uinst/linux/
  50. # The source for trusted loader
  51. TLDR_DIR := $(LINUX_SDK_DIR)/trts/linux/
  52. # Support for platform dependent 'setcontext'
  53. SC_DIR := $(LINUX_SDK_DIR)/trts/linux/$(ARCH)/
  54. TRTS_OBJS := init_enclave.o \
  55. trts.o \
  56. trts_ecall.o \
  57. trts_ocall.o \
  58. trts_util.o \
  59. trts_veh.o \
  60. trts_xsave.o \
  61. init_optimized_lib.o
  62. TINST_OBJS := t_instructions.o \
  63. deriv.o
  64. LOWLIB_OBJS := lowlib.o
  65. TLS_OBJS := get_tcs.o \
  66. restore_tls.o
  67. TLDR_ASM_OBJS := trts_pic.o \
  68. metadata_sec.o
  69. TLDR_C_OBJS := elf_parser.o \
  70. global_init.o \
  71. tls_support.o
  72. TLDR_OBJS := $(TLDR_ASM_OBJS) $(TLDR_C_OBJS)
  73. SC_OBJ := setcontext.o
  74. LIBTRTS := libsgx_trts_sim.a
  75. vpath %.cpp $(TRTS_DIR):$(TINST_DIR)
  76. vpath %.S $(LOWLIB_DIR):$(TLDR_DIR):$(SC_DIR)
  77. vpath %.c $(TLS_DIR):$(TLDR_DIR)
  78. # ------------------------------------------------------------
  79. .PHONY: all
  80. all: $(LIBTRTS) | $(BUILD_DIR)
  81. $(CP) $< $|
  82. $(LIBTRTS): $(TRTS_OBJS) $(TINST_OBJS) $(LOWLIB_OBJS) $(TLS_OBJS) $(TLDR_OBJS) $(SC_OBJ)
  83. $(AR) rcsD $@ $(TRTS_OBJS) $(TINST_OBJS) $(LOWLIB_OBJS) $(TLS_OBJS) $(TLDR_OBJS) $(SC_OBJ)
  84. # ------------------------------------------------------------
  85. $(TRTS_OBJS): CPPFLAGS += -I$(COMMON_DIR)/inc/tlibc \
  86. -I$(SIM_DIR)/tinst/
  87. # Explicitly disable optimization for tRTS simulation library,
  88. # since the '_SE3' function has assumptions on stack layout.
  89. # c.f. ../../tinst/Makefile
  90. $(TINST_OBJS): CPPFLAGS += -I$(SIM_DIR)/assembly/ \
  91. -I$(SIM_DIR)/assembly/linux \
  92. -I$(SIM_DIR)/uinst/ \
  93. -I$(LINUX_SDK_DIR)/selib/ \
  94. -O0
  95. $(TLS_OBJS): CPPFLAGS += -I$(SIM_DIR)/assembly/ \
  96. -I$(SIM_DIR)/assembly/linux \
  97. -I$(SIM_DIR)/uinst/
  98. $(TLDR_C_OBJS): CPPFLAGS += -I$(COMMON_DIR)/inc/internal/linux/ \
  99. -I$(SIM_DIR)/assembly/
  100. $(TLDR_ASM_OBJS): ASFLAGS += -I$(SIM_DIR)/assembly/
  101. $(SC_OBJ): ASFLAGS += -I$(LINUX_SDK_DIR)/cpprt/linux/libunwind/src/$(ARCH) -DISE=1
  102. $(BUILD_DIR):
  103. $(MKDIR) $@
  104. .PHONY: clean
  105. clean:
  106. @$(RM) *.o $(LIBTRTS) $(BUILD_DIR)/$(LIBTRTS)
  107. .PHONY: rebuild
  108. rebuild: clean all