summaryrefslogtreecommitdiff
path: root/target/Makefile
blob: fc3fd77f6eafea13cad016377d615f5b95b54d38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# This file is part of the OpenADK project. OpenADK is copyrighted
# material, please see the LICENCE file in the top-level directory.

include $(TOPDIR)/rules.mk
include $(TOPDIR)/mk/rootfs.mk

all: install

ifeq (${ADK_TARGET_KERNEL64},y)
KERNEL_CFG:=kernel64.config
else
KERNEL_CFG:=kernel.config
endif

### Kernel .config Creation
# The following target combines all kernel-related variables and
# config files into a single one to be used as the final kernel
# configuration when building. This is how it's done:
# 1) fetch all ADK_KPACKAGE_KMOD_* vars into
#    .kernelconfig.modules and set them to "m",
#    fetch all ADK_KERNEL_MOD_* vars into 
#    .kernelconfig.modules and set them to "m"
# 2) fetch all enabled ADK_KERNEL_* vars into
#    .kernelconfig.kernel (no conversion, as they are booleans)
# 3) repeat 2) for the disabled ones and save them into
#    .kernelconfig.nokernel (to overwrite defaults)
# 4) get the device-specific static kernel config and place it into
#    .kernelconfig.board
# 5) prepare for merging:
#    * if a variable is disabled in .kernelconfig.board and
#      enabled in either of .kernelconfig.{modules,kernel},
#      remove it from .kernelconfig.board
#    * append ${FS_CMDLINE} to the kernel commandline inside
#      .kernelconfig.board
# 6) merge (cat) it all together into .kernelconfig.tmp
# 7) check if .kernelconfig.tmp differs from the current one
#    (.kernelconfig) at all, overwriting the current one
#    only if it does (so the timestamp stays intact)
# 8) remove the temporary .kernelconfig.tmp
###
ADK_PACKAGE_CRYPTINIT_ROOT:=$(strip $(subst ",, $(ADK_PACKAGE_CRYPTINIT_ROOT)))
ADK_PACKAGE_CRYPTINIT_SWAP:=$(strip $(subst ",, $(ADK_PACKAGE_CRYPTINIT_SWAP)))
ADK_PACKAGE_CMDLINE:=root=$(ADK_PACKAGE_CRYPTINIT_ROOT) swap=$(ADK_PACKAGE_CRYPTINIT_SWAP) resume=/dev/mapper/swapcrypt

ifeq (${ADK_TARGET_KERNEL_CUSTOMISING},y)
config-prepare: $(TOPDIR)/.config
	@sed -n '/^ADK_KPACKAGE_KMOD/s//CONFIG/p' ${TOPDIR}/.config | \
	    sed 's/=y/=m/' >${BUILD_DIR}/.kernelconfig.modules
	@sed -n '/^ADK_KERNEL_MOD/s//CONFIG/p' ${TOPDIR}/.config | \
	    sed 's/=y/=m/' >>${BUILD_DIR}/.kernelconfig.modules
	@sed -n '/^ADK_KERNEL/s//CONFIG/p' ${TOPDIR}/.config \
	    >${BUILD_DIR}/.kernelconfig.kernel
	@sed -n '/^# ADK_KERNEL/s//# CONFIG/p' ${TOPDIR}/.config \
	    >${BUILD_DIR}/.kernelconfig.nokernel
ifeq ($(ADK_USE_KERNEL_MINICONFIG),y)
	@if [ -f ${ADK_TARGET_ARCH}/kernel/${ADK_TARGET_KERNEL_MINICONFIG} ];then \
		cat ${TOPDIR}/target/linux/kernel.config \
		    ${ADK_TARGET_ARCH}/kernel/${ADK_TARGET_KERNEL_MINICONFIG} > ${BUILD_DIR}/.kernelconfig.board; \
	else \
		echo "no miniconfig found for target system"; \
		exit 1; \
	fi
else
	@if [ -f ${ADK_TARGET_ARCH}/${KERNEL_CFG}.$(ADK_TARGET_SYSTEM) ];then \
		cp ${ADK_TARGET_ARCH}/${KERNEL_CFG}.$(ADK_TARGET_SYSTEM) ${BUILD_DIR}/.kernelconfig.board; \
	else \
		cp ${ADK_TARGET_ARCH}/${KERNEL_CFG} ${BUILD_DIR}/.kernelconfig.board; \
	fi
endif
	@(cat ${BUILD_DIR}/.kernelconfig.{modules,kernel} | \
	    while IFS='=' read symbol value; do \
		sed -i -e "/^# $$symbol/d" ${BUILD_DIR}/.kernelconfig.board; \
	done;)
	@sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${FS_CMDLINE}"#' \
		${BUILD_DIR}/.kernelconfig.board
ifneq ($(ADK_TARGET_CMDLINE),)
	@sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${ADK_TARGET_CMDLINE}"#' \
		${BUILD_DIR}/.kernelconfig.board
endif
ifneq ($(ADK_PACKAGE_CRYPTINIT_ROOT),)
	@sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${ADK_PACKAGE_CMDLINE}"#' \
		${BUILD_DIR}/.kernelconfig.board
endif
ifeq ($(ADK_QUIET_KERNEL),y)
	@sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 quiet"#' \
		${BUILD_DIR}/.kernelconfig.board
endif
ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
	@sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
		${BUILD_DIR}/.kernelconfig.board
endif
ifeq ($(ADK_KERNEL_NETCONSOLE),y)
	@sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 netconsole=@$(ADK_PARAMETER_NETCONSOLE_SRC_IP)/,@$(ADK_PARAMETER_NETCONSOLE_DST_IP)/"#' \
		${BUILD_DIR}/.kernelconfig.board
endif
	@cd ${BUILD_DIR} && cat .kernelconfig.board .kernelconfig.nokernel \
	    .kernelconfig.kernel .kernelconfig.modules \
	    >.kernelconfig.tmp
	@cd ${BUILD_DIR} && cmp -s .kernelconfig.tmp .kernelconfig || \
	    cp .kernelconfig.tmp .kernelconfig
	@-rm -f ${BUILD_DIR}/.kernelconfig.tmp
else
config-prepare: $(TOPDIR)/.config
	if [ -f ${ADK_TARGET_ARCH}/${KERNEL_CFG}.$(ADK_TARGET_SYSTEM) ];then \
		cp ${ADK_TARGET_ARCH}/${KERNEL_CFG}.$(ADK_TARGET_SYSTEM) ${BUILD_DIR}/.kernelconfig.board; \
	else \
		cp ${ADK_TARGET_ARCH}/${KERNEL_CFG} ${BUILD_DIR}/.kernelconfig.board; \
	fi
endif

prepare: $(ADK_TARGET_ARCH)-prepare
compile: $(ADK_TARGET_ARCH)-compile
image: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-imageinstall
install: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-install $(ADK_TARGET_ARCH)-imageinstall
clean: $(ADK_TARGET_ARCH)-clean $(ADK_TARGET_ARCH)-imageclean

%-clean:
	$(TRACE) target/$(patsubst %-clean,%,$@)-clean
	$(MAKE) -C $(patsubst %-clean,%,$@) clean
%-imageclean:
	$(TRACE) target/$(patsubst %-imageclean,%,$@)-imageclean
	$(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
%-prepare:
	$(TRACE) target/$(patsubst %-prepare,%,$@)-prepare
	$(MAKE) -C $(patsubst %-prepare,%,$@) prepare
%-imageprepare:
	$(TRACE) target/$(patsubst %-imageprepare,%,$@)-imageprepare
	$(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
%-compile: %-prepare
	$(TRACE) target/$(patsubst %-compile,%,$@)-compile
	$(MAKE) -C $(patsubst %-compile,%,$@) compile
%-install: %-compile
	$(TRACE) target/$(patsubst %-install,%,$@)-install
	$(MAKE) -C $(patsubst %-install,%,$@) install
%-imageinstall: %-imageprepare
	$(TRACE) target/$(patsubst %-imageinstall,%,$@)-imageinstall
	$(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall
	@echo 'Login as user root with password ${ADK_RUNTIME_PASSWORD} via ssh or console.'