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. # 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. endif
  32. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  33. subdirs += crypto/wolfssl
  34. endif
  35. objs = $(foreach dir,$(subdirs),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c)))
  36. ifeq ($(CRYPTO_PROVIDER),mbedtls)
  37. CFLAGS += -DCRYPTO_USE_MBEDTLS
  38. objs += crypto/adapters/mbedtls_adapter.o
  39. objs += crypto/adapters/mbedtls_dh.o
  40. objs += crypto/adapters/mbedtls_encoding.o
  41. endif
  42. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  43. CFLAGS += -DCRYPTO_USE_WOLFSSL
  44. objs += crypto/adapters/wolfssl_adapter.o
  45. objs += crypto/adapters/wolfssl_dh.o
  46. endif
  47. .PHONY: all
  48. all: $(target)graphene-lib.a
  49. ifeq ($(DEBUG),1)
  50. CC += -g
  51. CFLAGS += -DDEBUG
  52. endif
  53. $(target)graphene-lib.a: $(addprefix $(target),$(objs))
  54. @mkdir -p $(dir $@)
  55. $(call cmd,ar_a_o)
  56. $(target)%.o: %.c
  57. @mkdir -p $(dir $@)
  58. $(call cmd,cc_o_c)
  59. -include $(patsubst %.o,%.d,$(addprefix $(target),$(objs)))
  60. .PHONY: clean
  61. clean:
  62. rm -f $(objs) graphene-lib.a