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. 4AC_INIT([cras], [0.1], [dgreid@chromium.org], 5 [cras], [http://www.chromium.org/]) 6AC_PREREQ([2.59]) 7 8AC_CANONICAL_HOST 9 10AM_INIT_AUTOMAKE([1.10 -Wall no-define]) 11#AC_CONFIG_HEADERS([config.h]) 12 13# To compile with full logs, use V=1 with make instead. 14AM_SILENT_RULES([yes]) 15 16m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) 17AC_PROG_LIBTOOL 18AC_PROG_CC 19# c++ unit test (gtest). 20AC_PROG_CXX 21AC_LANG_C 22AM_PROG_CC_C_O 23PKG_PROG_PKG_CONFIG 24AC_CONFIG_FILES([Makefile src/Makefile libcras.pc]) 25 26PKG_CHECK_MODULES([LIBSPEEX], [ speexdsp >= 1.2 ]) 27PKG_CHECK_MODULES([ASOUNDLIB], [ alsa >= 1.1.0 ]) 28 29AC_CHECK_HEADERS([iniparser/iniparser.h]) 30 31AC_ARG_ENABLE([dbus], AS_HELP_STRING([--disable-dbus], [Disable all DBUS uses]), have_dbus=$enableval, have_dbus=yes) 32AM_CONDITIONAL(HAVE_DBUS, test "$have_dbus" = "yes") 33if test "$have_dbus" = "yes"; then 34 PKG_CHECK_MODULES([DBUS], [ dbus-1 >= 1.4.12 ]) 35 AS_VAR_APPEND([DBUS_CFLAGS], [" -DCRAS_DBUS"]) 36else 37 DBUS_CFLAGS= 38 DBUS_LIBS= 39fi 40AC_SUBST(DBUS_LIBS) 41AC_SUBST(DBUS_CFLAGS) 42 43AC_ARG_ENABLE([selinux], AS_HELP_STRING([--enable-selinux], [Enable SELinux calls]), have_selinux=$enableval, have_selinux=no) 44AM_CONDITIONAL(HAVE_SELINUX, test "$have_selinux" = "yes") 45if test "$have_selinux" = "yes"; then 46 PKG_CHECK_MODULES([SELINUX], [ libselinux ]) 47 AS_VAR_APPEND([SELINUX_CFLAGS], [" -DCRAS_SELINUX"]) 48else 49 SELINUX_CFLAGS= 50 SELINUX_LIBS= 51fi 52AC_SUBST(SELINUX_CFLAGS) 53AC_SUBST(SELINUX_LIBS) 54 55# WEBRTC APM support 56AC_ARG_ENABLE([webrtc-apm], AS_HELP_STRING([--enable-webrtc-apm], [Enable webrtc-apm uses]), have_webrtc_apm=$enableval, have_webrtc_apm=no) 57AM_CONDITIONAL(HAVE_WEBRTC_APM, test "$have_webrtc_apm" = "yes") 58if test "$have_webrtc_apm" = "yes"; then 59 PKG_CHECK_MODULES([WEBRTC_APM], [ libwebrtc_apm ]) 60 AC_DEFINE(HAVE_WEBRTC_APM, 1, [Define to use webrtc-apm.]) 61else 62 WEBRTC_APM_LIBS= 63fi 64AC_SUBST(WEBRTC_APM_LIBS) 65 66# Build fuzzer binaries 67AC_ARG_ENABLE([fuzzer], AS_HELP_STRING([--enable-fuzzer], [Enable fuzzer build]), have_fuzzer=$enableval, have_fuzzer=no) 68AM_CONDITIONAL(HAVE_FUZZER, test "$have_fuzzer" = "yes") 69if test "$have_fuzzer" = "yes"; then 70 AC_DEFINE(HAVE_FUZZER, 1, [Define to build fuzzers.]) 71fi 72 73PKG_CHECK_MODULES([SBC], [ sbc >= 1.0 ]) 74AC_CHECK_HEADERS([iniparser/iniparser.h iniparser.h], [FOUND_INIPARSER=1;break]) 75test [$FOUND_INIPARSER] || AC_MSG_ERROR([Missing iniparser, please install.]) 76AC_SEARCH_LIBS([LADSPA], [ladspa-sdk], [], [ 77 AC_CHECK_HEADERS([ladspa.h], [], [ 78 AC_MSG_ERROR([Missing ladspa-sdk, please install.]) 79 ]) 80]) 81PKG_CHECK_MODULES([UDEV], [ libudev >= 1.0 ]) 82PKG_CHECK_MODULES([GTEST], [ gtest >= 1.0 ]) 83AC_CHECK_LIB(asound, snd_pcm_ioplug_create,, 84 AC_ERROR([*** libasound has no external plugin SDK]), -ldl) 85 86AC_ARG_ENABLE([alsa-plugin], AS_HELP_STRING([--disable-alsa-plugin], 87 [Disable building of ALSA plugin])) 88 89AC_ARG_ENABLE([metrics], AS_HELP_STRING([--enable-metrics], [Enable metrics uses]), have_metrics=$enableval, have_metrics=no) 90if test "$have_metrics" = "yes"; then 91 AC_DEFINE(HAVE_LIB_METRICS, 1, [Define to use libmetrics]) 92 METRICS_LIBS=-lmetrics 93else 94 METRICS_LIBS= 95fi 96AC_SUBST(METRICS_LIBS) 97 98# Check if the system copy of the cras rust library should be used. If not, make sure cargo and rustc are present to build it. 99AC_ARG_WITH([system-cras-rust], 100 AS_HELP_STRING([--with-system-cras-rust], [Use the system provided cras_rust library]), 101 with_system_rust=$enableval, 102 with_system_rust=no) 103AM_CONDITIONAL(WITH_SYSTEM_RUST, test "$with_system_rust" = "yes") 104if test "$with_system_rust" = "no"; then 105 AC_CHECK_PROG(CARGO, [cargo], [yes], [no]) 106 AS_IF(test x$CARGO = xno, 107 AC_MSG_ERROR([cargo is required to build cras rust lib.]) 108 ) 109 AC_CHECK_PROG(RUSTC, [rustc], [yes], [no]) 110 AS_IF(test x$RUSTC = xno, 111 AC_MSG_ERROR([rustc is required to build cras rust lib.]) 112 ) 113fi 114 115# Determine ALSA plugin directory. 116test "x$prefix" = xNONE && prefix=$ac_default_prefix 117test "x$exec_prefix" = xNONE && exec_prefix=$prefix 118 119AC_ARG_WITH(plugindir, 120 AS_HELP_STRING([--with-plugindir=dir], 121 [path where ALSA plugin files are stored]), 122 plugindir="$withval", plugindir="") 123if test -z "$plugindir"; then 124 eval dir="$libdir" 125 case "$dir" in 126 /*) ;; 127 *) dir="$dir" 128 esac 129 plugindir="$dir/alsa-lib" 130fi 131AC_DEFINE_UNQUOTED(ALSA_PLUGIN_DIR, "$plugindir", 132 [directory containing ALSA add-on modules]) 133ALSA_PLUGIN_DIR="$plugindir" 134AC_SUBST(ALSA_PLUGIN_DIR) 135 136# Determine CRAS configuration directory. 137eval cras_config_file_dir="$sysconfdir/cras" 138AC_DEFINE_UNQUOTED(CRAS_CONFIG_FILE_DIR, "$cras_config_file_dir", 139 [directory containing CRAS configuration]) 140 141# CRAS socket dir 142AC_ARG_WITH(socketdir, 143 AS_HELP_STRING([--with-socketdir=dir], 144 [path where CRAS stores its sockets]), 145 socketdir="$withval", 146 socketdir="/run/cras") 147AC_DEFINE_UNQUOTED(CRAS_SOCKET_FILE_DIR, "$socketdir", 148 [directory containing CRAS socket files]) 149 150# SSE4_2 support 151AC_ARG_ENABLE(sse42, [AS_HELP_STRING([--enable-sse42],[enable SSE42 optimizations])], have_sse42=$enableval, have_sse42=yes) 152if test "x$host_cpu" != xx86_64; then 153 have_sse42=no 154fi 155if test "$have_sse42" = "yes"; then 156 AC_DEFINE(HAVE_SSE42,1,[Define to enable SSE42 optimizations.]) 157 SSE42_CFLAGS="-DOPS_SSE42 -msse4.2 -ffast-math" 158fi 159AM_CONDITIONAL(HAVE_SSE42, test "$have_sse42" = "yes") 160AC_SUBST(SSE42_CFLAGS) 161 162# AVX support 163AC_ARG_ENABLE(avx, [AS_HELP_STRING([--enable-avx],[enable AVX optimizations])], have_avx=$enableval, have_avx=yes) 164if test "x$host_cpu" != xx86_64; then 165 have_avx=no 166fi 167if test "$have_avx" = "yes"; then 168 AC_DEFINE(HAVE_AVX,1,[Define to enable AVX optimizations.]) 169 AVX_CFLAGS="-DOPS_AVX -mavx -ffast-math" 170fi 171AM_CONDITIONAL(HAVE_AVX, test "$have_avx" = "yes") 172AC_SUBST(AVX_CFLAGS) 173 174# AVX2 support 175AC_ARG_ENABLE(avx2, [AS_HELP_STRING([--enable-avx2],[enable AVX2 optimizations])], have_avx2=$enableval, have_avx2=yes) 176if test "x$host_cpu" != xx86_64; then 177 have_avx2=no 178fi 179if test "$have_avx2" = "yes"; then 180 AC_DEFINE(HAVE_AVX2,1,[Define to enable AVX2 optimizations.]) 181 AVX2_CFLAGS="-DOPS_AVX2 -mavx2 -ffast-math" 182fi 183AM_CONDITIONAL(HAVE_AVX2, test "$have_avx2" = "yes") 184AC_SUBST(AVX2_CFLAGS) 185 186# FMA support 187AC_ARG_ENABLE(fma, [AS_HELP_STRING([--enable-fma],[enable FMA optimizations])], have_fma=$enableval, have_fma=yes) 188if test "x$host_cpu" != xx86_64; then 189 have_fma=no 190fi 191if test "$have_fma" = "yes"; then 192 AC_DEFINE(HAVE_FMA,1,[Define to enable FMA optimizations.]) 193 FMA_CFLAGS="-DOPS_FMA -mavx2 -mfma -ffast-math" 194fi 195AM_CONDITIONAL(HAVE_FMA, test "$have_fma" = "yes") 196AC_SUBST(FMA_CFLAGS) 197 198AC_OUTPUT 199 200AC_MSG_NOTICE([ 201 202Enable SSE42: ${have_sse42} 203Enable AVX: ${have_avx} 204Enable AVX2: ${have_avx2} 205Enable FMA: ${have_fma} 206]) 207