1# Process this file with autoconf to produce a configure script. 2AC_INIT(RtMidi, 4.0.0, gary@music.mcgill.ca, rtmidi) 3AC_CONFIG_AUX_DIR(config) 4AC_CONFIG_SRCDIR(RtMidi.cpp) 5AC_CONFIG_FILES([rtmidi-config rtmidi.pc Makefile tests/Makefile doc/Makefile doc/doxygen/Doxyfile]) 6AM_INIT_AUTOMAKE([1.14 -Wall -Werror foreign subdir-objects]) 7 8# libtool version: current:revision:age 9# 10# If the library source code has changed at all since the last update, then 11# increment revision (`c:r:a' becomes `c:r+1:a'). 12# 13# If any interfaces have been added, removed, or changed since the last update, 14# increment current, and set revision to 0. 15# 16# If any interfaces have been added since the last public release, then 17# increment age. 18# 19# If any interfaces have been removed since the last public release, then set 20# age to 0. 21m4_define([lt_current], 5) 22m4_define([lt_revision], 0) 23m4_define([lt_age], 0) 24 25m4_define([lt_version_info], [lt_current:lt_revision:lt_age]) 26m4_define([lt_current_minus_age], [m4_eval(lt_current - lt_age)]) 27 28SO_VERSION=lt_version_info 29AC_SUBST(SO_VERSION) 30AC_SUBST(LIBS) 31AC_SUBST(api) 32AC_SUBST(req) 33 34api="" 35req="" 36 37# Fill GXX with something before test. 38GXX="no" 39 40# if the user did not provide any CXXFLAGS, we can override them 41AS_IF([test "x$CXXFLAGS" = "x" ], [override_cxx=yes], [override_cxx=no]) 42AS_IF([test "x$CFLAGS" = "x" ], [override_c=yes], [override_c=no]) 43 44# Check version number coherency between RtMidi.h and configure.ac 45AC_MSG_CHECKING([that version numbers are coherent]) 46RTMIDI_VERSION=`sed -n 's/#define RTMIDI_VERSION "\(.*\)"/\1/p' $srcdir/RtMidi.h` 47AS_IF( 48 [test "x$RTMIDI_VERSION" != "x$PACKAGE_VERSION"], 49 [AC_MSG_FAILURE([testing RTMIDI_VERSION==PACKAGE_VERSION failed, check that RtMidi.h defines RTMIDI_VERSION as "$PACKAGE_VERSION" or that the first line of configure.ac has been updated.])]) 50 51# Enable some nice automake features if they are available 52m4_ifdef([AM_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) 53m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 54 55# configure flags 56AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [enable various debugging output])]) 57AC_ARG_WITH(jack, [AS_HELP_STRING([--with-jack], [choose JACK server support])]) 58AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa], [choose native ALSA sequencer API support (linux only)])]) 59AC_ARG_WITH(core, [AS_HELP_STRING([--with-core], [ choose CoreMIDI API support (mac only)])]) 60AC_ARG_WITH(winmm, [AS_HELP_STRING([--with-winmm], [ choose Windows MultiMedia (MM) API support (win32 only)])]) 61AC_ARG_WITH(winks, [AS_HELP_STRING([--with-winks], [ choose kernel streaming support (win32 only)])]) 62 63 64# Checks for programs. 65AC_PROG_CXX(g++ CC c++ cxx) 66AM_PROG_AR 67AC_PATH_PROG(AR, ar, no) 68AS_IF([test "x$AR" = "xno"], [ 69 AC_MSG_ERROR([Could not find ar - needed to create a library]) 70]) 71 72LT_INIT([win32-dll]) 73AC_CONFIG_MACRO_DIR([m4]) 74 75# Checks for header files. 76AC_HEADER_STDC 77#AC_CHECK_HEADERS(sys/ioctl.h unistd.h) 78 79# Check for POSIX semaphore support 80AC_CHECK_HEADER([semaphore.h], [ 81 AC_CHECK_LIB(pthread, sem_init, 82 AC_DEFINE([HAVE_SEMAPHORE],[1],[Define to 1 if you have POSIX semaphore support on your system.]), 83 AC_MSG_WARN([POSIX semaphore support not found; data may be lost on closePort])) 84]) 85 86 87# check for debug 88AC_MSG_CHECKING(whether to compile debug version) 89debugflags="" 90object_path=Release 91AS_CASE([${enable_debug}], 92 [ yes ], [ 93 AC_MSG_RESULT([yes]) 94 CPPFLAGS="-D__RTMIDI_DEBUG ${CPPFLAGS}" 95 debugflags="${debugflags} -g" 96 object_path=Debug 97 ], 98 [ no ], [ 99 AC_MSG_RESULT([no!]) 100 debugflags="${debugflags} -O3" 101 ], [ 102 AC_MSG_RESULT([no]) 103 ]) 104# For debugging and optimization ... overwrite default because it has both -g and -O2 105AS_IF([test "x$debugflags" != x], 106 AS_IF([test "x$override_cxx" = "xyes" ], CXXFLAGS="$CXXFLAGS $debugflags", CXXFLAGS="$debugflags $CXXFLAGS") 107 AS_IF([test "x$override_c" = "xyes" ], CFLAGS="$CFLAGS $debugflags", CFLAGS="$debugflags $CFLAGS") 108 ) 109 110# Check compiler and use -Wall if gnu. 111AS_IF([test "x$GXX" = "xyes"], [ 112 CXXFLAGS="-Wall -Wextra ${CXXFLAGS}" 113]) 114 115# Checks for doxygen 116AC_CHECK_PROG( DOXYGEN, [doxygen], [doxygen] ) 117AM_CONDITIONAL( MAKE_DOC, [test "x${DOXYGEN}" != x] ) 118 119# Copy doc files to build dir if necessary 120AC_CONFIG_LINKS( [doc/doxygen/footer.html:doc/doxygen/footer.html] ) 121AC_CONFIG_LINKS( [doc/doxygen/header.html:doc/doxygen/header.html] ) 122AC_CONFIG_LINKS( [doc/doxygen/tutorial.txt:doc/doxygen/tutorial.txt] ) 123AC_CONFIG_LINKS( [doc/images/ccrma.gif:doc/images/ccrma.gif] ) 124AC_CONFIG_LINKS( [doc/images/mcgill.gif:doc/images/mcgill.gif] ) 125 126# Checks for package options and external software 127AC_CANONICAL_HOST 128 129# Aggregate options into a single string. 130AS_IF([test "x$with_jack" = "xyes"], [systems="$systems jack"]) 131AS_IF([test "x$with_alsa" = "xyes"], [systems="$systems alsa"]) 132AS_IF([test "x$with_core" = "xyes"], [systems="$systems core"]) 133AS_IF([test "x$with_winmm" = "xyes"], [systems="$systems winmm"]) 134AS_IF([test "x$with_winks" = "xyes"], [systems="$systems winks"]) 135AS_IF([test "x$with_dummy" = "xyes"], [systems="$systems dummy"]) 136required=" $systems " 137 138# If none, assign defaults if any are known for this OS. 139# User must specified with-* options for any unknown OS. 140AS_IF([test "x$systems" = "x"], 141 AS_CASE([$host], 142 [*-*-linux*], [systems="alsa jack"], 143 [*-*-gnu], [systems="jack"], 144 [*-*-kdragonfly*-gnu], [systems="jack"], 145 [*-apple*], [systems="core jack"], 146 [*-mingw32*], [systems="winmm winks jack"], 147 [*-mingw64*], [systems="winmm winks jack"] 148 )) 149 150# If any were specifically requested disabled, do it. 151AS_IF([test "x$with_jack" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v jack`]) 152AS_IF([test "x$with_alsa" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v alsa`]) 153AS_IF([test "x$with_winmm" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v winmm`]) 154AS_IF([test "x$with_winks" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v winks`]) 155AS_IF([test "x$with_core" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v core`]) 156AS_IF([test "x$with_dummy" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v dummy`]) 157systems=" `echo $systems|tr \\\\n ' '` " 158 159# For each MIDI system, check if it is selected and found. 160# Note: Order specified above is not necessarily respected. However, 161# *actual* priority is set at run-time, see RtMidiIn::openMidiApi and RtMidiOut::openMidiApi. 162# One AS_CASE per system, since they are not mutually-exclusive. 163 164AS_CASE(["$systems"], [*" jack "*], [ 165 AC_CHECK_LIB(jack, jack_client_open, 166 [api="$api -D__UNIX_JACK__" 167 req="$req jack" 168 need_pthread=yes 169 found="$found Jack" 170 LIBS="-ljack $LIBS"], 171 AS_CASE(["$required"], [*" jack "*], 172 AC_MSG_ERROR([JACK support requires the jack library!]))) 173 AC_CHECK_LIB(jack, jack_port_rename, AC_DEFINE(JACK_HAS_PORT_RENAME), ) 174]) 175 176AS_CASE(["$systems"], [*" alsa "*], [ 177 AC_CHECK_LIB(asound, snd_seq_open, 178 [api="$api -D__LINUX_ALSA__" 179 req="$req alsa" 180 need_pthread=yes 181 found="$found ALSA" 182 LIBS="-lasound $LIBS"], 183 AS_CASE(["$required"], [*" alsa "*], 184 AC_MSG_ERROR([ALSA support requires the asound library!]))) 185]) 186 187AS_CASE(["$systems"], [*" core "*], [ 188 AC_CHECK_HEADER(CoreMIDI/CoreMIDI.h, 189 [api="$api -D__MACOSX_CORE__" 190 need_pthread=yes 191 found="$found CoreMIDI", 192 LIBS="$LIBS -framework CoreMIDI -framework CoreFoundation -framework CoreAudio"], 193 AS_CASE(["$required"], [*" core "*], 194 AC_MSG_ERROR([CoreMIDI header files not found!]))) 195]) 196 197AS_CASE(["$systems"], [*" winmm "*], [ 198 AC_CHECK_HEADERS(windows.h mmsystem.h, 199 [api="$api -D__WINDOWS_MM__" 200 CPPFLAGS="-I$srcdir/include $CPPFLAGS" 201 need_ole32=yes 202 found="$found WinMM" 203 api="$api -D__WINDOWS_MM__" 204 LIBS="-lwinmm ${LIBS}"]) 205]) 206 207AS_CASE(["$systems"], [*" winks "*], [ 208 AC_CHECK_HEADERS(windows.h audioclient.h avrt.h mmdeviceapi.h, 209 [api="$api -D__WINDOWS_WINKS__" 210 CPPFLAGS="-I$srcdir/include $CPPFLAGS" 211 need_ole32=yes 212 found="$found kernel-streaming" 213 api="$api -D__WINDOWS_WINKS__" 214 LIBS="-lsetupapi -lksuser ${LIBS}"]) 215]) 216 217AS_IF([test -n "$need_ole32"], [LIBS="-lole32 $LIBS"]) 218 219AS_IF([test -n "$need_pthread"],[ 220 AC_MSG_CHECKING([for pthread]) 221 AC_CHECK_LIB(pthread, pthread_create, , 222 AC_MSG_ERROR([RtAudio requires the pthread library!]))]) 223 224AC_MSG_CHECKING([for MIDI API]) 225 226# Error case: no known realtime systems found. 227AS_IF([test x"$api" = "x"], [ 228 AC_MSG_RESULT([none]) 229 AC_MSG_ERROR([No known system type found for MIDI support!]) 230], [ 231 AC_MSG_RESULT([$found]) 232]) 233 234CPPFLAGS="$CPPFLAGS $api" 235 236AC_OUTPUT 237 238chmod oug+x rtmidi-config 239