Makefile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. include ../src/Makefile.Host
  2. CC = gcc
  3. AR = ar rcs
  4. CFLAGS = -Wall -fPIC -O2 -std=gnu99 -fgnu89-inline -U_FORTIFY_SOURCE \
  5. -fno-omit-frame-pointer \
  6. -fno-stack-protector -fno-builtin
  7. ARFLAGS =
  8. include ../src/host/$(PAL_HOST)/Makefile.am
  9. CFLAGS += -I. -I../include -I../src
  10. subdirs = string stdlib network graphene util crypto
  11. headers = api.h pal_crypto.h
  12. # Choose Crypto provider among (mbedtls|wolfssl)
  13. CRYPTO_PROVIDER ?= mbedtls
  14. # Select which crypto adpater you want to use here. This has to match
  15. # the #define in pal_crypto.h.
  16. #
  17. # Unfortunately, we cannot use just one .c file for the adapter. The LibOS
  18. # shim links against the crypto library, but it doesn't use Diffie-Hellman.
  19. # If the Diffie-Hellman stubs are in the same .o file as the SHA1 stubs,
  20. # this pulls Diffie-Hellman code into LibOS shim, resulting in unsatisfied
  21. # symbols.
  22. ifeq ($(CRYPTO_PROVIDER),mbedtls)
  23. subdirs += crypto/mbedtls
  24. headers += $(wildcard crypto/mbedtls/mbedtls/*.h)
  25. endif
  26. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  27. subdirs += crypto/wolfssl
  28. headers += $(wildcard crypto/wolfssl/*.h)
  29. endif
  30. objs = $(foreach dir,$(subdirs),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c)))
  31. ifeq ($(CRYPTO_PROVIDER),mbedtls)
  32. CFLAGS += -DCRYPTO_USE_MBEDTLS
  33. objs += crypto/adapters/mbedtls_adapter.o
  34. objs += crypto/adapters/mbedtls_dh.o
  35. endif
  36. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  37. CFLAGS += -DCRYPTO_USE_WOLFSSL
  38. objs += crypto/adapters/wolfssl_adapter.o
  39. objs += crypto/adapters/wolfssl_dh.o
  40. endif
  41. all: $(target)graphene-lib.a
  42. ifeq ($(DEBUG),1)
  43. CC += -g
  44. CFLAGS += -DDEBUG
  45. endif
  46. $(target)graphene-lib.a: $(addprefix $(target),$(objs))
  47. @echo [ $(notdir $@) ]
  48. @mkdir -p $(dir $@)
  49. @$(AR) $(ARFLAGS) $@ $^
  50. ../src/host_endian.h:
  51. @$(MAKE) -C ../src host_endian.h
  52. $(target)%.o: %.c $(headers) ../src/host_endian.h
  53. @echo [ $(notdir $@) ]
  54. @mkdir -p $(dir $@)
  55. @$(CC) $(CFLAGS) -c $< -o $@
  56. clean:
  57. rm -f $(objs) graphene-lib.a