Makefile 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 util crypto
  19. headers = api.h pal_crypto.h
  20. # Choose Crypto provider among (mbedtls|wolfssl)
  21. CRYPTO_PROVIDER ?= mbedtls
  22. # Select which crypto adpater you want to use here. This has to match
  23. # the #define in pal_crypto.h.
  24. #
  25. # Unfortunately, we cannot use just one .c file for the adapter. The LibOS
  26. # shim links against the crypto library, but it doesn't use Diffie-Hellman.
  27. # If the Diffie-Hellman stubs are in the same .o file as the SHA1 stubs,
  28. # this pulls Diffie-Hellman code into LibOS shim, resulting in unsatisfied
  29. # symbols.
  30. ifeq ($(CRYPTO_PROVIDER),mbedtls)
  31. subdirs += crypto/mbedtls
  32. headers += $(wildcard crypto/mbedtls/mbedtls/*.h)
  33. endif
  34. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  35. subdirs += crypto/wolfssl
  36. headers += $(wildcard crypto/wolfssl/*.h)
  37. endif
  38. objs = $(foreach dir,$(subdirs),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c)))
  39. ifeq ($(CRYPTO_PROVIDER),mbedtls)
  40. CFLAGS += -DCRYPTO_USE_MBEDTLS
  41. objs += crypto/adapters/mbedtls_adapter.o
  42. objs += crypto/adapters/mbedtls_dh.o
  43. endif
  44. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  45. CFLAGS += -DCRYPTO_USE_WOLFSSL
  46. objs += crypto/adapters/wolfssl_adapter.o
  47. objs += crypto/adapters/wolfssl_dh.o
  48. endif
  49. .PHONY: all
  50. all: $(target)graphene-lib.a
  51. ifeq ($(DEBUG),1)
  52. CC += -g
  53. CFLAGS += -DDEBUG
  54. endif
  55. $(target)graphene-lib.a: $(addprefix $(target),$(objs))
  56. @mkdir -p $(dir $@)
  57. $(call cmd,ar_a_o)
  58. $(target)%.o: %.c $(headers)
  59. @mkdir -p $(dir $@)
  60. $(call cmd,cc_o_c)
  61. .PHONY: clean
  62. clean:
  63. rm -f $(objs) graphene-lib.a