Makefile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. LINUX_GEN = 3.x
  2. LINUX_SRC = linux-3.14
  3. SRC_DIR = src
  4. TEST_DIR = test
  5. DIRS = ${SRC_DIR} ${TEST_DIR} $(LINUX_SRC)
  6. NPROCS := 1
  7. OS := $(shell uname -s)
  8. ifeq ($(OS),Linux)
  9. NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
  10. endif
  11. all debug:
  12. for d in ${SRC_DIR} $(TEST_DIR); \
  13. do \
  14. make -C $$d $@; \
  15. done
  16. make $(LINUX_SRC)/arch/x86/boot/bzImage
  17. $(LINUX_SRC)/arch/x86/boot/bzImage: $(LINUX_SRC)/Makefile $(LINUX_SRC)/.config
  18. make -C $(LINUX_SRC) -j$(NPROCS)
  19. install: $(LINUX_SRC)/arch/x86/boot/bzImage
  20. make -C $(LINUX_SRC) install modules_install headers_install
  21. .PHONY: test
  22. test:
  23. make -C test test
  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. [ ! -f $(LINUX_SRC).patch ] || git apply $(LINUX_SRC).patch
  29. $(LINUX_SRC)/.config:
  30. $(error "Configure the Linux kernel source and rerun the make command; Or run 'make linux-deb' to build a Linux kernel package")
  31. linux-deb:
  32. [ -f $(LINUX_SRC)/.config ] || \
  33. (cp /boot/config-$(shell uname -r) $(LINUX_SRC)/.config && \
  34. cd $(LINUX_SRC) && make menuconfig)
  35. cd $(LINUX_SRC) && \
  36. CONCURRENCY_LEVEL=$(NPROCS) make-kpkg --rootcmd fakeroot \
  37. --append-to-version -graphene --initrd \
  38. kernel-image kernel-headers
  39. clean:
  40. for d in ${SRC_DIR} $(TEST_DIR) $(LINUX_SRC); \
  41. do \
  42. make -C $$d clean; \
  43. done