forked from kitsunyan/intel-undervolt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·91 lines (81 loc) · 1.92 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
#!/bin/sh
arg() {
local a n s r
s="$1"
r="$2"
shift 2
for a in "$@"; do
n="${a%%=*}"
[ "$n" = "--$s" ] && r="${a#*=}"
done
echo "$r"
}
enable() {
local a n s r
s="$1"
r=false
shift
for a in "$@"; do
n="${a#--enable-}"
[ "$n" = "$s" ] && r=true
n="${a#--disable-}"
[ "$n" = "$s" ] && r=false
done
echo "$r"
}
pkgconfig="`arg pkgconfig pkg-config "$@"`"
bindir="`arg bindir /usr/bin "$@"`"
sysconfdir="`arg sysconfdir /etc "$@"`"
runstatedir="`arg runstatedir /run "$@"`"
enable_systemd="`enable systemd false "$@"`"
enable_elogind="`enable elogind false "$@"`"
enable_openrc="`enable openrc false "$@"`"
unitdir=
"$enable_systemd" && {
unitdir="`arg unitdir '' "$@"`"
[ -z "$unitdir" ] && unitdir="`"$pkgconfig" systemd --variable=systemdsystemunitdir`"
[ -z "$unitdir" ] && {
echo 'Failed to configure unitdir'
exit 1
}
}
eloginddir=
"$enable_elogind" && {
eloginddir="`arg eloginddir '' "$@"`"
[ -z "$eloginddir" ] && eloginddir="`"$pkgconfig" libelogind --variable=libdir`"
[ -z "$eloginddir" ] && {
echo 'Failed to configure eloginddir'
exit 1
}
}
sedcond() {
local v
"$2" && v=1
printf '%s' "s,^\(ENABLE_$1 =\).*$,\1 $v,"
}
sedarg() {
printf '%s' "s,^\($1 =\).*$,\1 $2,"
}
sed Makefile.in \
-e "`sedcond SYSTEMD "$enable_systemd"`" \
-e "`sedcond ELOGIND "$enable_elogind"`" \
-e "`sedcond OPENRC "$enable_openrc"`" \
-e "`sedarg BINDIR "$bindir"`" \
-e "`sedarg SYSCONFDIR "$sysconfdir"`" \
-e "`sedarg RUNSTATEDIR "$runstatedir"`" \
-e "`sedarg UNITDIR "$unitdir"`" \
-e "`sedarg ELOGINDDIR "$eloginddir"`" \
> Makefile || exit 1
echo "Enable systemd: $enable_systemd"
echo "Enable elogind: $enable_elogind"
echo "Enable OpenRC: $enable_openrc"
echo
echo "bindir: $bindir"
echo "sysconfdir: $sysconfdir"
"$enable_openrc" &&
echo "runstatedir: $runstatedir"
"$enable_systemd" &&
echo "unitdir: $unitdir"
"$enable_elogind" &&
echo "eloginddir: $eloginddir"
echo