-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure
executable file
·94 lines (75 loc) · 2.1 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/bash
# Copyright (c) 2022 LG Electronics Inc.
# SPDX-License-Identifier: GPL-2.0
prefix=/usr/local
CC=${CC:-${CROSS_COMPILE}gcc}
CXX=${CXX:-${CROSS_COMPILE}g++}
LD=${LD:-${CROSS_COMPILE}ld}
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)
--objdir=<DIR> set build dir as <DIR> (default: \${PWD})
"
exit 1
}
while getopts ":ho:-:p" opt; do
case "$opt" in
-)
# process --long-options
case "$OPTARG" in
help) usage ;;
*=*) opt=${OPTARG%%=*}; val=${OPTARG#*=}
eval "${opt/-/_}='$val'" ;;
*) ;;
esac
;;
o) output=$OPTARG ;;
*) usage ;;
esac
done
shift $((OPTIND - 1))
bindir=${bindir:-${prefix}/bin}
libdir=${libdir:-${prefix}/lib}
# objdir can be changed, reset output
objdir=$(readlink -f ${objdir})
output=${output:-${objdir}/.config}
cat >$output <<EOF
# this file is generated automatically
override prefix := $prefix
override bindir := $bindir
override libdir := $libdir
EOF
cat >>$output <<EOF
override CC := $CC
override CXX := $CXX
override LD := $LD
override CFLAGS = $CFLAGS
override CXXFLAGS = $CXXFLAGS
override LDFLAGS = $LDFLAGS
override srcdir := $srcdir
override objdir := $objdir
EOF
if [ "$srcdir" != "$objdir" ]; then
cat > $objdir/Makefile <<EOF
srcdir := $srcdir
objdir := $objdir
export srcdir objdir
MAKEFLAGS = --no-print-directory
all:
@\$(MAKE) -C \$(srcdir)
clean:
@rm -f heaptrace libheaptrace.so *.o
install:
@\$(MAKE) -C \$(srcdir) install
.PHONY: all clean install
EOF
if [ $(id -u) -eq 0 ]; then
chmod 666 $objdir/Makefile
fi
fi