Makefile 8.9 KB

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