Makefile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. include src/Makefile.Host
  2. ifeq ($(OS),Linux)
  3. NPROCS ?= $(shell grep -c ^processor /proc/cpuinfo)
  4. else
  5. NPROCS ?= 1
  6. endif
  7. ifeq ($(OS),Linux)
  8. LINUX_GEN := 3.x
  9. LINUX_SRC := linux-3.19
  10. LINUX_KERNEL := $(LINUX_SRC)/arch/x86/boot/bzImage
  11. endif
  12. DIRS = src test regression
  13. .PHONY: all clean
  14. all clean:
  15. for d in $(DIRS); \
  16. do \
  17. $(MAKE) -C $$d $@ || exit $?; \
  18. done
  19. .PHONY: linux-kernel
  20. linux-kernel: $(LINUX_KERNEL)
  21. ifneq ($(LINUX_KERNEL),)
  22. $(LINUX_KERNEL): $(LINUX_SRC)/Makefile $(LINUX_SRC)/graphene $(LINUX_SRC)/.config
  23. $(MAKE) -C $(LINUX_SRC) -j$(NPROCS)
  24. $(LINUX_SRC)/Makefile:
  25. [ -f $(LINUX_SRC).tar.gz ] || \
  26. wget https://www.kernel.org/pub/linux/kernel/v$(LINUX_GEN)/$(LINUX_SRC).tar.gz
  27. tar -xzf $(LINUX_SRC).tar.gz
  28. cd $(LINUX_SRC) && patch -p1 < ../$(LINUX_SRC).patch
  29. $(LINUX_SRC)/graphene: linux-kernel/graphene
  30. cd $(LINUX_SRC) && ln -s ../linux-kernel/graphene graphene
  31. $(LINUX_SRC)/.config: $(LINUX_SRC)/Makefile
  32. cd $(LINUX_SRC) && make menuconfig
  33. kernel_install: kernel
  34. $(MAKE) -C $(LINUX_SRC) install modules_install headers_install
  35. linux-deb:
  36. if [ ! -f $(LINUX_SRC)/.config ]; then \
  37. cp /boot/config-$(shell uname -r) $(LINUX_SRC)/.config && \
  38. cd $(LINUX_SRC) && $(MAKE) menuconfig; fi
  39. cd $(LINUX_SRC) && \
  40. CONCURRENCY_LEVEL=$(NPROCS) make-kpkg --rootcmd fakeroot \
  41. --append-to-version -graphene --initrd \
  42. kernel_image kernel_headers $(if $(DEBUG),kernel_debug,)
  43. else
  44. kernel_install:
  45. endif
  46. .PHONY: test
  47. test:
  48. $(MAKE) -C test test
  49. .PHONY: format
  50. format:
  51. clang-format -i $(shell find . -path ./linux-kernel -prune -o \
  52. -path ./lib/crypto/mbedtls -prune -o \
  53. -path ./lib/crypto/udivmodti4.c -prune -o \
  54. -path ./src/host/Linux-SGX/sgx-driver -prune -o \
  55. -path ./src/security/Linux/bpf-helper.h -prune -o \
  56. -path ./src/security/Linux/bpf_helper.c -prune -o \
  57. \( -name '*.h' -o -name '*.c' \) -print)
  58. .PHONY: pack
  59. pack:
  60. $(MAKE) -C test pack
  61. $(MAKE) -C regression pack