Files
graphene/Pal/lib/Makefile
Isaku Yamahata cdff566051 [Pal/Linux] enable stack protector
enable stack protector for Pal/Linux.
for other Pal, enabling stack protector results in error.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-07-24 17:46:28 -07:00

83 lines
2.2 KiB
Makefile

include ../../Makefile.configs
include ../../Makefile.rules
include ../src/Makefile.Host
CFLAGS = -Wall -fPIC -O2 -std=gnu99 -fgnu89-inline -U_FORTIFY_SOURCE \
$(call cc-option,-Wnull-dereference) \
-fno-omit-frame-pointer \
-fno-stack-protector -fno-builtin
ARFLAGS =
include ../src/host/$(PAL_HOST)/Makefile.am
CFLAGS += -I. -I../include -I../src
# TODO: enable stack protector pal/lib. security/Linux/libpal_sec.so is blocker.
# Makefile.am overwrites CFLAGS. defining CFLAGS before Makefile.am
# may not have effects.
CFLAGS += -fno-stack-protector
# Include host_endian.h from either the host-specific directory,
# or directly under the target directory.
ifeq ($(target),)
CFLAGS += -I../src/host/$(PAL_HOST)
else
CFLAGS += -I$(target)
endif
subdirs = string stdlib network graphene util crypto
headers = api.h pal_crypto.h
# Choose Crypto provider among (mbedtls|wolfssl)
CRYPTO_PROVIDER ?= mbedtls
# Select which crypto adpater you want to use here. This has to match
# the #define in pal_crypto.h.
#
# Unfortunately, we cannot use just one .c file for the adapter. The LibOS
# shim links against the crypto library, but it doesn't use Diffie-Hellman.
# If the Diffie-Hellman stubs are in the same .o file as the SHA1 stubs,
# this pulls Diffie-Hellman code into LibOS shim, resulting in unsatisfied
# symbols.
ifeq ($(CRYPTO_PROVIDER),mbedtls)
subdirs += crypto/mbedtls
headers += $(wildcard crypto/mbedtls/mbedtls/*.h)
endif
ifeq ($(CRYPTO_PROVIDER),wolfssl)
subdirs += crypto/wolfssl
headers += $(wildcard crypto/wolfssl/*.h)
endif
objs = $(foreach dir,$(subdirs),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c)))
ifeq ($(CRYPTO_PROVIDER),mbedtls)
CFLAGS += -DCRYPTO_USE_MBEDTLS
objs += crypto/adapters/mbedtls_adapter.o
objs += crypto/adapters/mbedtls_dh.o
endif
ifeq ($(CRYPTO_PROVIDER),wolfssl)
CFLAGS += -DCRYPTO_USE_WOLFSSL
objs += crypto/adapters/wolfssl_adapter.o
objs += crypto/adapters/wolfssl_dh.o
endif
.PHONY: all
all: $(target)graphene-lib.a
ifeq ($(DEBUG),1)
CC += -g
CFLAGS += -DDEBUG
endif
$(target)graphene-lib.a: $(addprefix $(target),$(objs))
@mkdir -p $(dir $@)
$(call cmd,ar_a_o)
$(target)%.o: %.c $(headers)
@mkdir -p $(dir $@)
$(call cmd,cc_o_c)
.PHONY: clean
clean:
rm -f $(objs) graphene-lib.a