@@ -205,7 +205,8 @@ echo "START ${ARC_ENDIAN}-endian uClibc: $(date)" | tee -a ${logfile}
205205# Initalize, including getting the tool versions.
206206. " ${ARC_GNU} " /toolchain/arc-init.sh
207207uclibc_build_dir=" $( echo " ${PWD} " ) " /uClibc
208- linux_build_dir=${LINUXDIR}
208+ linux_src_dir=${LINUXDIR}
209+ linux_build_dir=$build_dir /linux
209210
210211# If PDF docs are enabled, then check if prerequisites are satisfied.
211212if [ " x${DO_PDF} " = " x--pdf" ]
@@ -243,14 +244,25 @@ mkdir -p "$build_dir"
243244echo " Installing Linux headers ..." | tee -a " ${logfile} "
244245echo " ============================" >> " ${logfile} "
245246
246- cd " ${linux_build_dir} "
247-
248- # Configure Linux if not already
247+ cd " ${linux_src_dir} "
248+
249+ # It would be irresponsible for us to configure linux in source tree and leave
250+ # it at that, because if anybody else after that would try to configure/build
251+ # linux out-of-tree they will fail - Linux cannot configure out of tree when it
252+ # is already configured in tree. So we need to either clean configuration after
253+ # installing headers or just configure out of tree ourself. Second options
254+ # seems like more solid solution. However it will fail if Linux already has
255+ # been configured. Bam! In that case we just use Linux as-is. All of that is
256+ # mildly complex but this approach makes sure that this script is a friendly
257+ # neighbor and doesn't pollute in many places.
249258if [ ! -f .config ]
250259then
251- if make ARCH=${arch} defconfig >> " ${logfile} " 2>&1
260+ # Linux makefile expects this directory to exist.
261+ mkdir -p " $linux_build_dir "
262+ if make ARCH=arc defconfig O=" $linux_build_dir " >> " ${logfile} " 2>&1
252263 then
253264 echo " finished configuring Linux"
265+ cd " $linux_build_dir "
254266 else
255267 echo " ERROR: Linux configuration was not successful. Please"
256268 echo " see \" ${logfile} \" for details."
260272 echo " Linux already configured"
261273fi
262274
263- if make ARCH=${arch} INSTALL_HDR_PATH=${SYSROOTDIR} /usr \
275+ # Wherever linux has been configured in or out of tree, at this stage we are in
276+ # the directory with .config file.
277+ if make ARCH=arc INSTALL_HDR_PATH=${SYSROOTDIR} /usr \
264278 headers_install >> " ${logfile} " 2>&1
265279then
266280 echo " finished installing Linux headers"
0 commit comments