Allow linking against system libresample
authorToni Spets <toni.spets@iki.fi>
Tue, 1 Mar 2011 18:12:47 +0000 (20:12 +0200)
committerToni Spets <toni.spets@iki.fi>
Tue, 1 Mar 2011 18:12:47 +0000 (20:12 +0200)
configure.ac
src/Makefile.am

index 287b1e2..1455b07 100644 (file)
@@ -176,13 +176,20 @@ SM_TLS
 SM_LIBUSB
 
 have_ffmpeg=no
+have_libresample=no
 
-# search for system ffmpeg if not building for arcade
+# search for system libs if not building for arcade
 if test "$itg_arcade" = "no"; then
        AC_SEARCH_LIBS(avcodec_init, [avcodec], have_libavcodec=yes,  have_libavcodec=no)
        AC_SEARCH_LIBS(guess_format, [avformat], have_libavformat=yes,  have_libavformat=no)
        AC_SEARCH_LIBS(swscale_version, [swscale], have_libswscale=yes,  have_libswscale=no)
 
+       have_libresample=yes
+       AC_CHECK_LIB(resample, resample_open, [x=y], have_libresample=no, [-lm])
+       if test "$have_libresample" = "yes"; then
+               LIBS="$LIBS -lresample"
+       fi
+
        if test "$have_libavcodec" = "yes"; then
          AC_MSG_CHECKING([for libavcodec >= 0.6.1])
          AC_TRY_RUN([
@@ -226,6 +233,7 @@ if test "$itg_arcade" = "no"; then
 fi
 
 AM_CONDITIONAL(HAVE_FFMPEG, test "$have_ffmpeg" = "yes")
+AM_CONDITIONAL(HAVE_LIBRESAMPLE, test "$have_libresample" = "yes")
 
 SM_CHECK_CRASH_HANDLER
 
@@ -290,7 +298,9 @@ AM_CONDITIONAL(BUILD_TESTS, test "$enable_tests" = "yes" )
 AC_CONFIG_FILES(Makefile)
 AC_CONFIG_FILES(src/Makefile)
 
-# TODO: clean this up - kinda hacky...
-cd src/libresample && autoconf && ./configure && cd ../..
+if test "$have_libresample" = "no"; then
+       # use our own libresample in vain
+       cd src/libresample && autoconf && ./configure && cd ../..
+fi
 
 AC_OUTPUT
index 188ffb4..b4a45f0 100755 (executable)
@@ -21,6 +21,7 @@ else
 LIBS += -nodefaultlibs -Wl,-Bstatic -lstdc++ $(LUA_LIBS) -lXrandr -lXrender -lmad -lgcc -lgcc_eh -Wl,-Bdynamic -lpthread -lusb -lc
 endif
 
+if !HAVE_LIBRESAMPLE
 all: $(srcdir)/libresample/libresample.a $(srcdir)/crypto561/libcryptopp.a
 
 clean-local: clean_libresample
@@ -30,6 +31,9 @@ clean_libresample:
 
 $(srcdir)/libresample/libresample.a:
        cd $(srcdir)/libresample && autoconf && sh ./configure && make
+else
+all: $(srcdir)/crypto561/libcryptopp.a
+endif
 
 $(srcdir)/crypto561/libcryptopp.a:
        cd $(srcdir)/crypto561 && make -f GNUmakefile
@@ -442,11 +446,14 @@ main_LDADD = \
                  $(AUDIO_LIBS) \
                  $(SDL_LIBS) \
                  $(XLIBS) \
-                 $(srcdir)/libresample/libresample.a \
                  $(srcdir)/crypto561/libcryptopp.a
 
 openitg_SOURCES = $(main_SOURCES)
 
+if !HAVE_LIBRESAMPLE
+main_LDADD += $(srcdir)/libresample/libresample.a
+endif
+
 if !HAVE_FFMPEG
 openitg_LDADD = $(main_LDADD) \
        $(srcdir)/ffmpeg/lib/libavformat.a $(srcdir)/ffmpeg/lib/libavcodec.a
@@ -499,8 +506,11 @@ test_audio_readers_SOURCES = \
                RageSoundResampler.cpp RageSoundResampler.h
 
 test_audio_readers_LDADD = \
-               $(AUDIO_LIBS) \
-               $(srcdir)/libresample/libresample.a
+               $(AUDIO_LIBS)
+
+if !HAVE_LIBRESAMPLE
+test_audio_readers_LDADD += $(srcdir)/libresample/libresample.a
+endif
 
 TESTS += test_file_readers
 test_file_readers_SOURCES = \