Makefile 2.1 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 crypto
  19. CRYPTO_PROVIDER ?= mbedtls
  20. # Select which crypto adpater you want to use here. This has to match
  21. # the #define in pal_crypto.h.
  22. #
  23. # Unfortunately, we cannot use just one .c file for the adapter. The LibOS
  24. # shim links against the crypto library, but it doesn't use Diffie-Hellman.
  25. # If the Diffie-Hellman stubs are in the same .o file as the SHA1 stubs,
  26. # this pulls Diffie-Hellman code into LibOS shim, resulting in unsatisfied
  27. # symbols.
  28. ifeq ($(CRYPTO_PROVIDER),mbedtls)
  29. subdirs += crypto/mbedtls
  30. crypto_mbedtls_objs = $(addsuffix .o,aes aesni asn1parse base64 bignum cipher cipher_wrap cmac dhm md md_wrap oid rsa sha256)
  31. endif
  32. string_objs = $(addsuffix .o,atoi memcmp memcpy memset strchr strendswith strlen wordcopy)
  33. stdlib_objs = $(addsuffix .o,printfmt)
  34. network_objs = $(addsuffix .o,hton inet_pton)
  35. graphene_objs = $(addsuffix .o,config path)
  36. crypto_objs = $(addsuffix .o,udivmodti4)
  37. objs += $(foreach dir,$(subdirs),$(addprefix $(dir)/,$($(subst /,_,$(dir))_objs)))
  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. objs += crypto/adapters/mbedtls_encoding.o
  43. endif
  44. .PHONY: all
  45. all: $(target)graphene-lib.a
  46. ifeq ($(DEBUG),1)
  47. CC += -g
  48. CFLAGS += -DDEBUG
  49. endif
  50. $(target)graphene-lib.a: $(addprefix $(target),$(objs))
  51. @mkdir -p $(dir $@)
  52. $(call cmd,ar_a_o)
  53. $(target)%.o: %.c
  54. @mkdir -p $(dir $@)
  55. $(call cmd,cc_o_c)
  56. ifeq ($(filter clean,$(MAKECMDGOALS)),)
  57. -include $(patsubst %.o,%.d,$(addprefix $(target),$(objs)))
  58. endif
  59. .PHONY: clean
  60. clean:
  61. rm -f $(objs) graphene-lib.a