1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(src/cdaudio.c)
3
4LIBCDAUDIO_VERSION_MAJOR=0
5LIBCDAUDIO_VERSION_MINOR=99
6LIBCDAUDIO_VERSION_MICRO=12
7LIBCDAUDIO_VERSION=$LIBCDAUDIO_VERSION_MAJOR.$LIBCDAUDIO_VERSION_MINOR.$LIBCDAUDIO_VERSION_MICRO
8LIBCDAUDIO_VERSION_STRING="0.99.12p2"
9
10PACKAGE=libcdaudio
11
12AM_INIT_AUTOMAKE($PACKAGE, ${LIBCDAUDIO_VERSION_STRING})
13AM_MAINTAINER_MODE
14
15AM_CONFIG_HEADER(config.h)
16
17AC_PROG_AWK
18AC_PROG_CC
19AC_PROG_CPP
20AM_C_PROTOTYPES
21AM_PROG_CC_STDC
22AC_PROG_INSTALL
23AC_PROG_LN_S
24AC_PROG_MAKE_SET
25AM_PROG_LIBTOOL
26
27dnl AC_CANONICAL_HOST
28dnl AC_ARG_PROGRAM
29
30# We need to change the name of the installed package on some systems,
31# so we don't clash with existing system files.  We'll do this by
32# prefixing "lib" so it comes out as "libcdaudio.h" and
33# "liblibcdaudio.so".
34
35cdaudioname=cdaudio
36
37threads=yes
38
39AC_ARG_ENABLE(threads,
40AS_HELP_STRING([--enable-threads],
41               [build a thread-safe version of libcdaudio (default=guessed)]),
42[if test "$enableval" = "yes"
43then
44        threads=yes
45else
46        threads=no
47fi])
48
49AC_ARG_ENABLE(xbox-fix,
50AS_HELP_STRING([--enable-xbox-fix],
51               [include fix for compilation on XBox (default=no)]),
52[if test "$enableval" = "yes"
53then
54        xbox=1
55else
56        xbox=0
57fi],
58[xbox=0])
59
60AC_DEFINE_UNQUOTED(XBOX, $xbox, [Nonzero if building on XBox.])
61
62dnl POSIX.4 threads
63if test "$threads" = "yes"
64then
65        AC_CHECK_LIB(pthread,pthread_create,threads=-lpthread,threads=no)
66        echo 'threads='$threads
67        if test "$threads" = "no"
68        then
69                AC_CHECK_LIB(c_r,pthread_create,threads=-lc_r,threads=no)
70        fi
71fi
72
73sys=generic
74
75case "$host" in
76  *beos*)
77    cdaudioname=libcdaudio
78    sys=beos
79    AC_DEFINE(BEOS_CDAUDIO, , [This symbol will be defined if we are compiling from a BeOS system.  In that case, we will use closesocket() instead of close(), and we won't use shutdown() at all.])
80    LIBS="-lcdaudio $LIBS"
81    ;;
82  *irix*)
83    cdaudioname=libcdaudio
84    sys=irix
85    AC_DEFINE(IRIX_CDAUDIO, , [This symbol will be declared if we're compiling for an Irix system, and we have access to the Irix cdaudio library to do the dirty work.])
86    LIBS="-lcdaudio -lmediad -lds $LIBS"
87    ;;
88  *solaris*)
89    sys=solaris
90    AC_DEFINE(SOLARIS_GETMNTENT, , [Quick fix for Solaris.])
91    AC_DEFINE(BROKEN_SOLARIS_LEADOUT, , [Another quick fix.])
92    ;;
93esac
94
95AM_CONDITIONAL([IRIX], [test "$sys" = irix])
96AM_CONDITIONAL([BEOS], [test "$sys" = beos])
97
98AC_HEADER_DIRENT
99AC_HEADER_STDC
100AC_CHECK_HEADERS(fcntl.h sys/ioctl.h unistd.h linux/cdrom.h linux/ucdrom.h sys/cdio.h io/cam/cdrom.h stdarg.h mntent.h sys/mntent.h sys/types.h sys/param.h sys/ucred.h sys/mount.h strings.h,,,
101[[#if defined (HAVE_SYS_TYPES_H)
102# include <sys/types.h>
103#endif
104
105#if defined (HAVE_SYS_PARAM_H)
106# include <sys/param.h>
107#endif
108]])
109
110AC_C_CONST
111
112case "$cross_compiling" in
113  yes)
114    echo "You are cross compiling.  You will need to edit config.h and specify the target machine's endianness and word size manually."
115    ;;
116  no)
117    AC_C_BIGENDIAN
118    AC_CHECK_SIZEOF(long)
119    ;;
120esac
121
122AC_HEADER_TIME
123
124AC_PROG_GCC_TRADITIONAL
125AC_FUNC_VPRINTF
126AC_CHECK_FUNCS(gethostbyname gethostbyname_r mkdir socket strerror strstr strtol snprintf getmntinfo strtoul)
127AC_FUNC_GETMNTENT
128
129if test "$threads" != "no"
130then
131        AC_DEFINE(HAVE_PTHREAD, , [Define if your system provides POSIX.4 threads.])
132        CFLAGS="$CFLAGS -D_REENTRANT"
133        LIBRARY_LIB="$threads $LIBRARY_LIB"
134        REENTRANT="-D_REENTRANT"
135fi
136
137AC_SUBST(REENTRANT)
138AC_SUBST(LIBS)
139AC_SUBST(LIB_LDADD)
140AC_SUBST(LIBCDAUDIO_VERSION)
141AC_SUBST(LIBCDAUDIO_VERSION_MAJOR)
142AC_SUBST(LIBCDAUDIO_VERSION_MINOR)
143AC_SUBST(LIBCDAUDIO_VERSION_MICRO)
144AC_SUBST(cdaudioname)
145
146AC_OUTPUT([libcdaudio.pc libcdaudio-config Makefile src/Makefile
147src/cdaudio.h], [chmod +x libcdaudio-config])
148
149echo
150echo Ready to build libcdaudio $LIBCDAUDIO_VERSION_STRING.
151echo
152case $sys in
153     (irix)
154        echo "* I am configured for IRIX."
155        ;;
156     (beos)
157        echo "* I am configured for BeOS."
158        ;;
159     (solaris)
160        echo "* I am configured Solaris."
161        ;;
162     (*)
163        echo "* I am configured for a generic or GNU or GNU-like system."
164        ;;
165esac
166if test "$cross_compiling" = yes
167then
168        echo "* The build is a cross-compilation."
169else
170        echo "* The build is not a cross-compilation."
171fi
172if test $threads != no
173then
174        echo "* I will build a thread-safe version."
175else
176        echo "* I will build a non-thread-safe version."
177fi
178if test $xbox = 1
179then
180        echo "* I will use the XBox fix."
181else
182        echo "* I will not use the XBox fix."
183        echo "  If you're compiling on XBox, consider enabling the fix"
184        echo "  with --enable-xbox-fix."
185fi
186echo
187echo "=> If you want to help, please contact the maintainer."
188echo "   libcdaudio cannot evolve as long as there is no portability testing."
189echo "   We need people who can compile & test libcdaudio on:"
190echo "   OpenBSD  FreeBSD  NetBSD  Solaris  Irix  BeOS  OSF/1  XBox/MythTV"
191echo "   If you use a box with one of these operating systems, please consider"
192echo "   helping us."
193echo "   Thanks."
194echo
195echo 'You may build libcdaudio with your favorite Make program, e.g. "make".'
196