-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
configure
executable file
·88 lines (71 loc) · 2.09 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
#!/bin/sh
[ -z "${CC}" ] && CC=gcc
echo Configuring Shairport
rm -f config.mk config.h
echo "// automatically generated file" > config.h
LDFLAGS="${LDFLAGS} -lm -lpthread"
export_config()
{
echo "#define $1" >> config.h
echo "$1=yes" >> config.mk
eval "$1=yes"
}
# check for header $1 with CONFIG_ var $2
check_header()
{
echo "#include<$1>" > .header_test.c
if ${CC} ${CFLAGS} ${LDFLAGS} -c .header_test.c > /dev/null 2>&1 /dev/null; then
echo "$1 found"
if [ "$2" ]; then
export_config $2
fi
else
echo "$1 not found"
if [ ! "$2" ]; then
echo "Required header not found, cannot continue"
rm .header_test.c
rm -f config.mk config.h
exit 1
fi
fi
rm -f .header_test.c .header_test.o
}
# check for and use pkg-config package $2 with CONFIG_ var $3
do_pkg_config()
{
if pkg-config $2 2>/dev/null; then
CFLAGS="${CFLAGS} `pkg-config --cflags $2`"
LDFLAGS="${LDFLAGS} `pkg-config --libs $2`"
if [ "$3" ]; then
export_config $3
fi
echo "$1 found"
else
echo "$1 or its dev package not found"
if [ ! "$3" ]; then
echo "Required package not found, cannot continue"
rm -f config.mk config.h
exit 1
fi
fi
}
do_pkg_config OpenSSL openssl
do_pkg_config libao ao CONFIG_AO
do_pkg_config PulseAudio libpulse-simple CONFIG_PULSE
do_pkg_config ALSA alsa CONFIG_ALSA
do_pkg_config Avahi\ client avahi-client CONFIG_AVAHI
if [ `uname` = 'OpenBSD' ]; then
echo "OpenBSD machine, use sndio"
export_config CONFIG_SNDIO
LDFLAGS="${LDFLAGS} -lsndio"
fi
check_header getopt.h CONFIG_HAVE_GETOPT_H
# Don't build dns_sd backend if we have avahi
if [ -z "$CONFIG_AVAHI" ]; then
check_header dns_sd.h CONFIG_HAVE_DNS_SD_H
fi
echo "CFLAGS+=${CFLAGS}" >> config.mk
echo "LDFLAGS+=${LDFLAGS}" >> config.mk
echo CFLAGS: ${CFLAGS}
echo LDFLAGS: ${LDFLAGS}
echo "Configure successful. You may now build with 'make'"