1#------------------------------------------------------------------------------------
2# LinuxSampler's / liblinuxsampler's "official" release version:
3
4m4_define(linuxsampler_release_major, 2)
5m4_define(linuxsampler_release_minor, 2)
6m4_define(linuxsampler_release_build, 0)
7
8
9AC_INIT([linuxsampler],[linuxsampler_release_major.linuxsampler_release_minor.linuxsampler_release_build])
10AC_CONFIG_SRCDIR([configure.ac])
11
12#------------------------------------------------------------------------------------
13# The following is the libtool / shared library version. This doesn't have to
14# do anything with the release version. It MUST conform to the following rules:
15#
16#  1. Start with version information of `0:0:0' for each libtool library.
17#  2. Update the version information only immediately before a public release of
18#     your software. More frequent updates are unnecessary, and only guarantee
19#     that the current interface number gets larger faster.
20#  3. If the library source code has changed at all since the last update, then
21#     increment revision (`c:r:a' becomes `c:r+1:a').
22#  4. If any interfaces have been added, removed, or changed since the last update,
23#     increment current, and set revision to 0.
24#  5. If any interfaces have been added since the last public release, then increment
25#     age.
26#  6. If any interfaces have been removed since the last public release, then set age
27#     to 0.
28
29LIBLINUXSAMPLER_LT_CURRENT=6
30LIBLINUXSAMPLER_LT_REVISION=0
31LIBLINUXSAMPLER_LT_AGE=0
32SHARED_VERSION_INFO="$LIBLINUXSAMPLER_LT_CURRENT:$LIBLINUXSAMPLER_LT_REVISION:$LIBLINUXSAMPLER_LT_AGE"
33
34#------------------------------------------------------------------------------------
35# the LSCP specification version this LinuSampler release complies with:
36
37LSCP_RELEASE_MAJOR=1
38LSCP_RELEASE_MINOR=7
39
40AC_DEFINE_UNQUOTED(LSCP_RELEASE_MAJOR, ${LSCP_RELEASE_MAJOR}, [LSCP spec major version this release complies with.])
41AC_DEFINE_UNQUOTED(LSCP_RELEASE_MINOR, ${LSCP_RELEASE_MINOR}, [LSCP spec minor version this release complies with.])
42
43AM_INIT_AUTOMAKE([subdir-objects])
44AC_PROG_CC
45AC_PROG_CXX
46AC_LIBTOOL_WIN32_DLL
47AC_PROG_LIBTOOL
48AC_PROG_LEX
49AC_PROG_YACC
50
51AC_SUBST(SHLIB_VERSION_ARG)
52AC_SUBST(SHARED_VERSION_INFO)
53
54module=yes eval LIB_EXT=$shrext_cmds
55AC_SUBST(LIB_EXT)
56
57AC_C_BIGENDIAN
58AC_CANONICAL_HOST
59
60PKG_PROG_PKG_CONFIG
61
62###########################################################################
63# General Checks
64
65AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
66
67# make sure C++14 is supported by compiler
68# (add CXXFLAGS if required [e.g. -std=c++14])
69m4_ifdef([m4_include(m4/ax_cxx_compile_stdcxx.m4)],,
70             [sinclude([m4/ax_cxx_compile_stdcxx.m4])])
71AX_CXX_COMPILE_STDCXX(14, [], mandatory)
72
73AC_MSG_CHECKING([whether x86 architecture])
74def_arch_x86=0
75case $host_cpu in
76  "i386" | "i486" | "i586" | "i686" | "i786" | "x86_64")
77    echo "yes"
78    def_arch_x86=1;;
79  *)
80    echo "no";;
81esac
82AC_DEFINE_UNQUOTED(ARCH_X86,$def_arch_x86,[Define to 1 if you build for x86 architecture.])
83
84# determine the right gcc switch for CPU specific optimizations
85# (only if the user did not provide one)
86CXX_CPU_SWITCH=
87if ! echo "X $CXXFLAGS " | grep -q -- " \(-march=\|-mcpu=\|-mtune=\|-arch=\)" ; then
88  if test "$def_arch_x86" = 1 -a "$host_cpu" != "x86_64"; then
89    CXX_CPU_SWITCH="-march=$host_cpu"
90  elif test "$target_cpu" = "ppc"; then
91    CXX_CPU_SWITCH="-arch=$host_cpu"
92  fi
93fi
94AC_SUBST([CXX_CPU_SWITCH])
95
96mac=no
97linux=no
98case "$host" in
99    *-*-darwin*)
100        mac=yes
101        ;;
102    *-*-linux*)
103        linux=yes
104        ;;
105esac
106AM_CONDITIONAL(LINUX, test "$linux" = yes)
107AM_CONDITIONAL(MAC, test "$mac" = yes)
108
109# check if we're on MS Windows
110AC_CHECK_HEADERS(
111    mmsystem.h,
112    have_windows=1,
113    have_windows=0,
114    [#include <windef.h>]
115)
116AM_CONDITIONAL(HAVE_WINDOWS, test $have_windows = "1")
117
118AC_MSG_CHECKING([whether UNIX98 compatible])
119AC_LANG_PUSH([C])
120AC_RUN_IFELSE([AC_LANG_SOURCE([[
121#ifndef _GNU_SOURCE
122#define _GNU_SOURCE 1
123#endif
124#include <features.h>
125void main(void) {
126#if _XOPEN_SOURCE >= 500
127exit(0); /* UNIX98 compatible */
128#else
129exit(-1); /* not UNIX98 compatible */
130#endif
131}
132]])],
133have_unix98="yes",
134have_unix98="no",
135have_unix98="no"
136)
137AC_LANG_POP([C])
138AC_MSG_RESULT([$have_unix98])
139if test "$have_unix98" = "no" -a "$have_windows" = "0" -a "$mac" = "no" ; then
140    if test "x$HAVE_UNIX98" = "x"; then
141        echo "LinuxSampler only runs on UNIX98 compatible systems, which is mandatory for"
142        echo "pthread_mutexattr_settype() call in Mutex.cpp. You may want to run"
143        echo "./configure with environment variable HAVE_UNIX98=1 in case you think you"
144        echo "have a UNIX98 compatible system."
145        exit -1;
146    fi
147fi
148
149# check for <features.h>
150AC_CHECK_HEADERS(features.h)
151
152# test for POSIX thread library
153m4_ifdef([m4_include(m4/pthread.m4)],,
154             [sinclude([m4/pthread.m4])])
155ACX_PTHREAD
156LIBS="$PTHREAD_LIBS $LIBS"
157CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
158CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
159CC="$PTHREAD_CC"
160
161
162# check for compiler's pragma diagnostic capabilities
163m4_ifdef([m4_include(m4/pragma_diagnostics.m4)],,
164             [sinclude([m4/pragma_diagnostics.m4])])
165ACX_CXX_PRAGMA_DIAGNOSTICS
166
167
168# check for a bug in NPTL-enabled glibc
169# (see Gentoo bug report #194076)
170AC_ARG_ENABLE(nptl-bug-check,
171  [  --disable-nptl-bug-check
172                          Disable check for a bug in certain NPTL-enabled
173                          glibc versions that caused crashs.],
174  [config_check_nptl_bug="$enableval"],
175  [config_check_nptl_bug="yes"]
176)
177if test "$config_check_nptl_bug" = "yes"; then
178    m4_ifdef([m4_include(m4/nptl_bug.m4)],,
179             [sinclude([m4/nptl_bug.m4])])
180    ACX_NPTL_GLIBC_BUG([
181        echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
182        echo "You seem to have a buggy PTHREAD library! LinuxSampler would"
183        echo "probably crash due to this. Please report us the system you are"
184        echo "using and/or file a bug report to the bug tracking system of"
185        echo "your distribution."
186        echo "If you have a NPTL-enabled glibc AND it was compiled for TLS as"
187        echo "well, you can try to circumvent this problem for now by setting"
188        echo "the environment variable LD_ASSUME_KERNEL=\"2.4.1\" , which"
189        echo "should cause this test to pass."
190        echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
191        AC_MSG_ERROR([possibly NPTL glibc bug detected])
192    ])
193else
194    echo "NPTL glibc bug check disabled"
195fi
196
197
198# check whether C++ compiler supports "designated initializers"
199echo -n "Checking whether C++ compiler supports designated initializers (partly)... "
200AC_LANG_PUSH([C++])
201AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
202    #include <stdlib.h>
203    struct Foo {
204        int   a;
205        float b;
206        bool  c;
207        char  d;
208    };
209    static void bar(Foo o) {
210    }
211    int main() {
212        bar({
213          .a = 2,
214          .b = 4.3f,
215          .c = true,
216          .d = 'z'
217        });
218        return 0;
219    }
220    ]])],
221    [cxx_designated_init_partly="yes"],
222    [cxx_designated_init_partly="no"]
223)
224AC_LANG_POP([C++])
225if test $cxx_designated_init_partly = "yes"; then
226    echo "yes"
227else
228    echo "NO"
229    echo '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
230    echo '!                                                             !'
231    echo '! ERROR: Selected C++ compiler does not support designated    !'
232    echo '! initializers at all, not even partly!                       !'
233    echo '!                                                             !'
234    echo '! Please either update your C++ compiler or select a          !'
235    echo '! different compiler (e.g. GCC >= 8 or clang >= 5). If you    !'
236    echo '! have several C++ compilers installed on your machine, you   !'
237    echo '! can easily select a different compiler by environment       !'
238    echo '! variable, e.g. to compile with clang instead:               !'
239    echo '!                                                             !'
240    echo '! CXX=clang++ CC=clang ./configure && make                    !'
241    echo '!                                                             !'
242    echo '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
243    exit -1
244fi
245echo -n "Checking whether C++ compiler fully supports designated initializers... "
246AC_LANG_PUSH([C++])
247AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
248    #include <stdlib.h>
249    struct Foo {
250        int   a;
251        float b;
252        bool  c;
253        char  d;
254    };
255    static void bar(Foo o) {
256    }
257    int main() {
258        bar({
259          .d = 'z',
260          .a = 2
261        });
262        return 0;
263    }
264    ]])],
265    [cxx_designated_init_fully="yes"],
266    [cxx_designated_init_fully="no"]
267)
268AC_LANG_POP([C++])
269if test $cxx_designated_init_fully = "yes"; then
270    echo "yes"
271else
272    echo 'NO'
273    echo '***************************************************************'
274    echo '*                                                             *'
275    echo '* WARNING: Selected C++ compiler does not fully support       *'
276    echo '* designated initializers (only partly)!                      *'
277    echo '*                                                             *'
278    echo '* You will be able to compile LinuxSampler, but you will not  *'
279    echo '* be able to compile the test cases. Consider updating your   *'
280    echo '* C++ compiler or switching to a different compiler. Chances  *'
281    echo '* are that LinuxSampler will soon no longer support your      *'
282    echo '* compiler.                                                   *'
283    echo '*                                                             *'
284    echo '* If you have several C++ compilers installed on your machine,*'
285    echo '* you can easily select a different compiler by environment   *'
286    echo '* variable, e.g. to compile with clang instead:               *'
287    echo '*                                                             *'
288    echo '* CXX=clang++ CC=clang ./configure && make                    *'
289    echo '*                                                             *'
290    echo '***************************************************************'
291fi
292
293
294# In case Bison is available, determine the exact version, since we need to
295# use different custom parser code for Bison 2.x vs. Bison 3.x generated
296# parser yacc tables.
297if echo "$YACC" | grep -q bison; then
298    # NOTE: m4 removes [], that's why it needs to be escaped
299    bison_version=[`$YACC --version | head -n 1 | sed -e 's/[^0-9.]*\([-0-9.]\+\)$/\1/'`]
300    bison_version_major=`echo $bison_version | cut -d. -f1`
301    bison_version_minor=`echo $bison_version | cut -d. -f2`
302    AC_DEFINE_UNQUOTED(HAVE_BISON_MAJ,$bison_version_major,[Define to the major version of the GNU Bison program installed.])
303    AC_DEFINE_UNQUOTED(HAVE_BISON_MIN,$bison_version_minor,[Define to the minor version of the GNU Bison program installed.])
304fi
305
306
307
308###########################################################################
309# Checks for available audio and MIDI systems / drivers
310# (we throw an error if there's not at least one system for audio output and MIDI input available)
311
312have_midi_input_driver="false"
313have_audio_output_driver="false"
314
315# ALSA
316AC_ARG_ENABLE(alsa-driver,
317  [  --disable-alsa-driver
318                          Disable support for the Advanced Linux Sound
319                          Architecture (ALSA).],
320  [config_alsa_driver="$enableval"],
321  [config_alsa_driver="yes"]
322)
323have_alsa=0
324if test "$config_alsa_driver" = "yes"; then
325    AC_CHECK_HEADER(alsa/asoundlib.h,
326        AC_CHECK_LIB(asound, main,
327                                 have_alsa=1
328                                 ,
329                                 have_alsa=0
330                    )
331                    ,
332                    have_alsa=0
333    )
334    if test "$have_alsa" = "1"; then
335        have_midi_input_driver="true"
336        have_audio_output_driver="true";
337    fi
338
339    echo -n "checking Alsa version... "
340    AC_LANG_PUSH([C])
341    AC_RUN_IFELSE([AC_LANG_SOURCE([[
342        #include <alsa/asoundlib.h>
343        void main(void) {
344            /* ensure backward compatibility */
345            #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
346            #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
347            #endif
348            exit(SND_LIB_MAJOR);
349        }
350    ]])],
351    alsa_major=0,
352    alsa_major=$?,
353    alsa_major=0
354    )
355    AC_RUN_IFELSE([AC_LANG_SOURCE([[
356        #include <alsa/asoundlib.h>
357        void main(void) {
358            /* ensure backward compatibility */
359            #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
360            #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
361            #endif
362            exit(SND_LIB_MINOR);
363        }
364    ]])],
365    alsa_minor=0,
366    alsa_minor=$?,
367    alsa_minor=0
368    )
369    AC_RUN_IFELSE([AC_LANG_SOURCE([[
370        #include <alsa/asoundlib.h>
371        void main(void) {
372            /* ensure backward compatibility */
373            #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
374            #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
375            #endif
376            exit(SND_LIB_SUBMINOR);
377        }
378    ]])],
379    alsa_subminor=0,
380    alsa_subminor=$?,
381    alsa_subminor=0
382    )
383    AC_LANG_POP([C])
384    echo "$alsa_major.$alsa_minor.$alsa_subminor";
385    AC_DEFINE_UNQUOTED(ALSA_MAJOR,$alsa_major,[Define to the major version number of your Alsa installation.])
386    AC_DEFINE_UNQUOTED(ALSA_MINOR,$alsa_minor,[Define to the minor version number of your Alsa installation.])
387    AC_DEFINE_UNQUOTED(ALSA_SUBMINOR,$alsa_subminor,[Define to the subminor version number of your Alsa installation.])
388else
389    echo "ALSA support disabled by configure script parameter"
390fi
391AM_CONDITIONAL(HAVE_ALSA, test $have_alsa = "1")
392AC_DEFINE_UNQUOTED(HAVE_ALSA,$have_alsa,[Define to 1 if you have ALSA installed.])
393config_have_alsa="no"
394if test $have_alsa = "1"; then
395    config_have_alsa="yes"
396fi
397
398# JACK
399AC_ARG_ENABLE(jack-driver,
400  [  --disable-jack-driver
401                          Disable support for the Jack Audio Connection Kit
402                          (JACK).],
403  [config_jack_driver="$enableval"],
404  [config_jack_driver="yes"]
405)
406have_jack=0
407if test "$config_jack_driver" = "yes"; then
408    PKG_CHECK_MODULES(JACK, jack, have_jack=1, have_jack=0)
409    if test $have_jack = "1"; then
410        AC_SUBST(JACK_LIBS)
411        AC_SUBST(JACK_CFLAGS)
412        linuxsampler_save_LIBS=$LIBS
413        LIBS="$JACK_LIBS $LIBS"
414        AC_CHECK_FUNCS(jack_client_name_size jack_client_open \
415                       jack_on_info_shutdown)
416        LIBS=$linuxsampler_save_LIBS
417        have_audio_output_driver="true";
418    fi
419else
420    echo "JACK support disabled by configure script parameter"
421fi
422AM_CONDITIONAL(HAVE_JACK, test $have_jack = "1")
423AC_DEFINE_UNQUOTED(HAVE_JACK,$have_jack,[Define to 1 if you have JACK installed.])
424config_have_jack="no"
425if test $have_jack = "1"; then
426    config_have_jack="yes"
427fi
428
429# JACK MIDI
430have_jack_midi=0
431if test $have_jack = "1"; then
432    linuxsampler_save_CFLAGS=$CFLAGS
433    linuxsampler_save_LIBS=$LIBS
434    CFLAGS="$JACK_CFLAGS $CFLAGS"
435    LIBS="$JACK_LIBS $LIBS"
436    AC_CHECK_HEADER(jack/midiport.h, have_jack_midi=1, have_jack_midi=0)
437    if test $have_jack_midi = "1"; then
438        AC_CHECK_FUNCS(jack_midi_get_event_count)
439        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <jack/midiport.h>]], [[
440            jack_midi_clear_buffer(0, 0);
441        ]])], [AC_DEFINE(JACK_MIDI_FUNCS_NEED_NFRAMES, 1,
442                  [Define to 1 if you have the old jack midi functions that need an nframes argument.])])
443        have_midi_input_driver="true"
444    fi
445    CFLAGS=$linuxsampler_save_CFLAGS
446    LIBS=$linuxsampler_save_LIBS
447fi
448AM_CONDITIONAL(HAVE_JACK_MIDI, test $have_jack_midi = "1")
449AC_DEFINE_UNQUOTED(HAVE_JACK_MIDI, $have_jack_midi,
450                   [Define to 1 if you have JACK with MIDI support installed.])
451config_have_jack_midi="no"
452if test $have_jack_midi = "1"; then
453    config_have_jack_midi="yes"
454fi
455
456# ARTS
457AC_ARG_ENABLE(arts-driver,
458  [  --disable-arts-driver
459                          Disable support for the Analogue Realtime System
460                          (aRts).],
461  [config_arts_driver="$enableval"],
462  [config_arts_driver="yes"]
463)
464have_arts=0
465if test "$config_arts_driver" = "yes"; then
466    m4_ifdef([m4_include(m4/arts.m4)],,
467             [sinclude([m4/arts.m4])])
468    AM_PATH_ARTS(0.9.5, have_arts=1, have_arts=0)
469    if test "$have_arts" = "1"; then
470        have_audio_output_driver="true"
471    fi
472else
473    echo "ARTS support disabled by configure script parameter"
474fi
475AM_CONDITIONAL(HAVE_ARTS, test "$have_arts" = "1")
476AC_DEFINE_UNQUOTED(HAVE_ARTS,$have_arts,[Define to 1 if you have aRts installed.])
477config_have_arts="no"
478if test $have_arts = "1"; then
479    config_have_arts="yes"
480fi
481
482# ASIO AUDIO (Win32)
483AC_ARG_ENABLE(asiosdk-dir,
484  [  --enable-asiosdk-dir
485                          Directory where the ASIO SDK is located, this automatically
486                          enables the compilation of the ASIO audio output driver.],
487  [config_asiosdk_dir="${enableval}"],
488  [config_asiosdk_dir="."]
489)
490AC_SUBST(config_asiosdk_dir)
491
492AC_ARG_ENABLE(asio-driver,
493  [  --disable-asio-driver
494                          Disable support for the Windows ASIO driver.],
495  [config_asio_driver="$enableval"],
496  [config_asio_driver="yes"]
497)
498have_asio=0
499ASIOSDK_BASEDIR=
500if test "$config_asio_driver" = "yes"; then
501    asiosdk_headerfile=$config_asiosdk_dir/ASIOSDK2/common/asio.h
502    echo -n "checking for ASIO headerfile: $asiosdk_headerfile ...."
503    if test -e $asiosdk_headerfile ; then
504        echo yes
505        have_asio=1
506        ASIOSDK_BASEDIR="$config_asiosdk_dir"
507    else
508        echo no
509        have_asio=0
510    fi
511    if test "$have_asio" = "1"; then
512        have_audio_output_driver="true"
513    fi
514else
515    echo "Windows ASIO support disabled by configure script parameter"
516fi
517AC_SUBST(ASIOSDK_BASEDIR)
518AM_CONDITIONAL(HAVE_ASIO, test $have_asio = "1")
519AC_DEFINE_UNQUOTED(HAVE_ASIO,$have_asio,[Define to 1 if you have ASIO installed.])
520config_have_asio="no"
521if test $have_asio = "1"; then
522    config_have_asio="yes"
523fi
524
525# MidiShare (Linux, OS X, Windows)
526AC_ARG_ENABLE(midishare-driver,
527  [  --disable-midishare-driver
528                          Disable support for the MidiShare system.],
529  [config_midishare_driver="$enableval"],
530  [config_midishare_driver="yes"]
531)
532have_midishare=0
533if test "$config_midishare_driver" = "yes"; then
534    AC_CHECK_HEADER(MidiShare.h,
535        AC_CHECK_LIB(MidiShare, MidiCountEvs,
536                                have_midishare=1,
537                                have_midishare=0
538                    )
539                    ,
540                    have_midishare=0
541    )
542    if test "$have_midishare" = "1"; then
543        have_midi_input_driver="true"
544    fi
545else
546    echo "MidiShare support disabled by configure script parameter"
547fi
548AM_CONDITIONAL(HAVE_MIDISHARE, test $have_midishare = "1")
549AC_DEFINE_UNQUOTED(HAVE_MIDISHARE,$have_midishare,[Define to 1 if you have MidiShare installed.])
550config_have_midishare="no"
551if test $have_midishare = "1"; then
552    config_have_midishare="yes"
553fi
554
555# CoreMIDI (OS X)
556AC_ARG_ENABLE(coremidi-driver,
557  [  --disable-coremidi-driver
558                          Disable support for the Apple CoreMIDI system.],
559  [config_coremidi_driver="$enableval"],
560  [config_coremidi_driver="yes"]
561)
562have_coremidi=0
563if test "$config_coremidi_driver" = "yes"; then
564    AC_CHECK_HEADER(CoreMIDI/CoreMIDI.h,
565        have_coremidi=1,
566        have_coremidi=0
567    )
568    if test "$have_coremidi" = "1"; then
569        have_midi_input_driver="true"
570    fi
571else
572    echo "CoreMIDI support disabled by configure script parameter"
573fi
574AM_CONDITIONAL(HAVE_COREMIDI, test $have_coremidi = "1")
575AC_DEFINE_UNQUOTED(HAVE_COREMIDI,$have_coremidi,[Define to 1 if you have CoreMIDI installed.])
576config_have_coremidi="no"
577if test $have_coremidi = "1"; then
578    config_have_coremidi="yes"
579fi
580
581# CoreAudio (OS X)
582AC_ARG_ENABLE(coreaudio-driver,
583  [  --disable-coreaudio-driver
584                          Disable support for the Apple CoreAudio system.],
585  [config_coreaudio_driver="$enableval"],
586  [config_coreaudio_driver="yes"]
587)
588have_coreaudio=0
589if test "$config_coreaudio_driver" = "yes"; then
590    AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
591        have_coreaudio=1,
592        have_coreaudio=0
593    )
594    if test "$have_coreaudio" = "1"; then
595        have_audio_output_driver="true"
596    fi
597else
598    echo "CoreAudio support disabled by configure script parameter"
599fi
600AM_CONDITIONAL(HAVE_COREAUDIO, test $have_coreaudio = "1")
601AC_DEFINE_UNQUOTED(HAVE_COREAUDIO,$have_coreaudio,[Define to 1 if you have CoreAudio installed.])
602config_have_coreaudio="no"
603if test $have_coreaudio = "1"; then
604    config_have_coreaudio="yes"
605fi
606
607# MME MIDI (Win32)
608AC_ARG_ENABLE(mmemidi-driver,
609  [  --disable-mmemidi-driver
610                          Disable support for the Windows MME MIDI system.],
611  [config_mmemidi_driver="$enableval"],
612  [config_mmemidi_driver="yes"]
613)
614have_mmemidi=0
615if test "$config_mmemidi_driver" = "yes"; then
616    AC_CHECK_HEADERS(mmsystem.h,
617        have_mmemidi=1,
618        have_mmemidi=0
619    )
620    if test "$have_mmemidi" = "1"; then
621        have_midi_input_driver="true"
622    fi
623else
624    echo "MME MIDI support disabled by configure script parameter"
625fi
626AM_CONDITIONAL(HAVE_MME_MIDI, test $have_mmemidi = "1")
627AC_DEFINE_UNQUOTED(HAVE_MME_MIDI,$have_mmemidi,[Define to 1 if you have MME MIDI installed.])
628config_have_mme="no"
629if test $have_mmemidi = "1"; then
630    config_have_mme="yes"
631fi
632
633# DSSI
634AC_CHECK_HEADERS(dssi.h,
635	config_have_dssi="yes",
636	config_have_dssi="no")
637AM_CONDITIONAL(HAVE_DSSI, test $config_have_dssi = "yes")
638
639# LV2
640PKG_CHECK_MODULES(LV2, lv2 >= 1.0.0, config_have_lv2="yes", config_have_lv2="no")
641if test "$config_have_lv2" != "yes"; then
642    PKG_CHECK_MODULES(LV2, lv2core >= 1.0.0, config_have_lv2="yes", config_have_lv2="no")
643fi
644AC_SUBST(LV2_CFLAGS)
645AC_SUBST(LV2_LIBS)
646AM_CONDITIONAL(HAVE_LV2, test $config_have_lv2 = "yes")
647
648# VST
649AC_ARG_ENABLE(vstsdk-dir,
650  [  --enable-vstsdk-dir
651                          Directory where the VST SDK is located.
652                          This automatically enables the compilation
653                          of the VST plugin.],
654  [VSTSDK_DIR="${enableval}"],
655  [VSTSDK_DIR=]
656)
657AC_SUBST(VSTSDK_DIR)
658AM_CONDITIONAL(HAVE_VST, test "x$VSTSDK_DIR" != "x")
659config_have_vst="no"
660if test "x$VSTSDK_DIR" != "x"; then
661    config_have_vst="yes"
662fi
663
664# AU
665AC_CHECK_HEADERS(AudioUnit/AudioUnit.h,
666	config_have_au="yes",
667	config_have_au="no")
668AM_CONDITIONAL(HAVE_AU, test $config_have_au = "yes")
669AM_CONDITIONAL(HAVE_AUFLAGS, test "$AUFLAGS" != "")
670
671if test $config_have_au = "yes" ; then
672    if test "x$DEVELOPER_EXTRAS_DIR" = "x" ; then
673        if test -d /Developer/Extras ; then
674            DEVELOPER_EXTRAS_DIR=/Developer/Extras
675        else
676            DEVELOPER_EXTRAS_DIR=/Developer/Examples
677        fi
678    fi
679    AC_SUBST(DEVELOPER_EXTRAS_DIR)
680fi
681
682if test "x$MAC_PLUGIN_INSTALL_DIR" = "x" ; then
683    MAC_PLUGIN_INSTALL_DIR=/Library/Audio/Plug-Ins
684fi
685AC_SUBST(MAC_PLUGIN_INSTALL_DIR)
686
687# have we found at least one MIDI input and one audio output driver ?
688if test "$have_midi_input_driver" = "false"; then
689    echo "No supported MIDI input system found!"
690    echo "Sorry, LinuxSampler only supports the following MIDI drivers at the moment:"
691    echo "ALSA, JACK, MIDIShare, CoreMIDI, MME."
692    echo "If you think you have one of those available on your system, make sure you"
693    echo "also have the respective development (header) files installed."
694    exit -1;
695fi
696if test "$have_audio_output_driver" = "false"; then
697    echo "No supported audio output system found!"
698    echo "Sorry, LinuxSampler only supports ALSA, JACK, ARTS and ASIO as audio output"
699    echo "driver at the moment!"
700    exit -1;
701fi
702
703
704
705###########################################################################
706# Checks for various DLL libraries
707
708# Check presence of libgig
709libgig_version="4.3.0"
710PKG_CHECK_MODULES(GIG, gig >= $libgig_version, HAVE_GIG=true, HAVE_GIG=false)
711if test "$HAVE_GIG" = "false"; then
712    echo "Required libgig version not found!"
713    echo "You need to have libgig version ${libgig_version} installed!"
714    exit -1;
715else
716    echo "yes, found libgig $libgig_version"
717fi
718AC_SUBST(GIG_CFLAGS)
719AC_SUBST(GIG_LIBS)
720
721# SF2 Engine (requires libgig)
722AC_ARG_ENABLE(sf2-engine,
723  [  --disable-sf2-engine
724                          Disable compilation of the SF2 engine.
725			  You need to have libgig installed.],
726  [config_sf2_engine="$enableval"],
727  [config_sf2_engine="yes"]
728)
729HAVE_SF2=0;
730if test "$config_sf2_engine" = "yes"; then
731    HAVE_SF2=1
732else
733    echo "SF2 engine disabled by configure script parameter"
734fi
735AM_CONDITIONAL(HAVE_SF2, test $HAVE_SF2 = 1)
736AC_DEFINE_UNQUOTED(HAVE_SF2,$HAVE_SF2,[Define to 1 if you want SF2 engine and have libsf2 installed.])
737config_have_sf2="no"
738if test $HAVE_SF2 = "1"; then
739    config_have_sf2="yes"
740fi
741
742# Check presence of libsndfile
743libsndfile_version="1.0"
744PKG_CHECK_MODULES(SNDFILE, sndfile >= $libsndfile_version, HAVE_SNDFILE=true, HAVE_SNDFILE=false)
745if test "$HAVE_SNDFILE" = "false"; then
746    echo "Required libsndfile version not found!"
747    echo "You need to have libsndfile version ${libsndfile_version} installed!"
748    exit -1;
749else
750    echo "yes, found libsndfile $libsndfile_version"
751fi
752AC_SUBST(SNDFILE_CFLAGS)
753AC_SUBST(SNDFILE_LIBS)
754
755# Check for Vorbis and FLAC support in libsndfile
756linuxsampler_save_CFLAGS=$CFLAGS
757CFLAGS="$SNDFILE_CFLAGS $CFLAGS"
758AC_CHECK_DECLS([SF_FORMAT_VORBIS, SF_FORMAT_FLAC], [], [], [[#include <sndfile.h>]])
759
760# Check for loop functionality in libsndfile
761AC_CHECK_MEMBERS([SF_INSTRUMENT.loops],,
762		 [AC_MSG_WARN([Your version of libsndfile does not support
763    reading of loop information. LinuxSampler will not be able to
764    extract loop information from sample files.])],
765		 [#include <sndfile.h>])
766CFLAGS=$linuxsampler_save_CFLAGS
767
768# Instruments DB feature (requires SQLite 3.3)
769AC_ARG_ENABLE(instruments-db,
770  [  --disable-instruments-db
771                          Disable compilation of the sampler's instruments
772                          database feature. You need to have SQLite 3.3
773                          or younger installed for this feature.],
774  [config_instruments_db="$enableval"],
775  [config_instruments_db="yes"]
776)
777HAVE_SQLITE3=0;
778if test "$config_instruments_db" = "yes"; then
779    # Check presence of sqlite3
780    sqlite_version="3.3"
781    PKG_CHECK_MODULES(SQLITE3, sqlite3 >= $sqlite_version, HAVE_SQLITE3=true, HAVE_SQLITE3=false)
782    AC_SUBST(SQLITE3_LIBS)
783    AC_SUBST(SQLITE3_CFLAGS)
784    if test $HAVE_SQLITE3 = false; then
785        HAVE_SQLITE3=0
786        config_instruments_db="no"
787        echo "*** Required sqlite version not found!"
788        echo "*** You need to have sqlite version ${sqlite_version} or higher"
789        echo "*** for instruments database support to be enabled."
790        echo "*** Support for instruments DB will be disabled!"
791    else
792        HAVE_SQLITE3=1
793    fi
794else
795    echo "Instruments DB feature disabled by configure script parameter"
796fi
797AM_CONDITIONAL(HAVE_SQLITE3, test $HAVE_SQLITE3 = 1)
798AC_DEFINE_UNQUOTED(HAVE_SQLITE3,$HAVE_SQLITE3,[Define to 1 if you want the instruments DB feature and have SQLITE3 installed.])
799
800
801
802###########################################################################
803# Handle Configuration Options
804
805# TODO: should we use AC_ARG_VAR(variable, description) instead?
806
807AC_ARG_ENABLE(asm,
808  [  --disable-asm
809                          Enable hand-crafted assembly optimizations
810                          (default=on). LinuxSampler provides CPU specific
811                          assembly optimizations. This is currently limited
812                          to just enter a fast (denormal) FPU mode on x86
813                          platforms. There are currently no synthesis core
814                          assembly optimizations anymore since LS 0.4.0],
815  [config_asm="$enableval"],
816  [config_asm="yes"]
817)
818if test "$config_asm" = "yes"; then
819  AC_DEFINE_UNQUOTED(CONFIG_ASM, 1, [Define to 1 if you want to enable asm optimizations.])
820fi
821
822AC_ARG_ENABLE(dev-mode,
823  [  --enable-dev-mode
824                          Enable development mode (default=off). In that mode
825                          we do some extra sanity checks here and there.
826                          This helps to spot possible problems, but reduces
827                          efficiency a bit],
828  [config_dev_mode="$enableval"],
829  [config_dev_mode="no"]
830)
831if test "$config_dev_mode" = "yes"; then
832  AC_DEFINE_UNQUOTED(CONFIG_DEVMODE, 1, [Define to 1 if you want to enable development mode.])
833fi
834
835AC_ARG_ENABLE(debug-level,
836  [  --enable-debug-level
837                          Specify verbosity of console messages (default=1).
838                          The higher the value, the higher will be verbosity.
839                          A value of 0 means no console output at all.
840                          There's not really an upper limit but the usual
841                          level of all messages is currently somewhere less
842                          than 10.],
843  [config_debug_level="${enableval}"],
844  [config_debug_level="1"]
845)
846AC_DEFINE_UNQUOTED(CONFIG_DEBUG_LEVEL, $config_debug_level, [Define console verbosity.])
847
848AC_ARG_ENABLE(rt-exceptions,
849  [  --enable-rt-exceptions
850                          Enable exceptions in the realtime thread
851                          (default=no). If this is enabled, exceptions will
852                          be thrown on critical errors in the realtime
853                          context as well. Otherwise if disabled
854                          segmentation faults will be forced by the
855                          application on critical errors.],
856  [config_rt_exceptions="$enableval"],
857  [config_rt_exceptions="no"]
858)
859if test "$config_rt_exceptions" = "yes"; then
860  AC_DEFINE_UNQUOTED(CONFIG_RT_EXCEPTIONS, 1, [Define to 1 to allow exceptions in the realtime context.])
861fi
862
863AC_CHECK_FUNC(pthread_testcancel,
864  [config_pthread_testcancel="yes"],
865  [config_pthread_testcancel="no"]
866)
867if test "$config_pthread_testcancel" = "yes"; then
868  AC_DEFINE_UNQUOTED(CONFIG_PTHREAD_TESTCANCEL, 1, [Define to 1 if pthread_testcancel() is available.])
869fi
870
871AC_ARG_ENABLE(preload-samples,
872  [  --enable-preload-samples
873                          Due to seeking and latency issues with hard drives
874                          we have to cache a small part of samples' head in
875                          RAM (default=32768). The higher this value the
876                          more memory will be occupied for each sample, but
877                          the safer this will be in regards of possible
878                          droputs. A 'good' value depends on the running
879                          system and usage dependant factors.],
880  [config_preload_samples="${enableval}"],
881  [config_preload_samples="32768"]
882)
883AC_DEFINE_UNQUOTED(CONFIG_PRELOAD_SAMPLES, $config_preload_samples, [Define amount of sample points to be cached in RAM.])
884
885AC_ARG_ENABLE(max-pitch,
886  [  --enable-max-pitch
887                          Specify the maximum allowed pitch value in octaves
888                          (default=4). To lower memory usage you might want
889                          set a smaller value.],
890  [config_max_pitch="${enableval}"],
891  [config_max_pitch="4"]
892)
893AC_DEFINE_UNQUOTED(CONFIG_MAX_PITCH, $config_max_pitch, [Define max. allowed pitch.])
894
895AC_ARG_ENABLE(max-events,
896  [  --enable-max-events
897                          Specify the maximum allowed amount of events to be
898                          processed per fragment (default=1024).],
899  [config_max_events="${enableval}"],
900  [config_max_events="1024"]
901)
902AC_DEFINE_UNQUOTED(CONFIG_MAX_EVENTS_PER_FRAGMENT, $config_max_events, [Define max. allowed events per fragment.])
903
904AC_ARG_ENABLE(eg-bottom,
905  [  --enable-eg-bottom
906                          Bottom limit of envelope generators
907                          (default=0.001). Certain kinds of curve types like
908                          exponential curves converge against 0 but never
909                          reach 0. So we have to define a certain low value
910                          after which we should consider all smaller values
911                          to be 'almost zero'. The smaller this value, the
912                          longer will voices survive in EG's release stage
913                          and thus waste voices. If this value is too high
914                          will cause click sounds though.],
915  [config_eg_bottom="${enableval}"],
916  [config_eg_bottom="0.001"]
917)
918AC_DEFINE_UNQUOTED(CONFIG_EG_BOTTOM, $config_eg_bottom, [Define bottom limit of envelopes.])
919
920AC_ARG_ENABLE(eg-min-release-time,
921  [  --enable-eg-min-release-time
922                          Specify the lowest allowed release time in seconds
923                          (default=0.0025). This value will also be used to
924                          ramp down voices on voice stealing. This value
925                          should always be less than the period time of the
926                          used audio driver, as in case of voice stealing
927                          the killed voice needs to be completely ramped
928                          down in the same fragment.],
929  [config_eg_min_release_time="${enableval}"],
930  [config_eg_min_release_time="0.0025"]
931)
932AC_DEFINE_UNQUOTED(CONFIG_EG_MIN_RELEASE_TIME, $config_eg_min_release_time, [Define min. release time.])
933
934AC_ARG_ENABLE(refill-streams,
935  [  --enable-refill-streams
936                          Number of streams that should be refilled in each
937                          disk thread cycle (default=4).],
938  [config_refill_streams="${enableval}"],
939  [config_refill_streams="4"]
940)
941AC_DEFINE_UNQUOTED(CONFIG_REFILL_STREAMS_PER_RUN, $config_refill_streams, [Define amount of streams to be refilled per cycle.])
942
943AC_ARG_ENABLE(stream-min-refill,
944  [  --enable-stream-min-refill
945                          Minimum refill size for disk streams (default=1024).
946                          The disk thread will go to sleep for a while if no
947                          stream had to be refilled more than this value in
948                          a disk thread cycle.],
949  [config_stream_min_refill="${enableval}"],
950  [config_stream_min_refill="1024"]
951)
952AC_DEFINE_UNQUOTED(CONFIG_STREAM_MIN_REFILL_SIZE, $config_stream_min_refill, [Define min. stream refill size.])
953
954AC_ARG_ENABLE(stream-max-refill,
955  [  --enable-stream-max-refill
956                          Maximum refill size for disk streams
957                          (default=65536). The disk thread will refill
958                          each stream only by a size of this value per
959                          disk thread cycle.],
960  [config_stream_max_refill="${enableval}"],
961  [config_stream_max_refill="65536"]
962)
963AC_DEFINE_UNQUOTED(CONFIG_STREAM_MAX_REFILL_SIZE, $config_stream_max_refill, [Define max. stream refill size.])
964
965AC_ARG_ENABLE(stream-size,
966  [  --enable-stream-size
967                          Size of each stream's ring buffer in sample points
968                          (default=262144).],
969  [config_stream_size="${enableval}"],
970  [config_stream_size="262144"]
971)
972AC_DEFINE_UNQUOTED(CONFIG_STREAM_BUFFER_SIZE, $config_stream_size, [Define each stream's ring buffer size.])
973
974AC_ARG_ENABLE(max-streams,
975  [  --enable-max-streams
976                          Initial maximum amount of disk streams
977                          (default=90). This value can be changed at
978                          runtime. It should always be higher than the
979                          maximum amount of voices.],
980  [config_max_streams="${enableval}"],
981  [config_max_streams="90"]
982)
983AC_DEFINE_UNQUOTED(CONFIG_DEFAULT_MAX_STREAMS, $config_max_streams, [Define initial max. streams.])
984
985AC_ARG_ENABLE(max-voices,
986  [  --enable-max-voices
987                          Initial maximum amount of voices (default=64).
988                          This value can be changed at runtime. It should
989                          always be lower than the maximum amount of disk
990                          streams.],
991  [config_max_voices="${enableval}"],
992  [config_max_voices="64"]
993)
994AC_DEFINE_UNQUOTED(CONFIG_DEFAULT_MAX_VOICES, $config_max_voices, [Define initial max. voices.])
995
996AC_ARG_ENABLE(subfragment-size,
997  [  --enable-subfragment-size
998                          Every audio fragment will be splitted into
999                          subfragments. Where each subfragment renders
1000                          audio with constant synthesis parameters. This is
1001                          done for efficiency reasons. This parameter
1002                          defines the default size of a subfragment in
1003                          sample points. A large value means less CPU time
1004                          whereas a low value means better audio quality
1005                          (default=32).],
1006  [config_subfragment_size="${enableval}"],
1007  [config_subfragment_size="32"]
1008)
1009AC_DEFINE_UNQUOTED(CONFIG_DEFAULT_SUBFRAGMENT_SIZE, $config_subfragment_size, [Define default subfragment size (in sample points).])
1010
1011AC_ARG_ENABLE(global-attenuation-default,
1012  [  --enable-global-attenuation-default
1013                          To prevent clipping all samples will be lowered
1014                          in amplitude by this given default factor (can
1015                          be overridden at runtime).
1016                          (default=0.35)],
1017  [config_global_attenuation_default="${enableval}"],
1018  [config_global_attenuation_default="0.35"]
1019)
1020AC_DEFINE_UNQUOTED(CONFIG_GLOBAL_ATTENUATION_DEFAULT, $config_global_attenuation_default, [Define default global volume attenuation (as floating point factor).])
1021
1022AC_ARG_ENABLE(voice-steal-algo,
1023  [  --enable-voice-steal-algo
1024                          Voice stealing algorithm to be used. Currently
1025                          available options:
1026                            none:
1027                              Disable voice stealing completely.
1028                            oldestvoiceonkey (default):
1029                              Try to kill a voice on the same key first,
1030                              if no success, proceed with the oldest key.
1031                            oldestkey:
1032                              Try to kill a voice from the oldest active
1033                              key.],
1034  [ if test ! "(" "${enableval}" = "none" \
1035              -o "${enableval}" = "oldestvoiceonkey" \
1036              -o "${enableval}" = "oldestkey" ")" ; then
1037      AC_MSG_ERROR([Unknown voice stealing algorithm for parameter --enable-voice-steal-algo])
1038    else
1039      config_voice_steal_algo="${enableval}"
1040    fi
1041  ],
1042  [config_voice_steal_algo="oldestvoiceonkey"]
1043)
1044AC_DEFINE_UNQUOTED(CONFIG_VOICE_STEAL_ALGO, voice_steal_algo_${config_voice_steal_algo}, [Define voice stealing algorithm to be used.])
1045
1046AC_ARG_ENABLE(sysex-buffer-size,
1047  [  --enable-sysex-buffer-size
1048                          System Exclusive Message buffer size in kB
1049                          (default=2048).],
1050  [config_sysex_buffer_size="${enableval}"],
1051  [config_sysex_buffer_size="2048"]
1052)
1053AC_DEFINE_UNQUOTED(CONFIG_SYSEX_BUFFER_SIZE, $config_sysex_buffer_size, [Define SysEx buffer size.])
1054
1055AC_ARG_ENABLE(force-filter,
1056  [  --enable-force-filter
1057                          If enabled will force filter to be used even if
1058                          no usage was define in instrument patch files.
1059                          (default=no).],
1060  [config_force_filter="$enableval"],
1061  [config_force_filter="no"]
1062)
1063if test "$config_force_filter" = "yes"; then
1064  AC_DEFINE_UNQUOTED(CONFIG_FORCE_FILTER, 1, [Define to 1 to force filter usage.])
1065fi
1066
1067AC_ARG_ENABLE(filter-cutoff-min,
1068  [  --enable-filter-cutoff-min
1069                          Minimum filter cutoff frequency in Hz
1070                          (default=100.0).],
1071  [config_filter_cutoff_min="${enableval}"],
1072  [config_filter_cutoff_min="100.0"]
1073)
1074AC_DEFINE_UNQUOTED(CONFIG_FILTER_CUTOFF_MIN, ${config_filter_cutoff_min}f, [Define min. filter cutoff frequency.])
1075
1076AC_ARG_ENABLE(filter-cutoff-max,
1077  [  --enable-filter-cutoff-max
1078                          Maximum filter cutoff frequency in Hz
1079                          (default=10000.0).],
1080  [config_filter_cutoff_max="${enableval}"],
1081  [config_filter_cutoff_max="10000.0"]
1082)
1083AC_DEFINE_UNQUOTED(CONFIG_FILTER_CUTOFF_MAX, ${config_filter_cutoff_max}f, [Define max. filter cutoff frequency.])
1084
1085AC_ARG_ENABLE(override-cutoff-ctrl,
1086  [  --enable-override-cutoff-ctrl
1087                          Override filter cutoff MIDI controller (default=no).
1088                          Note: you have to define the MIDI controller number
1089                          here, it's not a boolean parameter type! If this
1090                          option is used, controller number given by
1091                          instrument patch will be ignored and instead this
1092                          supplied value will be used.],
1093  [config_override_cutoff_ctrl="${enableval}"],
1094  [config_override_cutoff_ctrl="no"]
1095)
1096if test ! "$config_override_cutoff_ctrl" = "no"; then
1097  AC_DEFINE_UNQUOTED(CONFIG_OVERRIDE_CUTOFF_CTRL, $config_override_cutoff_ctrl, [Define to a MIDI controller number to override cutoff control.])
1098fi
1099
1100AC_ARG_ENABLE(override-resonance-ctrl,
1101  [  --enable-override-resonance-ctrl
1102                          Override filter resonance MIDI controller
1103                          (default=no). Note: you have to define the MIDI
1104                          controller number here, it's not a boolean
1105                          parameter type! If this option is used, controller
1106                          number given by instrument patch will be ignored
1107                          and instead this supplied value will be used.],
1108  [config_override_resonance_ctrl="${enableval}"],
1109  [config_override_resonance_ctrl="no"]
1110)
1111if test ! "$config_override_resonance_ctrl" = "no"; then
1112  AC_DEFINE_UNQUOTED(CONFIG_OVERRIDE_RESONANCE_CTRL, $config_override_resonance_ctrl, [Define to a MIDI controller number to override resonance control.])
1113fi
1114
1115AC_ARG_ENABLE(override-filter-type,
1116  [  --enable-override-filter-type
1117                          Override filter type (default=no). Options:
1118                          hp: for highpass
1119                          bp: for bandpass
1120                          br: for bandreject
1121                          lp: for lowpass
1122                          lpt: for lowpass turbo],
1123  [ if   test "${enableval}" = "hp" ; then
1124       config_override_filter_type="::gig::vcf_type_highpass"
1125    elif test "${enableval}" = "bp" ; then
1126       config_override_filter_type="::gig::vcf_type_bandpass"
1127    elif test "${enableval}" = "br" ; then
1128       config_override_filter_type="::gig::vcf_type_bandreject"
1129    elif test "${enableval}" = "lp" ; then
1130       config_override_filter_type="::gig::vcf_type_lowpass"
1131    elif test "${enableval}" = "lpt" ; then
1132       config_override_filter_type="::gig::vcf_type_lowpassturbo"
1133    elif test ! "${enableval}" = "no"; then
1134       AC_MSG_ERROR([Unknown filter type for parameter --enable-override-filter-type])
1135    fi
1136  ],
1137  [config_override_filter_type="no"]
1138)
1139if test ! "$config_override_filter_type" = "no"; then
1140  AC_DEFINE_UNQUOTED(CONFIG_OVERRIDE_FILTER_TYPE, $config_override_filter_type, [Define to a filter type to always force that filter type.])
1141fi
1142
1143AC_ARG_ENABLE(gs-checksum,
1144  [  --enable-gs-checksum
1145                          Enable Roland General Synth SysEx checksum check
1146                          (default=no). If this is enabled, all GS SysEx
1147                          messages which do not provide a correct checksum
1148                          will be ignored. This is disabled by default as
1149                          not all devices honor GS checksums.],
1150  [config_assert_gs_sysex_checksum="$enableval"],
1151  [config_assert_gs_sysex_checksum="no"]
1152)
1153if test "config_assert_gs_sysex_checksum" = "yes"; then
1154  AC_DEFINE_UNQUOTED(CONFIG_ASSERT_GS_SYSEX_CHECKSUM, 1, [Define to 1 if you want to enable GS SysEx check.])
1155fi
1156
1157AC_ARG_ENABLE(portamento-time-min,
1158  [  --enable-portamento-time-min
1159                          Minimum Portamento time in seconds
1160                          (default=0.1).],
1161  [config_portamento_time_min="${enableval}"],
1162  [config_portamento_time_min="0.1"]
1163)
1164AC_DEFINE_UNQUOTED(CONFIG_PORTAMENTO_TIME_MIN, $config_portamento_time_min, [Define min. portamento time.])
1165
1166AC_ARG_ENABLE(portamento-time-max,
1167  [  --enable-portamento-time-max
1168                          Maximum Portamento time in seconds
1169                          (default=32).],
1170  [config_portamento_time_max="${enableval}"],
1171  [config_portamento_time_max="32"]
1172)
1173AC_DEFINE_UNQUOTED(CONFIG_PORTAMENTO_TIME_MAX, $config_portamento_time_max, [Define max. portamento time.])
1174
1175AC_ARG_ENABLE(portamento-time-default,
1176  [  --enable-portamento-time-default
1177                          Default Portamento time in seconds
1178                          (default=1).],
1179  [config_portamento_time_default="${enableval}"],
1180  [config_portamento_time_default="1"]
1181)
1182AC_DEFINE_UNQUOTED(CONFIG_PORTAMENTO_TIME_DEFAULT, $config_portamento_time_default, [Define default portamento time.])
1183
1184AC_ARG_ENABLE(signed-triang-algo,
1185  [  --enable-signed-triang-algo
1186                          Signed triangular wave algorithm to be used (e.g. for LFOs).
1187                          Currently available options:
1188                            intmath:
1189                              Uses integer math without any branch will then be
1190                              converted to floating point value for each sample point.
1191                              This int->float conversion might hurt on some systems.
1192                            intmathabs:
1193                              Similar to intmath but uses abs() function.
1194                              Depending on compiler and platrofm this could
1195                              perform better than integer math as it avoids
1196                              an extra integer multiply instruction.
1197                            diharmonic:
1198                              The triangular wave will be approximated by adding two
1199                              sinusoidials. This solution might especially hurt on
1200                              systems with weak floating point unit.
1201                            benchmark (default):
1202                              This is not an algorithm. Use this option if the
1203                              appropriate algorithm should be automatically
1204                              chosen by the configure script by performing a
1205                              benchmark between the algorithms mentioned above.
1206                              This will NOT work for cross compilation!],
1207  [ if test ! "(" "${enableval}" = "intmath" \
1208              -o "${enableval}" = "intmathabs" \
1209              -o "${enableval}" = "diharmonic" ")" ; then
1210      AC_MSG_ERROR([Unknown triangular wave algorithm for parameter --enable-signed-triang-algo])
1211    else
1212      config_signed_triang_algo="${enableval}"
1213    fi
1214  ],
1215  [config_signed_triang_algo="benchmark"]
1216)
1217
1218AC_ARG_ENABLE(unsigned-triang-algo,
1219  [  --enable-unsigned-triang-algo
1220                          Unsigned triangular wave algorithm to be used (e.g. for LFOs).
1221                          Currently available options:
1222                            intmath:
1223                              Uses integer math without any branch will then be
1224                              converted to floating point value for each sample point.
1225                              This int->float conversion might hurt on some systems.
1226                            intmathabs:
1227                              Similar to intmath but uses abs() function.
1228                              Depending on compiler and platrofm this could
1229                              perform better than integer math as it avoids
1230                              an extra integer multiply instruction.
1231                            diharmonic:
1232                              The triangular wave will be approximated by adding two
1233                              sinusoidials. This solution might especially hurt on
1234                              systems with weak floating point unit.
1235                            benchmark (default):
1236                              This is not an algorithm. Use this option if the
1237                              appropriate algorithm should be automatically
1238                              chosen by the configure script by performing a
1239                              benchmark between the algorithms mentioned above.
1240                              This will NOT work for cross compilation!],
1241  [ if test ! "(" "${enableval}" = "intmath" \
1242              -o "${enableval}" = "intmathabs" \
1243              -o "${enableval}" = "diharmonic" ")" ; then
1244      AC_MSG_ERROR([Unknown triangular wave algorithm for parameter --enable-unsigned-triang-algo])
1245    else
1246      config_unsigned_triang_algo="${enableval}"
1247    fi
1248  ],
1249  [config_unsigned_triang_algo="benchmark"]
1250)
1251
1252AC_ARG_ENABLE(process-muted-channels,
1253  [  --enable-process-muted-channels
1254                          Enable processing of muted channels (default=no).
1255                          In that mode all MIDI events in the muted channels
1256                          will be processed. This will provide information
1257                          about the active voices in the muted channels and
1258                          will not discard notes, triggered in mute mode,
1259                          when the channel is unmuted. But also will reduce
1260                          the efficiency.],
1261  [config_process_muted_channels="$enableval"],
1262  [config_process_muted_channels="no"]
1263)
1264if test "$config_process_muted_channels" = "yes"; then
1265  AC_DEFINE_UNQUOTED(CONFIG_PROCESS_MUTED_CHANNELS, 1, [Define to 1 if you want to enable processing of muted channels.])
1266fi
1267
1268AC_ARG_ENABLE(process-all-notes-off,
1269  [  --disable-process-all-notes-off
1270                          Disable interpretation of All-Notes-Off MIDI
1271                          messages (default=on). By default LS will release
1272                          all voices whenever it receives an All-Notes-Off
1273                          MIDI message. You can disable this behavior, so
1274                          that LS simply ignores such messages.],
1275  [config_process_all_notes_off="$enableval"],
1276  [config_process_all_notes_off="yes"]
1277)
1278if test "$config_process_all_notes_off" = "yes"; then
1279  AC_DEFINE_UNQUOTED(CONFIG_PROCESS_ALL_NOTES_OFF, 1, [Define to 1 if you want to enable processing of All-Notes-Off MIDI messages.])
1280fi
1281
1282AC_ARG_ENABLE(interpolate-volume,
1283  [  --disable-interpolate-volume
1284                          Disable interpolation of volume modulation
1285                          (default=on). With this enabled, the volume changes
1286                          generated by for example the envelope generator
1287                          will be smoother, minimizing the risk for audio
1288                          clicks. Disable it to reduce CPU usage.],
1289  [config_interpolate_volume="$enableval"],
1290  [config_interpolate_volume="yes"]
1291)
1292if test "$config_interpolate_volume" = "yes"; then
1293  AC_DEFINE_UNQUOTED(CONFIG_INTERPOLATE_VOLUME, 1, [Define to 1 if you want to enable interpolation of volume modulation.])
1294fi
1295
1296AC_ARG_ENABLE(master-volume-sysex-by-port,
1297  [  --enable-master-volume-sysex-by-port
1298                          Whether global volume sysex message should be
1299                          applied globally to the whole sampler or only to
1300                          the sampler channels connected to the same MIDI
1301                          input port on which the sysex message arrived on.
1302                          By default global volume sysex messages apply
1303                          globally to the whole sampler, since many MIDI
1304                          devices behave that way.],
1305  [config_master_volume_sysex_by_port="$enableval"],
1306  [config_master_volume_sysex_by_port="no"]
1307)
1308if test "$config_master_volume_sysex_by_port" = "yes"; then
1309  AC_DEFINE_UNQUOTED(CONFIG_MASTER_VOLUME_SYSEX_BY_PORT, 1, [Define to 1 if you want global volume sysex message only be applied to the respective MIDI port.])
1310fi
1311
1312AC_ARG_ENABLE(plugin-dir,
1313  [  --enable-plugin-dir
1314                          Directory where the sampler shall look for potential plugins,
1315                          that is 3rd party shared libraries that should be loaded by
1316                          the sampler on startup. By default the sampler will search
1317                          for plugins in the subdirectory "plugins" below its own
1318                          library directory.
1319                          (i.e. /usr/local/lib/linuxsampler/plugins)],
1320  [config_plugin_dir="${enableval}"],
1321  [config_plugin_dir="${libdir}/linuxsampler/plugins"]
1322)
1323AC_SUBST(config_plugin_dir)
1324
1325AC_ARG_ENABLE(default-instruments-db-location,
1326  [  --enable-default-instruments-db-location
1327                          Only when instruments DB feature is enabled: file name
1328                          which shall be taken as default location of the
1329                          instruments DB file. This location can still be
1330                          overridden at runtime with a command line switch.
1331                          (default: /var/lib/linuxsampler/instruments.db)],
1332  [config_default_instruments_db_file="${enableval}"],
1333  [config_default_instruments_db_file="/var/lib/linuxsampler/instruments.db"]
1334)
1335AC_DEFINE_UNQUOTED(
1336    CONFIG_DEFAULT_INSTRUMENTS_DB_LOCATION,
1337    "$config_default_instruments_db_file",
1338    [Only when instruments DB feature is enabled: default location of the DB file.]
1339)
1340AC_SUBST(config_default_instruments_db_file)
1341
1342
1343###########################################################################
1344# Automatic Benchmarks (to detect the best algorithms for the system)
1345
1346if test "$config_signed_triang_algo" = "benchmark"; then
1347    echo -n "benchmarking for the best (signed) triangular oscillator algorithm... "
1348    AC_LANG_PUSH([C++])
1349    AC_RUN_IFELSE([AC_LANG_SOURCE([[
1350            #define SIGNED 1
1351            #define SILENT 1
1352            #include "${srcdir}/benchmarks/triang.cpp"
1353        ]])],
1354        triang_signed=0,
1355        triang_signed=$?,
1356        triang_signed=0
1357    )
1358    AC_LANG_POP([C++])
1359    if test "$triang_signed" = "2"; then
1360        config_signed_triang_algo="intmath"
1361        echo "integer math"
1362    elif test "$triang_signed" = "3"; then
1363        config_signed_triang_algo="diharmonic"
1364        echo "di harmonics"
1365    elif test "$triang_signed" = "5"; then
1366        config_signed_triang_algo="intmathabs"
1367        echo "integer math using abs()"
1368    else
1369        echo "Benchmark of signed triangular wave algorithms failed!"
1370        echo "Maybe you are doing cross compilation? In that case you have to select"
1371        echo "an algorithm manually with './configure --enable-signed-triang-algo=...'"
1372        echo "Call './configure --help' for further information or read configure.in."
1373        exit -1;
1374    fi
1375else
1376    case "$config_signed_triang_algo" in
1377        intmath)
1378            triang_signed=2 ;;
1379        diharmonic)
1380            triang_signed=3 ;;
1381        intmathabs)
1382            triang_signed=5 ;;
1383    esac
1384fi
1385AC_DEFINE_UNQUOTED(CONFIG_SIGNED_TRIANG_ALGO, ${triang_signed}, [Define signed triangular wave algorithm to be used.])
1386
1387if test "$config_unsigned_triang_algo" = "benchmark"; then
1388    echo -n "benchmarking for the best (unsigned) triangular oscillator algorithm... "
1389    AC_LANG_PUSH([C++])
1390    AC_RUN_IFELSE([AC_LANG_SOURCE([[
1391            #define SIGNED 0
1392            #define SILENT 1
1393            #include "${srcdir}/benchmarks/triang.cpp"
1394        ]])],
1395        triang_unsigned=0,
1396        triang_unsigned=$?,
1397        triang_unsigned=0
1398    )
1399    AC_LANG_POP([C++])
1400    if test "$triang_unsigned" = "2"; then
1401        config_unsigned_triang_algo="intmath"
1402        echo "integer math"
1403    elif test "$triang_unsigned" = "3"; then
1404        config_unsigned_triang_algo="diharmonic"
1405        echo "di harmonics"
1406    elif test "$triang_unsigned" = "5"; then
1407        config_unsigned_triang_algo="intmathabs"
1408        echo "integer math using abs()"
1409    else
1410        echo "Benchmark of unsigned triangular wave algorithms failed!"
1411        echo "Maybe you are doing cross compilation? In that case you have to select"
1412        echo "an algorithm manually with './configure --enable-unsigned-triang-algo=...'"
1413        echo "Call './configure --help' for further information or read configure.in."
1414        exit -1;
1415    fi
1416else
1417    case "$config_unsigned_triang_algo" in
1418        intmath)
1419            triang_unsigned=2 ;;
1420        diharmonic)
1421            triang_unsigned=3 ;;
1422        intmathabs)
1423            triang_unsigned=5 ;;
1424    esac
1425fi
1426AC_DEFINE_UNQUOTED(CONFIG_UNSIGNED_TRIANG_ALGO, ${triang_unsigned}, [Define unsigned triangular wave algorithm to be used.])
1427
1428
1429###########################################################################
1430# Create Build Files
1431
1432AC_CONFIG_HEADERS([config.h])
1433
1434AC_LANG([C++])
1435
1436# autoconf 2.59/libtool 1.5.12 bug? work-around. Without a check like
1437# this, the dlfcn.h check in am_prog_libtool may fail.
1438AC_CHECK_HEADER(stdlib.h)
1439
1440AC_CONFIG_FILES([\
1441    Makefile \
1442    man/Makefile \
1443    man/linuxsampler.1 \
1444    man/lscp.1 \
1445    src/Makefile \
1446    src/db/Makefile \
1447    src/network/Makefile \
1448    src/engines/Makefile \
1449    src/engines/gig/Makefile \
1450    src/engines/sf2/Makefile \
1451    src/engines/sfz/Makefile \
1452    src/engines/common/Makefile \
1453    src/effects/Makefile \
1454    src/common/Makefile \
1455    src/testcases/Makefile \
1456    src/drivers/Makefile \
1457    src/drivers/audio/Makefile \
1458    src/drivers/midi/Makefile \
1459    src/plugins/Makefile \
1460    src/hostplugins/Makefile \
1461    src/hostplugins/dssi/Makefile \
1462    src/hostplugins/lv2/Makefile \
1463    src/hostplugins/lv2/manifest.ttl \
1464    src/hostplugins/vst/Makefile \
1465    src/hostplugins/au/Makefile \
1466    src/scriptvm/Makefile \
1467    src/scriptvm/editor/Makefile \
1468    src/shell/Makefile \
1469    linuxsampler.spec \
1470    debian/Makefile \
1471    Artwork/Makefile \
1472    scripts/Makefile \
1473    osx/Makefile \
1474    osx/linuxsampler.xcodeproj/Makefile \
1475    Documentation/Makefile \
1476    Documentation/Engines/Makefile \
1477    Documentation/Engines/gig/Makefile \
1478    linuxsampler.pc \
1479    Doxyfile \
1480])
1481AC_OUTPUT
1482
1483# resolve all nested variables in '${config_plugin_dir}'
1484# (merely for providing a human readable summary below)
1485while test $config_plugin_dir != `eval echo ${config_plugin_dir}` ; do
1486	config_plugin_dir=`eval echo ${config_plugin_dir}`
1487done
1488
1489
1490###########################################################################
1491# Output All Configuration Options
1492
1493echo ""
1494echo "#####################################################################"
1495echo "# LinuxSampler Configuration                                        #"
1496echo "#-------------------------------------------------------------------#"
1497echo "# Release Version: ${VERSION}"
1498echo "# LSCP Version: ${LSCP_RELEASE_MAJOR}.${LSCP_RELEASE_MINOR}"
1499echo "#-------------------------------------------------------------------"
1500echo "# Assembly Optimizations: ${config_asm}"
1501echo "# Development Mode: ${config_dev_mode}"
1502echo "# Debug Level: ${config_debug_level}"
1503echo "# Use Exceptions in RT Context: ${config_rt_exceptions}"
1504echo "# Preload Samples: ${config_preload_samples}"
1505echo "# Maximum Pitch: ${config_max_pitch} (octaves)"
1506echo "# Maximum Events: ${config_max_events}"
1507echo "# Envelope Bottom Level: ${config_eg_bottom} (linear)"
1508echo "# Envelope Minimum Release Time: ${config_eg_min_release_time} s"
1509echo "# Streams to be refilled per Disk Thread Cycle: ${config_refill_streams}"
1510echo "# Minimum Stream Refill Size: ${config_stream_min_refill}"
1511echo "# Maximum Stream Refill Size: ${config_stream_max_refill}"
1512echo "# Stream Size: ${config_stream_size}"
1513echo "# Default Maximum Disk Streams: ${config_max_streams}"
1514echo "# Default Maximum Voices: ${config_max_voices}"
1515echo "# Default Subfragment Size: ${config_subfragment_size}"
1516echo "# Default Global Volume Attenuation: ${config_global_attenuation_default}"
1517echo "# Voice Stealing Algorithm: ${config_voice_steal_algo}"
1518echo "# Signed Triangular Oscillator Algorithm: ${config_signed_triang_algo}"
1519echo "# Unsigned Triangular Oscillator Algorithm: ${config_unsigned_triang_algo}"
1520echo "# SysEx Buffer Size: ${config_sysex_buffer_size} Byte"
1521echo "# Min. Portamento Time: ${config_portamento_time_min} s"
1522echo "# Max. Portamento Time: ${config_portamento_time_max} s"
1523echo "# Default Portamento Time: ${config_portamento_time_default} s"
1524echo "# Force Filter Usage: ${config_force_filter}"
1525echo "# Filter Cutoff Minimum: ${config_filter_cutoff_min} Hz"
1526echo "# Filter Cutoff Maximum: ${config_filter_cutoff_max} Hz"
1527echo "# Override Filter Cutoff Controller: ${config_override_cutoff_ctrl}"
1528echo "# Override Filter Resonance Controller: ${config_override_resonance_ctrl}"
1529echo "# Override Filter Type: ${config_override_filter_type}"
1530echo "# Assert GS SysEx Checksum: ${config_assert_gs_sysex_checksum}"
1531echo "# Process Muted Channels: ${config_process_muted_channels}"
1532echo "# Process All-Notes-Off MIDI message: ${config_process_all_notes_off}"
1533echo "# Apply global volume SysEx by MIDI port: ${config_master_volume_sysex_by_port}"
1534echo "# Interpolate Volume: ${config_interpolate_volume}"
1535echo "# Instruments database support: ${config_instruments_db}"
1536if test "$config_instruments_db" = "yes"; then
1537echo "# Instruments DB default location: ${config_default_instruments_db_file}"
1538fi
1539echo "# Plugin Path: ${config_plugin_dir}"
1540echo "#-------------------------------------------------------------------"
1541echo "# MIDI Input Drivers:"
1542echo "# ALSA: ${config_have_alsa}, JACK: ${config_have_jack_midi}, CoreMIDI: ${config_have_coremidi}, MME: ${config_have_mme}, MidiShare: ${config_have_midishare}"
1543echo "#-------------------------------------------------------------------"
1544echo "# Audio Output Drivers:"
1545echo "# ALSA: ${config_have_alsa}, JACK: ${config_have_jack}, ARTS: ${config_have_arts}, CoreAudio: ${config_have_coreaudio}, ASIO: ${config_have_asio}"
1546echo "#-------------------------------------------------------------------"
1547echo "# Sampler Engines:"
1548echo "# GIG: yes, SF2: ${config_have_sf2}, SFZ: yes"
1549echo "#-------------------------------------------------------------------"
1550echo "# Effect plugin systems for internal effects:"
1551echo "# LADSPA: yes"
1552echo "#-------------------------------------------------------------------"
1553echo "# Building sampler as plugin for following host standards:"
1554echo "# DSSI: ${config_have_dssi}, LV2: ${config_have_lv2}, VST: ${config_have_vst}, AU: ${config_have_au}"
1555echo "#-------------------------------------------------------------------#"
1556echo "# Read './configure --help' or file 'configure.in' for details.     #"
1557echo "#####################################################################"
1558echo ""
1559echo "Good. Now type 'make' to compile, followed by 'make install' as root."
1560echo ""
1561