configure.ac 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # Process this file with autoconf to produce a configure script.
  2. AC_INIT(RtMidi, 2.1.0, gary@music.mcgill.ca, rtmidi)
  3. AC_CONFIG_AUX_DIR(config)
  4. AC_CONFIG_SRCDIR(RtMidi.cpp)
  5. AC_CONFIG_FILES([rtmidi-config librtmidi.pc Makefile tests/Makefile])
  6. AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
  7. # Fill GXX with something before test.
  8. AC_SUBST( GXX, ["no"] )
  9. # Checks for programs.
  10. AC_PROG_CXX(g++ CC c++ cxx)
  11. AM_PROG_AR
  12. AC_PROG_RANLIB
  13. AC_PATH_PROG(AR, ar, no)
  14. if [[ $AR = "no" ]] ; then
  15. AC_MSG_ERROR("Could not find ar - needed to create a library");
  16. fi
  17. # Checks for header files.
  18. AC_HEADER_STDC
  19. #AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
  20. # Check for debug
  21. AC_MSG_CHECKING(whether to compile debug version)
  22. AC_ARG_ENABLE(debug,
  23. [ --enable-debug = enable various debug output],
  24. [AC_SUBST( cppflag, [-D__RTMIDI_DEBUG__] ) AC_SUBST( cxxflag, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
  25. [AC_SUBST( cppflag, [] ) AC_SUBST( cxxflag, [-O3] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
  26. # Set paths if prefix is defined
  27. if test "x$prefix" != "x" && test "x$prefix" != "xNONE"; then
  28. LIBS="$LIBS -L$prefix/lib"
  29. CPPFLAGS="$CPPFLAGS -I$prefix/include"
  30. fi
  31. # For -I and -D flags
  32. CPPFLAGS="$CPPFLAGS $cppflag"
  33. # For debugging and optimization ... overwrite default because it has both -g and -O2
  34. #CXXFLAGS="$CXXFLAGS $cxxflag"
  35. CXXFLAGS="$cxxflag"
  36. # Check compiler and use -Wall if gnu.
  37. if [test $GXX = "yes" ;] then
  38. AC_SUBST( cxxflag, ["-Wall -Wextra"] )
  39. fi
  40. CXXFLAGS="$CXXFLAGS $cxxflag"
  41. # Checks for package options and external software
  42. AC_CANONICAL_HOST
  43. AC_SUBST( sharedlib, ["librtmidi.so"] )
  44. AC_SUBST( sharedname, ["librtmidi.so.\$(RELEASE)"] )
  45. AC_SUBST( libflags, ["-shared -Wl,-soname,\$(SHARED).\$(MAJOR) -o \$(SHARED).\$(RELEASE)"] )
  46. case $host in
  47. *-apple*)
  48. AC_SUBST( sharedlib, ["librtmidi.dylib"] )
  49. AC_SUBST( sharedname, ["librtmidi.\$(RELEASE).dylib"] )
  50. AC_SUBST( libflags, ["-dynamiclib -o librtmidi.\$(RELEASE).dylib"] )
  51. esac
  52. AC_SUBST( api, [""] )
  53. AC_SUBST( req, [""] )
  54. AC_MSG_CHECKING(for MIDI API)
  55. case $host in
  56. *-*-linux*)
  57. AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (mac and linux only)], [
  58. api="$api -D__UNIX_JACK__"
  59. AC_MSG_RESULT(using JACK)
  60. AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))], )
  61. # Look for ALSA flag
  62. AC_ARG_WITH(alsa, [ --with-alsa = choose native ALSA sequencer API support (linux only)], [
  63. api="$api -D__LINUX_ALSA__"
  64. req="$req alsa"
  65. AC_MSG_RESULT(using ALSA)
  66. AC_CHECK_LIB(asound, snd_seq_open, , AC_MSG_ERROR(ALSA support requires the asound library!))], )
  67. if [test "$api" == "";] then
  68. AC_MSG_RESULT(using ALSA)
  69. AC_SUBST( api, [-D__LINUX_ALSA__] )
  70. req="$req alsa"
  71. AC_CHECK_LIB(asound, snd_seq_open, , AC_MSG_ERROR(ALSA sequencer support requires the asound library!))
  72. fi
  73. # Checks for pthread library.
  74. AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtMidi requires the pthread library!))
  75. ;;
  76. *-apple*)
  77. AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (mac and linux only)], [
  78. api="$api -D__UNIX_JACK__"
  79. AC_MSG_RESULT(using JACK)
  80. AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))], )
  81. # Look for Core flag
  82. AC_ARG_WITH(core, [ --with-core = choose CoreMidi API support (mac only)], [
  83. api="$api -D__MACOSX_CORE__"
  84. AC_MSG_RESULT(using CoreMidi)
  85. AC_CHECK_HEADER(CoreMIDI/CoreMIDI.h, [], [AC_MSG_ERROR(CoreMIDI header files not found!)] )
  86. LIBS="$LIBS -framework CoreMIDI -framework CoreFoundation -framework CoreAudio" ], )
  87. # If no api flags specified, use CoreMidi
  88. if [test "$api" == ""; ] then
  89. AC_SUBST( api, [-D__MACOSX_CORE__] )
  90. AC_MSG_RESULT(using CoreMidi)
  91. AC_CHECK_HEADER(CoreMIDI/CoreMIDI.h,
  92. [],
  93. [AC_MSG_ERROR(CoreMIDI header files not found!)] )
  94. AC_SUBST( LIBS, ["-framework CoreMIDI -framework CoreFoundation -framework CoreAudio"] )
  95. fi
  96. ;;
  97. *-mingw32*)
  98. # Look for WinMM flag
  99. AC_ARG_WITH(winmm, [ --with-winmm = choose Windows MultiMedia (MM) API support (windoze only)], [
  100. api="$api -D__WINDOWS_MM__"
  101. AC_MSG_RESULT(using WinMM)
  102. AC_SUBST( LIBS, [-lwinmm] )], )
  103. AC_ARG_WITH(winks, [ --with-winks = choose kernel streaming support (windoze only)], [
  104. api="$api -D__WINDOWS_KS__"
  105. AC_SUBST( LIBS, ["-lsetupapi -lksuser"] )
  106. AC_MSG_RESULT(using kernel streaming) ], )
  107. # I can't get the following check to work so just manually add the library
  108. # or could try the following? AC_LIB_WINMM([midiOutGetNumDevs])
  109. # AC_CHECK_LIB(winmm, midiInGetNumDevs, , AC_MSG_ERROR(Windows MIDI support requires the winmm library!) )],)
  110. # If no api flags specified, use WinMM
  111. if [test "$api" == "";] then
  112. AC_SUBST( api, [-D__WINDOWS_MM__] )
  113. AC_MSG_RESULT(using WinMM)
  114. AC_SUBST( LIBS, [-lwinmm] )
  115. fi
  116. ;;
  117. *)
  118. # Default case for unknown realtime systems.
  119. AC_MSG_ERROR(Unknown system type for MIDI support!)
  120. ;;
  121. esac
  122. CPPFLAGS="$CPPFLAGS $api"
  123. AC_OUTPUT
  124. chmod oug+x rtmidi-config