949a3e52e5
Change-Id: I532f5f44c785c1a72407b504568d54fc6cbabf8f
137 lines
3.6 KiB
Bash
Executable file
137 lines
3.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
############################
|
|
#
|
|
# Author: Koustubha Bhat
|
|
# Date : 3-April-2014
|
|
# VU University, Amsterdam.
|
|
#
|
|
############################
|
|
|
|
##################
|
|
# Initialization
|
|
##################
|
|
|
|
set -o errexit
|
|
|
|
MYPWD="`pwd`"
|
|
ARCH=i386
|
|
MINIX_ROOT=
|
|
MINIX_LLVM_DIR=
|
|
GOLD_DEST_DIR=
|
|
EXITCODE=0
|
|
|
|
function check_current_dir()
|
|
{
|
|
#Make sure we are running from the root dir of the Minix sources
|
|
if [ -d ./minix/drivers ] && [ -d ./minix/servers ] ; then
|
|
MINIX_ROOT="${MYPWD}"
|
|
elif [ -d ../../minix/drivers ] && [ -d ../../minix/servers ]; then
|
|
MINIX_ROOT="${MYPWD}/../.."
|
|
else
|
|
echo "Please run the script from either of the following locations:"
|
|
echo "> Root of the Minix sources."
|
|
echo " OR"
|
|
echo "> minix/llvm directory of the Minix sources."
|
|
exit 1
|
|
fi
|
|
|
|
MINIX_LLVM_DIR="${MINIX_ROOT}/minix/llvm"
|
|
GOLD_DEST_DIR="${MINIX_ROOT}/minix/llvm/bin"
|
|
|
|
MINIX_ROOT_1=`readlink -f ${MINIX_ROOT}`
|
|
MINIX_DEST_DIR=`readlink -f ${MINIX_ROOT}/../obj.${ARCH}`
|
|
MINIX_TOOLS_DIR="${MINIX_DEST_DIR}/tooldir.`uname -s`-`uname -r`-`uname -m`"
|
|
}
|
|
|
|
# Make sure we are running from the right directory
|
|
check_current_dir
|
|
|
|
# Create common.inc
|
|
if [ ! -f ${MINIX_LLVM_DIR}/common.inc ]; then
|
|
echo "# This file was automatically generated by configure.llvm" > ${MINIX_LLVM_DIR}/common.inc
|
|
echo "DESTDIR=\"${MINIX_DEST_DIR}\"" >> ${MINIX_LLVM_DIR}/common.inc
|
|
echo "TOOLDIR=\"${MINIX_TOOLS_DIR}/bin\"" >> ${MINIX_LLVM_DIR}/common.inc
|
|
fi
|
|
|
|
STATIC_DIR="${MINIX_LLVM_DIR}/static"
|
|
|
|
if [ ! -f ${STATIC_DIR}/Makefile.common.inc ]; then
|
|
echo "# This file was automatically generated by configure.llvm" > ${STATIC_DIR}/Makefile.common.inc
|
|
echo "_MINIX_ARCH=${ARCH}" >> ${STATIC_DIR}/Makefile.common.inc
|
|
echo "_MINIX_ROOT=${MINIX_ROOT_1}" >> ${STATIC_DIR}/Makefile.common.inc
|
|
echo "_MINIX_TOOLS_DIR=${MINIX_TOOLS_DIR}" >> ${STATIC_DIR}/Makefile.common.inc
|
|
fi
|
|
|
|
. ${MINIX_LLVM_DIR}/minix.inc
|
|
|
|
# Set default values for essential variables
|
|
: ${JOBS=1}
|
|
: ${GEN_GOLD_PLUGIN="yes"}
|
|
: ${REBUILD_MINIX="yes"}
|
|
: ${GEN_STATIC_MAGIC="yes"}
|
|
|
|
########################
|
|
# Generate Gold Plugin
|
|
########################
|
|
|
|
if [ "${GEN_GOLD_PLUGIN}" == "yes" ] && [ -f "${MYPWD}/.gold_generated" ]; then
|
|
GEN_GOLD_PLUGIN="no"
|
|
fi
|
|
|
|
if [ "${GEN_GOLD_PLUGIN}" == "yes" ]; then
|
|
${MINIX_LLVM_DIR}/generate_gold_plugin.sh
|
|
if [ ! -f "${GOLD_DEST_DIR}/libLTO.so" ] || [ ! -f "${GOLD_DEST_DIR}/LLVMgold.so" ]; then
|
|
echo "Failure: generate_gold_plugin.sh"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Finished generating gold plugin."
|
|
touch "${MYPWD}/.gold_generated"
|
|
else
|
|
echo "Gold plugin generation: NO"
|
|
fi
|
|
|
|
########################
|
|
# Build Minix
|
|
########################
|
|
export BUILDVARS=$(echo "${BUILDVARS} -V MKBITCODE=yes"| sed -e 's,-V MKMAGIC=yes,-V DBG=-g -V STRIPFLAG=-s -V CPPFLAGS=-D_MINIX_MAGIC=1,')
|
|
|
|
if [ "${REBUILD_MINIX}" == "yes" ]; then
|
|
|
|
echo "Building Minix..."
|
|
echo "CC:$CC"
|
|
echo "CXX:$CXX"
|
|
echo "JOBS:$JOBS"
|
|
echo "BUILDVARS:$BUILDVARS"
|
|
echo
|
|
cd ${MINIX_ROOT}
|
|
./releasetools/x86_hdimage.sh -b || EXITCODE=1
|
|
cd ${MYPWD}
|
|
if [ "$EXITCODE" != "0" ]; then
|
|
echo "Error: Failed building Minix source code."
|
|
exit $EXITCODE
|
|
else
|
|
echo "Completed building Minix source code."
|
|
fi
|
|
else
|
|
echo "Building Minix: NO"
|
|
fi
|
|
|
|
if [ "${GEN_STATIC_MAGIC}" == "yes" ]; then
|
|
echo "Building static magic library..."
|
|
cd ${STATIC_DIR}/magic
|
|
make install || EXITCODE=1
|
|
cd ${MYPWD}
|
|
if [ "$EXITCODE" != "0" ]; then
|
|
echo "Error: Failed building static magic library."
|
|
exit $EXITCODE
|
|
else
|
|
echo "Completed building static magic library."
|
|
fi
|
|
else
|
|
echo "Building static magic library: NO"
|
|
fi
|
|
|
|
exit $EXITCODE
|