configure.ac 4.9 KB

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