/
build
executable file
·143 lines (126 loc) · 3.4 KB
/
build
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
#!/bin/sh
# toplevel ELLCC distribution build script
# OG: Debug feature to find out where the errors come from...
bailout () {
echo $1
echo "Error: leaving module $cwd"
exit 1
}
# Get the staging directory.
prefix=`pwd`
all=0
package=""
while [ $# -gt 0 ] ; do
case $1 in
-a)
# Build all configurations except host.
all=1
shift
;;
-p)
# package all configurations.
shift
package=$1
shift
;;
*)
break
;;
esac
done
# Figure out the compilers to use.
. ./build-setup $*
if [ $debug -ne 0 ] ; then
echo $WHY
echo host=$host
echo build=$build
echo os=$os
echo hostos=$hostos
echo tuple=$tuple
echo libtuple=$libtuple
echo cc=$cc
echo cxx=$cxx
echo hcc=$hcc
echo hcxx=$hcxx
echo ar=$ar
echo ranlib=$ranlib
echo builddir=$builddir
echo bindir=$bindir
echo haslibs=$haslibs
echo maxjobs=$maxjobs
exit 0
fi
if [ $all -eq 1 ] ; then
# Build all configurations except host.
BldConfigs=`cd libecc/config; echo *-linux-* *-w64-mingw32`
for config in $BldConfigs ; do
# Don't rebuild the host.
if [ `bin/ecc-getarch $config`-`bin/ecc-getos $config` = $host-$hostos ] ; then
continue
fi
# The microblaze can't self host.
if [ `bin/ecc-getarch $config` = microblaze ] ; then
continue
fi
./build $config || bailout "Build failed for $config"
done
# RICH: ./build -m || bailout "Build failed for MinGW"
exit 0
fi
if [ "$package" != "" ] ; then
# Package all configurations.
BldConfigs=`cd libecc/config; echo *-linux-* *-w64-mingw32`
for config in $BldConfigs ; do
# The microblaze can't self host.
if [ `bin/ecc-getarch $config` = microblaze ] ; then
continue
fi
if [ ! -e llvm-build-$config ] ; then
echo "$config packaging failed because it hasn't been built"
bailout "Packaging failed for $config"
else
./mkdist $config $package || bailout "Packaging failed for $config"
fi
done
exit 0
fi
# Copy extra bin scripts.
mkdir -p $bindir
cp -p bin-extra/* $bindir
# Configure for an LLVM+Clang build.
mkdir -p llvm-build$builddir
${MAKE} DIR=llvm-build$builddir CC="$cc" CXX="$cxx" AR="$ar" RANLIB="$ranlib" \
TARGET=$host OS=$os HOSTOS=$hostos TUPLE=$tuple \
bindir=$bindir prefix=$prefix build=$build haslibs=$haslibs \
llvm.configure || bailout "Configure failed for llvm"
# Build the LLVM tools.
${MAKE} -C llvm-build$builddir -j ${maxjobs} || bailout "Make failed for llvm"
# Build the GNU tools.
cd gnu
./build $arg1 || bailout "Build failed for gnu"
cd ..
# Now install the ELLCC tools.
${MAKE} -j ${maxjobs} -C llvm-build$builddir install || bailout "Install failed for llvm"
if [ "$host" != "$build" ] ; then
# The host system is not the build system.
# No need to build the libraries again.
echo Configured to $WHY.
echo C compiler: $cc
echo C++ compiler: $cxx
echo In: llvm-build$builddir
exit 0
fi
# Build libecc.
cd libecc
${MAKE} || bailout "Make failed for libecc"
cd ..
if [ "x$hostos" = "xlinux" ] ; then
if [ "$haslibs" != "yes" ] ; then
# Make sure ELLCC_ARG0 is set in the next build.
find llvm-build* -name driver.o | xargs rm -f
echo "Please run the build script again to bootstrap ecc."
echo "This may be done a few times:"
echo "1. ecc is built with itself (compiled with gcc) and libecc."
echo "2. ecc is built with itself (compiled with itself) and libecc."
fi
fi