1# ----------------------------------------------------------------------------
2# configure script
3#   autoconf script for TSE3 library
4#   (c) Pete Goodliffe, 2000-2002
5# ----------------------------------------------------------------------------
6
7dnl Process this file with autoconf to produce a configure script.
8
9
10# ----------------------------------------------------------------------------
11# Initialisation and package information
12# ----------------------------------------------------------------------------
13
14AC_INIT(Makefile.am)
15
16TSE3_PACKAGE=tse3
17TSE3_VERSION=`cat $srcdir/Version`
18
19AM_INIT_AUTOMAKE($TSE3_PACKAGE, $TSE3_VERSION)
20AM_CONFIG_HEADER(config.h)
21
22# ----------------------------------------------------------------------------
23# Compile environment
24# ----------------------------------------------------------------------------
25
26# Compilers
27AC_PROG_CC
28# AC_REQUIRE([AC_PROG_CPP])
29AC_PROG_CPP
30AC_PROG_INSTALL
31
32AC_PROG_CXX
33# AC_PROG_CXX_WORKS
34# AC_PROG_CXX_GNU
35
36# Environment
37AC_CYGWIN
38
39# Ensure debugging is disabled
40if (echo $CXXFLAGS | grep "\-g" >/dev/null 2>/dev/null) then
41AC_MSG_WARN("CXXFLAGS is set to \"$CXXFLAGS\"")
42echo
43echo "****  warning: You are building this library with debugging   ****"
44echo "****      enabled, which will make the library enormous.      ****"
45echo "****   You can try setting the environment variable CXXFLAGS  ****"
46echo "****     to -O2 to prevent the default -g flag being added.   ****"
47echo
48fi
49
50# Library creation
51AM_ENABLE_SHARED
52AM_DISABLE_STATIC
53AM_PROG_LIBTOOL
54AC_SUBST(LIBTOOL_DEPS)
55
56# Switch on all warnings: build must be silent ;-)
57test "$GCC" = yes && CCFLAGS="$CFLAGS -W -Wall -ansi -pedantic"
58test "$GCC" = yes && CXXFLAGS="$CXXFLAGS -W -Wall -ansi -pedantic"
59
60# gcc-cpp has the wonderful -MM option to produce nicer dependencies
61test "$GCC" = yes && CPP_MM=M; AC_SUBST(CPP_MM)
62
63# Checks for header files
64AC_HEADER_DIRENT
65AC_HEADER_STDC
66AC_CHECK_HEADERS(sys/soundcard.h machine/soundcard.h linux/awe_voice.h awe_voice.h /usr/src/sys/i386/isa/sound/awe_voice.h /usr/src/sys/gnu/i386/isa/sound/awe_voice.h unistd.h alsa/asoundlib.h sys/asoundlib.h kde/arts/artsmidi.h arts/artsmidi.h)
67
68# Checks for typdefs, structures, and compiler characteristics
69AC_C_CONST
70AC_TYPE_SIZE_T
71
72# Checks for library functions.
73AC_CHECK_FUNCS(select)
74
75# ----------------------------------------------------------------------------
76# TSE3 feature support
77# ----------------------------------------------------------------------------
78
79#
80# The features that can be configured at compile time are:
81#   - Whether to install documentation - if an RPM is being built, we
82#     don't need to install this, or we may get two copies of the
83#     documentation
84#     (controlled by the TSE3_INSTALL_DOCS flag)
85#   - Whether to support multiple threads
86#     (controlled by the TSE3_WITHOUT_MUTEX flag)
87#   - Whether to support the Open Sound System (OSS)
88#     (controlled by the TSE3_WITH_OSS flag)
89#   - Whether to support the Advanced Linux Sound Architecture (ALSA)
90#     (controlled by the TSE3_WITH_ALSA flag)
91#   - Whether to support the aRts
92#     (controlled by the TSE3_WITH_ARTS flag)
93#
94# For the last three we need to check whether the target machine supports
95# the library, and whether the user wants to build that support in.
96#
97
98# ----------------------------------------------------------------------------
99# Checks for documentation installation
100
101install_tse3_doc="yes"
102AC_MSG_CHECKING(whether to install library documentation)
103AC_ARG_WITH(doc-install,
104[  --with-doc-install      whether to install TSE3 library documentation],
105[if test "$withval" = yes; then
106  AC_MSG_RESULT(yes)
107else
108  AC_MSG_RESULT(no)
109  install_tse3_doc="no"
110fi], [AC_MSG_RESULT(yes)])
111
112AM_CONDITIONAL(INSTALL_TSE3_DOC, test "$install_tse3_doc" = "yes")
113
114# ----------------------------------------------------------------------------
115# Checks for multithread support (Mutex class)
116
117AC_MSG_CHECKING(whether threading support is wanted)
118AC_ARG_WITH(mutex,
119[  --with-mutex            whether to support multithreading in TSE3],
120[if test "$withval" = yes; then
121  AC_MSG_RESULT(yes)
122else
123  AC_MSG_RESULT(no)
124  AC_DEFINE(TSE3_WITHOUT_MUTEX,1,[Define if threading support is not required])
125fi], [AC_MSG_RESULT(yes)])
126
127# ----------------------------------------------------------------------------
128# Checks for OSS library support
129
130# 1. Check whether OSS is there
131have_oss="no"
132AC_DEFUN(AC_CHECK_OSS,
133[
134  AC_CHECK_HEADER(sys/soundcard.h,
135  [
136      have_oss="yes"
137      AC_DEFINE(HAVE_OSS, 1,
138          [Define if you have <sys/soundcard.h> (required for OSS support)])
139  ], [have_oss="no"])
140])
141AC_CHECK_OSS
142
143AM_CONDITIONAL(HAVE_OSS, test "$have_oss" = "yes")
144
145AC_MSG_CHECKING(whether OSS is available)
146if test "$have_oss" = "yes"; then
147  AC_MSG_RESULT(yes)
148else
149  AC_MSG_RESULT(no)
150fi
151
152# 2. Check whether OSS is wanted
153AC_MSG_CHECKING(whether OSS support is wanted)
154AC_ARG_WITH(oss,
155[  --with-oss              whether to support the OSS library],
156[if test "$withval" = "yes"; then
157  AC_MSG_RESULT(yes)
158  with_oss="yes"
159else
160  AC_MSG_RESULT(no)
161  with_oss="no"
162fi], [AC_MSG_RESULT(yes); with_oss="yes"])
163
164if test "$with_oss" = "yes" -a "$have_oss" = "yes"; then
165  AC_SUBST(TSE3_WITH_OSS)
166  AC_DEFINE(TSE3_WITH_OSS,1,[Define if OSS library support is required])
167fi
168AM_CONDITIONAL(TSE3_WITH_OSS, test "$with_oss" = "yes" -a "$have_oss" = "yes")
169
170# ----------------------------------------------------------------------------
171# Checks for ALSA library support
172
173# 1. Check whether ALSA is there
174have_alsa="no"
175AC_DEFUN(AC_CHECK_LIBASOUND,
176[
177  dnl Alsa headers?
178  alsa_header_prefix="NONE"
179  AC_CHECK_HEADER(sys/asoundlib.h,  alsa_header_prefix="sys")
180  AC_CHECK_HEADER(alsa/asoundlib.h, alsa_header_prefix="alsa")
181
182  ac_ldflags_save="$LDFLAGS"
183  LDFLAGS="$all_libraries $LDFLAGS"
184  LIBASOUND=""
185  if test "x$alsa_header_prefix" != "xNONE"; then
186
187    dnl Alsa library exists?
188    AC_CHECK_LIB(asound,snd_seq_create_simple_port,[
189      AC_TRY_RUN([
190#include <$alsa_header_prefix/asoundlib.h>
191int main() { return (SND_LIB_MAJOR == 0 && SND_LIB_MINOR != 5 && SND_LIB_MINOR != 9) || SND_LIB_MAJOR != 1; }
192        ] ,[
193        have_alsa="yes"
194        LIBASOUND="-lasound"
195        AC_DEFINE(HAVE_ALSA, 1,
196          [Define if you have libasound (required for alsa support)])
197      ], [ have_alsa="no" ], [ have_alsa="no" ])
198    ], [
199      have_alsa="no"
200    ])
201
202    dnl Alsa library version
203    alsa_version="none"
204    AC_MSG_CHECKING(for Alsa version)
205    alsa_tmpfile=`mktemp /tmp/tse3-conftest-alsaversion.XXXXXX`
206    AC_TRY_RUN([
207#include <$alsa_header_prefix/asoundlib.h>
208#include <stdio.h>
209    int main()
210    {
211        FILE *temp = fopen("$alsa_tmpfile", "w");
212        if (SND_LIB_MAJOR == 0)
213        {
214            fprintf(temp, "%d.%d", SND_LIB_MAJOR, SND_LIB_MINOR);
215        }
216        else
217        {
218            fprintf(temp, "%d", SND_LIB_MAJOR);
219        }
220        fclose(temp);
221        return 0;
222    }
223    ], alsa_version="determining...", alsa_version="none", AC_MSG_WARN(Using Alsa whilst cross compiling. Presuming 0.9.x) && cat "0.9" > $alsa_tmpfile)
224    alsa_version=`cat $alsa_tmpfile`
225    rm $alsa_tmpfile
226    AC_MSG_RESULT($alsa_version)
227    if test "$alsa_version" = "0.5"; then
228      AC_DEFINE(TSE3_WITH_ALSA_0_5_X,1,[Define if you have Alsa 0.5.x])
229    fi
230    if test "$alsa_version" = "0.9"; then
231      AC_DEFINE(TSE3_WITH_ALSA_0_9_X,1,[Define if you have Alsa 0.9.x])
232    fi
233    if test "$alsa_version" = "1"; then
234      AC_DEFINE(TSE3_WITH_ALSA_0_9_X,1,[Define if you have Alsa 0.9.x])
235    fi
236  fi
237  AC_SUBST(LIBASOUND)
238  LDFLAGS="$ac_ldflags_save"
239
240])
241AC_CHECK_LIBASOUND
242
243AM_CONDITIONAL(HAVE_ALSA, test "$have_alsa" = "yes")
244
245AC_MSG_CHECKING(whether ALSA is available)
246if test "$have_alsa" = "yes"; then
247  AC_MSG_RESULT(yes)
248else
249  AC_MSG_RESULT(no)
250fi
251
252# 2. Check whether ALSA is wanted
253AC_MSG_CHECKING(whether ALSA support is wanted)
254AC_ARG_WITH(alsa,
255[  --with-alsa             whether to support the ALSA library],
256[if test "$withval" = yes; then
257  AC_MSG_RESULT(yes)
258  with_alsa="yes"
259else
260  AC_MSG_RESULT(no)
261  with_alsa="no"
262fi], [AC_MSG_RESULT(yes); with_alsa="yes"])
263
264if test "$with_alsa" = "yes" -a "$have_alsa" = "yes"; then
265  AC_SUBST(TSE3_WITH_ALSA)
266  AC_DEFINE(TSE3_WITH_ALSA,1,[Define if ALSA library support is required])
267  TSE3_ALSA_VERSION=$alsa_version
268  AC_SUBST(TSE3_ALSA_VERSION)
269  TSE3_ALSA_PREFIX=$alsa_header_prefix
270  AC_SUBST(TSE3_ALSA_PREFIX)
271  AC_SUBST(TSE3_WITH_ALSA_0_5_X)
272  AC_SUBST(TSE3_WITH_ALSA_0_9_X)
273else
274  TSE3_ALSA_VERSION=none
275  AC_SUBST(TSE3_ALSA_VERSION)
276fi
277AM_CONDITIONAL(TSE3_WITH_ALSA, test "$with_alsa" = "yes" -a "$have_alsa" = "yes")
278AM_CONDITIONAL(TSE3_WITH_ALSA_0_5_X, test "$with_alsa" = "yes" -a "$have_alsa" = "yes" -a "$alsa_version" = "0.5")
279AM_CONDITIONAL(TSE3_WITH_ALSA_0_9_X, test "$with_alsa" = "yes" -a "$have_alsa" = "yes" -a "$alsa_version" = "0.9")
280
281# ----------------------------------------------------------------------------
282# Checks for aRts library support
283
284# 1. Check whether aRts is there
285have_aRts="no"
286AC_DEFUN(AC_CHECK_LIBARTS,
287[
288  dnl aRts headers? We'll favour the generic includes then the existing
289  dnl kde-config, then SuSE KDE3 then SuSE KDE2
290  aRts_header_prefix="NONE"
291  AC_CHECK_HEADER(kde/arts/artsmidi.h, aRts_header_prefix="kde/arts")
292  AC_CHECK_HEADER(arts/artsmidi.h, aRts_header_prefix="arts")
293  if test "x$aRts_header_prefix" = "xNONE"; then
294    if test `which kde-config`; then
295      AC_MSG_CHECKING(aRts header location from kde-config)
296      aRts_header_prefix_kdeconf=`kde-config --prefix`/include
297      AC_MSG_RESULT($aRts_header_prefix_kdeconf)
298      AC_CHECK_FILE($aRts_header_prefix_kdeconf/arts/artsmidi.h, aRts_header_prefix=$aRts_header_prefix_kdeconf/arts)
299      AC_CHECK_FILE($aRts_header_prefix_kdeconf/kde/arts/artsmidi.h, aRts_header_prefix=$aRts_header_prefix_kdeconf/kde/arts)
300    fi
301  fi
302  if test "x$aRts_header_prefix" = "xNONE"; then
303    AC_CHECK_HEADER(/opt/kde3/include/arts/artsmidi.h, aRts_header_prefix="/opt/kde3/include/arts")
304  fi
305  if test "x$aRts_header_prefix" = "xNONE"; then
306    AC_CHECK_HEADER(/opt/kde2/include/arts/artsmidi.h, aRts_header_prefix="/opt/kde2/include/arts")
307  fi
308
309  echo "aRts prefix is $aRts_header_prefix"
310
311  ac_ldflags_save="$LDFLAGS"
312  aRts_library_prefix=""
313  if test `which kde-config`; then
314    aRts_library_prefix=`kde-config --prefix`/lib
315  fi
316  LDFLAGS="$all_libraries -L$aRts_library_prefix $LDFLAGS"
317  if test "x$aRts_header_prefix" != "xNONE"; then
318    AC_CHECK_LIB(artsc,arts_init,[
319      have_aRts="yes"
320      LIBARTS="-L$aRts_library_prefix -lartsc"
321      AC_DEFINE(HAVE_ARTS, 1,
322        [Define if you have libartsc (required for aRts support)])
323      dnl We add the KDEDIRS path (or preferably KDEDIRS) for linkage to
324      dnl libmcop
325      dnl if test "x$KDEDIR" = "x"; then
326      dnl   LIBARTS="-L$KDEDIRS $LIBARTS"
327      dnl else
328      dnl   LIBARTS="-L$KDEDIR $LIBARTS"
329      dnl fi
330    ], [
331      have_aRts="no"
332    ])
333  fi
334  AC_SUBST(LIBARTS)
335  LDFLAGS="$ac_ldflags_save"
336])
337AC_CHECK_LIBARTS
338
339AM_CONDITIONAL(HAVE_ARTS, test "$have_aRts" = "yes")
340
341AC_MSG_CHECKING(whether aRts is available)
342if test "$have_aRts" = "yes"; then
343  AC_MSG_RESULT(yes)
344else
345  AC_MSG_RESULT(no)
346fi
347
348# 2. Check whether aRts is wanted
349AC_MSG_CHECKING(whether aRts support is wanted)
350AC_ARG_WITH(aRts,
351[  --with-aRts             whether to support the aRts library],
352[if test "$withval" = "yes"; then
353  AC_MSG_RESULT(yes)
354  with_aRts="yes"
355else
356  AC_MSG_RESULT(no)
357  with_aRts="no"
358fi], [AC_MSG_RESULT(yes); with_aRts="yes"])
359
360if test "$with_aRts" = "yes" -a "$have_aRts" = "yes"; then
361  AC_SUBST(TSE3_WITH_ARTS)
362  AC_DEFINE(TSE3_WITH_ARTS,1,[Define if aRts library support is required])
363  TSE3_ARTS_PREFIX=$aRts_header_prefix
364  AC_SUBST(TSE3_ARTS_PREFIX)
365fi
366AM_CONDITIONAL(TSE3_WITH_ARTS, test "$with_aRts" = "yes" -a "$have_aRts" = "yes")
367
368# ----------------------------------------------------------------------------
369# Checks for WIN32 platform
370
371# 1. Check if we're running on either cygwin or mingw32
372
373AC_MSG_CHECKING(whether Win32 MIDI is available)
374
375have_win32="no"
376if test "$CYGWIN" = "yes"; then
377  have_win32="yes"
378fi
379if test "$MINGW32" = "yes"; then
380  have_win32="yes"
381fi
382
383if test "$have_win32" = "yes"; then
384  AC_MSG_RESULT(yes)
385else
386  AC_MSG_RESULT(no)
387fi
388
389# 2. Check whether Win32 is wanted
390AC_MSG_CHECKING(whether Win32 support is wanted)
391AC_ARG_WITH(win32,
392[  --with-win32            whether to support the Win32 platform],
393[if test "$withval" = "yes"; then
394  AC_MSG_RESULT(yes)
395  with_win32="yes"
396else
397  AC_MSG_RESULT(no)
398  with_win32="no"
399fi], [AC_MSG_RESULT(yes); with_win32="yes"])
400
401if test "$with_win32" = "yes" -a "$have_win32" = "yes"; then
402  AC_SUBST(TSE3_WITH_WIN32)
403  AC_DEFINE(TSE3_WITH_WIN32,1,[Define if Win32 platform support is required])
404fi
405AM_CONDITIONAL(TSE3_WITH_WIN32, test "$with_win32" = "yes" -a "$have_win32" = "yes")
406
407
408# ----------------------------------------------------------------------------
409# Finally, output the makefiles
410# ----------------------------------------------------------------------------
411
412AC_OUTPUT(
413    Makefile                        \
414    doc/Makefile                    \
415    demos/Makefile                  \
416    src/Makefile                    \
417    src/tse3/Makefile               \
418    src/tse3/app/Makefile           \
419    src/tse3/cmd/Makefile           \
420    src/tse3/file/Makefile          \
421    src/tse3/ins/Makefile           \
422    src/tse3/plt/Makefile           \
423    src/tse3/util/Makefile          \
424    src/tse3/listen/Makefile        \
425    src/tse3/listen/app/Makefile    \
426    src/tse3/listen/cmd/Makefile    \
427    src/tse3/listen/ins/Makefile    \
428    src/tse3play/Makefile           \
429    src/examples/Makefile           \
430    src/examples/contents/Makefile  \
431    src/examples/scale/Makefile     \
432    src/examples/midifile/Makefile  \
433    src/examples/ports/Makefile     \
434    src/examples/recording/Makefile \
435)
436