]>
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
() {
171 local kernel_arch
="$(get_kernel_arch "${arch}")"
172 local flavour
="default"
174 local config_in
=$
(mktemp
)
175 local config_out
=$
(mktemp
)
176 local diff_out
=$
(mktemp
)
178 merge_config
${arch} ${flavour} ${config_in} --mode=none
182 cat ${config_in} > .config
184 echo "You may now edit the configuration..."
185 make ARCH
=${kernel_arch} "$@"
187 cat .config
> ${config_out}
191 ${SCRIPTS_DIR}/configdiff.py ${config_in} ${config_out} > ${diff_out}
193 # Update the rest of the configurations.
194 diff_configs
${diff_out} --mode=oldconfig
196 rm -f ${config_in} ${config_out} ${diff_out}
200 # Intersection of all files.
202 # Diff against merge of (config-generic and config-x86-generic).
204 function diff_configs
() {
205 local extra_configs
="$@"
211 declare -A platform_configs
212 declare -A subplatform_configs
216 for config
in ${CONFIGS}; do
220 filename
=${tmpdir}/config-${arch}-${flavour}
222 merge_config
${arch} ${flavour} ${filename} ${extra_configs}
224 platform
="$(get_platform "${arch}")"
225 subplatform
="$(get_subplatform "${arch}")"
227 if [ -n "${subplatform}" ]; then
228 subplatform_configs
[${subplatform}]="${subplatform_configs[${subplatform}]} ${filename}"
230 platform_configs[${platform}]="${platform_configs[${platform}]} ${filename}"
235 for platform
in ${PLATFORMS}; do
236 for subplatform
in ${SUBPLATFORMS[${platform}]}; do
237 filename
="${tmpdir}/config-${subplatform}-common"
238 ${SCRIPTS_DIR}/configcommon.py ${subplatform_configs[${subplatform}]} \
241 platform_configs
[${platform}]="${platform_configs[${platform}]} ${filename}"
244 filename="${tmpdir}/config-
${platform}-common"
245 ${SCRIPTS_DIR}/configcommon.py ${platform_configs[${platform}]} \
248 common_configs="${common_configs} ${filename}"
251 ${SCRIPTS_DIR}/configcommon.py ${common_configs} > ${tmpdir}/config-generic
253 for platform in ${PLATFORMS}; do
254 for subplatform in ${SUBPLATFORMS[${platform}]}; do
255 ${SCRIPTS_DIR}/configdiff.py \
256 ${tmpdir}/config-${platform}-common \
257 ${tmpdir}/config-${subplatform}-common \
258 > ${tmpdir}/config-${subplatform}-generic
261 ${SCRIPTS_DIR}/configdiff.py \
262 ${tmpdir}/config-generic \
263 ${tmpdir}/config-${platform}-common \
264 > ${tmpdir}/config-${platform}-generic
267 for config in ${CONFIGS}; do
271 filename=${tmpdir}/config-${arch}-${flavour}
274 aarch64:default|armv7hl:default|x86_64:default)
275 # Virtual configuration
280 platform="$
(get_subplatform
"${arch}" || get_platform
"${arch}")"
281 ${SCRIPTS_DIR}/configdiff.py ${tmpdir}/config-${platform}-common \
282 ${filename} > ${filename}.tmp
285 mv ${filename}{.tmp,}
287 rm -f ${tmpdir}/config-*-common
289 for config in ${tmpdir}/*; do
290 if ! cmp $(basename ${config}) ${config} &>/dev/null; then
291 echo "$
(basename ${config}) has changed.
"
293 cat ${config} > $(basename ${config})
300 KERNEL_DIR="$
(search_kernel_dir
)"
303 while [ $# -gt 0 ]; do
307 echo "${0} - available commands
:"
308 echo " * merge
<arch
> <flavour
> <output filename
>"
311 echo " * olddefconfig
"
314 listnewconfig|menuconfig|merge|oldconfig|olddefconfig)
322 if ! get_platform "${ARCH}" &>/dev/null; then
323 echo "Unknown architecture
: ${ARCH}" >&2
330 if [ -z "${KERNEL_DIR}" ]; then
331 echo >&2 "KERNEL_DIR was not
set!"
335 if [ -z "${action}" ]; then
336 echo >&2 "No action given... Try
${0} help.
"
345 listnewconfig|menuconfig|oldconfig|olddefconfig)
346 make_config "${ARCH}" "${action}"