forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.llvm
More file actions
executable file
·147 lines (126 loc) · 3.8 KB
/
Copy pathconfigure.llvm
File metadata and controls
executable file
·147 lines (126 loc) · 3.8 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
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
############################
#
# Author: Koustubha Bhat
# Date : 3-April-2014
# VU University, Amsterdam.
#
############################
##################
# Initialization
##################
set -o errexit
MYPWD="`pwd`"
MINIX_ROOT=
MINIX_LLVM_DIR=
GOLD_DEST_DIR=
DEFAULT_LLVM_ROOT=
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"
DEFAULT_LLVM_ROOT="${MINIX_ROOT}/../../llvm-apps"
}
# 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
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
# Configure llvm-apps
cp ${ROOT}/conf/common.overrides.llvm-minix.inc ${ROOT}/common.overrides.llvm.inc
MINIX_ROOT_1=`readlink -f ${MINIX_ROOT}`
echo "_MINIX_ROOT=\"${MINIX_ROOT_1}\"" > ${ROOT}/common.overrides.minix.inc
if [ ! -d ${ROOT}/.tmp ]; then
mkdir ${ROOT}/.tmp 2>/dev/null || true
fi
# 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
echo "It is found that Gold plugin has already been generated. Would you like to re-generate? [y | n]"
if [ "$INTERACTIVE" == "no" ]; then
response=n
else
read response
fi
if [ "y" == "$response" ] || [ "Y" == "$response" ]; then
echo "Gold shall be regenerated."
else
GEN_GOLD_PLUGIN="no"
fi
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
########################
if [ "${REBUILD_MINIX}" == "yes" ]; then
echo "Building Minix..."
echo "CC:$CC"
echo "CXX:$CXX"
echo "JOBS:$JOBS"
echo
cd ${MINIX_ROOT}
BUILDVARS="-V MKBITCODE=yes" ./releasetools/x86_hdimage.sh
EXITCODE=$?
cd ${MYPWD}
if [ "$EXITCODE" != "0" ]; then
echo "Error: Failed building Minix source code."
exit $EXITCODE
else
echo "Completed building Minix source code."
exit $EXITCODE
fi
else
echo "Building Minix: NO"
fi
# Reconfigure llvm-apps
MINIX_TOOLS_DIR=$(readlink -f ${MINIX_ROOT}/../obj.i386/tooldir.*)
echo "MINIX_TOOLS_DIR=\"${MINIX_TOOLS_DIR}\"" >> ${ROOT}/common.overrides.minix.inc