configure.ac 5.0 KB

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