phunix/minix/llvm/configure.llvm
David van Moolenbroek b2ed49a5d8 libmagicrt: integrate into build system
The magic runtime library is now built as part of the regular build, if
the MKMAGIC=yes flag is passed to the build system.  The library has
been renamed from "magic" to "magicrt" to resolve a name clash with BSD
file(1)'s libmagic.  All its level-5 LLVM warnings have been resolved.
 The final library, "libmagicrt.bcc", is now stored in the destination
library directory rather than in the source tree.

Change-Id: Iebd4b93a2cafbb59f95d938ad1edb8b4f6e729f6
2016-01-13 20:32:32 +01:00

112 lines
2.8 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
. ${MINIX_LLVM_DIR}/minix.inc
# Set default values for essential variables
: ${JOBS=1}
: ${GEN_GOLD_PLUGIN="yes"}
: ${REBUILD_MINIX="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 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
exit $EXITCODE