configure.ac 9.1 KB

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