[go: up one dir, main page]

File: configure

package info (click to toggle)
uftrace 0.9.0-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 3,896 kB
  • sloc: ansic: 41,425; python: 7,369; makefile: 698; asm: 488; cpp: 461; sh: 349
file content (238 lines) | stat: -rwxr-xr-x 6,491 bytes parent folder | download
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/usr/bin/env 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})
  --sysconfdir=<DIR>    override the etc dir as <DIR>

  --with-elfutils=<DIR> search for elfutils in <DIR>/include and <DIR>/lib

  --without-libelf      build without libelf (and libdw)     (even if found on the system)
  --without-libdw       build without libdw                  (even if found on the system)
  --without-libstdc++   build without libstdc++              (even if found on the system)
  --without-libpython   build without libpython2.7           (even if found on the system)
  --without-libncurses  build without libncursesw            (even if found on the system)

  -p                    preserve old setting

  Some influential environment variables:
    ARCH                Target architecture    e.g. arm, aarch64, or x86_64
    CROSS_COMPILE       Specify the compiler prefix during compilation
                        e.g. CC is overridden by \$(CROSS_COMPILE)gcc
    CFLAGS              C compiler flags
    LDFLAGS             linker flags
"
    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
}

IGNORE=
while getopts ":ho:-:p" opt; do
    case "$opt" in
        -)
	    # process --long-options
	    case "$OPTARG" in
                help)            usage ;;
                without-libelf)  IGNORE="${IGNORE} libelf libdw" ;;
                without-*)       IGNORE="${IGNORE} ${OPTARG#*-}" ;;
                *=*)             opt=${OPTARG%%=*}; val=${OPTARG#*=}
                                 eval "${opt/-/_}='$val'" ;;
                *)               ;;
            esac
	    ;;
        o)       output=$OPTARG ;;
        p)       preserve ;;
        *)       usage ;;
    esac
done
shift $((OPTIND - 1))

for arg; 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 [ "$etcdir" = /usr/etc ]; then
    etcdir=/etc
fi
if [ -n "$sysconfdir" ]; then
    etcdir=$sysconfdir
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=

export CC CFLAGS LD LDFLAGS

make -siC ${srcdir}/check-deps check-clean
make -siC ${srcdir}/check-deps check-build

for dep in $IGNORE; do
    TARGET=
    case "$dep" in
        libelf)      TARGET=have_libelf        ;;
        libdw)       TARGET=have_libdw         ;;
        libpython*)  TARGET=have_libpython2.7  ;;
        libncurse*)  TARGET=have_libncurses    ;;
        libstdc++)   TARGET=cxa_demangle       ;;
        perf*)       TARGET=perf_clockid       ;;
        sched*)      TARGET=perf_context_switch;;
        *)           ;;
    esac
    if [ ! -z "$TARGET" ]; then
        rm -f ${srcdir}/check-deps/$TARGET
    fi
done

echo "uftrace detected system features:"

print_feature()
{
    item=$1
    file=$2
    description=$3

    if [ -t 1 ]; then
        # use colored output only when stdout is tty
        if [ -f ${srcdir}/check-deps/${file} ]; then
             \033[0m"
        else
            
        fi
    else
        if [ -f ${srcdir}/check-deps/${file} ]; then
             "
        else
            
        fi
    fi
    printf "...%15s: [ ${onoff} ] - %s\n" "${item}" "${description}"
}

printf "...%15s: %s\n" "prefix" "${prefix}"
print_feature "libelf" "have_libelf" "more flexible ELF data handling"
print_feature "libdw" "have_libdw" "DWARF debug info support"
print_feature "libpython2.7" "have_libpython2.7" "python scripting support"
print_feature "libncursesw" "have_libncurses" "TUI support"
print_feature "cxa_demangle" "cxa_demangle" "full demangler support with libstdc++"
print_feature "perf_event" "perf_clockid" "perf (PMU) event support"
print_feature "schedule" "perf_context_switch" "scheduler event support"

cat >$output <<EOF
# this file is generated automatically
override prefix := $prefix
override bindir := $bindir
override libdir := $libdir
override mandir := $mandir
override etcdir := $etcdir
EOF

if [ ! -z $with_elfutils ]; then
    echo "override elfdir := $with_elfutils" >> $output
fi

cat >>$output <<EOF

override ARCH   := $ARCH
override CC     := $CC
override LD     := $LD
override CFLAGS  = $CFLAGS
override LDFLAGS = $LDFLAGS

override srcdir := $srcdir
override objdir := $objdir
EOF

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 cmds arch libmcount libtraceevent utils misc
	@rm -f uftrace version.h *.o *.op

prepare:
	@mkdir -p cmds arch/\$(ARCH) libmcount libtraceevent utils misc

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