Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. endif
  41. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  42. CFLAGS += -DCRYPTO_USE_WOLFSSL
  43. objs += crypto/adapters/wolfssl_adapter.o
  44. objs += crypto/adapters/wolfssl_dh.o
  45. endif
  46. .PHONY: all
  47. all: $(target)graphene-lib.a
  48. ifeq ($(DEBUG),1)
  49. CC += -g
  50. CFLAGS += -DDEBUG
  51. endif
  52. $(target)graphene-lib.a: $(addprefix $(target),$(objs))
  53. @mkdir -p $(dir $@)
  54. $(call cmd,ar_a_o)
  55. $(target)%.o: %.c
  56. @mkdir -p $(dir $@)
  57. $(call cmd,cc_o_c)
  58. -include $(patsubst %.o,%.d,$(addprefix $(target),$(objs)))
  59. .PHONY: clean
  60. clean:
  61. rm -f $(objs) graphene-lib.a