1 # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 AC_INIT([cras], [0.1], [dgreid (a] chromium.org], 5 [cras], [http://www.chromium.org/]) 6 AC_PREREQ([2.59]) 7 8 AC_CANONICAL_HOST 9 10 AM_INIT_AUTOMAKE([1.10 -Wall no-define]) 11 #AC_CONFIG_HEADERS([config.h]) 12 13 m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) 14 AC_PROG_LIBTOOL 15 AC_PROG_CC 16 # c++ unit test (gtest). 17 AC_PROG_CXX 18 AC_LANG_C 19 AM_PROG_CC_C_O 20 PKG_PROG_PKG_CONFIG 21 AC_CONFIG_FILES([Makefile src/Makefile libcras.pc]) 22 23 PKG_CHECK_MODULES([LIBSPEEX], [ speexdsp >= 1.2 ]) 24 PKG_CHECK_MODULES([ASOUNDLIB], [ alsa >= 1.1.0 ]) 25 26 AC_ARG_ENABLE([dbus], AS_HELP_STRING([--disable-dbus], [Disable all DBUS uses]), have_dbus=$enableval, have_dbus=yes) 27 AM_CONDITIONAL(HAVE_DBUS, test "$have_dbus" = "yes") 28 if test "$have_dbus" = "yes"; then 29 PKG_CHECK_MODULES([DBUS], [ dbus-1 >= 1.4.12 ]) 30 AS_VAR_APPEND([DBUS_CFLAGS], [" -DCRAS_DBUS"]) 31 else 32 DBUS_CFLAGS= 33 DBUS_LIBS= 34 fi 35 AC_SUBST(DBUS_LIBS) 36 AC_SUBST(DBUS_CFLAGS) 37 38 AC_ARG_ENABLE([selinux], AS_HELP_STRING([--enable-selinux], [Enable SELinux calls]), have_selinux=$enableval, have_selinux=no) 39 AM_CONDITIONAL(HAVE_SELINUX, test "$have_selinux" = "yes") 40 if test "$have_selinux" = "yes"; then 41 PKG_CHECK_MODULES([SELINUX], [ libselinux ]) 42 AS_VAR_APPEND([SELINUX_CFLAGS], [" -DCRAS_SELINUX"]) 43 else 44 SELINUX_CFLAGS= 45 SELINUX_LIBS= 46 fi 47 AC_SUBST(SELINUX_CFLAGS) 48 AC_SUBST(SELINUX_LIBS) 49 50 # WEBRTC APM support 51 AC_ARG_ENABLE([webrtc-apm], AS_HELP_STRING([--disable-webrtc-apm], [Disable webrtc-apm uses]), have_webrtc_apm=$enableval, have_webrtc_apm=yes) 52 AM_CONDITIONAL(HAVE_WEBRTC_APM, test "$have_webrtc_apm" = "yes") 53 if test "$have_webrtc_apm" = "yes"; then 54 PKG_CHECK_MODULES([WEBRTC_APM], [ libwebrtc_apm ]) 55 AC_DEFINE(HAVE_WEBRTC_APM, 1, [Define to use webrtc-apm.]) 56 else 57 WEBRTC_APM_LIBS= 58 fi 59 AC_SUBST(WEBRTC_APM_LIBS) 60 61 PKG_CHECK_MODULES([SBC], [ sbc >= 1.0 ]) 62 AC_CHECK_LIB(asound, snd_pcm_ioplug_create,, 63 AC_ERROR([*** libasound has no external plugin SDK]), -ldl) 64 65 AC_ARG_ENABLE([alsa-plugin], AS_HELP_STRING([--disable-alsa-plugin], 66 [Disable building of ALSA plugin])) 67 68 AC_ARG_ENABLE([metrics], AS_HELP_STRING([--enable-metrics], [Enable metrics uses]), have_metrics=$enableval, have_metrics=no) 69 if test "$have_metrics" = "yes"; then 70 AC_DEFINE(HAVE_LIB_METRICS, 1, [Define to use libmetrics]) 71 METRICS_LIBS=-lmetrics-${BASE_VER} 72 else 73 METRICS_LIBS= 74 fi 75 AC_SUBST(METRICS_LIBS) 76 77 # Determine ALSA plugin directory. 78 test "x$prefix" = xNONE && prefix=$ac_default_prefix 79 test "x$exec_prefix" = xNONE && exec_prefix=$prefix 80 81 AC_ARG_WITH(plugindir, 82 AS_HELP_STRING([--with-plugindir=dir], 83 [path where ALSA plugin files are stored]), 84 plugindir="$withval", plugindir="") 85 if test -z "$plugindir"; then 86 eval dir="$libdir" 87 case "$dir" in 88 /*) ;; 89 *) dir="$dir" 90 esac 91 plugindir="$dir/alsa-lib" 92 fi 93 AC_DEFINE_UNQUOTED(ALSA_PLUGIN_DIR, "$plugindir", 94 [directory containing ALSA add-on modules]) 95 ALSA_PLUGIN_DIR="$plugindir" 96 AC_SUBST(ALSA_PLUGIN_DIR) 97 98 # Determine CRAS configuration directory. 99 eval cras_config_file_dir="$sysconfdir/cras" 100 AC_DEFINE_UNQUOTED(CRAS_CONFIG_FILE_DIR, "$cras_config_file_dir", 101 [directory containing CRAS configuration]) 102 103 # CRAS socket dir 104 AC_ARG_WITH(socketdir, 105 AS_HELP_STRING([--with-socketdir=dir], 106 [path where CRAS stores its sockets]), 107 socketdir="$withval", 108 socketdir="/run/cras") 109 AC_DEFINE_UNQUOTED(CRAS_SOCKET_FILE_DIR, "$socketdir", 110 [directory containing CRAS socket files]) 111 112 # SSE4_2 support 113 AC_ARG_ENABLE(sse42, [AS_HELP_STRING([--enable-sse42],[enable SSE42 optimizations])], have_sse42=$enableval, have_sse42=yes) 114 if test "x$host_cpu" != xx86_64; then 115 have_sse42=no 116 fi 117 if test "$have_sse42" = "yes"; then 118 AC_DEFINE(HAVE_SSE42,1,[Define to enable SSE42 optimizations.]) 119 SSE42_CFLAGS="-DOPS_SSE42 -msse4.2 -ffast-math" 120 fi 121 AM_CONDITIONAL(HAVE_SSE42, test "$have_sse42" = "yes") 122 AC_SUBST(SSE42_CFLAGS) 123 124 # AVX support 125 AC_ARG_ENABLE(avx, [AS_HELP_STRING([--enable-avx],[enable AVX optimizations])], have_avx=$enableval, have_avx=yes) 126 if test "x$host_cpu" != xx86_64; then 127 have_avx=no 128 fi 129 if test "$have_avx" = "yes"; then 130 AC_DEFINE(HAVE_AVX,1,[Define to enable AVX optimizations.]) 131 AVX_CFLAGS="-DOPS_AVX -mavx -ffast-math" 132 fi 133 AM_CONDITIONAL(HAVE_AVX, test "$have_avx" = "yes") 134 AC_SUBST(AVX_CFLAGS) 135 136 # AVX2 support 137 AC_ARG_ENABLE(avx2, [AS_HELP_STRING([--enable-avx2],[enable AVX2 optimizations])], have_avx2=$enableval, have_avx2=yes) 138 if test "x$host_cpu" != xx86_64; then 139 have_avx2=no 140 fi 141 if test "$have_avx2" = "yes"; then 142 AC_DEFINE(HAVE_AVX2,1,[Define to enable AVX2 optimizations.]) 143 AVX2_CFLAGS="-DOPS_AVX2 -mavx2 -ffast-math" 144 fi 145 AM_CONDITIONAL(HAVE_AVX2, test "$have_avx2" = "yes") 146 AC_SUBST(AVX2_CFLAGS) 147 148 # FMA support 149 AC_ARG_ENABLE(fma, [AS_HELP_STRING([--enable-fma],[enable FMA optimizations])], have_fma=$enableval, have_fma=yes) 150 if test "x$host_cpu" != xx86_64; then 151 have_fma=no 152 fi 153 if test "$have_fma" = "yes"; then 154 AC_DEFINE(HAVE_FMA,1,[Define to enable FMA optimizations.]) 155 FMA_CFLAGS="-DOPS_FMA -mavx2 -mfma -ffast-math" 156 fi 157 AM_CONDITIONAL(HAVE_FMA, test "$have_fma" = "yes") 158 AC_SUBST(FMA_CFLAGS) 159 160 AC_OUTPUT 161 162 AC_MSG_NOTICE([ 163 164 Enable SSE42: ${have_sse42} 165 Enable AVX: ${have_avx} 166 Enable AVX2: ${have_avx2} 167 Enable FMA: ${have_fma} 168 ]) 169