Repository navigation
Expand file tree
/
Copy pathconfigure.llvm
More file actions
executable file
·136 lines (114 loc) · 3.61 KB
/
Copy pathconfigure.llvm
File metadata and controls
executable file
·136 lines (114 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/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