forked from lhzhang/compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·95 lines (80 loc) · 2.85 KB
/
configure
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
#! /bin/sh
set -e
curdir=`pwd`
base=$(cd $(dirname $0) && pwd)
src=$base
while [ "${1#-}" != "$1" ]; do
opt=$1
shift
case $opt in
--prefix=*) prefix=${opt#*=} ;;
--src=*) src=${opt#*=} ;;
-t) target=$1; shift ;;
-u) update=y ;;
-n) run=echo ;;
-j*) make_j=$opt ;;
esac
done
if [ "$update" = y ]; then
if [ -d $src ]; then
(cd $src && git pull)
else
git clone git://github.com/path64/compiler.git $src
fi
fi
cross=${target:+${target}-}
machine=$(${cross}gcc -dumpmachine)
gcc=${machine}-gcc
prefix=${prefix:-/usr/local/path64/$machine}
version=$(cd $src && git describe --tags --match '[0-9]*')
oldversion=$(ls $prefix/lib 2>/dev/null || echo none)
[ "$update" = y ] && [ "$version" = "$oldversion" ] && exit
if [ -z "$build" ]; then
build=$curdir/build
fi
$run mkdir -p $build
$run cd $build
case $machine in
mips64*) targets='mips_32=-mabi=n32 mips_64=-mabi=64' ;;
x86*64*|amd64*) targets='x86_64=-m64 x86_32=-m32' ;;
x86*|i?86*) targets='x86_32=-m32' ;;
*) echo "Unsupported machine $machine"; exit 1 ;;
esac
for t in $targets; do
name=${t%%=*}
flags=${t#$name}
flags=${flags#=}
path64_targets="${path64_targets:+${path64_targets};}$name"
libgcc=$($gcc $flags -print-libgcc-file-name)
crt=$($gcc $flags -print-file-name=crt1.o)
gcclib=$(realpath ${libgcc%/*})
gcccrt=$(realpath ${crt%/*})
ld_so=$($gcc $flags --help -v 2>&1 >/dev/null |
awk '/-dynamic-linker/ { match($0, "-dynamic-linker +[^ ]+");
print substr($0, RSTART+16, RLENGTH-16) }')
PATH64_DEFS="$PATH64_DEFS
-DPSC_CRTBEGIN_PATH_${name}=${gcclib}
-DPSC_LIBSUPCPP_PATH_${name}=${gcclib}
-DPSC_LIBSTDCPP_PATH_${name}=${gcclib}
-DPSC_LIBGCC_PATH_${name}=${gcclib}
-DPSC_LIBGCC_EH_PATH_${name}=${gcclib}
-DPSC_LIBGCC_S_PATH_${name}=${gcclib}
"
done
if [ -n "${target}" ]; then
psc_target="-DPSC_TARGET=${machine}"
fi
$run cmake -DCMAKE_INSTALL_PREFIX=$prefix \
-DCMAKE_BUILD_TYPE=Debug \
-DPATH64_ENABLE_PSCRUNTIME=OFF \
${psc_target} \
-DPATH64_ENABLE_TARGETS="$path64_targets" \
${PATH64_DEFS} \
-DPATH64_ENABLE_PROFILING=OFF \
-DPATH64_ENABLE_FORTRAN=OFF \
-DPSC_FULL_VERSION=$version \
$src
makefile=$curdir/Makefile
echo "all:\n\tcd build; \${MAKE}\n" > $makefile
echo "install:\n\tcd build; \${MAKE} install" >> $makefile
echo "test:\n\tcd build; \${MAKE} test" >> $makefile