home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 February / PCO_0299.ISO / filesbbs / linux / mikmod-3.000 / mikmod-3 / mikmod-3.1.2 / configure.in < prev    next >
Encoding:
Text File  |  1998-12-07  |  8.4 KB  |  441 lines

  1. dnl Process this file with autoconf to produce a configure script.
  2. dnl
  3. dnl $Id: configure.in,v 1.9 1998/12/07 06:01:55 miod Exp $
  4.  
  5. AC_INIT(include/mikmod.h)
  6. AM_INIT_AUTOMAKE(mikmod,3.1.2)
  7. AM_CONFIG_HEADER(config.h)
  8.  
  9. dnl
  10. dnl MikMod specific control variables
  11. dnl
  12.  
  13. driver_af=
  14. driver_alsa=
  15. driver_esd=
  16. driver_oss=
  17. virtch2=
  18. debug=
  19. efence=
  20. headphone=
  21.  
  22. # We don't want that autoconf messes with the CFLAGS if they are not set,
  23. # we'll provide better CFLAGS for gcc than it. Yet another dirty kluge...
  24. if test -z "$CFLAGS"
  25. then
  26.     CFLAGS=" "
  27. fi
  28.  
  29. dnl
  30. dnl Configure script options
  31. dnl
  32.  
  33. AC_ARG_ENABLE(af,
  34. [  --enable-af             include AudioFile driver [default under OSF/1]],
  35. [if test "$enableval" = "yes"; then
  36.   driver_af=yes
  37. else
  38.   driver_af=no
  39. fi])
  40.  
  41. AC_ARG_ENABLE(alsa,
  42. [  --enable-alsa           Linux only: include Advanced Linux Sound Architecture
  43.                           driver [guessed]],
  44. [if test "$enableval" = "yes"; then
  45.   driver_alsa=yes
  46. else
  47.   driver_alsa=no
  48. fi])
  49.  
  50. AC_ARG_ENABLE(esd,
  51. [  --enable-esd            include Enlightened sound daemon driver [guessed]],
  52. [if test "$enableval" = "yes"; then
  53.   driver_esd=yes
  54. else
  55.   driver_esd=no
  56. fi])
  57.  
  58. AC_ARG_ENABLE(oss,
  59. [  --enable-oss            include OSS driver [guessed]],
  60. [if test "$enableval" = "yes"; then
  61.   driver_oss=yes
  62. else
  63.   driver_oss=no
  64. fi])
  65.  
  66. AC_ARG_ENABLE(hqmixer,
  67. [  --enable-hqmixer        use high-quality mixer [default=no]],
  68. [if test "$enableval" = "yes"; then
  69.   virtch2=yes
  70. else
  71.   virtch2=no
  72. fi])
  73.  
  74. AC_ARG_ENABLE(headphone,
  75. [  --enable-headphone      SunOS only: redirect sound to the headphone jack
  76.                           [default=no]],
  77. [if test "$enableval" = "yes"; then
  78.   headphone=$enable_headphone
  79. else
  80.   headphone=no
  81. fi])
  82.  
  83. AC_ARG_ENABLE(snagger,
  84. [  --enable-snagger        enable cpu time snagger feature [default=no]],
  85. [if test "$enableval" = "yes"; then
  86.   snagger=yes
  87. else
  88.   snagger=no
  89. fi])
  90.  
  91. AC_ARG_ENABLE(debug,
  92. [  --enable-debug          build a debug version of MikMod [default=no]],
  93. [if test "$enableval" = "yes"; then
  94.   debug=yes
  95. else
  96.   debug=no
  97. fi
  98. AM_DISABLE_SHARED
  99. AM_ENABLE_STATIC])
  100.  
  101. AC_ARG_ENABLE(efence,
  102. [  --enable-efence         build a debug version of MikMod with ElectricFence
  103.                           [default=no]],
  104. [if test "$enableval" = "yes"; then
  105.   efence=yes
  106. else
  107.   efence=no
  108. fi
  109. AM_DISABLE_SHARED
  110. AM_ENABLE_STATIC])
  111.  
  112. dnl
  113. dnl Checks for programs.
  114. dnl
  115.  
  116. AC_PROG_CC
  117. AC_PROG_INSTALL
  118. AC_PROG_LN_S
  119. AM_PROG_LIBTOOL
  120. AC_PROG_RANLIB
  121.  
  122. dnl
  123. dnl Checks for libraries.
  124. dnl
  125.  
  126. AC_CHECK_LIB(asound,snd_cards,can_alsa=yes,can_alsa=no)
  127.  
  128. dnl AC_CHECK_LIB(esd,esd_open_sound,can_esd=yes,can_esd=no)
  129. dnl If esd is compiled with alsa support, AC_CHECK_LIB will fail
  130. dnl So try this :
  131. if test "$can_alsa" = "yes"
  132. then
  133.     AC_MSG_CHECKING([if esd is present and requires alsa])
  134.     oldlibs=$LIBS
  135.     LIBS="$LIBS -lesd"
  136.     AC_TRY_LINK([#include <esd.h>],[void *p=esd_open_sound;],
  137.         can_esd=yes,can_esd=no)
  138.     LIBS=$oldlibs
  139.     if test "$can_esd" = "yes"
  140.     then
  141.         esd_needs_alsa=no
  142.         AC_MSG_RESULT([yes, and does not require alsa])
  143.     else
  144.         oldlibs=$LIBS
  145.         LIBS="$LIBS -lesd -lasound"
  146.         AC_TRY_LINK([#include <esd.h>],[void *p=esd_open_sound;],
  147.             can_esd=yes,can_end=no)
  148.         LIBS=$oldlibs
  149.         if test "$can_esd" = "yes"
  150.         then
  151.             esd_needs_alsa=yes
  152.             AC_MSG_RESULT([yes, and requires alsa])
  153.         else
  154.             AC_MSG_RESULT(no)
  155.         fi
  156.     fi
  157. else
  158.     AC_CHECK_LIB(esd,esd_open_sound,can_esd=yes,can_esd=no)
  159.     esd_needs_alsa=no
  160. fi
  161.  
  162. AC_CHECK_LIB(audio,ALseterrorhandler,driver_sgi=yes,driver_sgi=no)
  163. AC_CHECK_LIB(AF,AFOpenAudioConn,can_af=yes,can_af=no)
  164. AC_CHECK_LIB(ncurses,initscr,enable_ncurses=yes)
  165.  
  166. dnl
  167. dnl Checks for header files.
  168. dnl
  169.  
  170. AC_HEADER_STDC
  171. AC_HEADER_SYS_WAIT
  172. AC_CHECK_HEADERS(fnmatch.h)
  173. AC_CHECK_HEADERS(ncurses.h)
  174. AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/ioctl.h sys/time.h unistd.h)
  175. AC_CHECK_HEADERS(sched.h)
  176.  
  177. dnl Checks for bogus Linux old libc5 sched.h
  178.  
  179. if test "`uname`" = "Linux"
  180. then
  181.     AC_MSG_CHECKING([whether sched.h is correct])
  182.     AC_TRY_COMPILE([#include <sched.h>],[sched_yield();],
  183.         broken_sched=no,broken_sched=yes)
  184.     if test "$broken_sched" = "yes"
  185.     then
  186.         AC_DEFINE(BROKEN_SCHED)
  187.         AC_MSG_RESULT(no)
  188.     else
  189.         AC_MSG_RESULT(yes)
  190.     fi
  191. fi
  192.  
  193. if test "$can_esd" = "yes"
  194. then
  195.     AC_MSG_CHECKING([for esd_close in -lesd])
  196.     oldlibs=$LIBS
  197.     LIBS="$LIBS -lesd"
  198.     if test "$esd_needs_alsa" = "yes"
  199.     then
  200.         LIBS="$LIBS -lasound"
  201.     fi
  202.     AC_TRY_LINK([#include <esd.h>],[void *p=esd_close;],
  203.         has_esd_close=yes,has_esd_close=no)
  204.     LIBS=$oldlibs
  205.     if test "$has_esd_close" = "yes"
  206.     then
  207.         AC_MSG_RESULT(yes)
  208.         AC_DEFINE(HAVE_ESD_CLOSE)
  209.     else
  210.         AC_MSG_RESULT(no)
  211.     fi
  212. fi
  213.  
  214. dnl
  215. dnl Checks for typedefs, structures, and compiler characteristics.
  216. dnl
  217.  
  218. AC_C_CONST
  219. AC_TYPE_PID_T
  220. AC_TYPE_SIZE_T
  221. AC_HEADER_TIME
  222.  
  223. dnl
  224. dnl Checks for library functions.
  225. dnl
  226.  
  227. AC_FUNC_FNMATCH
  228. AC_FUNC_MEMCMP
  229. AC_TYPE_SIGNAL
  230. AC_CHECK_FUNCS(usleep,have_usleep=yes)
  231. AC_CHECK_FUNCS(getopt_long_only,have_getopt_long_only=yes)
  232. AC_HEADER_EGREP(usleep,unistd.h,have_usleep_h=yes)
  233. AC_HEADER_EGREP(usleep,sys/unistd.h,have_usleep_h=yes)
  234.  
  235. dnl
  236. dnl Choose settings
  237. dnl
  238.  
  239. # If we can guess the drivers needed from the system, no need to ask the user
  240. # to specify it manually
  241. case `uname` in
  242.     AIX)
  243.         AC_DEFINE(AIX)
  244.         AC_DEFINE(DRV_AIX)
  245.         DRIVER_OBJ="drv_aix.lo $DRIVER_OBJ"
  246.     ;;
  247.     HP-UX)
  248.         AC_DEFINE(DRV_HP)
  249.         DRIVER_OBJ="drv_hp.lo $DRIVER_OBJ"
  250.     ;;
  251.     IRIX*)
  252.         if test "$driver_sgi" = "yes"
  253.         then
  254.             AC_DEFINE(DRV_SGI)
  255.             DRIVER_OBJ="drv_sgi.lo $DRIVER_OBJ"
  256.             PLAYER_LIB="-laudio $PLAYER_LIB"
  257.             LIBRARY_LIB="-laudio $LIBRARY_LIB"
  258.         fi
  259.     ;;
  260.     NetBSD|OpenBSD)
  261.         AC_DEFINE(DRV_SUN)
  262.         DRIVER_OBJ="drv_sun.lo $DRIVER_OBJ"
  263.     ;;
  264.     SunOS)
  265.         AC_DEFINE(DRV_SUN)
  266.         DRIVER_OBJ="drv_sun.lo $DRIVER_OBJ"
  267.         case `uname -r` in
  268.             4.*)
  269.                 AC_DEFINE(SUNOS)
  270.             ;;
  271.             *) ;;
  272.         esac
  273.         if test "$headphone" = "yes"
  274.         then
  275.             AC_DEFINE(USE_HEADPHONE)
  276.         fi
  277.     ;;
  278.     FreeBSD)
  279.         driver_oss=yes
  280.     ;;
  281.     OSF1)
  282.         if test "$can_af" = "yes"
  283.         then
  284.             driver_af=yes
  285.         fi
  286.     ;;
  287.     *) ;;
  288. esac
  289.             
  290. if test "$driver_af" = "yes"
  291. then
  292.     AC_DEFINE(DRV_AF)
  293.     DRIVER_OBJ="drv_AF.lo $DRIVER_OBJ"
  294.     PLAYER_LIB="-lAF $PLAYER_LIB"
  295.     LIBRARY_LIB="-lAF $LIBRARY_LIB"
  296. fi
  297.  
  298. if test "$can_alsa" = "yes"
  299. then
  300.     if test "$driver_alsa" != "no"
  301.     then
  302. dnl testing /proc/asound is not reliable, if alsa is not loaded at this time...
  303. dnl     AC_MSG_CHECKING([for ALSA (/proc/asound)])
  304. dnl     if test -c /proc/asound/cards
  305. dnl     then
  306. dnl         AC_MSG_RESULT(found)
  307.          AC_DEFINE(DRV_ALSA)
  308.          DRIVER_OBJ="drv_alsa.lo $DRIVER_OBJ"
  309.          PLAYER_LIB="-lasound $PLAYER_LIB"
  310.          LIBRARY_LIB="-lasound $LIBRARY_LIB"
  311. dnl     else
  312. dnl         AC_MSG_RESULT(not found)
  313. dnl    fi
  314.     else
  315.         if test "$esd_needs_alsa" = "yes"
  316.         then
  317.             driver_esd=no
  318.         fi
  319.     fi
  320. else
  321.     if test "$esd_needs_alsa" = "yes"
  322.     then
  323.         driver_esd=no
  324.     fi
  325. fi
  326.  
  327. if test "$can_esd" = "yes"
  328. then
  329.     if test "$driver_esd" != "no"
  330.     then
  331.         AC_DEFINE(DRV_ESD)
  332.         DRIVER_OBJ="drv_esd.lo $DRIVER_OBJ"
  333.         PLAYER_LIB="-lesd $PLAYER_LIB"
  334.         LIBRARY_LIB="-lesd $LIBRARY_LIB"
  335.     fi
  336. fi
  337.  
  338. if test "$driver_oss" != "no"
  339. then
  340.     AC_MSG_CHECKING([for OSS (/dev/sndstat)])
  341.     if test -c /dev/sndstat
  342.     then
  343.         AC_MSG_RESULT(found)
  344.         AC_DEFINE(DRV_OSS)
  345.         DRIVER_OBJ="drv_oss.lo $DRIVER_OBJ"
  346.     else
  347.         AC_MSG_RESULT(not found)
  348.     fi
  349. fi
  350.  
  351. if test "$virtch2" = "yes"
  352. then
  353.     AC_DEFINE(VIRTCH2)
  354.     VIRTCH="virtch2.lo"
  355. else
  356.     VIRTCH="virtch.lo"
  357. fi
  358.  
  359. if test "$snagger" = "yes"
  360. then
  361.     AC_DEFINE(CPUTIME_SNAGGER)
  362. fi
  363.  
  364. if test "$efence" = "yes"
  365. then
  366.     debug=yes
  367.     PLAYER_LIB="$PLAYER_LIB -lefence"
  368. fi
  369. if test "$debug" = "yes"
  370. then
  371.     AC_DEFINE(MIKMOD_DEBUG)
  372.     CC="$CC -g"
  373. fi
  374.  
  375. # If compiling with gcc, use adequate optimization flags
  376. case $CC in
  377.     gcc*)
  378.         CFLAGS="$CFLAGS -O3 -funroll-loops -ffast-math -Wall"
  379.         # No inlining for debug version
  380.         if test "$debug" != "yes"
  381.         then
  382.             CFLAGS="$CFLAGS -finline-functions"
  383.         fi
  384.         ;;
  385.     *) ;;
  386. esac
  387.  
  388. dnl
  389. dnl Choose extra stuff
  390. dnl
  391.  
  392. if test "$have_usleep_h" != "yes"
  393. then
  394.     AC_DEFINE(NEED_USLEEP)
  395. fi
  396. if test "$have_getopt_long_only" != "yes"
  397. then
  398.     EXTRA_OBJ="getopt.o getopt1.o $EXTRA_OBJ"
  399. fi
  400. # Yet another kluge to get the result of AC_FUNC_FNMATCH. Might break with newer
  401. # versions of autoconf.
  402. if test "$ac_cv_func_fnmatch_works" != "yes"
  403. then
  404.     EXTRA_OBJ="fnmatch.o $EXTRA_OBJ"
  405. fi
  406. if test "$have_usleep" != "yes"
  407. then
  408.     EXTRA_OBJ="usleep.o $EXTRA_OBJ"
  409. fi
  410.  
  411. if test "$enable_ncurses" = "yes"
  412. then
  413.     PLAYER_LIB="-lncurses $PLAYER_LIB"
  414. else
  415.     PLAYER_LIB="-lcurses $PLAYER_LIB"
  416. fi
  417.  
  418. dnl
  419. dnl Create Makefiles
  420. dnl
  421.  
  422. AC_SUBST(DRIVER_OBJ)
  423. AC_SUBST(VIRTCH)
  424. AC_SUBST(LIBRARY_LIB)
  425. AC_SUBST(EXTRA_OBJ)
  426. AC_SUBST(PLAYER_LIB)
  427.  
  428. dnl AC_SUBST(PACKAGE)
  429. dnl AC_SUBST(VERSION)
  430.  
  431. AC_OUTPUT(Makefile
  432.           docs/Makefile
  433.           drivers/Makefile
  434.           extra/Makefile
  435.           include/Makefile
  436.           libmikmod/Makefile
  437.           loaders/Makefile
  438.           mikmod/Makefile
  439.           mmio/Makefile
  440.           playercode/Makefile)
  441.