Makefile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. # Include host_endian.h from either the host-specific directory,
  11. # or directly under the target directory.
  12. ifeq ($(target),)
  13. CFLAGS += -I../src/host/$(PAL_HOST)
  14. else
  15. CFLAGS += -I$(target)
  16. endif
  17. subdirs = string stdlib network graphene util crypto
  18. headers = api.h pal_crypto.h
  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. headers += $(wildcard crypto/mbedtls/mbedtls/*.h)
  32. endif
  33. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  34. subdirs += crypto/wolfssl
  35. headers += $(wildcard crypto/wolfssl/*.h)
  36. endif
  37. objs = $(foreach dir,$(subdirs),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c)))
  38. ifeq ($(CRYPTO_PROVIDER),mbedtls)
  39. CFLAGS += -DCRYPTO_USE_MBEDTLS
  40. objs += crypto/adapters/mbedtls_adapter.o
  41. objs += crypto/adapters/mbedtls_dh.o
  42. endif
  43. ifeq ($(CRYPTO_PROVIDER),wolfssl)
  44. CFLAGS += -DCRYPTO_USE_WOLFSSL
  45. objs += crypto/adapters/wolfssl_adapter.o
  46. objs += crypto/adapters/wolfssl_dh.o
  47. endif
  48. .PHONY: all
  49. all: $(target)graphene-lib.a
  50. ifeq ($(DEBUG),1)
  51. CC += -g
  52. CFLAGS += -DDEBUG
  53. endif
  54. $(target)graphene-lib.a: $(addprefix $(target),$(objs))
  55. @echo [ $(notdir $@) ]
  56. @mkdir -p $(dir $@)
  57. @$(AR) $(ARFLAGS) $@ $^
  58. $(target)%.o: %.c $(headers)
  59. @echo [ $(notdir $@) ]
  60. @mkdir -p $(dir $@)
  61. @$(CC) $(CFLAGS) -c $< -o $@
  62. .PHONY: clean
  63. clean:
  64. rm -f $(objs) graphene-lib.a