This repository was archived by the owner on Jun 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·148 lines (126 loc) · 3.31 KB
/
configure
File metadata and controls
executable file
·148 lines (126 loc) · 3.31 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
#!/bin/sh
CC='gcc'
# remove old output files
rm -f config.mk
have_lib() {
echo -n "checking for $1 ... "
pkg-config "--exists" $1 2>/dev/null
test $? -ne 0 && echo "no" && return 1
echo "yes" && return 0
}
have_header() {
echo -n "checking for $1 ... "
echo "#include <$1>" | $CC $CFLAGS -E -xc -o /dev/null - 2>/dev/null
test $? -ne 0 && echo "no" && return 1
echo "yes" && return 0
}
assert_header() {
have_header "$1" && return 0
echo "missing header: $1" && exit 1
}
assert_lib() {
have_lib "$1" && return 0
echo "missing lib: $1" && exit 1
}
assert_version() {
pkg-config "--atleast-version=$2" "$1" && return 0
echo "need $1 $2, have `pkg-config --modversion $1`" && exit 1
}
have_file() {
echo -n "checking for $1 ... "
test -e "$1" && echo "yes" && return 0
echo "no" && return 1
}
have_exe() {
echo -n "checking for $1 ... "
which $1 >/dev/null 2>/dev/null
test $? -ne 0 && echo "no" && return 1
echo "yes" && return 0
}
assert_exe() {
have_exe $1 && return 0
echo "missing: $1" && exit 1
}
have_cpuflag() {
echo -n "checking for $1 ... "
grep -q $1 "/proc/cpuinfo" 2>/dev/null
test $? -ne 0 && echo "no" && return 1
echo "yes" && return 0
}
ask() {
while true; do
read -p "$1 [y/n] " reply
case "$reply" in
Y|y) return 0;;
N|n) return 1;;
esac
done
}
run_script() {
old_dir=`pwd`
if test -n "$2"; then cd $2; fi
./$1
result=$?
cd $old_dir
return $result
}
# in case there is local stuff
if test -d "/usr/local/include"; then CPPFLAGS="$CPPFLAGS -I/usr/local/include"; fi
if test -d '/usr/local/lib'; then LDFLAGS="$LDFLAGS -L/usr/local/lib"; fi
# build environment
assert_exe 'make'
assert_exe "$CC"
assert_exe "pkg-config"
assert_lib 'shout'
assert_version 'shout' '2.2.2'
assert_header 'lame/lame.h'
assert_lib 'samplerate'
# bass
check_bass() {
if have_file 'bass/bass.h' && have_file 'bass/libbass.so'; then
assert_lib 'id3tag'
CPPFLAGS="$CPPFLAGS -DENABLE_BASS -Ibass"
LINK_BASS='$(shell pkg-config --libs id3tag) -ldl'
BASSSOURCE='libbass.o bassdecoder.o'
return 0
fi
return 1
}
# only for linux
if test `uname -s` = 'Linux' && ! check_bass; then
if ask '==> download BASS for module playback?'; then
assert_exe 'wget'
assert_exe 'unzip'
run_script getbass.sh bass
if ! check_bass; then
exit 1;
fi
fi
fi
# ffmpeg
assert_lib 'libavcodec'
assert_lib 'libavformat'
assert_lib 'libavutil'
CPPFLAGS="$CPPFLAGS `pkg-config --cflags libavformat libavcodec libavutil`"
LINK_FFMPEG='$(shell pkg-config --libs libavformat libavcodec libavutil)'
if ! have_header 'libavcodec/avcodec.h'; then
CPPFLAGS="$CPPFLAGS -DFFMPEG_OLD_HEADER"
fi
# replaygain
if ! have_file 'replaygain/libreplaygain.a'; then
run_script build.sh replaygain
fi
if have_exe "git" && have_file ".git" ; then
CPPFLAGS="$CPPFLAGS -DBUILD_ID=\$(shell git describe --always)"
fi
# generate makefile
cat <<EOF >config.mk
CC = $CC
CFLAGS = -std=c99 -O2 -ffast-math -pthread
CPPFLAGS = $CPPFLAGS -Ireplaygain
BASSOURCE = $BASSSOURCE
LINK_BASS = $LINK_BASS -pthread
LINK_FFMPEG = $LINK_FFMPEG
LDFLAGS = $LDFLAGS -lm
EOF
echo "smooth operator"