1#!/bin/bash
2
3set -e
4
5bits32=
6cbits32=
7modules=
8alisp=
9lto=
10if [ $# -ne 0 ]; then
11  endloop=
12  while [ -z "$endloop" ]; do
13    case "$1" in
14    32)
15      bits32=yes
16      cbits32="-m32"
17      echo "Forced 32-bit library build..."
18      shift ;;
19    modules)
20      modules=yes
21      echo "Forced mixer modules build..."
22      shift ;;
23    alisp)
24      alisp=yes
25      echo "Forced alisp code build..."
26      shift ;;
27    python2)
28      python2=yes
29      echo "Forced python2 interpreter build..."
30      shift ;;
31    lto)
32      lto="-flto -flto-partition=none"
33      echo "Forced lto build..."
34      shift ;;
35    static)
36      static=yes
37      echo "Selected static build..."
38      shift ;;
39    *)
40      endloop=yes
41      ;;
42    esac
43  done
44fi
45if [ $# -ne 0 -a -z "$bit32" ]; then
46  args="$@"
47elif [ -r /etc/asound/library_args ]; then
48  args="`cat /etc/asound/library_args`"
49  if [ -z "$bits32" ]; then
50    test -r /etc/asound/library64_args && \
51      args="`cat /etc/asound/library64_args`"
52  fi
53else
54  prefix="/usr"
55  libdir="/usr/lib"
56  libdir2="/usr/lib"
57  if [ -z "$bits32" ]; then
58    test -d /usr/lib64 && libdir="/usr/lib64"
59    test -f /lib64/libasound.so.2 && libdir="/lib64"
60    test -d /usr/lib64 && libdir2="/usr/lib64"
61  else
62    test -f /lib/libasound.so.2 && libdir="/lib"
63  fi
64  args="--disable-aload --prefix=$prefix --libdir=$libdir"
65  args="$args --with-plugindir=$libdir2/alsa-lib"
66  args="$args --with-pkgconfdir=$libdir2/pkgconfig"
67fi
68
69if [ "$modules" = "yes" ]; then
70  args="$args --enable-mixer-modules"
71  args="$args --enable-mixer-pymods"
72fi
73
74if [ "$alisp" = "yes" ]; then
75  args="$args --enable-alisp"
76fi
77
78if [ "$python2" = "yes" ]; then
79  args="$args --enable-python2"
80fi
81
82if [ "$static" = "yes" ]; then
83  #args="$args --enable-shared=no --enable-static=yes"
84  args="$args --disable-shared"
85fi
86
87
88touch ltconfig
89libtoolize --force --copy --automake
90aclocal $ACLOCAL_FLAGS
91autoheader
92automake --foreign --copy --add-missing
93touch depcomp		# seems to be missing for old automake
94autoconf
95export CFLAGS="$cbits32 -O2 -Wall -W -Wunused-const-variable=0 -pipe -g $lto"
96if [ -n "$lto" ]; then
97  export AR="gcc-ar"
98  export RANLIB="gcc-ranlib"
99fi
100echo "CFLAGS=$CFLAGS"
101echo "./configure $args"
102./configure $args || exit 1
103unset CFLAGS
104if [ -z "$GITCOMPILE_NO_MAKE" ]; then
105  make
106fi
107