configure.ac 5.0 KB

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