-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·73 lines (60 loc) · 1.49 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
#!/bin/sh
#
# Dummy configure to extract parameters and pass the to make
#
[ -z "$CC" ] && CC=gcc
HEADERS=""
try_compile_c()
{
echo "$1" | $CC $CFLAGS -c -x c -o /dev/null - > /dev/null 2>&1
}
check_for_compiler()
{
echo -n "Checking for working compiler ($CC) ... "
if try_compile_c "int main(void) { return 0; }"; then
echo "OK"
else
echo "Failed"
exit 1;
fi
}
check_for_header()
{
echo -n "Checking for <$1> ... "
try_compile_c "
#include <$1>
int main(void) { return 0; }"
if [ $? -eq 0 ]; then
echo "Yes"
HEADERS="$HEADERS $1"
else
echo "No"
fi
}
check_for_compiler
check_for_header "mpv/client.h"
check_for_header "mpg123.h"
echo -n > config.mk
echo "#ifndef CONFIG_H" > config.h
echo "#define CONFIG_H" >> config.h
echo >> config.h
while true; do
case "$1" in
--prefix=*) echo "PREFIX=$(echo $1|cut -d= -f2)" >> config.mk; shift;;
--libdir=*) echo "LIBDIR=$(echo $1|cut -d= -f2)" >> config.mk; shift;;
--mandir=*) echo "MANDIR=$(echo $1|cut -d= -f2)" >> config.mk; shift;;
--bindir=*) echo "BINDIR=$(echo $1|cut -d= -f2)" >> config.mk; shift;;
--sysconfdir=*) echo "SYSCONFDIR=$(echo $1|cut -d= -f2)" >> config.mk; shift;;
--*) shift;;
*) break;
esac
done
[ -n "$CC" ] && echo "CC=$CC" >> config.mk
[ -n "$CFLAGS" ] && echo "CFLAGS=$CFLAGS" >> config.mk
for i in $HEADERS; do
HEADER=$(echo $i |tr [a-z]./ [A-Z]__)
echo "#define HAVE_$HEADER 1" >> config.h
echo "HAVE_$HEADER=yes" >> config.mk
done
echo >> config.h
echo "#endif /* CONFIG_H */" >> config.h