1
0

Makefile 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. include $(ADK_TOPDIR)/rules.mk
  4. include $(ADK_TOPDIR)/mk/rootfs.mk
  5. KERNEL_MODULES_USED:=$(shell grep ^ADK_KERNEL $(ADK_TOPDIR)/.config|grep =m)
  6. all: install
  7. ### Kernel .config Creation
  8. # The following target combines all kernel-related variables and
  9. # config files into a single one to be used as the final kernel
  10. # configuration when building. This is how it's done:
  11. # 1) fetch all enabled ADK_KERNEL_* vars into
  12. # .kernelconfig.kernel
  13. # 2) get the global and device-specific static kernel config and place it into
  14. # .kernelconfig.board
  15. # 3) append $(FS_CMDLINE) to the kernel commandline inside .kernelconfig.board
  16. # 4) merge both together into .kernelconfig.tmp
  17. # 5) check if .kernelconfig.tmp differs from the current one
  18. # (.kernelconfig) at all, overwriting the current one
  19. # only if it does (so the timestamp stays intact)
  20. # 6) remove the temporary .kernelconfig.tmp
  21. ###
  22. ADK_PACKAGE_CRYPTINIT_ROOT:=$(strip $(subst ",, $(ADK_PACKAGE_CRYPTINIT_ROOT)))
  23. ADK_PACKAGE_CRYPTINIT_SWAP:=$(strip $(subst ",, $(ADK_PACKAGE_CRYPTINIT_SWAP)))
  24. ADK_PACKAGE_CMDLINE:=root=$(ADK_PACKAGE_CRYPTINIT_ROOT) swap=$(ADK_PACKAGE_CRYPTINIT_SWAP) resume=/dev/mapper/swapcrypt
  25. ifeq ($(ADK_TARGET_KERNEL_CUSTOMISING),y)
  26. config-prepare: $(ADK_TOPDIR)/.config
  27. @PATH='$(HOST_PATH)' sed -n '/^ADK_KERNEL/s//CONFIG/p' $(ADK_TOPDIR)/.config \
  28. >$(BUILD_DIR)/.kernelconfig.kernel
  29. @if [ -f $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) ];then \
  30. cat $(ADK_TOPDIR)/target/linux/kernel.config \
  31. $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) > $(BUILD_DIR)/.kernelconfig.board; \
  32. else \
  33. echo "no miniconfig found for target system"; \
  34. exit 1; \
  35. fi
  36. ifneq ($(ADK_TARGET_NO_CMDLINE),y)
  37. ifeq ($(ADK_APPLIANCE_KODI),y)
  38. $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 consoleblank=0 vt.global_cursor_default=0"#' \
  39. $(BUILD_DIR)/.kernelconfig.board
  40. endif
  41. ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_VGA_ONLY),y)
  42. $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE)"#' \
  43. $(BUILD_DIR)/.kernelconfig.board
  44. endif
  45. ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_SERIAL_ONLY),y)
  46. $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED)"#' \
  47. $(BUILD_DIR)/.kernelconfig.board
  48. endif
  49. ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_VGA_SERIAL),y)
  50. $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE) console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED)"#' \
  51. $(BUILD_DIR)/.kernelconfig.board
  52. endif
  53. ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_SERIAL_VGA),y)
  54. $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED) console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE)"#' \
  55. $(BUILD_DIR)/.kernelconfig.board
  56. endif
  57. ifeq ($(ADK_TARGET_SYSTEM_QEMU_M68K_Q800)$(ADK_TARGET_SYSTEM_QEMU_M68K_MCF5208),y)
  58. @$(SED) 's#^\(CONFIG_.*BOOTPARAM_STRING="\)\(.*\)"#\1\2 ro $(FS_CMDLINE)"#' \
  59. $(BUILD_DIR)/.kernelconfig.board
  60. endif
  61. ifeq ($(ADK_TARGET_ROOTFS_NFSROOT),)
  62. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ro"#' \
  63. $(BUILD_DIR)/.kernelconfig.board
  64. else
  65. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 rw"#' \
  66. $(BUILD_DIR)/.kernelconfig.board
  67. endif
  68. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(FS_CMDLINE)"#' \
  69. $(BUILD_DIR)/.kernelconfig.board
  70. ifneq ($(ADK_TARGET_CMDLINE),)
  71. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(ADK_TARGET_CMDLINE)"#' \
  72. $(BUILD_DIR)/.kernelconfig.board
  73. endif
  74. ifeq ($(ADK_TARGET_QEMU_WITH_GRAPHIC),y)
  75. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=tty0"#' \
  76. $(BUILD_DIR)/.kernelconfig.board
  77. endif
  78. ifneq ($(ADK_PACKAGE_CRYPTINIT_ROOT),)
  79. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(ADK_PACKAGE_CMDLINE)"#' \
  80. $(BUILD_DIR)/.kernelconfig.board
  81. endif
  82. ifeq ($(ADK_RUNTIME_QUIET_INIT),y)
  83. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 rcquiet=1"#' \
  84. $(BUILD_DIR)/.kernelconfig.board
  85. endif
  86. ifeq ($(ADK_RUNTIME_QUIET_KERNEL),y)
  87. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 quiet loglevel=2 vt.global_cursor_default=0"#' \
  88. $(BUILD_DIR)/.kernelconfig.board
  89. endif
  90. ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
  91. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
  92. $(BUILD_DIR)/.kernelconfig.board
  93. endif
  94. ifeq ($(ADK_KERNEL_NETCONSOLE),y)
  95. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 netconsole=@$(ADK_PARAMETER_NETCONSOLE_SRC_IP)/,@$(ADK_PARAMETER_NETCONSOLE_DST_IP)/"#' \
  96. $(BUILD_DIR)/.kernelconfig.board
  97. endif
  98. endif
  99. @cd $(BUILD_DIR) && cat .kernelconfig.board .kernelconfig.kernel \
  100. >.kernelconfig.tmp
  101. @cd $(BUILD_DIR) && cmp -s .kernelconfig.tmp .kernelconfig || \
  102. cp .kernelconfig.tmp .kernelconfig
  103. @-rm -f $(BUILD_DIR)/.kernelconfig.tmp
  104. else
  105. config-prepare: $(ADK_TOPDIR)/.config
  106. @if [ -f $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) ];then \
  107. cat $(ADK_TOPDIR)/target/linux/kernel.config \
  108. $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) > $(BUILD_DIR)/.kernelconfig.board; \
  109. else \
  110. echo "no miniconfig found for target system"; \
  111. exit 1; \
  112. fi
  113. @cd $(BUILD_DIR) && cmp -s .kernelconfig.board .kernelconfig || \
  114. cp .kernelconfig.board .kernelconfig
  115. endif
  116. prepare: $(ADK_TARGET_ARCH)-prepare
  117. compile: $(ADK_TARGET_ARCH)-compile
  118. image: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-imageinstall
  119. targethelp: $(ADK_TARGET_ARCH)-targethelp
  120. install: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-install $(ADK_TARGET_ARCH)-imageinstall
  121. clean: $(ADK_TARGET_ARCH)-clean $(ADK_TARGET_ARCH)-imageclean
  122. %-clean:
  123. $(START_TRACE) "target/$(patsubst %-clean,%,$@)-clean.. "
  124. $(MAKE) -C $(patsubst %-clean,%,$@) clean
  125. $(CMD_TRACE) " done"
  126. $(END_TRACE)
  127. %-imageclean:
  128. $(START_TRACE) "target/$(patsubst %-imageclean,%,$@)-imageclean.. "
  129. $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
  130. $(CMD_TRACE) " done"
  131. $(END_TRACE)
  132. %-prepare:
  133. $(START_TRACE) "target/$(patsubst %-prepare,%,$@)-prepare.. "
  134. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
  135. $(CMD_TRACE) " done"
  136. $(END_TRACE)
  137. %-imageprepare:
  138. $(START_TRACE) "target/$(patsubst %-imageprepare,%,$@)-imageprepare.. "
  139. ifeq ($(ADK_RUNTIME_DEV_UDEV),y)
  140. ifneq ($(KERNEL_MODULES_USED),)
  141. # This should be made a package instead
  142. $(CP) $(BUILD_DIR)/linux-$(ADK_TARGET_ARCH)/modules/lib $(TARGET_DIR)
  143. rm -f "$(TARGET_DIR)"/lib/modules/*/build \
  144. "$(TARGET_DIR)"/lib/modules/*/source
  145. endif
  146. endif
  147. @for x in $$(ls $(ADK_TOPDIR)/scripts/preimage/*.sh 2>/dev/null); do \
  148. [[ -x "$$x" ]] && $$x; \
  149. break; \
  150. done
  151. $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
  152. $(CMD_TRACE) " done"
  153. $(END_TRACE)
  154. %-compile: %-prepare
  155. $(MAKE) -C $(patsubst %-compile,%,$@) compile
  156. %-install: %-compile
  157. $(MAKE) -C $(patsubst %-install,%,$@) install
  158. %-targethelp:
  159. $(MAKE) -C $(patsubst %-targethelp,%,$@) targethelp
  160. %-imageinstall: %-imageprepare
  161. $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall
  162. @for x in $$(ls $(ADK_TOPDIR)/scripts/postimage/*.sh 2>/dev/null); do \
  163. [[ -x "$$x" ]] && $$x; \
  164. break; \
  165. done
  166. @echo "Login as user root via ssh or console."