-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·161 lines (133 loc) · 4.05 KB
/
configure
File metadata and controls
executable file
·161 lines (133 loc) · 4.05 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
#-*- mode: shell-script; -*-
prefix=/usr/local
srcdir=$(readlink -f $(dirname $0))
objdir=$(readlink -f ${objdir:-${PWD}})
output=${output:-${objdir}/.config}
usage() {
echo "Usage: $0 [<options>]
--help print this message
--prefix=<DIR> set install root dir as <DIR> (default: /usr/local)
--bindir=<DIR> set executable install dir as <DIR> (default: \${prefix}/bin)
--libdir=<DIR> set library install dir as <DIR> (default: \${prefix}/lib)
--mandir=<DIR> set manual doc install dir as <DIR> (default: \${prefix}/share/man)
--objdir=<DIR> set build dir as <DIR> (default: \${PWD})
-p preserve old setting
"
exit 1
}
# preserve old settings
preserve() {
if [ -f ${output} ]; then
while read pre opt op val; do
# do not change directory settings (to prevent confusion)
if [ "${opt:3}" = "dir" ]; then
continue
fi
if [ "$op" = ":=" -o "$op" = "=" ]; then
eval "$opt=\"$val\""
fi
done < ${output}
fi
}
while getopts ":ho:-:p" opt; do
case "$opt" in
-)
# process --long-options
case "$OPTARG" in
help) usage ;;
*=*) opt=${OPTARG%%=*}; val=${OPTARG#*=}
eval "$opt=$val" ;;
*) val="${!OPTIND}"; OPTIND=$((OPTIND + 1));
eval "$OPTARG=$val" ;;
esac
;;
o) output=$OPTARG ;;
p) preserve ;;
*) usage ;;
esac
done
shift $((OPTIND - 1))
for arg in "$@"; do
opt=${arg%%=*}
val=${arg#*=}
eval "$opt='$val'"
done
if [ -z "$ARCH" ]; then
uname_M=$(uname -m 2>/dev/null || echo not)
ARCH=$(echo $uname_M | sed -e s/i.86/i386/ -e s/arm.*/arm/ )
if [ "$ARCH" = "x86_64" ] && echo "$CFLAGS" | grep -w m32 ; then
ARCH=i386
fi
fi
bindir=${bindir:-${prefix}/bin}
libdir=${libdir:-${prefix}/lib}
etcdir=${etcdir:-${prefix}/etc}
mandir=${mandir:-${prefix}/share/man}
if echo ${etcdir} | grep -qs /usr/local; then
etcdir=$(echo ${etcdir} | sed -e "s^/usr/local^^")
fi
if echo ${etcdir} | grep -qs /usr; then
etcdir=$(echo ${etcdir} | sed -e "s^/usr^^")
fi
CC=${CC:-${CROSS_COMPILE}gcc}
LD=${LD:-${CROSS_COMPILE}ld}
# objdir can be changed, reset output
objdir=$(readlink -f ${objdir})
output=${output:-${objdir}/.config}
#
# this is needed to suppress warning from make below.
# otherwise it'll get the following warning
# when called from make -jN.
#
# warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
#
MAKEFLAGS=
MAKEOVERRIDES=
make -siC ${srcdir}/check-deps check-build
if [ ! -e ${srcdir}/check-deps/have_libelf ]; then
echo "Error: cannot find 'libelf' (from elfutils): Please install it first."
exit 1
fi
echo "# this file is generated automatically" > $output
echo override prefix := $prefix >> $output
echo override bindir := $bindir >> $output
echo override libdir := $libdir >> $output
echo override mandir := $mandir >> $output
echo override etcdir := $etcdir >> $output
echo >> $output
echo override ARCH := $ARCH >> $output
echo override CC := $CC >> $output
echo override LD := $LD >> $output
echo override CFLAGS = $CFLAGS >> $output
echo override LDFLAGS = $LDFLAGS >> $output
echo >> $output
echo override srcdir := $srcdir >> $output
echo override objdir := $objdir >> $output
if [ $(id -u) -eq 0 ]; then
chmod 666 $output
fi
if [ "$srcdir" != "$objdir" ]; then
cat > $objdir/Makefile <<EOF
ARCH := $ARCH
srcdir := $srcdir
objdir := $objdir
export ARCH srcdir objdir
MAKEFLAGS = --no-print-directory
all: prepare
@\$(MAKE) -C \$(srcdir)
clean:
@rm -rf arch libmcount libtraceevent utils
@rm -f uftrace version.h *.o *.op
prepare:
@mkdir -p arch/\$(ARCH) libmcount libtraceevent utils
install:
@\$(MAKE) -C \$(srcdir) install
test: all
@\$(MAKE) -C \$(srcdir)/tests TESTARG="\$(TESTARG)" test
.PHONY: all clean prepare test install
EOF
if [ $(id -u) -eq 0 ]; then
chmod 666 $objdir/Makefile
fi
fi