Makefile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. .PHONY: all
  42. all: $(target)graphene-lib.a
  43. ifeq ($(DEBUG),1)
  44. CC += -g
  45. CFLAGS += -DDEBUG
  46. endif
  47. $(target)graphene-lib.a: $(addprefix $(target),$(objs))
  48. @echo [ $(notdir $@) ]
  49. @mkdir -p $(dir $@)
  50. @$(AR) $(ARFLAGS) $@ $^
  51. ../src/host_endian.h:
  52. @$(MAKE) -C ../src host_endian.h
  53. $(target)%.o: %.c $(headers) ../src/host_endian.h
  54. @echo [ $(notdir $@) ]
  55. @mkdir -p $(dir $@)
  56. @$(CC) $(CFLAGS) -c $< -o $@
  57. .PHONY: clean
  58. clean:
  59. rm -f $(objs) graphene-lib.a