1# Configuration script for Snd
2#
3# we now depend completely on pc (pkgconfig) files.
4#   Motif apparently has none.
5#   gmp, mpfr, and mpc deliberately have none!
6
7
8AC_INIT(snd, 21.2, bil@ccrma.stanford.edu, ftp://ccrma-ftp.stanford.edu/pub/Lisp/snd-21.tar.gz)
9
10AC_CONFIG_SRCDIR(snd.c)
11AC_CANONICAL_HOST # needed by case $host below
12AC_CONFIG_HEADERS(mus-config.h)
13AC_CONFIG_FILES(makefile)
14AC_PROG_CC
15
16# AC_HEADER_STDC
17AC_PROG_INSTALL
18
19MAKE_TARGET="snd"
20AUDIO_SYSTEM="None"
21RANDOM_FEATURES=""
22OPTIONAL_LIBRARIES=""
23LOCAL_LANGUAGE="None"
24GRAPHICS_TOOLKIT="None"
25
26PACKAGE=Snd
27VERSION=21.2
28
29#--------------------------------------------------------------------------------
30# configuration options
31#   --with-motif          use Motif
32#   --with-alsa           use ALSA if possible (the default)
33#   --with-oss            use OSS
34#   --with-jack           use Jack
35#   --without-audio       stub out all audio
36#   --with-gmp            include multiprecision arithmetic via gmp, mpfr, and mpc
37#   --disable-deprecated  do not include any deprecated stuff (in motif, s7, sndlib, clm, etc)
38#   --with-ladspa         include LADSPA plugin support (Linux)
39#   --with-gui            make Snd with(out) any graphics support
40#   --with-notcurses      make Snd with notcurses (text-based interface)
41#   --with-forth          use Forth as the extension language
42#   --with-ruby           use Ruby as the extension language
43#   --with-s7             use s7 as the extension language (default = yes)
44#   --with-pure-s7        s7 WITH_PURE_S7
45#   --with-s7-history     s7 WITH_HISTORY
46#   --with-s7-profiling   s7 WITH_PROFILE
47#   --with-extension-language use some extension language (default=yes)
48#   --with-temp-dir       directory to use for temp files
49#   --with-save-dir       directory to use for saved-state files
50#   --with-doc-dir        directory to search for documentation
51#   --with-gl             include OpenGL support (default=no, Motif only)
52#   --with-gl2ps          include gl2ps (Motif only)
53#   --with-editres 	  include EditRes in xm
54#   --without-gsl         omit GSL even if it exists
55#   --without-fftw        omit FFTW even if it exists
56#   --with-pulseaudio     use PulseAudio
57#   --with-portaudio      use portaudio
58#   --with-webserver      use webserver
59
60
61AC_ARG_WITH(gui,         [  --with-gui  	      	  make Snd with graphics support])
62AC_ARG_WITH(notcurses,   [  --with-notcurses  	      	  make Snd with notcurses])
63AC_ARG_WITH(gl,          [  --with-gl		  include OpenGL support, Motif only])
64AC_ARG_WITH(gl2ps,       [  --with-gl2ps		  include gl2ps, Motif only])
65AC_ARG_WITH(motif,	 [  --with-motif	  	  use libXm to build Snd])
66AC_ARG_WITH(editres,     [  --with-editres	  include editres in xm])
67
68AC_ARG_WITH(alsa,        [  --with-alsa		  use ALSA])
69AC_ARG_WITH(oss,         [  --with-oss		  use OSS])
70AC_ARG_WITH(jack,        [  --with-jack		  use JACK])
71AC_ARG_WITH(ladspa,	 [  --with-ladspa  	  include support for LADSPA plugins, Linux only])
72AC_ARG_WITH(pulseaudio,  [  --with-pulseaudio 	  use PulseAudio, default=no])
73AC_ARG_WITH(portaudio,   [  --with-portaudio 	  use portaudio, default=no])
74
75AC_ARG_WITH(extension-language, [  --with-extension-language use some extension language, default=yes])
76AC_ARG_WITH(s7,          [  --with-s7  	          use S7, default=yes])
77AC_ARG_WITH(forth,       [  --with-forth	  	  use Forth as the extension language])
78AC_ARG_WITH(ruby,        [  --with-ruby             use Ruby as the extension language])
79
80AC_ARG_WITH(pure-s7,     [  --with-pure-s7	  s7 WITH_PURE_S7])
81AC_ARG_WITH(s7-history,  [  --with-s7-history	  s7 WITH_HISTORY])
82AC_ARG_WITH(s7-profiling, [  --with-s7-profiling	  s7 WITH_PROFILE])
83
84AC_ARG_WITH(gsl,         [  --with-gsl		  use GSL, default=yes])
85AC_ARG_WITH(fftw,        [  --with-fftw		  use fftw, default=yes])
86AC_ARG_WITH(gmp,         [  --with-gmp		  include multiprecision arithmetic via gmp, mpfr, and mpc, default=no])
87AC_ARG_WITH(audio,       [  --without-audio         don't include any audio functionality])
88
89AC_ARG_WITH(temp-dir,    [  --with-temp-dir	  directory to use for temp files], AC_DEFINE_UNQUOTED(MUS_DEFAULT_TEMP_DIR, "${withval}"))
90AC_ARG_WITH(save-dir,    [  --with-save-dir	  directory to use for saved-state files], AC_DEFINE_UNQUOTED(MUS_DEFAULT_SAVE_DIR, "${withval}"))
91AC_ARG_WITH(doc-dir,     [  --with-doc-dir	  directory to search for documentation], AC_DEFINE_UNQUOTED(MUS_DEFAULT_DOC_DIR, "${withval}"))
92AC_ARG_WITH(webserver,   [  --with-webserver 	  use webserver, default=no])
93
94AC_ARG_ENABLE(deprecated,[  --disable-deprecated	  do not include any deprecated stuff from s7, motif, clm, libgsl, snd, or sndlib])
95
96
97AC_C_BIGENDIAN
98AC_CHECK_SIZEOF(void *)
99
100
101
102#--------------------------------------------------------------------------------
103# pkg-config
104#--------------------------------------------------------------------------------
105# AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
106# from pkg.m4
107dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
108dnl ----------------------------------
109dnl Since: 0.16
110dnl
111dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
112dnl first found in the path. Checks that the version of pkg-config found
113dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
114dnl used since that's the first version where most current features of
115dnl pkg-config existed.
116AC_DEFUN([PKG_PROG_PKG_CONFIG],
117[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
118m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
119m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
120AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
121AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
122AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
123
124if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
125	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
126fi
127if test -n "$PKG_CONFIG"; then
128	_pkg_min_version=m4_default([$1], [0.9.0])
129	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
130	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
131		AC_MSG_RESULT([yes])
132	else
133		AC_MSG_RESULT([no])
134		PKG_CONFIG=""
135	fi
136fi[]dnl
137])dnl PKG_PROG_PKG_CONFIG
138
139PKG_PROG_PKG_CONFIG
140
141
142
143#--------------------------------------------------------------------------------
144# fftw
145#--------------------------------------------------------------------------------
146
147FFTW_LIBS=""
148FFTW_CFLAGS=""
149if test "$with_fftw" != no; then
150  AC_MSG_CHECKING(for fftw3)
151  if test x$PKG_CONFIG != xno ; then
152    if $PKG_CONFIG fftw3 --exists ; then
153      FFTW_LIBS="`$PKG_CONFIG fftw3 --libs`"
154      FFTW_CFLAGS="`$PKG_CONFIG fftw3 --cflags`"
155      AC_DEFINE(HAVE_FFTW3)
156      OPTIONAL_LIBRARIES="$OPTIONAL_LIBRARIES fftw-`$PKG_CONFIG fftw3 --modversion`"
157      AC_MSG_RESULT(yes)
158    else
159      AC_MSG_RESULT(no)
160    fi
161  fi
162fi
163AC_SUBST(FFTW_LIBS)
164AC_SUBST(FFTW_CFLAGS)
165
166
167
168
169#--------------------------------------------------------------------------------
170# GMP, MPFR, MPC
171#--------------------------------------------------------------------------------
172
173# no pc files -- deliberately! We'll just add the libraries and let the chips fall...
174
175GMP_LIBS=""
176
177if test "$with_gmp" = yes ; then
178  GMP_LIBS="-lgmp -lmpfr -lmpc -lm"
179  AC_DEFINE(WITH_GMP)
180  OPTIONAL_LIBRARIES="$OPTIONAL_LIBRARIES gmp mpfr mpc"
181fi
182
183AC_SUBST(GMP_LIBS)
184
185
186
187#--------------------------------------------------------------------------------
188# GSL
189#--------------------------------------------------------------------------------
190
191GSL_LIBS=""
192GSL_CFLAGS=""
193
194if test "$with_gsl" != no; then
195  AC_MSG_CHECKING(for gsl)
196  if test x$PKG_CONFIG != xno ; then
197    if $PKG_CONFIG gsl --exists ; then
198      GSL_LIBS="`$PKG_CONFIG gsl --libs`"
199      GSL_CFLAGS="`$PKG_CONFIG gsl --cflags`"
200      AC_DEFINE(HAVE_GSL)
201      OPTIONAL_LIBRARIES="$OPTIONAL_LIBRARIES gsl-`$PKG_CONFIG gsl --modversion`"
202      AC_MSG_RESULT(yes)
203    else
204      AC_MSG_RESULT(no)
205    fi
206  fi
207fi
208
209AC_SUBST(GSL_LIBS)
210AC_SUBST(GSL_CFLAGS)
211
212
213
214#--------------------------------------------------------------------------------
215# Ladspa
216#--------------------------------------------------------------------------------
217
218if test "$with_ladspa" = yes ; then
219  AC_DEFINE(HAVE_LADSPA)
220  RANDOM_FEATURES="$RANDOM_FEATURES ladspa"
221fi
222
223
224
225#--------------------------------------------------------------------------------
226# graphics
227#--------------------------------------------------------------------------------
228
229# graphics: motif chosen if --with-motif
230#           notcurses if --with-notcurses -- I might expand this someday -- I think graphs are doable
231#           else no gui (notcurses possible)
232
233XLIBS=""
234XFLAGS=""
235
236GX_FILES=""
237GX_HEADERS=""
238
239GRFX_FILES=""
240GRFX_HEADERS=""
241GRFX_CFLAGS=""
242GRFX_LIBS=""
243GRFX_LD_LIBS=""
244
245ac_snd_gui_choice=none
246
247if test "$with_motif" = no ; then
248  with_gui=no
249fi
250# Motif has no pkg-config file, so to make it the default would mean looking for /usr/include/Xm or something
251
252if test "$with_gui" = no ; then
253  AC_DEFINE(USE_NO_GUI)
254  GX_FILES="NO_GUI_O_FILES"
255  GX_HEADERS="NO_GUI_HEADERS"
256  ac_snd_gui_choice=no
257fi
258
259
260#--------------------------------------------------------------------------------
261# X/Motif
262#--------------------------------------------------------------------------------
263
264# here as in the gmp case, we simply set up the libs/flags and hope for the best
265
266if test "$with_motif" = yes ; then
267  AC_PATH_XTRA
268
269  GRFX_FLAGS="$X_CFLAGS"
270  X_POST_LIBS="-lX11 $X_EXTRA_LIBS -lXext"
271  case "$host" in
272    *-apple-*)
273      X_POST_LIBS="$X_POST_LIBS -lSM -lICE"
274      ;;
275    *-*-linux*)
276      X_POST_LIBS="$X_POST_LIBS -lSM -lICE -lXft"
277      ;;
278  esac
279  X_PRE_LIBS="$X_LIBS $X_PRE_LIBS -lXm -lXt"
280
281  GX_FILES="MOTIF_O_FILES"
282  GX_HEADERS="SND_X_HEADERS"
283
284  if test "$with_editres" = yes ; then
285    AC_DEFINE(WITH_EDITRES)
286    OPTIONAL_LIBRARIES="$OPTIONAL_LIBRARIES editres"
287    X_PRE_LIBS="$X_PRE_LIBS -lXmu"
288  fi
289
290  GRFX_LIBS="$X_PRE_LIBS $X_POST_LIBS -lXpm"
291  AC_DEFINE(USE_MOTIF)
292  GRAPHICS_TOOLKIT="Motif"
293  ac_snd_gui_choice=Motif
294fi
295
296
297#--------------------------------------------------------------------------------
298# notcurses
299#--------------------------------------------------------------------------------
300
301if test "$with_notcurses" = yes ; then
302  AC_MSG_CHECKING(for notcurses)
303  AC_DEFINE(USE_NO_GUI)
304  GX_FILES="NO_GUI_O_FILES"
305  GX_HEADERS="NO_GUI_HEADERS"
306  ac_snd_gui_choice=notcurses
307
308  if $PKG_CONFIG notcurses --exists ; then
309    GRFX_CFLAGS="`$PKG_CONFIG notcurses --cflags`"
310    GRFX_LIBS="`$PKG_CONFIG notcurses --libs`"
311    GRAPHICS_TOOLKIT=Notcurses-`$PKG_CONFIG notcurses --modversion`
312
313    if $PKG_CONFIG --exists 'notcurses < 2.0.0' ; then
314      GRFX_CFLAGS="$GRFX_CFLAGS -DNOTCURSES_1=1"
315    fi
316
317# someone screwed up notcurses/version.h in FC version 2.0.7 -- it is missing the numeric version macros
318    if $PKG_CONFIG --exists 'notcurses >= 2.0.5' ; then
319      GRFX_CFLAGS="$GRFX_CFLAGS -DNOTCURSES_2_0_5=1"
320    fi
321
322    AC_DEFINE(USE_NOTCURSES)
323    AC_MSG_RESULT(yes)
324  else
325    AC_MSG_RESULT(no)
326  fi
327fi
328
329
330#--------------------------------------------------------------------------------
331# no GUI
332#--------------------------------------------------------------------------------
333
334if test "$ac_snd_gui_choice" = none ; then
335  AC_DEFINE(USE_NO_GUI)
336  GX_FILES="NO_GUI_O_FILES"
337  GX_HEADERS="NO_GUI_HEADERS"
338fi
339
340# fallback on no-gui
341if test "$with_gui" = no ; then
342  AC_DEFINE(USE_NO_GUI)
343  GX_FILES="NO_GUI_O_FILES"
344  GX_HEADERS="NO_GUI_HEADERS"
345  ac_snd_gui_choice=no
346fi
347
348
349AC_SUBST(XLIBS)
350AC_SUBST(XFLAGS)
351
352AC_SUBST(GX_FILES)
353AC_SUBST(GX_HEADERS)
354
355AC_SUBST(GRFX_LIBS)
356AC_SUBST(GRFX_CFLAGS)
357AC_SUBST(GRFX_LD_LIBS)
358
359
360
361
362#--------------------------------------------------------------------------------
363# OpenGL
364#--------------------------------------------------------------------------------
365
366GL_LIBS=""
367GL_FILES=""
368GL_FLAGS=""
369
370if test "$with_gl" = yes ; then
371  if test x$PKG_CONFIG != xno ; then
372    AC_MSG_CHECKING(for opengl)
373    if $PKG_CONFIG gl --exists ; then
374
375      GL_CFLAGS="`$PKG_CONFIG gl --cflags`"
376      GL_LIBS="`$PKG_CONFIG gl --libs`"
377      GL_FILES="gl.o"
378      AC_DEFINE(HAVE_GL)
379      OPTIONAL_LIBRARIES="$OPTIONAL_LIBRARIES openGL"
380
381      if $PKG_CONFIG glu --exists ; then
382          AC_DEFINE(HAVE_GLU)
383          GL_CFLAGS="$GL_CFLAGS `$PKG_CONFIG glu --cflags`"
384          GL_LIBS="$GL_LIBS `$PKG_CONFIG glu --libs`"
385      fi
386
387      if test "$with_gl2ps" = yes ; then
388        AC_DEFINE(WITH_GL2PS)
389        RANDOM_FEATURES="$RANDOM_FEATURES gl2ps"
390        GL_FILES="$GL_FILES gl2ps.o"
391      fi
392      AC_MSG_RESULT(yes)
393    else
394      AC_MSG_RESULT(no)
395    fi
396  fi
397fi
398
399AC_SUBST(GL_LIBS)
400AC_SUBST(GL_FILES)
401AC_SUBST(GL_FLAGS)
402
403
404
405#--------------------------------------------------------------------------------
406# language
407#--------------------------------------------------------------------------------
408
409# language choice: ruby if --with-ruby and we can find a ruby pc file
410#                  forth if --with-forth
411#                  none if --without-extension-language
412#                  s7 otherwise
413
414XEN_LIBS=""
415XEN_CFLAGS=""
416ac_snd_extension_language=none
417
418if test "$with_extension_language" = no ; then
419  ac_snd_extension_language=no
420  LOCAL_LANGUAGE="None"
421fi
422
423
424#--------------------------------------------------------------------------------
425# Ruby
426#--------------------------------------------------------------------------------
427
428# Yuri suggests: ruby -r rbconfig -e 'C = RbConfig::CONFIG' -e 'puts C["ruby_version"]' | sed -E 's|([[:digit:]]+\.[[:digit:]]+).*|\1|'
429
430# Mike Scholz suggests:
431#    For finding ruby*.pc, one way is to place a link from any version in your installation
432#    to ruby.pc in a well-known directory which is first in your $PKG_CONFIG_PATH.
433#	ln -fs /usr/local/lib/pkgconfig/ruby-2.7.2.pc ~/lib/pkgconfig/ruby.pc
434#	setenv PKG_CONFIG_PATH ~/lib/pkgconfig:${PKG_CONFIG_PATH}
435
436if test "$with_ruby" = yes ; then
437  if test x$PKG_CONFIG != xno ; then
438    m4_foreach([ruby_version], [[ruby-3.0], [ruby-2.8], [ruby-2.7], [ruby-2.6], [ruby-2.5], [ruby-2.4], [ruby-2.3], [ruby-2.2], [ruby-2.1], [ruby-2.0], [ruby], [ruby-1.9.3], [ruby-1.9], [ruby-1.8]],
439      [
440      if test "$ac_snd_extension_language" = none ; then
441        if $PKG_CONFIG ruby_version --exists ; then
442          AC_DEFINE(HAVE_RUBY)
443          XEN_CFLAGS="-fPIC `$PKG_CONFIG ruby_version --cflags`"
444          # this depends on building ruby itself with the --enable-shared flag
445	  #   we need -Wno-incompatible-pointer in gcc, but that doesn't work in g++!
446          XEN_LIBS="`$PKG_CONFIG ruby_version --libs`"
447          LOCAL_LANGUAGE=Ruby-`$PKG_CONFIG ruby_version --modversion`
448          ac_snd_extension_language=Ruby
449#	  CC="$CC -fdeclspec"
450          S7_LIB=""
451          AC_SUBST(S7_LIB)
452        fi
453      fi
454      ])
455  fi
456fi
457
458
459#--------------------------------------------------------------------------------
460# Forth
461#--------------------------------------------------------------------------------
462
463if test "$with_forth" = yes ; then
464  AC_PATH_PROG([FTH], [fth], [no])
465  AC_MSG_CHECKING([for Forth])
466  if test "${FTH}" != no ; then
467    XEN_CFLAGS=`${FTH} --no-init-file --eval .cflags`
468    XEN_LIBS=`${FTH} --no-init-file --eval .libs`
469    AC_MSG_RESULT([yes])
470    AC_DEFINE(HAVE_FORTH)
471    LOCAL_LANGUAGE="Forth"
472    ac_snd_extension_language=Forth
473    S7_LIB=""
474    AC_SUBST(S7_LIB)
475  else
476    AC_MSG_RESULT([no])
477  fi
478fi
479
480
481#--------------------------------------------------------------------------------
482# s7 (the default)
483#--------------------------------------------------------------------------------
484
485if test "$with_s7" != no && test "$ac_snd_extension_language" = none ; then
486  AC_DEFINE(HAVE_SCHEME)
487  ac_snd_extension_language=s7
488  LOCAL_LANGUAGE="s7"
489  S7_LIB="s7.o"
490  AC_SUBST(S7_LIB)
491fi
492
493AC_SUBST(XEN_LIBS)
494AC_SUBST(XEN_CFLAGS)
495
496
497
498
499#--------------------------------------------------------------------------------
500# OGG, Flac, Speex, Mpeg, Timidity, TTA, Wavpack
501# --------------------------------------------------------------------------------
502
503AC_CHECK_PROG(PATH_OGGDEC, oggdec, no) # OGG read
504AC_CHECK_PROG(PATH_OGGENC, oggenc, no) # OGG write
505
506if test "$PATH_OGGDEC" != "no" ; then
507  if test "$PATH_OGGENC" != "no" ; then
508    AC_DEFINE(HAVE_OGG)
509    AC_DEFINE_UNQUOTED(PATH_OGGDEC, "${PATH_OGGDEC}")
510    AC_DEFINE_UNQUOTED(PATH_OGGENC, "${PATH_OGGENC}")
511  fi
512fi
513
514
515AC_CHECK_PROG(PATH_MPG123, mpg123, no) # MPEG read/write?
516
517if test "$PATH_MPG123" != "no" ; then
518  AC_DEFINE(HAVE_MPEG)
519  AC_DEFINE_UNQUOTED(PATH_MPG123, "${PATH_MPG123}")
520fi
521
522
523AC_CHECK_PROG(PATH_MPG321, mpg321, no) # MPEG read/write?
524
525if test "$PATH_MPG321" != "no" ; then
526  AC_DEFINE(HAVE_MPEG)
527  AC_DEFINE(HAVE_MPG321)
528  AC_DEFINE_UNQUOTED(PATH_MPG321, "${PATH_MPG321}")
529fi
530
531
532AC_CHECK_PROG(PATH_SPEEXDEC, speexdec, no) # Speex read
533AC_CHECK_PROG(PATH_SPEEXENC, speexenc, no) # Speex write
534
535if test "$PATH_SPEEXDEC" != "no" ; then
536  if test "$PATH_SPEEXENC" != "no" ; then
537    AC_DEFINE(HAVE_SPEEX)
538    AC_DEFINE_UNQUOTED(PATH_SPEEXDEC, "${PATH_SPEEXDEC}")
539    AC_DEFINE_UNQUOTED(PATH_SPEEXENC, "${PATH_SPEEXENC}")
540  fi
541fi
542
543
544AC_CHECK_PROG(PATH_FLAC, flac, no) # Flac read/write
545
546if test "$PATH_FLAC" != "no" ; then
547  AC_DEFINE(HAVE_FLAC)
548  AC_DEFINE_UNQUOTED(PATH_FLAC, "${PATH_FLAC}")
549fi
550
551
552AC_CHECK_PROG(PATH_TIMIDITY, timidity, no) # Timidity for .mid -> .wav
553
554if test "$PATH_TIMIDITY" != "no" ; then
555  AC_DEFINE(HAVE_TIMIDITY)
556  AC_DEFINE_UNQUOTED(PATH_TIMIDITY, "${PATH_TIMIDITY}")
557fi
558
559
560AC_CHECK_PROG(PATH_WAVPACK, wavpack, no)
561AC_CHECK_PROG(PATH_WVUNPACK, wvunpack, no)
562
563if test "$PATH_WAVPACK" != "no" ; then
564  if test "$PATH_WVUNPACK" != "no" ; then
565    AC_DEFINE(HAVE_WAVPACK)
566    AC_DEFINE_UNQUOTED(PATH_WAVPACK, "${PATH_WAVPACK}")
567    AC_DEFINE_UNQUOTED(PATH_WVUNPACK, "${PATH_WVUNPACK}")
568  fi
569fi
570
571
572
573
574#--------------------------------------------------------------------------------
575# Audio
576#--------------------------------------------------------------------------------
577
578AUDIO_LIB=""
579JACK_LIBS=""
580JACK_FLAGS=""
581
582if test "$with_audio" != no ; then
583
584  if test "$with_pulseaudio" = yes ; then
585    AC_DEFINE(MUS_PULSEAUDIO)
586    AUDIO_LIB="-lpulse-simple -lpulse"
587    AUDIO_SYSTEM=pulseaudio
588  fi
589
590  if test "$with_portaudio" = yes ; then
591    AC_DEFINE(MUS_PORTAUDIO)
592    AUDIO_SYSTEM=portaudio
593    AUDIO_LIB="-lportaudio"
594  fi
595
596  if test "$with_jack" = yes ; then
597    if test "$with_alsa" = yes ; then
598      AUDIO_SYSTEM=ALSA+JACK
599    else
600      AUDIO_SYSTEM=JACK
601    fi
602    AC_DEFINE(MUS_JACK)
603    if test x$PKG_CONFIG != xno ; then
604      if $PKG_CONFIG jack --exists ; then
605        JACK_LIBS="`$PKG_CONFIG jack --libs`"
606        JACK_FLAGS="`$PKG_CONFIG jack --cflags`"
607        if $PKG_CONFIG samplerate --exists ; then
608  	  JACK_LIBS="$JACK_LIBS `$PKG_CONFIG samplerate --libs`"
609  	  JACK_FLAGS="$JACK_FLAGS `$PKG_CONFIG samplerate --cflags`"
610        else
611          JACK_LIBS="$JACK_LIBS -lsamplerate"
612        fi
613      else
614        JACK_LIBS="-ljack -lsamplerate"
615      fi
616    else
617      JACK_LIBS="-ljack -lsamplerate"
618    fi
619  JACK_LIBS="$JACK_LIBS -lpthread"
620  fi
621
622  if test "$with_alsa" = yes ; then
623    AC_DEFINE(HAVE_ALSA)
624    AUDIO_LIB="-lasound"
625    if test "$with_jack" = yes ; then
626      AUDIO_SYSTEM=ALSA+JACK
627    else
628      AUDIO_SYSTEM=ALSA
629    fi
630  fi
631
632  if test "$with_oss" = yes ; then
633    AC_DEFINE(HAVE_OSS)
634    AUDIO_SYSTEM=OSS
635  fi
636
637  if test "$AUDIO_SYSTEM" = None ; then
638    case "$host" in
639      *-*-linux*)
640        AUDIO_SYSTEM=ALSA
641        AC_DEFINE(HAVE_ALSA)
642        AUDIO_LIB="-lasound"
643	;;
644      *-*-sunos4*)
645	AUDIO_SYSTEM=Sun
646        ;;
647      *-*-solaris*)
648	AUDIO_SYSTEM=Sun
649        ;;
650      *-*-hpux*)
651	AUDIO_SYSTEM=Hpux
652        ;;
653      *-*-bsdi*)
654	AC_DEFINE(HAVE_OSS)
655	AUDIO_SYSTEM=OSS
656        ;;
657      *-*-freebsd*)
658	AC_DEFINE(HAVE_OSS)
659	AUDIO_SYSTEM=OSS
660	;;
661      *-*-openbsd*)
662	AUDIO_SYSTEM=OpenBSD
663	AUDIO_LIB="-lsndio"
664        ;;
665      *-*-netbsd*)
666	AUDIO_SYSTEM=NetBSD
667        ;;
668      *-*-cygwin*)
669	if test "$with_jack" != yes ; then
670	  AUDIO_SYSTEM=Windows
671	fi
672	;;
673      *-*-mingw*)
674	audio_system=Windows
675	;;
676      *-apple-*)
677	if test "$with_jack" != yes ; then
678	  AUDIO_SYSTEM=MacOSX
679	  AUDIO_LIB="-framework CoreAudio -framework CoreFoundation -framework CoreMIDI"
680        else
681          AUDIO_SYSTEM=JACK
682	  JACK_LIBS="-framework CoreAudio -framework CoreServices -framework AudioUnit -L/usr/local/lib -ljack -lsamplerate"
683          JACK_FLAGS="-I/usr/local/include"
684	fi
685	;;
686    esac
687  fi
688fi
689
690AC_MSG_CHECKING([for audio system])
691AC_MSG_RESULT($AUDIO_SYSTEM)
692
693if test "$AUDIO_SYSTEM" != None ; then
694  AC_DEFINE(WITH_AUDIO)
695fi
696
697AC_SUBST(AUDIO_LIB)
698AC_SUBST(JACK_LIBS)
699AC_SUBST(JACK_FLAGS)
700
701
702
703#--------------------------------------------------------------------------------
704# compiler/loader flags
705#--------------------------------------------------------------------------------
706
707LIBS=""
708LDSO_FLAGS=""
709SO_FLAGS=""
710SO_LD="ld"
711# the SO_* stuff here is for consistency with the sndlib configure script
712
713case "$host" in
714  *-*-linux*)
715#    CFLAGS="-Wno-stringop-overflow $CFLAGS"
716    LDSO_FLAGS="-shared"
717    LIBS="$LIBS -lm -ldl"
718    if test "$GCC" = yes ; then
719      SO_FLAGS="-fPIC $SO_FLAGS"
720      SO_LD="$CC"
721    fi
722    ;;
723
724  *-*-kfreebsd*|*-*-gnu*)
725      LDSO_FLAGS="-shared"
726      LIBS="$LIBS -lm -ldl"
727      if test "$GCC" = yes ; then
728        SO_FLAGS="-fPIC $SO_FLAGS"
729      fi
730
731      AUDIO_SYSTEM=OSS
732
733      if test "$with_jack" = yes ; then
734             if test "$with_oss" != yes ; then
735               AUDIO_SYSTEM=JACK
736             fi
737      fi
738
739      case $AUDIO_SYSTEM in
740          JACK)
741              AC_DEFINE(HAVE_JACK_IN_LINUX)
742              AC_DEFINE(HAVE_OSS)
743              AUDIO_LIB="-lsamplerate"
744              ;;
745          OSS)
746              AC_DEFINE(HAVE_OSS)
747              AUDIO_SYSTEM=OSS
748              ;;
749      esac
750      ;;
751
752  *-*-sunos4*)
753    LIBS="$LIBS -lm"
754    ;;
755
756  *-*-solaris*)
757    LIBS="$LIBS -lm"
758    LDSO_FLAGS="-G"
759    ;;
760
761  *-*-hpux*)
762    LDSO_FLAGS="+z -Ae +DA1.1"
763    if test "$GCC" = yes ; then
764      SO_FLAGS="-fPIC $SO_FLAGS"
765    fi
766    ;;
767
768  *-*-bsdi*)
769    LIBS="$LIBS -lm"
770    if test "$GCC" = yes ; then
771      SO_FLAGS="-fPIC $SO_FLAGS"
772    fi
773    ;;
774
775  *-*-freebsd*)
776    LIBS="$LIBS -lm"
777    if test "$GCC" = yes ; then
778      SO_LD="$CC"
779      SO_FLAGS="-fPIC $SO_FLAGS"
780      CFLAGS="-fPIC $CFLAGS"
781      LDSO_FLAGS="-shared"
782    fi
783    ;;
784
785  *-*-openbsd*)
786    LIBS="$LIBS -lm"
787    if test "$GCC" = yes ; then
788      SO_LD="$CC"
789      SO_FLAGS="-fPIC $SO_FLAGS"
790      CFLAGS="-ftrampolines $CFLAGS"
791      LDSO_FLAGS="-shared"
792    fi
793    ;;
794
795  *-*-netbsd*)
796    LIBS="$LIBS -lm"
797    if test "$GCC" = yes ; then
798      SO_LD="$CC"
799      SO_FLAGS="-fPIC $SO_FLAGS"
800      LDSO_FLAGS="-shared"
801    fi
802    ;;
803
804  *-*-mingw*)
805    LIBS="$LIBS -lwinmm -lwsock32"
806    LDFLAGS="$LDFLAGS -mwindows"
807    SO_INSTALL=":"
808    SO_LD=":"
809    ;;
810
811  *-apple-*)
812    SO_LD="$CC"
813    LDSO_FLAGS="-dynamic -bundle -undefined suppress -flat_namespace"
814    ;;
815esac
816
817AC_SUBST(LDSO_FLAGS)
818AC_SUBST(SO_FLAGS)
819AC_SUBST(SO_LD)
820
821
822#--------------------------------------------------------------------------------
823# webserver
824#--------------------------------------------------------------------------------
825
826WEBSERVER_LIBS=""
827WEBSERVER_FILES=""
828
829if test "$with_webserver" = yes ; then
830  AC_DEFINE(ENABLE_WEBSERVER)
831
832  WEBSERVER_FILES="s7webserver/s7webserver.o s7webserver/qhttpserver-master/lib/libqhttpserver.a"
833  WEBSERVER_LIBS="`pkg-config --libs QtNetwork` -lstdc++"
834
835  RANDOM_FEATURES="$RANDOM_FEATURES webserver"
836fi
837
838AC_SUBST(WEBSERVER_LIBS)
839AC_SUBST(WEBSERVER_FILES)
840
841
842
843#--------------------------------------------------------------------------------
844# export-dynamic
845#--------------------------------------------------------------------------------
846
847CFLAGS="-O2 -I. $CFLAGS"
848ORIGINAL_LDFLAGS="$LDFLAGS"
849
850case "$host" in
851  *-*-linux* | *-*-bsdi* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd*)
852    if test "$CC" = "gcc" || test "$CC" = "g++" || test "$CC" = "cc" ; then
853      LDFLAGS="$LDFLAGS -Wl,-export-dynamic"
854    fi
855esac
856
857
858
859#--------------------------------------------------------------------------------
860# disable-deprecated
861#--------------------------------------------------------------------------------
862
863if test "$enable_deprecated" = no ; then
864  CFLAGS="-DGSL_DISABLE_DEPRECATED -Wall -Wno-array-bounds -Wno-stringop-overflow $CFLAGS"
865  AC_DEFINE(DISABLE_DEPRECATED)
866fi
867
868
869#--------------------------------------------------------------------------------
870# pure-s7
871#--------------------------------------------------------------------------------
872
873if test "$with_pure_s7" = yes ; then
874  CFLAGS="-DWITH_PURE_S7 $CFLAGS"
875fi
876
877#--------------------------------------------------------------------------------
878# s7-history
879#--------------------------------------------------------------------------------
880
881if test "$with_s7_history" = yes ; then
882  CFLAGS="-DWITH_HISTORY $CFLAGS"
883fi
884
885#--------------------------------------------------------------------------------
886# s7-profiling
887#--------------------------------------------------------------------------------
888
889if test "$with_s7_profiling" = yes ; then
890  CFLAGS="-DWITH_S7_PROFILE $CFLAGS"
891  RANDOM_FEATURES="$RANDOM_FEATURES profiling"
892fi
893
894
895
896#--------------------------------------------------------------------------------
897# output
898#--------------------------------------------------------------------------------
899
900AC_SUBST(INSTALL)
901AC_SUBST(CFLAGS)
902AC_SUBST(ORIGINAL_LDFLAGS)
903AC_SUBST(LDFLAGS)
904AC_SUBST(MAKE_TARGET)
905AC_OUTPUT
906
907AC_MSG_RESULT([
908  Options selected
909  -------------------------
910  Snd version ...........: $VERSION
911  CFLAGS ................: $CFLAGS
912  LDFLAGS ...............:$LDFLAGS
913  LIBS...................: $LIBS
914  prefix.................: ${prefix}
915  extension language.....: $LOCAL_LANGUAGE
916  audio system...........: $AUDIO_SYSTEM
917  graphics toolkit.......: $GRAPHICS_TOOLKIT
918  optional libraries.....:$OPTIONAL_LIBRARIES
919  random features........:$RANDOM_FEATURES
920  environs...............: $host $CC
921])
922
923