forked from bloomberg/bde_verify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_llvm.sh
executable file
·86 lines (76 loc) · 2.68 KB
/
config_llvm.sh
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
#! /usr/bin/env bash
# config_llvm.sh -*-Shell-script-*-
# Script for configuring an LLVM/Clang build via cmake
# The parameters differ somewhat among Linux, MacOS, and SunOS, and are
# complicated enough to warrant having a script rather than just
# documentation.
OS=$(uname -s)
if [ $# -lt 2 -o "${1:0:23}" != "-DCMAKE_INSTALL_PREFIX=" -o ! -d "${!#}" ]
then
echo "usage: $(basename $0) -DCMAKE_INSTALL_PREFIX=dir ... llvm-source-dir"
exit 1
fi
if [ "$OS" = "Darwin" ]; then
CXX=$(which clang++)
CC=$(which clang)
else
if [ "$GCCDIR" = "" ]; then
cxx=$CXX
if [ "$cxx" = "" ]; then cxx=g++; fi
g=$(which "$cxx" 2>/dev/null)
if [ "$g" != "" ]; then
GCCDIR=$(dirname $g)/..
else
echo "Set GCCDIR or CXX, or have g++ locatable on PATH"
exit 1
fi
elif [ "$(basename $GCCDIR)" = bin ]; then
echo "GCCDIR should not end in '/bin'"
echo "try 'export GCCDIR=$(dirname $GCCDIR)'"
exit 1
fi
if [ "$CXX" = "" ]; then CXX=$GCCDIR/bin/g++; fi
if [ "$CC" = "" ]; then CC=$GCCDIR/bin/gcc; fi
fi
case $OS in
Linux)
L1=$GCCDIR/lib64
L2=/usr/lib64
L="-L $L1 -L $L2 -Wl,-R,$L1,-R,$L2 -fno-use-linker-plugin"
F="-D_GLIBCXX_USE_CXX11_ABI=0"
targets="'X86'"
;;
SunOS)
L1=$GCCDIR/lib/sparcv9
L2=/usr/lib/sparcv9
L="-L $L1 -L $L2 -Wl,-R,$L1,-R,$L2"
F="-D_GLIBCXX_USE_CXX11_ABI=1"
E=-DLIBXML2_LIBRARIES=/usr/lib/sparcv9/libxml2.so
targets="'Sparc'"
;;
Darwin)
if ! which aspell > /dev/null; then
echo >&2 "Prerequisit 'aspell' is not installed."
echo >&2 "Try 'brew install aspell'."
exit 1
fi
W="-Wno-unused-function"
targets="'X86'"
;;
*)
echo "$(basename $0) is meant only for Linux, MacOS, and SunOS systems"
exit 1
;;
esac
W="-Wno-unused-function"
cmake \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_FLAGS="-m64 $L $W $F $CXXFLAGS" \
-DCMAKE_C_FLAGS="-m64 $L $W $F $CFLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="-m64 $L $W $F $LDFLAGS" \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DLLVM_LIBDIR_SUFFIX=64 \
-DLLVM_TARGETS_TO_BUILD=$targets \
-DLLVM_ENABLE_TERMINFO=OFF \
$E "$@"