Makefile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. OS ?= $(shell uname -s)
  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.14
  10. LINUX_KERNEL := $(LINUX_SRC)/arch/x86/boot/bzImage
  11. endif
  12. DIRS = src test regression
  13. all debug clean:
  14. for d in $(DIRS); \
  15. do \
  16. $(MAKE) -C $$d $@; \
  17. done
  18. .PHONY: kernel
  19. kernel: $(LINUX_KERNEL)
  20. ifneq ($(LINUX_KERNEL),)
  21. $(LINUX_KERNEL): $(LINUX_SRC)/Makefile $(LINUX_SRC)/graphene $(LINUX_SRC)/.config
  22. $(MAKE) -C $(LINUX_SRC) -j$(NPROCS)
  23. $(LINUX_SRC)/Makefile:
  24. [ -f $(LINUX_SRC).tar.gz ] || \
  25. wget https://www.kernel.org/pub/linux/kernel/v$(LINUX_GEN)/$(LINUX_SRC).tar.gz
  26. tar -xzf $(LINUX_SRC).tar.gz
  27. cd $(LINUX_SRC) && patch -p1 < ../$(LINUX_SRC).patch
  28. $(LINUX_SRC)/graphene: linux-kernel/graphene
  29. cd $(LINUX_SRC) && ln -s ../linux-kernel/graphene graphene
  30. $(LINUX_SRC)/.config: $(LINUX_SRC)/Makefile
  31. cd $(LINUX_SRC) && make menuconfig
  32. install: $(LINUX_KERNEL)
  33. $(MAKE) -C $(LINUX_SRC) install modules_install headers_install
  34. linux-deb:
  35. if [ ! -f $(LINUX_SRC)/.config ]; then \
  36. cp /boot/config-$(shell uname -r) $(LINUX_SRC)/.config && \
  37. cd $(LINUX_SRC) && $(MAKE) menuconfig; fi
  38. cd $(LINUX_SRC) && \
  39. CONCURRENCY_LEVEL=$(NPROCS) make-kpkg --rootcmd fakeroot \
  40. --append-to-version -graphene --initrd \
  41. kernel_image kernel_debug kernel_headers
  42. else
  43. install:
  44. endif
  45. .PHONY: test
  46. test:
  47. $(MAKE) -C test test
  48. .PHONY: pack
  49. pack:
  50. $(MAKE) -C test pack
  51. $(MAKE) -C regression pack