2011-12-23 17:06:13 +00:00
|
|
|
#!/bin/bash
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
# Print statistics when we exit
|
|
|
|
trap exit 1 2 3 15
|
|
|
|
trap stats 0
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
# Keep track of the number of builds and errors
|
|
|
|
nb_errors=0
|
|
|
|
errors_list=""
|
|
|
|
nb_defconfigs=0
|
|
|
|
ret=0
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
time_start=$(date +%s)
|
|
|
|
|
2015-02-03 10:14:46 +00:00
|
|
|
filename=$(basename $0)
|
2010-10-01 16:48:47 +00:00
|
|
|
|
|
|
|
is_print_stats=1
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
#-----------------------------------------------------------------------
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
usage() {
|
|
|
|
is_print_stats=0
|
|
|
|
echo "Usage: ${filename} [OPTION]..."
|
|
|
|
echo "Barebox MAKEALL tools."
|
|
|
|
echo ""
|
|
|
|
echo "it's allow you to compile specific defconfig or ARCH or all"
|
|
|
|
echo "as"
|
|
|
|
echo ""
|
|
|
|
echo "CROSS_COMPILE=arm-linux- ARCH=arm ./MAKEALL at91sam9263ek_defconfig"
|
|
|
|
echo "CROSS_COMPILE=arm-linux- ARCH=arm ./MAKEALL"
|
|
|
|
echo ""
|
|
|
|
echo "The cross-compiler can be specify via"
|
|
|
|
echo " CROSS_COMPILE default"
|
|
|
|
echo " CROSS_COMPILE_<arch> arch default"
|
2013-06-05 06:17:45 +00:00
|
|
|
echo " CROSS_COMPILE_<target> defconfig specific"
|
2010-10-01 16:48:47 +00:00
|
|
|
echo ""
|
|
|
|
echo "it will be evaluated in the invert order"
|
|
|
|
echo ""
|
|
|
|
echo "or via config"
|
|
|
|
echo ""
|
|
|
|
echo "you can specify it via env CONFIG or option -c (overwrite env)"
|
|
|
|
echo ""
|
|
|
|
echo "CONFIG=./MAKEALL.cfg ARCH=arm ./MAKEALL at91sam9263ek_defconfig"
|
|
|
|
echo "CONFIG=./MAKEALL.cfg ARCH=arm ./MAKEALL"
|
|
|
|
echo ""
|
|
|
|
echo "and for all"
|
|
|
|
echo ""
|
|
|
|
echo "CONFIG=./MAKEALL.cfg ./MAKEALL"
|
|
|
|
echo ""
|
|
|
|
echo "you can specify via env or option"
|
|
|
|
echo "env option"
|
|
|
|
echo "ARCH -a arch"
|
|
|
|
echo "CONFIG -c config"
|
|
|
|
echo "JOBS -j jobs"
|
|
|
|
echo "BUILDDIR -O build dir"
|
|
|
|
echo "LOGDIR -l log dir"
|
2013-02-03 10:16:55 +00:00
|
|
|
echo "REGEX -e regex"
|
2010-10-01 16:48:47 +00:00
|
|
|
echo ""
|
|
|
|
}
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
stats() {
|
|
|
|
[ ${is_print_stats} -lt 1 ] && return
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
echo ""
|
|
|
|
echo "--------------------- SUMMARY ----------------------------"
|
|
|
|
echo "defconfigs compiled: ${nb_defconfigs}"
|
|
|
|
time_stop=$(date +%s)
|
|
|
|
time_diff=$((${time_stop} - ${time_start}))
|
|
|
|
printf "compiled in %4is\n" ${time_diff}
|
|
|
|
if [ ${nb_errors} -gt 0 ] ; then
|
2013-06-05 06:17:45 +00:00
|
|
|
echo "defconfigs with warnings or errors: ${nb_errors} (${errors_list} )"
|
2010-10-01 16:48:47 +00:00
|
|
|
fi
|
|
|
|
echo "----------------------------------------------------------"
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
exit ${ret}
|
|
|
|
}
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
check_pipe_status() {
|
|
|
|
for i in "${PIPESTATUS[@]}"
|
|
|
|
do
|
|
|
|
[ $i -gt 0 ] && return 1
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
do_build_target() {
|
|
|
|
local arch=$1
|
|
|
|
local target=$2
|
|
|
|
local target_time_start=$(date +%s)
|
|
|
|
local log_report="${LOGDIR}/${target}/report.log"
|
|
|
|
local log_err="${LOGDIR}/${target}/errors.log"
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
rm -rf "${BUILDDIR}"
|
|
|
|
mkdir -p "${LOGDIR}/${target}"
|
|
|
|
printf "Building ${arch} ${target} \n" >&2 | tee -a "${log_report}"
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2015-02-03 10:14:46 +00:00
|
|
|
tmp=$(echo "${target}" | tr - _)
|
2012-09-19 09:40:42 +00:00
|
|
|
|
2015-02-03 10:14:46 +00:00
|
|
|
cross_compile=$(eval echo '$CROSS_COMPILE_'${tmp})
|
|
|
|
cross_compile_set=$(eval echo '${CROSS_COMPILE_'${tmp}'+set}')
|
2010-10-07 16:38:49 +00:00
|
|
|
if [ "${cross_compile_set}" = "" ]
|
2010-10-01 16:48:47 +00:00
|
|
|
then
|
2015-02-03 10:14:46 +00:00
|
|
|
cross_compile=$(eval echo '$CROSS_COMPILE_'${arch})
|
|
|
|
cross_compile_set=$(eval echo '${CROSS_COMPILE_'${arch}'+set}')
|
2010-10-07 16:38:49 +00:00
|
|
|
if [ "${cross_compile_set}" = "" ]
|
2010-10-01 16:48:47 +00:00
|
|
|
then
|
|
|
|
cross_compile=${CROSS_COMPILE}
|
|
|
|
fi
|
|
|
|
fi
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2015-02-03 10:14:48 +00:00
|
|
|
MAKE="make -j${JOBS} CROSS_COMPILE=${cross_compile} ARCH=${arch} O=${BUILDDIR}"
|
|
|
|
${MAKE} ${target} 2>&1 > "${log_report}" | tee "${log_err}"
|
2007-11-09 10:48:09 +00:00
|
|
|
|
|
|
|
check_pipe_status
|
2015-02-03 10:14:44 +00:00
|
|
|
result="$?"
|
|
|
|
|
|
|
|
printf "Configure: " | tee -a "${log_report}"
|
|
|
|
|
|
|
|
if [ "$result" = "0" ]; then
|
2010-10-01 16:48:47 +00:00
|
|
|
printf "OK \n" | tee -a "${log_report}"
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2015-02-03 10:14:48 +00:00
|
|
|
${MAKE} -s 2>&1 >> "${log_report}" | tee -a "${log_err}"
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2015-02-03 10:14:44 +00:00
|
|
|
check_pipe_status
|
|
|
|
result="$?"
|
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
printf "Compile: " ${target} | tee -a "${log_report}"
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2015-02-03 10:14:44 +00:00
|
|
|
if [ "$result" = "0" ]; then
|
2010-10-01 16:48:47 +00:00
|
|
|
printf "OK \n" | tee -a "${log_report}"
|
|
|
|
${cross_compile}size ${BUILDDIR}/barebox | tee -a "${log_report}"
|
2007-11-09 10:48:09 +00:00
|
|
|
else
|
2010-10-01 16:48:47 +00:00
|
|
|
printf "FAILED \n" | tee -a "${log_report}"
|
|
|
|
ret=1
|
2007-11-09 10:48:09 +00:00
|
|
|
fi
|
2010-10-01 16:48:47 +00:00
|
|
|
else
|
|
|
|
printf "FAILED \n" | tee -a "${log_report}"
|
|
|
|
printf "Compile: ------ \n" | tee -a "${log_report}"
|
|
|
|
ret=1
|
|
|
|
fi
|
2007-11-09 10:48:09 +00:00
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
if [ -s "${log_err}" ] ; then
|
|
|
|
nb_errors=$((nb_errors + 1))
|
|
|
|
errors_list="${errors_list} ${target}"
|
2007-11-09 10:48:09 +00:00
|
|
|
else
|
2010-10-01 16:48:47 +00:00
|
|
|
rm "${log_err}"
|
2007-11-09 10:48:09 +00:00
|
|
|
fi
|
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
nb_defconfigs=$((nb_defconfigs + 1))
|
|
|
|
|
|
|
|
target_time_stop=$(date +%s)
|
|
|
|
target_time_diff=$((${target_time_stop} - ${target_time_start}))
|
|
|
|
printf "Compiled in %4is\n" ${target_time_diff} | tee -a "${log_report}"
|
|
|
|
}
|
|
|
|
|
|
|
|
do_build() {
|
|
|
|
local arch=$1
|
2013-02-03 10:16:55 +00:00
|
|
|
local regex=$2
|
2010-10-01 16:48:47 +00:00
|
|
|
|
2013-02-03 10:16:55 +00:00
|
|
|
find arch/${arch}/configs -name "${regex}_defconfig" | while read i
|
2010-10-01 16:48:47 +00:00
|
|
|
do
|
|
|
|
local target=$(basename $i)
|
|
|
|
|
|
|
|
do_build_target ${arch} ${target}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
do_build_all() {
|
|
|
|
local build_target=0
|
|
|
|
|
|
|
|
for i in arch/*
|
|
|
|
do
|
|
|
|
local arch=$(basename $i)
|
|
|
|
|
|
|
|
if [ -d $i ]
|
|
|
|
then
|
2015-01-29 03:09:51 +00:00
|
|
|
do_build ${arch} "*"
|
2010-10-01 16:48:47 +00:00
|
|
|
build_target=$((build_target + 1))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
return $build_target
|
|
|
|
}
|
|
|
|
|
2013-02-03 10:16:55 +00:00
|
|
|
while getopts "hc:j:O:l:a:e:" Option
|
2010-10-01 16:48:47 +00:00
|
|
|
do
|
|
|
|
case $Option in
|
|
|
|
a )
|
|
|
|
ARCH=${OPTARG}
|
|
|
|
;;
|
|
|
|
c )
|
|
|
|
CONFIG=${OPTARG}
|
|
|
|
;;
|
|
|
|
j )
|
|
|
|
JOBS=${OPTARG}
|
|
|
|
;;
|
|
|
|
l )
|
|
|
|
LOGDIR=${OPTARG}
|
|
|
|
;;
|
|
|
|
O )
|
|
|
|
BUILDDIR=${OPTARG}
|
|
|
|
;;
|
2013-02-03 10:16:55 +00:00
|
|
|
e )
|
|
|
|
REGEX=${OPTARG}
|
|
|
|
;;
|
2010-10-01 16:48:47 +00:00
|
|
|
h )
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
2007-11-09 10:48:09 +00:00
|
|
|
done
|
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
shift $((OPTIND - 1))
|
|
|
|
|
|
|
|
if [ ! "${JOBS}" ] ; then
|
|
|
|
#linux, BSD, MacOS
|
|
|
|
nb_cpu=`getconf _NPROCESSORS_ONLN`
|
|
|
|
|
|
|
|
if [ $? -gt 0 ]
|
|
|
|
then
|
|
|
|
nb_cpu=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
JOBS=$((${nb_cpu} * 2))
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! "${LOGDIR}" ]
|
|
|
|
then
|
|
|
|
LOGDIR="log"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! "${BUILDDIR}" ]
|
|
|
|
then
|
|
|
|
BUILDDIR="makeall_builddir"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${CONFIG}" ]
|
|
|
|
then
|
2015-02-03 10:14:46 +00:00
|
|
|
basedir=$(dirname ${CONFIG})
|
2010-10-01 16:48:47 +00:00
|
|
|
|
|
|
|
if [ ! "${basedir}" ] || [ "${basedir}" = "." ]
|
|
|
|
then
|
|
|
|
CONFIG="./${CONFIG}"
|
|
|
|
fi
|
|
|
|
|
2011-11-27 10:49:16 +00:00
|
|
|
. "${CONFIG}"
|
2010-10-01 16:48:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
[ -d "${LOGDIR}" ] || mkdir ${LOGDIR} || exit 1
|
|
|
|
|
2013-02-03 10:16:55 +00:00
|
|
|
if [ ! "${REGEX}" ]
|
|
|
|
then
|
|
|
|
REGEX="*"
|
|
|
|
fi
|
|
|
|
|
2010-10-01 16:48:47 +00:00
|
|
|
if [ ! "${ARCH}" ] || [ ! -d arch/${ARCH} ]
|
|
|
|
then
|
|
|
|
do_build_all
|
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "You need to specify the ARCH or CROSS_COMPILE_<arch> or CROSS_COMPILE_<target> in your config file"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]
|
|
|
|
then
|
2013-02-03 10:16:55 +00:00
|
|
|
do_build ${ARCH} "${REGEX}"
|
2010-10-01 16:48:47 +00:00
|
|
|
else
|
|
|
|
do_build_target ${ARCH} $1
|
|
|
|
fi
|
2012-08-16 16:49:00 +00:00
|
|
|
exit $nb_errors
|