Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. INCLUDES := -I.. \
  34. -I$(COMMON_DIR)/inc \
  35. -I$(COMMON_DIR)/inc/internal \
  36. -I$(LINUX_SDK_DIR)/tseal \
  37. -I$(LINUX_SDK_DIR)/simulation/tinst \
  38. -I$(LINUX_SDK_DIR)/simulation/urtssim \
  39. -I$(SGX_IPP_INC) \
  40. -I$(LINUX_EXTERNAL_DIR)/epid \
  41. -I$(LINUX_EXTERNAL_DIR)/rdrand/ \
  42. -I$(LINUX_PSW_DIR)/ae/inc \
  43. -I$(LINUX_PSW_DIR)/ae/inc/internal \
  44. -I$(LINUX_PSW_DIR)/ae/common
  45. CXXFLAGS += -Wall -fPIC $(INCLUDES) -Werror -g
  46. CFLAGS := $(filter-out -fPIC -Werror, $(CFLAGS)) -Wall $(INCLUDES)
  47. VERSION_SCRIPT = $(shell pwd)/uae_service_sim.linux.version
  48. LD_OPT_WITHVER = -Wl,--version-script=$(VERSION_SCRIPT)
  49. RDRAND_LIBDIR := $(LINUX_EXTERNAL_DIR)/rdrand/src
  50. RDRAND_MAKEFILE := $(RDRAND_LIBDIR)/Makefile
  51. EXTERNAL_LIB += -L$(IPP_LIBS_DIR) $(LD_IPP)
  52. EXTERNAL_LIB += -L$(RDRAND_LIBDIR) -lrdrand
  53. EXTERNAL_LIB += -L$(RDRAND_LIBDIR) -lrt
  54. EXTERNAL_LIB += -ldl
  55. vpath %.cpp $(LINUX_PSW_DIR)/ae/common \
  56. $(LINUX_SDK_DIR)/simulation/urtssim \
  57. $(COMMON_DIR)/src
  58. vpath %.c $(COMMON_DIR)/src
  59. CPP_SRC := $(wildcard *.cpp ../*.cpp) se_sig_rl.cpp cpusvn_util.cpp sgx_read_rand.cpp
  60. C_SRC := se_trace.c se_thread.c
  61. OBJ := $(CPP_SRC:.cpp=.o) \
  62. $(C_SRC:.c=.o)
  63. DLLNAME = libsgx_uae_service_sim.so
  64. DLLNAME_DEBUG = libsgx_uae_service_sim.so.debug
  65. LIBUAE_SERVICE_DEPLOY := libsgx_uae_service_deploy.so
  66. .PHONY: all
  67. all: $(DLLNAME) $(DLLNAME_DEBUG) $(LIBUAE_SERVICE_DEPLOY) | $(BUILD_DIR)
  68. $(CP) $(DLLNAME) $|
  69. $(CP) $(LIBUAE_SERVICE_DEPLOY) $|
  70. ifndef DEBUG
  71. $(CP) $(DLLNAME_DEBUG) $|
  72. endif
  73. ifneq ($(USE_OPT_LIBS), 0)
  74. $(DLLNAME): $(OBJ) -lrdrand
  75. $(CXX) $(CXXFLAGS) $(OBJ) -shared $(EXTERNAL_LIB) -o $@ $(LD_OPT_WITHVER)
  76. else
  77. -lcrypto_px:
  78. $(MAKE) -C $(IPP_LIBS_DIR)
  79. $(DLLNAME): $(OBJ) -lrdrand -lcrypto_px
  80. $(CXX) $(CXXFLAGS) $(OBJ) -shared $(EXTERNAL_LIB) -o $@ $(LD_OPT_WITHVER)
  81. endif
  82. $(DLLNAME_DEBUG): $(DLLNAME)
  83. ifndef DEBUG
  84. $(CP) $(DLLNAME) $(DLLNAME).orig
  85. $(OBJCOPY) --only-keep-debug $(DLLNAME) $(DLLNAME_DEBUG)
  86. $(STRIP) -g $(DLLNAME)
  87. $(OBJCOPY) --add-gnu-debuglink=$(DLLNAME_DEBUG) $(DLLNAME)
  88. endif
  89. %.o: %.c
  90. $(CC) $(CFLAGS) -Werror -fPIC -c $< -o $@
  91. %.o: %.cpp
  92. $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
  93. -lrdrand: $(RDRAND_MAKEFILE)
  94. $(MAKE) -C $(RDRAND_LIBDIR)
  95. $(RDRAND_MAKEFILE):
  96. ifeq ($(ARCH), x86)
  97. @cd $(RDRAND_LIBDIR);./configure
  98. else
  99. @cd $(RDRAND_LIBDIR);./configure CFLAGS=-fPIC
  100. endif
  101. $(LIBUAE_SERVICE_DEPLOY): ../uae_service_deploy.c
  102. $(CC) -fPIC -shared -Wl,-soname=libsgx_uae_service.so $< -o $@
  103. $(BUILD_DIR):
  104. @$(MKDIR) $@
  105. .PHONY: clean
  106. clean:
  107. @$(RM) *.o
  108. @$(RM) ../*.o $(DLLNAME).orig
  109. @$(RM) $(DLLNAME) $(BUILD_DIR)/$(DLLNAME)
  110. @$(RM) $(DLLNAME_DEBUG) $(BUILD_DIR)/$(DLLNAME_DEBUG)
  111. @$(RM) $(LIBUAE_SERVICE_DEPLOY) $(BUILD_DIR)/$(LIBUAE_SERVICE_DEPLOY)
  112. ifeq ($(USE_OPT_LIBS), 0)
  113. @$(MAKE) -C $(IPP_LIBS_DIR) clean
  114. endif
  115. ifeq ($(RDRAND_MAKEFILE), $(wildcard $(RDRAND_MAKEFILE)))
  116. @$(MAKE) distclean -C $(RDRAND_LIBDIR)
  117. endif
  118. .PHONY: rebuild
  119. rebuild:
  120. $(MAKE) clean
  121. $(MAKE) all