set -o errexit
MYPWD="`pwd`"
+ARCH=i386
MINIX_ROOT=
MINIX_LLVM_DIR=
GOLD_DEST_DIR=
-DEFAULT_LLVM_ROOT=
EXITCODE=0
function check_current_dir()
MINIX_LLVM_DIR="${MINIX_ROOT}/minix/llvm"
GOLD_DEST_DIR="${MINIX_ROOT}/minix/llvm/bin"
- DEFAULT_LLVM_ROOT="${MINIX_ROOT}/../../llvm-apps"
+
+ 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
-# LLVM ROOT is the bridging connection from minix branch to the llvm-apps branch
-if [ "${ROOT}" == "" ]; then
-
- echo "\${ROOT} is not set."
- echo "Please specify the path to the \"llvm-apps\" repository..."
- echo "Default value: ${DEFAULT_LLVM_ROOT} . "
- echo "If this is correct, press ENTER. Otherwise please enter the path."
- if [ "$INTERACTIVE" = "no" ]; then
- response=""
- else
- read response
- fi
+# 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
- if [ "" == "${response}" ]; then
- ROOT=${DEFAULT_LLVM_ROOT}
- else
- ROOT=${response}
- fi
-fi
-echo "LLVM root directory is set to :"
-echo " ${ROOT}"
-
-# Persist the LLVM ROOT path information
-[ -f ${MINIX_LLVM_DIR}/common.inc ] || cp ${MINIX_LLVM_DIR}/common.inc.default ${MINIX_LLVM_DIR}/common.inc
-ROOT_1=`echo ${ROOT} | sed "s/\\\//\\\\\\\\\//g"`
-sed -i "s/ROOT=.*$/ROOT=\"${ROOT_1}\"/g" ${MINIX_LLVM_DIR}/common.inc
-. ${MINIX_LLVM_DIR}/minix.inc
+STATIC_DIR="${MINIX_LLVM_DIR}/static"
-if [ ! -d ${ROOT}/.tmp ]; then
- mkdir ${ROOT}/.tmp 2>/dev/null || true
+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
./releasetools/x86_hdimage.sh -b || EXITCODE=1
cd ${MYPWD}
if [ "$EXITCODE" != "0" ]; then
- echo "Error: Failed building Minix source code."
+ echo "Error: Failed building Minix source code."
+ exit $EXITCODE
else
echo "Completed building Minix source code."
fi
echo "Building Minix: NO"
fi
-# Configure llvm-apps
-cp ${ROOT}/conf/common.overrides.llvm-minix.inc ${ROOT}/common.overrides.llvm.inc
-MINIX_ROOT_1=`readlink -f ${MINIX_ROOT}`
-MINIX_TOOLS_DIR=$(readlink -f ${MINIX_ROOT}/../obj.i386/tooldir.*)
-echo "_MINIX_ROOT=\"${MINIX_ROOT_1}\"" > ${ROOT}/common.overrides.minix.inc
-echo "_MINIX_TOOLS_DIR=\"${MINIX_TOOLS_DIR}\"" >> ${ROOT}/common.overrides.minix.inc
+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
MINIX_LLVM_DIR="${MINIX_ROOT}/minix/llvm"
}
+# Copied from configure.llvm.inc
+function build_llvm_libs()
+{
+ local LIBS=""
+ for a in $*
+ do
+ LIBS="$LIBS `find $INSTALL_DIR -maxdepth 1 -name ${a}\*.bcc | xargs`"
+ done
+ echo $LIBS
+}
+
function find_static_libs()
{
local stat_libs_llvmapps=
exit 1
fi
-# set up the bridge to llvm-apps repository and initialize
. ${MINIX_LLVM_DIR}/minix.inc
-. ${ROOT}/apps/scripts/include/configure.llvm.inc
-echo "LLVM root directory is set to :"
-echo " ${ROOT}"
echo ".so and .bcc binaries of LLVM passes set to be picked up from:"
echo " ${INSTALL_DIR}"
echo " and"