Makefile 7.3 KB

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