]>
git.ipfire.org Git - ipfire-3.x.git/blob - kernel/scripts/configure
2 ###############################################################################
3 # IPFire.org - An Open Source Firewall Solution #
4 # Copyright (C) - IPFire Development Team <info@ipfire.org> #
5 ###############################################################################
7 BASEDIR
=$
(dirname ${0})
11 CONFIGS
="x86_64:default"
14 CONFIGS
="${CONFIGS} aarch64:default"
17 CONFIGS
="${CONFIGS} armv7hl:default"
20 declare -A SUBPLATFORMS
27 for dir
in /builddir
/source
/linux-
*; do
28 if [ -d "${dir}" ]; then
35 function get_platform
() {
51 function get_subplatform
() {
67 function get_kernel_arch
() {
83 function merge_config
() {
90 for arg
in arch flavour output
; do
91 if [ -z "${!arg}" ]; then
92 echo >&2 "merge usage: <arch> <flavour> <output filename>"
97 local config_mode
="olddefconfig"
99 while [ $# -gt 0 ]; do
102 config_mode
=${1#--mode=}
106 echo >&2 "Unknown option: ${1}"
109 extra_configs
="${extra_configs} ${1}"
115 local configs
="${extra_configs} config-generic"
117 case "${arch}:${flavour}" in
120 configs
="${configs} config-x86-generic"
125 configs
="${configs} config-arm-generic config-arm64-generic"
130 configs
="${configs} config-arm-generic config-arm32-generic"
133 echo >&2 "ERROR: Invalid parameters given: $@"
138 # Merge the configuration files from its elementary configuration
140 local tmp_out
=$
(mktemp
)
141 local tmp_in
=$
(mktemp
)
144 for config
in ${configs}; do
145 cat ${tmp_out} > ${tmp_in}
146 perl
${SCRIPTS_DIR}/merge.pl \
147 ${tmp_in} ${config} > ${tmp_out}
150 if [ "${config_mode}" != "none" ]; then
151 echo "Running 'make olddefconfig' for ${arch} (${flavour})..."
152 local kernel_arch
="$(get_kernel_arch "${arch}")"
155 cat ${tmp_out} > .config
156 make ARCH
="${kernel_arch}" ${config_mode}
157 cat .config
> ${tmp_out}
161 cat ${tmp_out} > ${output}
162 rm -f ${tmp_in} ${tmp_out}
165 # This function runs an interactive "make oldconfig".
166 function make_config
() {
168 local kernel_arch
="x86"
169 local flavour
="default"
171 local config_in
=$
(mktemp
)
172 local config_out
=$
(mktemp
)
173 local diff_out
=$
(mktemp
)
175 merge_config
${arch} ${flavour} ${config_in} --mode=none
179 cat ${config_in} > .config
181 echo "You may now edit the configuration..."
182 make ARCH
=${kernel_arch} "$@"
184 cat .config
> ${config_out}
188 ${SCRIPTS_DIR}/configdiff.py ${config_in} ${config_out} > ${diff_out}
190 # Update the rest of the configurations.
191 diff_configs
${diff_out} --mode=oldconfig
193 rm -f ${config_in} ${config_out} ${diff_out}
197 # Intersection of all files.
199 # Diff against merge of (config-generic and config-x86-generic).
201 function diff_configs
() {
202 local extra_configs
="$@"
208 declare -A platform_configs
209 declare -A subplatform_configs
213 for config
in ${CONFIGS}; do
217 filename
=${tmpdir}/config-${arch}-${flavour}
219 merge_config
${arch} ${flavour} ${filename} ${extra_configs}
221 platform
="$(get_platform "${arch}")"
222 subplatform
="$(get_subplatform "${arch}")"
224 if [ -n "${subplatform}" ]; then
225 subplatform_configs
[${subplatform}]="${subplatform_configs[${subplatform}]} ${filename}"
227 platform_configs[${platform}]="${platform_configs[${platform}]} ${filename}"
232 for platform
in ${PLATFORMS}; do
233 for subplatform
in ${SUBPLATFORMS[${platform}]}; do
234 filename
="${tmpdir}/config-${subplatform}-common"
235 ${SCRIPTS_DIR}/configcommon.py ${subplatform_configs[${subplatform}]} \
238 platform_configs
[${platform}]="${platform_configs[${platform}]} ${filename}"
241 filename="${tmpdir}/config-
${platform}-common"
242 ${SCRIPTS_DIR}/configcommon.py ${platform_configs[${platform}]} \
245 common_configs="${common_configs} ${filename}"
248 ${SCRIPTS_DIR}/configcommon.py ${common_configs} > ${tmpdir}/config-generic
250 for platform in ${PLATFORMS}; do
251 for subplatform in ${SUBPLATFORMS[${platform}]}; do
252 ${SCRIPTS_DIR}/configdiff.py \
253 ${tmpdir}/config-${platform}-common \
254 ${tmpdir}/config-${subplatform}-common \
255 > ${tmpdir}/config-${subplatform}-generic
258 ${SCRIPTS_DIR}/configdiff.py \
259 ${tmpdir}/config-generic \
260 ${tmpdir}/config-${platform}-common \
261 > ${tmpdir}/config-${platform}-generic
264 for config in ${CONFIGS}; do
268 filename=${tmpdir}/config-${arch}-${flavour}
271 aarch64:default|armv7hl:default|x86_64:default)
272 # Virtual configuration
277 platform="$
(get_subplatform
"${arch}" || get_platform
"${arch}")"
278 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-${platform}-common \
279 ${filename} > ${filename}.tmp
282 mv ${filename}{.tmp,}
284 rm -f ${tmpdir}/config-*-common
286 for config in ${tmpdir}/*; do
287 if ! cmp $(basename ${config}) ${config} &>/dev/null; then
288 echo "$
(basename ${config}) has changed.
"
290 cat ${config} > $(basename ${config})
296 KERNEL_DIR="$
(search_kernel_dir
)"
299 while [ $# -gt 0 ]; do
303 echo "${0} - available commands
:"
304 echo " * merge
<arch
> <flavour
> <output filename
>"
307 echo " * olddefconfig
"
310 menuconfig|merge|oldconfig|olddefconfig)
317 if [ -z "${KERNEL_DIR}" ]; then
318 echo >&2 "KERNEL_DIR was not
set!"
322 if [ -z "${action}" ]; then
323 echo >&2 "No action given... Try
${0} help.
"
332 menuconfig|oldconfig|olddefconfig)
333 make_config "${action}"