buildenv.mk 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. ENV := $(strip $(wildcard $(TOP_DIR)/buildenv.mk))
  32. ifeq ($(ENV),)
  33. $(error "Can't find $(TOP_DIR)/buildenv.mk")
  34. endif
  35. include $(TOP_DIR)/buildenv.mk
  36. WORK_DIR := $(shell pwd)
  37. AENAME := $(notdir $(WORK_DIR))
  38. SONAME := $(AENAME).so
  39. ifdef DEBUG
  40. CONFIG := config_debug.xml
  41. else
  42. CONFIG := config.xml
  43. endif
  44. EDLFILE := $(wildcard *.edl)
  45. LINUX_EPID := $(LINUX_EXTERNAL_DIR)/epid/lib/linux
  46. EXTERNAL_LIB_NO_CRYPTO = -lsgx_tstdc
  47. URTSLIB := -lsgx_urts
  48. TRTSLIB := -lsgx_trts
  49. EXTERNAL_LIB_NO_CRYPTO += -lsgx_tservice
  50. TCRYPTO_LIBDIR := $(LINUX_SDK_DIR)/tlibcrypto
  51. EXTERNAL_LIB = $(EXTERNAL_LIB_NO_CRYPTO) -L$(TCRYPTO_LIBDIR) -lsgx_tcrypto
  52. INCLUDE := -I$(LINUX_PSW_DIR)/ae/inc \
  53. -I$(COMMON_DIR)/inc \
  54. -I$(COMMON_DIR)/inc/tlibc \
  55. -I$(COMMON_DIR)/inc/internal \
  56. -I$(LINUX_SDK_DIR)/selib \
  57. -I$(LINUX_SDK_DIR)/trts
  58. SIGNTOOL := $(ROOT_DIR)/build/linux/sgx_sign
  59. SGXSIGN := $(ROOT_DIR)/build/linux/sgx_sign
  60. KEYFILE := $(LINUX_SDK_DIR)/sign_tool/sample_sec.pem
  61. EDGER8R := $(LINUX_SDK_DIR)/edger8r/linux/_build/Edger8r.native
  62. CXXFLAGS += $(ENCLAVE_CXXFLAGS)
  63. CFLAGS += $(ENCLAVE_CFLAGS)
  64. LDTFLAGS = -L$(BUILD_DIR) -Wl,--whole-archive $(TRTSLIB) -Wl,--no-whole-archive \
  65. -Wl,--start-group $(EXTERNAL_LIB) -Wl,--end-group \
  66. -Wl,--version-script=$(ROOT_DIR)/build-scripts/enclave.lds $(ENCLAVE_LDFLAGS)
  67. LDTFLAGS_NO_CRYPTO = -L$(BUILD_DIR) -Wl,--whole-archive $(TRTSLIB) -Wl,--no-whole-archive \
  68. -Wl,--start-group $(EXTERNAL_LIB_NO_CRYPTO) -Wl,--end-group \
  69. -Wl,--version-script=$(ROOT_DIR)/build-scripts/enclave.lds $(ENCLAVE_LDFLAGS)
  70. LDTFLAGS += -fuse-ld=gold -Wl,--rosegment -Wl,-Map=out.map -Wl,--undefined=version -Wl,--gc-sections
  71. LDTFLAGS_NO_CRYPTO += -fuse-ld=gold -Wl,--rosegment -Wl,-Map=out.map -Wl,--undefined=version -Wl,--gc-sections
  72. DEFINES := -D__linux__
  73. vpath %.cpp $(COMMON_DIR)/src:$(LINUX_PSW_DIR)/ae/common
  74. .PHONY : version
  75. version.o: $(LINUX_PSW_DIR)/ae/common/version.cpp
  76. $(CXX) $(CXXFLAGS) -fno-exceptions -fno-rtti $(INCLUDE) $(DEFINES) -c $(LINUX_PSW_DIR)/ae/common/version.cpp -o $@