1
0

Makefile 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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_CUSTOMISING),y)
  30. config-prepare: $(ADK_TOPDIR)/.config
  31. @PATH='$(HOST_PATH)' sed -n '/^ADK_KERNEL/s//CONFIG/p' $(ADK_TOPDIR)/.config \
  32. >$(BUILD_DIR)/.kernelconfig.kernel
  33. @if [ -f $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) ];then \
  34. cat $(ADK_TOPDIR)/target/linux/kernel.config \
  35. $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) > $(BUILD_DIR)/.kernelconfig.board; \
  36. else \
  37. echo "no miniconfig found for target system"; \
  38. exit 1; \
  39. fi
  40. ifneq ($(ADK_TARGET_NO_CMDLINE),y)
  41. ifeq ($(ADK_APPLIANCE_KODI),y)
  42. $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 consoleblank=0 vt.global_cursor_default=0"#' \
  43. $(BUILD_DIR)/.kernelconfig.board
  44. endif
  45. ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_VGA_ONLY),y)
  46. $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE)"#' \
  47. $(BUILD_DIR)/.kernelconfig.board
  48. endif
  49. ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_SERIAL_ONLY),y)
  50. $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED)"#' \
  51. $(BUILD_DIR)/.kernelconfig.board
  52. endif
  53. ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_VGA_SERIAL),y)
  54. $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE) console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED)"#' \
  55. $(BUILD_DIR)/.kernelconfig.board
  56. endif
  57. ifeq ($(ADK_RUNTIME_VERBOSE_KERNEL_SERIAL_VGA),y)
  58. $(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=$(ADK_RUNTIME_CONSOLE_SERIAL_DEVICE),$(ADK_RUNTIME_CONSOLE_SERIAL_SPEED) console=$(ADK_RUNTIME_CONSOLE_VGA_DEVICE)"#' \
  59. $(BUILD_DIR)/.kernelconfig.board
  60. endif
  61. ifeq ($(ADK_TARGET_SYSTEM_QEMU_M68K_Q800)$(ADK_TARGET_SYSTEM_QEMU_M68K_MCF5208),y)
  62. @$(SED) 's#^\(CONFIG_.*BOOTPARAM_STRING="\)\(.*\)"#\1\2 ro $(FS_CMDLINE)"#' \
  63. $(BUILD_DIR)/.kernelconfig.board
  64. endif
  65. ifeq ($(ADK_TARGET_ROOTFS_NFSROOT),)
  66. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ro"#' \
  67. $(BUILD_DIR)/.kernelconfig.board
  68. else
  69. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 rw"#' \
  70. $(BUILD_DIR)/.kernelconfig.board
  71. endif
  72. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(FS_CMDLINE)"#' \
  73. $(BUILD_DIR)/.kernelconfig.board
  74. ifneq ($(ADK_TARGET_CMDLINE),)
  75. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(ADK_TARGET_CMDLINE)"#' \
  76. $(BUILD_DIR)/.kernelconfig.board
  77. endif
  78. ifeq ($(ADK_TARGET_QEMU_WITH_GRAPHIC),y)
  79. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=tty0"#' \
  80. $(BUILD_DIR)/.kernelconfig.board
  81. endif
  82. ifneq ($(ADK_PACKAGE_CRYPTINIT_ROOT),)
  83. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 $(ADK_PACKAGE_CMDLINE)"#' \
  84. $(BUILD_DIR)/.kernelconfig.board
  85. endif
  86. ifeq ($(ADK_RUNTIME_QUIET_INIT),y)
  87. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 rcquiet=1"#' \
  88. $(BUILD_DIR)/.kernelconfig.board
  89. endif
  90. ifeq ($(ADK_RUNTIME_QUIET_KERNEL),y)
  91. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 quiet loglevel=2 vt.global_cursor_default=0"#' \
  92. $(BUILD_DIR)/.kernelconfig.board
  93. endif
  94. ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
  95. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
  96. $(BUILD_DIR)/.kernelconfig.board
  97. endif
  98. ifeq ($(ADK_KERNEL_NETCONSOLE),y)
  99. @$(SED) 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 netconsole=@$(ADK_PARAMETER_NETCONSOLE_SRC_IP)/,@$(ADK_PARAMETER_NETCONSOLE_DST_IP)/"#' \
  100. $(BUILD_DIR)/.kernelconfig.board
  101. endif
  102. endif
  103. @cd $(BUILD_DIR) && cat .kernelconfig.board .kernelconfig.kernel \
  104. >.kernelconfig.tmp
  105. @cd $(BUILD_DIR) && cmp -s .kernelconfig.tmp .kernelconfig || \
  106. cp .kernelconfig.tmp .kernelconfig
  107. @-rm -f $(BUILD_DIR)/.kernelconfig.tmp
  108. else
  109. config-prepare: $(ADK_TOPDIR)/.config
  110. @if [ -f $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) ];then \
  111. cat $(ADK_TOPDIR)/target/linux/kernel.config \
  112. $(ADK_TARGET_ARCH)/kernel/$(ADK_TARGET_SYSTEM) > $(BUILD_DIR)/.kernelconfig.board; \
  113. else \
  114. echo "no miniconfig found for target system"; \
  115. exit 1; \
  116. fi
  117. @cd $(BUILD_DIR) && cmp -s .kernelconfig.board .kernelconfig || \
  118. cp .kernelconfig.board .kernelconfig
  119. endif
  120. prepare: $(ADK_TARGET_ARCH)-prepare
  121. compile: $(ADK_TARGET_ARCH)-compile
  122. image: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-imageinstall
  123. targethelp: $(ADK_TARGET_ARCH)-targethelp
  124. install: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-install $(ADK_TARGET_ARCH)-imageinstall
  125. clean: $(ADK_TARGET_ARCH)-clean $(ADK_TARGET_ARCH)-imageclean
  126. %-clean:
  127. $(START_TRACE) "target/$(patsubst %-clean,%,$@)-clean.. "
  128. $(MAKE) -C $(patsubst %-clean,%,$@) clean
  129. $(CMD_TRACE) " done"
  130. $(END_TRACE)
  131. %-imageclean:
  132. $(START_TRACE) "target/$(patsubst %-imageclean,%,$@)-imageclean.. "
  133. $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
  134. $(CMD_TRACE) " done"
  135. $(END_TRACE)
  136. %-prepare:
  137. $(START_TRACE) "target/$(patsubst %-prepare,%,$@)-prepare.. "
  138. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
  139. $(CMD_TRACE) " done"
  140. $(END_TRACE)
  141. %-imageprepare:
  142. $(START_TRACE) "target/$(patsubst %-imageprepare,%,$@)-imageprepare.. "
  143. ifeq ($(ADK_RUNTIME_DEV_UDEV),y)
  144. ifneq ($(KERNEL_MODULES_USED),)
  145. # This should be made a package instead
  146. $(CP) $(BUILD_DIR)/linux-$(ADK_TARGET_ARCH)/modules/lib $(TARGET_DIR)
  147. rm -f "$(TARGET_DIR)"/lib/modules/*/build \
  148. "$(TARGET_DIR)"/lib/modules/*/source
  149. endif
  150. endif
  151. @for x in $$(ls $(ADK_TOPDIR)/scripts/preimage/*.sh 2>/dev/null); do \
  152. [[ -x "$$x" ]] && $$x; \
  153. break; \
  154. done
  155. $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
  156. $(CMD_TRACE) " done"
  157. $(END_TRACE)
  158. %-compile: %-prepare
  159. $(MAKE) -C $(patsubst %-compile,%,$@) compile
  160. %-install: %-compile
  161. $(MAKE) -C $(patsubst %-install,%,$@) install
  162. %-targethelp:
  163. $(MAKE) -C $(patsubst %-targethelp,%,$@) targethelp
  164. %-imageinstall: %-imageprepare
  165. $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall
  166. @for x in $$(ls $(ADK_TOPDIR)/scripts/postimage/*.sh 2>/dev/null); do \
  167. [[ -x "$$x" ]] && $$x; \
  168. break; \
  169. done
  170. @echo "Login as user root via ssh or console."