| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# |
| 4 |
# display help screeen |
| 5 |
# |
| 6 |
help() { |
| 7 |
cat << END |
| 8 |
Usage: configure [options] |
| 9 |
--prefix=DIR set arch independent install prefix to DIR [$prefix] |
| 10 |
--exec-prefix=DIR set arch dependent install prefix to DIR [\$prefix] |
| 11 |
--bindir=DIR install executables in DIR [\$exec_prefix/bin] |
| 12 |
--datadir=DIR install read-only data in DIR [\$prefix/share] |
| 13 |
--includedir=DIR install header files in DIR [\$prefix/include] |
| 14 |
--libdir=DIR install libraries in DIR [\$exec_prefix/lib] |
| 15 |
--pkgconfdir=DIR install pkg-config file in DIR [\$libdir/pkgconfig] |
| 16 |
--mandir=DIR install man pages in DIR [\$prefix/man] |
| 17 |
--precision=NUMBER default sndiod device bit-depth [$precision] |
| 18 |
--privsep-user=USER non-privileged user for sndio daemon [$user] |
| 19 |
--enable-alsa enable alsa audio & midi backends [$alsa] |
| 20 |
--disable-alsa disable alsa audio & midi backends |
| 21 |
--enable-sun enable sun audio backend [$sun] |
| 22 |
--disable-sun disable sun audio backend |
| 23 |
--enable-rmidi enable character device midi backend [$rmidi] |
| 24 |
--disable-rmidi disable character device midi backend |
| 25 |
--enable-umidi enable usb-midi backend [$umidi] |
| 26 |
--disable-umidi disable usb-midi backend |
| 27 |
--enable-dynamic build the dynamic library [$dynamic] |
| 28 |
--enable-static build the static library [$static] |
| 29 |
--with-libbsd use the libbsd rather than bsd-compat/* |
| 30 |
--without-libbsd don't use libbsd |
| 31 |
--default-dev=DEV set default device [$dev] |
| 32 |
END |
| 33 |
} |
| 34 |
|
| 35 |
# |
| 36 |
# defaults |
| 37 |
# |
| 38 |
version=1.10.0 # package version (used by pkg-config) |
| 39 |
prefix=/usr/local # where to install sndio |
| 40 |
so="libsndio.so.\${MAJ}.\${MIN}" # shared libs to build |
| 41 |
so_cflags="-fPIC" # clags to build shared objects |
| 42 |
static_lib="libsndio.a" # static libs to build |
| 43 |
alsa=no # do we want alsa support ? |
| 44 |
sun=no # do we want sun support ? |
| 45 |
oss=no # do we want oss support ? |
| 46 |
rmidi=no # do we want support for raw char dev ? |
| 47 |
umidi=no # do we want support for umidi ? |
| 48 |
dynamic=yes # do we build libsndio.so and links |
| 49 |
static=no # do we build libsndio.a |
| 50 |
precision=16 # sndiod default device bit-depth |
| 51 |
user=_sndio # non-privileged user for sndio daemon |
| 52 |
libbsd=no # use libbsd? |
| 53 |
so_ldflags= # extra linker flags for shared libs |
| 54 |
unset vars # variables passed as arguments |
| 55 |
unset exec_prefix # prefix for arch. independent files |
| 56 |
unset bindir # path where to install binaries |
| 57 |
unset datadir # path where to install doc |
| 58 |
unset mandir # path where to install man pages |
| 59 |
unset includedir # path where to install header file |
| 60 |
unset libdir # path where to install library |
| 61 |
unset pkgconfdir # path where to install pkg-config file |
| 62 |
unset defs # no extra #defines |
| 63 |
unset ldadd # no extra libraries (-l options) |
| 64 |
unset dev |
| 65 |
|
| 66 |
# |
| 67 |
# guess OS-specific parameters |
| 68 |
# |
| 69 |
case `uname` in |
| 70 |
Linux) |
| 71 |
alsa=yes |
| 72 |
ldadd="-lrt -lm" |
| 73 |
user=sndiod |
| 74 |
so_link="libsndio.so libsndio.so.\${MAJ} libsndio.so.\${MAJ}.0" |
| 75 |
so_ldflags="-Wl,-soname=libsndio.so.\${MAJ}" |
| 76 |
defs='-D_GNU_SOURCE -DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME' |
| 77 |
;; |
| 78 |
GNU/kFreeBSD) # OSS output support on kFreeBSD, but otherwise like linux |
| 79 |
oss=yes |
| 80 |
ldadd="-lrt -lm" |
| 81 |
user=sndiod |
| 82 |
so_ldflags="-Wl,-soname=libsndio.so.\${MAJ}" |
| 83 |
so_link="libsndio.so libsndio.so.\${MAJ} libsndio.so.\${MAJ}.0" |
| 84 |
defs='-D_GNU_SOURCE -DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME \\\ |
| 85 |
-DHAVE_GETPEEREID' |
| 86 |
;; |
| 87 |
GNU) # No output support on Hurd, but otherwise like linux |
| 88 |
oss=no |
| 89 |
ldadd="-lrt -lm" |
| 90 |
user=sndiod |
| 91 |
so_ldflags="-Wl,-soname=libsndio.so.\${MAJ}" |
| 92 |
so_link="libsndio.so libsndio.so.\${MAJ} libsndio.so.\${MAJ}.0" |
| 93 |
defs='-D_GNU_SOURCE -DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME \\\ |
| 94 |
-DHAVE_GETPEEREID' |
| 95 |
;; |
| 96 |
NetBSD) |
| 97 |
sun=no |
| 98 |
rmidi=yes |
| 99 |
user=_sndio |
| 100 |
so_link="libsndio.so" |
| 101 |
defs='-DHAVE_ARC4RANDOM -DHAVE_GETPEEREID -DHAVE_ISSETUGID \\\ |
| 102 |
-DHAVE_STRLCAT -DHAVE_STRLCPY \\\ |
| 103 |
-DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME' |
| 104 |
;; |
| 105 |
OpenBSD) |
| 106 |
sun=yes |
| 107 |
rmidi=yes |
| 108 |
user=_sndiop |
| 109 |
defs='-DHAVE_ARC4RANDOM -DHAVE_GETPEEREID -DHAVE_ISSETUGID \\\ |
| 110 |
-DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRTONUM \\\ |
| 111 |
-DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME' |
| 112 |
;; |
| 113 |
DragonFly|FreeBSD) |
| 114 |
oss=yes |
| 115 |
umidi=yes |
| 116 |
user=_sndio |
| 117 |
so_ldflags="-Wl,-soname=libsndio.so.\${MAJ}.\${MIN}" |
| 118 |
so_link="libsndio.so" |
| 119 |
defs='-DHAVE_ARC4RANDOM -DHAVE_GETPEEREID -DHAVE_ISSETUGID \\\ |
| 120 |
-DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRTONUM \\\ |
| 121 |
-DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME' |
| 122 |
;; |
| 123 |
Darwin) |
| 124 |
rmidi=no |
| 125 |
so="libsndio.\${MAJ}.\${MIN}.dylib" |
| 126 |
so_link="libsndio.dylib" |
| 127 |
defs='-DHAVE_ARC4RANDOM -DHAVE_GETPEEREID -DHAVE_ISSETUGID \\\ |
| 128 |
-DHAVE_STRLCAT -DHAVE_STRLCPY' |
| 129 |
esac |
| 130 |
|
| 131 |
# shell word separator (none) |
| 132 |
IFS='' |
| 133 |
|
| 134 |
# sed-quoted new-line |
| 135 |
nl='\ |
| 136 |
' |
| 137 |
|
| 138 |
for i; do |
| 139 |
case "$i" in |
| 140 |
--prefix=*) |
| 141 |
prefix="${i#--prefix=}" |
| 142 |
shift;; |
| 143 |
--exec-prefix=*) |
| 144 |
exec_prefix="${i#--exec-prefix=}" |
| 145 |
shift;; |
| 146 |
--bindir=*) |
| 147 |
bindir="${i#--bindir=}" |
| 148 |
shift;; |
| 149 |
--datadir=*) |
| 150 |
datadir="${i#--datadir=}" |
| 151 |
shift;; |
| 152 |
--includedir=*) |
| 153 |
includedir="${i#--includedir=}" |
| 154 |
shift;; |
| 155 |
--libdir=*) |
| 156 |
libdir="${i#--libdir=}" |
| 157 |
shift;; |
| 158 |
--pkgconfdir=*) |
| 159 |
pkgconfdir="${i#--pkgconfdir=}" |
| 160 |
shift;; |
| 161 |
--mandir=*) |
| 162 |
mandir="${i#--mandir=}" |
| 163 |
shift;; |
| 164 |
--enable-dynamic) |
| 165 |
dynamic=yes |
| 166 |
static=no |
| 167 |
shift;; |
| 168 |
--enable-static) |
| 169 |
static=yes |
| 170 |
dynamic=no |
| 171 |
shift;; |
| 172 |
--enable-alsa) |
| 173 |
alsa=yes |
| 174 |
shift;; |
| 175 |
--disable-alsa) |
| 176 |
alsa=no |
| 177 |
shift;; |
| 178 |
--enable-oss) |
| 179 |
oss=yes |
| 180 |
shift;; |
| 181 |
--disable-oss) |
| 182 |
oss=no |
| 183 |
shift;; |
| 184 |
--enable-sun) |
| 185 |
sun=yes |
| 186 |
shift;; |
| 187 |
--disable-sun) |
| 188 |
sun=no |
| 189 |
shift;; |
| 190 |
--enable-rmidi) |
| 191 |
rmidi=yes |
| 192 |
shift;; |
| 193 |
--disable-rmidi) |
| 194 |
rmidi=no |
| 195 |
shift;; |
| 196 |
--enable-umidi) |
| 197 |
umidi=yes |
| 198 |
shift;; |
| 199 |
--disable-umidi) |
| 200 |
umidi=no |
| 201 |
shift;; |
| 202 |
--privsep-user=*) |
| 203 |
user="${i#--privsep-user=}" |
| 204 |
shift;; |
| 205 |
--precision=*) |
| 206 |
precision="${i#--precision=}" |
| 207 |
if [ "$precision" != 16 -a "$precision" != 24 ]; then |
| 208 |
echo "$i: only 16 and 24 are supported" >&2 |
| 209 |
exit 1 |
| 210 |
fi |
| 211 |
shift;; |
| 212 |
--with-libbsd) |
| 213 |
libbsd=yes |
| 214 |
shift;; |
| 215 |
--without-libbsd) |
| 216 |
libbsd=no |
| 217 |
shift;; |
| 218 |
--default-dev=*) |
| 219 |
dev="${i#--default-dev=}" |
| 220 |
shift;; |
| 221 |
CC=*|CFLAGS=*|LDFLAGS=*|AR=*) |
| 222 |
vars="$vars$i$nl" |
| 223 |
shift;; |
| 224 |
*) |
| 225 |
help |
| 226 |
exit 1 |
| 227 |
;; |
| 228 |
esac |
| 229 |
done |
| 230 |
|
| 231 |
# |
| 232 |
# if $xxxdir is not specified, define it to $prefix/xxx |
| 233 |
# |
| 234 |
exec_prefix="${exec_prefix:-$prefix}" |
| 235 |
bindir="${bindir:-$exec_prefix/bin}" |
| 236 |
datadir="${datadir:-$prefix/share}" |
| 237 |
includedir="${includedir:-$prefix/include}" |
| 238 |
libdir="${libdir:-$exec_prefix/lib}" |
| 239 |
pkgconfdir="${pkgconfdir:-$libdir/pkgconfig}" |
| 240 |
mandir="${mandir:-$prefix/share/man}" |
| 241 |
|
| 242 |
# |
| 243 |
# if we build the static library, exclude the dynamic one from the build |
| 244 |
# |
| 245 |
if [ $static = yes ]; then |
| 246 |
so= |
| 247 |
so_link= |
| 248 |
so_cflags= |
| 249 |
so_ldflags= |
| 250 |
else |
| 251 |
static_lib= |
| 252 |
fi |
| 253 |
|
| 254 |
# |
| 255 |
# umidi implies rmidi |
| 256 |
# |
| 257 |
if [ $umidi = yes ]; then |
| 258 |
rmidi=yes |
| 259 |
fi |
| 260 |
|
| 261 |
# |
| 262 |
# if using ALSA, add corresponding parameters |
| 263 |
# |
| 264 |
if [ $alsa = yes ]; then |
| 265 |
defs="$defs -DUSE_ALSA" |
| 266 |
ldadd="-lasound $ldadd" |
| 267 |
fi |
| 268 |
|
| 269 |
# |
| 270 |
# if using OSS, add corresponding parameters |
| 271 |
# |
| 272 |
if [ $oss = yes ]; then |
| 273 |
defs="$defs -DUSE_OSS" |
| 274 |
fi |
| 275 |
|
| 276 |
# |
| 277 |
# if using Sun API, add corresponding parameters |
| 278 |
# |
| 279 |
if [ $sun = yes ]; then |
| 280 |
defs="$defs -DUSE_SUN -DUSE_SUN_MIXER" |
| 281 |
fi |
| 282 |
|
| 283 |
# |
| 284 |
# if using raw character devices for midi, add corresponding parameters |
| 285 |
# |
| 286 |
if [ $rmidi = yes ]; then |
| 287 |
defs="$defs -DUSE_RMIDI" |
| 288 |
fi |
| 289 |
|
| 290 |
# |
| 291 |
# if using usb-midi raw devices for midi, add corresponding parameters |
| 292 |
# |
| 293 |
if [ $umidi = yes ]; then |
| 294 |
defs="$defs -DUSE_UMIDI" |
| 295 |
fi |
| 296 |
|
| 297 |
# |
| 298 |
# if using libbsd, add corresponding parameters |
| 299 |
# |
| 300 |
if [ $libbsd = yes ]; then |
| 301 |
# no arc4random as libbsd has a questionable implementation |
| 302 |
defs="$defs -DUSE_LIBBSD -DHAVE_STRLCPY -DHAVE_STRLCAT -DHAVE_STRTONUM" |
| 303 |
ldadd="$ldadd -lbsd" |
| 304 |
fi |
| 305 |
|
| 306 |
if [ -n "$dev" ]; then |
| 307 |
defs="$defs -DDEFAULT_DEV='\"$dev\"'" |
| 308 |
fi |
| 309 |
|
| 310 |
|
| 311 |
for f in Makefile aucat/Makefile midicat/Makefile sndiod/Makefile \ |
| 312 |
libsndio/Makefile \ |
| 313 |
sndioctl/Makefile \ |
| 314 |
examples/Makefile \ |
| 315 |
contrib/init.d.sndiod \ |
| 316 |
contrib/sndiod.service |
| 317 |
do |
| 318 |
sed \ |
| 319 |
-e "s:@bindir@:$bindir:" \ |
| 320 |
-e "s:@datadir@:$datadir:" \ |
| 321 |
-e "s:@includedir@:$includedir:" \ |
| 322 |
-e "s:@libdir@:$libdir:" \ |
| 323 |
-e "s:@pkgconfdir@:$pkgconfdir:" \ |
| 324 |
-e "s:@mandir@:$mandir:" \ |
| 325 |
-e "s:@version@:$version:" \ |
| 326 |
-e "s:@defs@:$defs:" \ |
| 327 |
-e "s:@ldadd@:$ldadd:" \ |
| 328 |
-e "s:@so@:$so:" \ |
| 329 |
-e "s:@so_link@:$so_link:" \ |
| 330 |
-e "s:@so_cflags@:$so_cflags:" \ |
| 331 |
-e "s:@so_ldflags@:$so_ldflags:" \ |
| 332 |
-e "s:@static_lib@:$static_lib:" \ |
| 333 |
-e "s:@vars@:${vars}:" \ |
| 334 |
-e "s:@precision@:$precision:" \ |
| 335 |
-e "s:@user@:$user:" \ |
| 336 |
-e "s:@devs@:$devs:" \ |
| 337 |
< $f.in > $f |
| 338 |
done |
| 339 |
|
| 340 |
# |
| 341 |
# Generate sndio.pc. Substitute path prefixes with ${prefix} or |
| 342 |
# ${exec_prefix} variable names, so that they can be overriden by the |
| 343 |
# user |
| 344 |
# |
| 345 |
cat <<EOF >libsndio/sndio.pc |
| 346 |
prefix=${prefix} |
| 347 |
exec_prefix=`echo $exec_prefix | sed -e "s:^${prefix}:\\${prefix}:"` |
| 348 |
libdir=`echo $libdir | sed -e "s:^${exec_prefix}:\\${exec_prefix}:"` |
| 349 |
includedir=`echo $includedir | sed -e "s:^${prefix}:\\${prefix}:"` |
| 350 |
|
| 351 |
Name: sndio |
| 352 |
Description: sndio library |
| 353 |
Version: ${version} |
| 354 |
Requires: |
| 355 |
Libs: -L\${libdir} -lsndio |
| 356 |
Cflags: -I\${includedir} |
| 357 |
EOF |
| 358 |
|
| 359 |
chmod +x contrib/init.d.sndiod |
| 360 |
|
| 361 |
cat <<EOF |
| 362 |
|
| 363 |
version.................. $version |
| 364 |
bindir................... $bindir |
| 365 |
datadir.................. $datadir |
| 366 |
includedir............... $includedir |
| 367 |
libdir................... $libdir |
| 368 |
pkgconfdir............... $pkgconfdir |
| 369 |
mandir................... $mandir |
| 370 |
user..................... $user |
| 371 |
libbsd................... $libbsd |
| 372 |
precision................ $precision |
| 373 |
alsa..................... $alsa |
| 374 |
oss...................... $oss |
| 375 |
sun...................... $sun |
| 376 |
rmidi.................... $rmidi |
| 377 |
umidi.................... $umidi |
| 378 |
static................... $static |
| 379 |
|
| 380 |
Do "make && make install" to compile and install sndio |
| 381 |
|
| 382 |
Installation requires the "$libdir" directory to be part of |
| 383 |
the system library search path. The "$user" user must exist and |
| 384 |
its primary group must have access to audio and MIDI hardware. |
| 385 |
|
| 386 |
EOF |