ref: 018886f3f3bb452a480bb6c4e833dce14562f9fe
dir: /configure.ac/
dnl Process this file with autoconf to produce a configure script. AC_INIT(SoX, 12.18.3, cbagwell@users.sourceforge.net) AM_INIT_AUTOMAKE dnl create a config.h file (Automake will add -DHAVE_CONFIG_H) AM_CONFIG_HEADER(src/stconfig.h) AC_CONFIG_SRCDIR(sox.1) dnl Checks for programs. AC_PROG_CC AC_PROG_RANLIB AC_PROG_INSTALL AC_PROG_LN_S dnl Debugging AC_MSG_CHECKING([if we want a debug build]) AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [make a debug build]), [ if test $enableval = yes; then CFLAGS="-g" if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -ggdb" fi AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi ], [ AC_MSG_RESULT(no) ]) dnl Extra CFLAGS if we have gcc if test "$GCC" = yes; then CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wstrict-prototypes -pedantic" fi dnl Check for system dependent features. AC_C_BIGENDIAN AC_C_INLINE dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h unistd.h byteswap.h) dnl Checks for library functions. AC_CHECK_FUNCS(strcasecmp strdup) AC_REPLACE_FUNCS(getopt_long) AM_CONDITIONAL(GETOPT_LONG, test x$getopt_long = xtrue) dnl Check if math library is needed. AC_CHECKING(if math library is required during link) AC_CHECK_FUNC(pow) if test "$ac_cv_func_pow" = no; then AC_CHECK_LIB(m, pow) fi dnl Large File Support AC_SYS_LARGEFILE AC_FUNC_FSEEKO dnl Check for ALSA audio AC_CHECK_HEADERS(alsa/asoundlib.h, [with_alsa=yes AC_CHECK_LIB(asound, snd_pcm_open,, with_alsa=no)], with_alsa=no) if test "$with_alsa" = yes; then AC_DEFINE(HAVE_ALSA, 1, [Define to 1 if you have ALSA.]) fi dnl Check for OSS audio with_oss=no AC_CHECK_HEADERS(sys/soundcard.h, with_oss=yes) AC_CHECK_HEADERS(machine/soundcard.h, with_oss=yes) if test "$with_oss" = yes; then AC_DEFINE(HAVE_OSS, 1, [Define to 1 if you have OSS.]) fi dnl Check for Sun-style audio with_sun_audio=no AC_CHECK_HEADERS(sys/audioio.h, with_sun_audio=yes) AC_CHECK_HEADERS(sun/audioio.h, with_sun_audio=yes) if test "$with_sun_audio" = yes; then AC_DEFINE(HAVE_SUN_AUDIO, 1, [Define to 1 if you have Sun /dev/audio.]) fi dnl Check for Ogg Vorbis libraries AC_CHECK_HEADER(vorbis/codec.h, [with_ogg_vorbis=yes AC_CHECK_LIB(ogg, ogg_packet_clear,, with_ogg_vorbis=no) AC_CHECK_LIB(vorbisfile, ov_clear,, with_ogg_vorbis=no) AC_CHECK_LIB(vorbisenc, vorbis_encode_init_vbr,, with_ogg_vorbis=no)], with_ogg_vorbis=no) dnl Check for FLAC libraries with_flac=yes AC_ARG_WITH(flac, AS_HELP_STRING([--with-flac], [Use FLAC if present (default is YES)])) if test "$with_flac" = yes; then AC_CHECK_HEADER(FLAC/file_encoder.h, [AC_CHECK_LIB(FLAC, FLAC__file_encoder_new,,with_flac=no)], with_flac=no) fi dnl Check for MAD libraries with_mad=yes AC_ARG_WITH(mad, AS_HELP_STRING([--with-mad], [Use MAD (MP3 Audio Decoder) if present (default is YES)])) if test "$with_mad" = yes; then AC_CHECK_HEADER(mad.h, [AC_CHECK_LIB(mad, mad_stream_buffer,,with_mad=no)], with_mad=no) fi dnl Test for LAME library. with_lame=yes AC_ARG_WITH(lame, AS_HELP_STRING([--with-lame], [Use LAME (LAME Ain't an MP3 Encoder) if present (default is YES)])) if test "$with_lame" = yes; then AC_CHECK_HEADER(lame/lame.h, [AC_CHECK_LIB(mp3lame, lame_init,,with_lame=no)], with_lame=no) fi dnl Test for libsamplerate. with_samplerate=yes AC_ARG_WITH(samplerate, AS_HELP_STRING([--with-samplerate], [Use libsamplerate (aka Secret Rabbit Code) if present (default is YES)])) if test "$with_samplerate" = yes; then PKG_CHECK_MODULES(SAMPLERATE, samplerate >= 0.0.15, AC_DEFINE(HAVE_SAMPLERATE, 1, [Set to 1 if you have libsamplerate.]), with_samplerate=no) fi AC_SUBST(SAMPLERATE_CFLAGS) AC_SUBST(SAMPLERATE_LIBS) dnl LUA, LUAC, LUA_INCLUDES, LUA_LIBS have_lua=yes AC_SUBST(LUA) AC_SUBST(LUAC) AC_SUBST(LUA_INCLUDES) AC_SUBST(LUA_LIBS) dnl Arguments AC_ARG_WITH([lua-prefix], [AS_HELP_STRING([--with-lua-prefix=DIR], [Lua files are in DIR])]) AC_ARG_WITH([lua-includes], [AS_HELP_STRING([--with-lua-includes=DIR], [Lua include files are in DIR])]) AC_ARG_WITH([lua-libraries], [AS_HELP_STRING([--with-lua-libraries=DIR], [Lua library files are in DIR])]) AC_ARG_WITH([lua-suffix], [AS_HELP_STRING([--with-lua-suffix=ARG], [Lua binary and library files are suffixed with ARG])]) dnl LUA if test "x$with_lua_prefix" = x; then lua_search_path="$PATH" else lua_search_path="$with_lua_prefix/bin" fi if test "x$LUA" = x; then AC_PATH_PROG([LUA], [lua$with_lua_suffix], [], [$lua_search_path]) test "x$LUA" = x && AC_MSG_ERROR([*** Can't build ion without lua]) fi dnl lua_version AC_MSG_CHECKING([for lua version >= 5.1]) lua_version=$($LUA -v 2>&1 | head -n 1 | cut -d' ' -f2) case $lua_version in 0.* | 1.* | 2.* | 3.* | 4.* | 5.0) AC_MSG_RESULT([no (found $lua_version)]) have_lua=no ;; *) AC_MSG_RESULT([yes (found $lua_version)]) ;; esac dnl dnl dnl LUAC dnl if test "x$LUAC" = x; then dnl AC_PATH_PROG([LUAC], [luac$with_lua_suffix], [], [$lua_search_path]) dnl test "x$LUAC" = x && exit 1 dnl fi dnl dnl luac_version dnl AC_MSG_CHECKING([for lua version = luac version]) dnl luac_version=$($LUAC -v 2>&1 | head -n 1 | cut -d' ' -f2) dnl if test "x$lua_version" = "x$luac_version"; then dnl AC_MSG_RESULT([yes (found $luac_version)]) dnl else dnl AC_MSG_RESULT([no (found $luac_version)]) dnl exit 1 dnl fi dnl LUA_INCLUDES if test "x$with_lua_includes" != x; then LUA_INCLUDES="-I$with_lua_includes" elif test "x$with_lua_prefix" != x; then LUA_INCLUDES="-I$with_lua_prefix/include" fi save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $LUA_INCLUDES" AC_CHECK_HEADERS([lua.h lualib.h], [], [have_lua=no], []) CFLAGS="$save_CFLAGS" dnl LUA_LIBS if test "x$with_lua_libraries" != x; then LUA_LIBS="-L$with_lua_libraries" elif test "x$with_lua_prefix" != x; then LUA_LIBS="-L$with_lua_prefix/lib" fi AC_CHECK_LIB([m], [exp], [lua_extra_libs="$lua_extra_libs -lm"], []) AC_CHECK_LIB([dl], [dlopen], [lua_extra_libs="$lua_extra_libs -ldl"], []) AC_CHECK_LIB([lua$with_lua_suffix], [lua_call], [LUA_LIBS="$LUA_LIBS -llua$with_lua_suffix $lua_extra_libs"], [have_lua=no], [$LUA_LIBS $lua_extra_libs]) dnl liblua_version AC_MSG_CHECKING([for liblua version >= 5.1]) save_CFLAGS="$CFLAGS" save_LIBS="$LIBS" CFLAGS="$CFLAGS $LUA_INCLUDES" LIBS="$LIBS $LUA_LIBS" AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <lua.h> #include <stdlib.h> #include <string.h> #include <stdio.h> int main() { printf("(found %s, %d)... ", LUA_VERSION, LUA_VERSION_NUM); if(LUA_VERSION_NUM >= 501) exit(EXIT_SUCCESS); exit(EXIT_FAILURE); } ]])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) CFLAGS="$save_CFLAGS" LIBS="$save_LIBS" if test "$have_lua" = yes; then AC_DEFINE(HAVE_LUA, 1, [Define to 1 if you have Lua.]) fi dnl Generate output files. AX_CREATE_STDINT_H(src/ststdint.h) AC_SUBST(with_alsa with_oss) dnl For play.in AC_CONFIG_FILES(Makefile src/Makefile src/libgsm/Makefile src/libst-config src/play) AC_OUTPUT dnl Report configuration. echo echo "ALSA Driver....................... $with_alsa" echo "OSS Driver........................ $with_oss" echo "SUN /dev/audio.................... $with_sun_audio" echo "Ogg Vorbis support................ $with_ogg_vorbis" echo "FLAC support...................... $with_flac" echo "MAD MP3 Decoder................... $with_mad" echo "LAME MP3 Encoder.................. $with_lame" echo "Secret Rabbit Code resampling..... $with_samplerate" echo "Lua scripting..................... $with_lua" echo echo "Configure finished. Do 'make; make install' to compile and install SoX." echo