1
0

Makefile 6.9 KB

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