1
0

Makefile 8.2 KB

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