Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. include ../../Makefile.configs
  2. include ../../Makefile.rules
  3. include ../src/Makefile.Host
  4. CFLAGS = -Wall -fPIC -O2 -std=gnu99 -fgnu89-inline -U_FORTIFY_SOURCE \
  5. $(call cc-option,-Wnull-dereference) \
  6. -fno-omit-frame-pointer \
  7. -fno-stack-protector -fno-builtin
  8. ARFLAGS =
  9. include ../src/host/$(PAL_HOST)/Makefile.am
  10. CFLAGS += -I. -I../include -I../src
  11. # Include host_endian.h from either the host-specific directory,
  12. # or directly under the target directory.
  13. ifeq ($(target),)
  14. CFLAGS += -I../src/host/$(PAL_HOST)
  15. else
  16. CFLAGS += -I$(target)
  17. endif
  18. subdirs = string stdlib network graphene crypto
  19. # Choose Crypto provider among (mbedtls|wolfssl)
  20. CRYPTO_PROVIDER ?= mbedtls
  21. # Select which crypto adpater you want to use here. This has to match
  22. # the #define in pal_crypto.h.
  23. #
  24. # Unfortunately, we cannot use just one .c file for the adapter. The LibOS
  25. # shim links against the crypto library, but it doesn't use Diffie-Hellman.
  26. # If the Diffie-Hellman stubs are in the same .o file as the SHA1 stubs,
  27. # this pulls Diffie-Hellman code into LibOS shim, resulting in unsatisfied
  28. # symbols.
  29. ifeq ($(CRYPTO_PROVIDER),mbedtls)
  30. subdirs += crypto/mbedtls
  31. crypto_mbedtls_objs = $(addsuffix .o,aes aesni asn1parse base64 bignum cipher cipher_wrap cmac dhm md md_wrap oid rsa sha256)
  32. endif
  33. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  34. subdirs += crypto/wolfssl
  35. crypto_wolfssl_objs = $(addsuffix .o,$(patsubst %.c,%.o,$(sort $(wildcard crypto/wolfssl/*.c))))
  36. endif
  37. string_objs = $(addsuffix .o,atoi memcmp memcpy memset strchr strendswith strlen wordcopy)
  38. stdlib_objs = $(addsuffix .o,printfmt)
  39. network_objs = $(addsuffix .o,hton inet_pton)
  40. graphene_objs = $(addsuffix .o,config path)
  41. crypto_objs = $(addsuffix .o,udivmodti4)
  42. objs += $(foreach dir,$(subdirs),$(addprefix $(dir)/,$($(subst /,_,$(dir))_objs)))
  43. ifeq ($(CRYPTO_PROVIDER),mbedtls)
  44. CFLAGS += -DCRYPTO_USE_MBEDTLS
  45. objs += crypto/adapters/mbedtls_adapter.o
  46. objs += crypto/adapters/mbedtls_dh.o
  47. objs += crypto/adapters/mbedtls_encoding.o
  48. endif
  49. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  50. CFLAGS += -DCRYPTO_USE_WOLFSSL
  51. objs += crypto/adapters/wolfssl_adapter.o
  52. objs += crypto/adapters/wolfssl_dh.o
  53. endif
  54. .PHONY: all
  55. all: $(target)graphene-lib.a
  56. ifeq ($(DEBUG),1)
  57. CC += -g
  58. CFLAGS += -DDEBUG
  59. endif
  60. $(target)graphene-lib.a: $(addprefix $(target),$(objs))
  61. @mkdir -p $(dir $@)
  62. $(call cmd,ar_a_o)
  63. $(target)%.o: %.c
  64. @mkdir -p $(dir $@)
  65. $(call cmd,cc_o_c)
  66. -include $(patsubst %.o,%.d,$(addprefix $(target),$(objs)))
  67. .PHONY: clean
  68. clean:
  69. rm -f $(objs) graphene-lib.a