1# $Id: configure.in,v 1.68 2003/03/02 16:37:12 t1mpy Exp $
2
3# Copyright 1999, 2000 Scott Thomas Haug <eldamitri@users.sourceforge.net>
4# Copyright (C) 2002 Thijmen Klok <thijmen@id3lib.org>
5#
6# This file is free software; as a special exception the author gives
7# unlimited permission to copy and/or distribute it, with or without
8# modifications, as long as this notice is preserved.
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
12# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14# require autoconf 2.13
15AC_PREREQ(2.13)
16
17# init autoconf (and check for presence fo reconf)
18AC_INIT(reconf)
19
20ID3LIB_NAME=id3lib
21
22dnl The following has been adapted from glib (http://www.gtk.org)
23dnl
24dnl we need to AC_DIVERT_PUSH/AC_DIVERT_POP these variable definitions so they
25dnl are available for $ac_help expansion (don't we all *love* autoconf?)
26#AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
27ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
28			      [AC_DIVERT_PUSH(NOTICE)])
29
30# Making releases:
31#   ID3LIB_PATCH_VERSION += 1;
32#   ID3LIB_INTERFACE_AGE += 1;
33#   ID3LIB_BINARY_AGE += 1;
34# if any functions have been added, set ID3LIB_INTERFACE_AGE to 0.
35# if backwards compatibility has been broken,
36# set ID3LIB_BINARY_AGE _and_ ID3LIB_INTERFACE_AGE to 0.
37#
38
39ID3LIB_MAJOR_VERSION=3
40ID3LIB_MINOR_VERSION=8
41ID3LIB_PATCH_VERSION=3
42ID3LIB_ADDED_VERSION=
43ID3LIB_VERSION=$ID3LIB_MAJOR_VERSION.$ID3LIB_MINOR_VERSION.$ID3LIB_PATCH_VERSION$ID3LIB_ADDED_VERSION
44
45ID3LIB_INTERFACE_AGE=0
46ID3LIB_BINARY_AGE=0
47AC_DIVERT_POP()dnl
48
49AC_SUBST(ID3LIB_NAME)
50AC_SUBST(ID3LIB_MAJOR_VERSION)
51AC_SUBST(ID3LIB_MINOR_VERSION)
52AC_SUBST(ID3LIB_PATCH_VERSION)
53AC_SUBST(ID3LIB_VERSION)
54AC_SUBST(ID3LIB_INTERFACE_AGE)
55AC_SUBST(ID3LIB_BINARY_AGE)
56
57# for documentation purposes
58DOX_DIR_HTML=api
59DOX_DIR_LATEX=latex
60DOX_DIR_MAN=man
61DOX_DIR_RTF=rtf
62
63AC_SUBST(DOX_DIR_HTML)
64AC_SUBST(DOX_DIR_LATEX)
65AC_SUBST(DOX_DIR_MAN)
66AC_SUBST(DOX_DIR_RTF)
67
68# libtool versioning
69LT_RELEASE=$ID3LIB_MAJOR_VERSION.$ID3LIB_MINOR_VERSION
70LT_CURRENT=`expr $ID3LIB_PATCH_VERSION - $ID3LIB_INTERFACE_AGE`
71LT_REVISION=$ID3LIB_INTERFACE_AGE
72LT_AGE=`expr $ID3LIB_BINARY_AGE - $ID3LIB_INTERFACE_AGE`
73AC_SUBST(LT_RELEASE)
74AC_SUBST(LT_CURRENT)
75AC_SUBST(LT_REVISION)
76AC_SUBST(LT_AGE)
77
78VERSION=$ID3LIB_VERSION
79PACKAGE=$ID3LIB_NAME
80
81dnl This is a hack to get the release date using cvs checkin macros
82ID3LIB_FULLNAME=$ID3LIB_NAME-$ID3LIB_VERSION
83
84AC_SUBST(ID3LIB_FULLNAME)
85
86AM_CONFIG_HEADER(config.h)
87
88AM_INIT_AUTOMAKE($PACKAGE,$VERSION)
89
90AC_ISC_POSIX
91
92dnl Initialize libtool
93AM_PROG_LIBTOOL
94
95dnl Initialize maintainer mode
96AM_MAINTAINER_MODE
97
98#AC_CANONICAL_HOST
99
100dnl figure debugging default, prior to $ac_help setup
101dnl
102ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
103			      [AC_DIVERT_PUSH(NOTICE)])
104if test `expr $ID3LIB_MINOR_VERSION \% 2` = 1 ; then
105        debug_default=yes
106else
107        debug_default=minimum
108fi
109AC_DIVERT_POP()dnl
110
111dnl declare --enable-* args and collect ac_help strings
112AC_ARG_ENABLE(ansi,  [  --enable-ansi           turn on strict ansi [default=no]], , enable_ansi=no)
113dnl
114AC_SUBST(ID3LIB_DEBUG_FLAGS)
115
116dnl Checks for programs
117AC_PROG_CC
118AC_PROG_CXX
119AC_PROG_CXXCPP
120AC_PROG_INSTALL
121
122dnl for executable extensions
123AC_EXEEXT
124
125dnl Checks for libraries.
126AC_CHECK_LIB(z,uncompress,AC_DEFINE_UNQUOTED(HAVE_ZLIB))#,,
127#  AC_MSG_ERROR([id3lib requires zlib to process compressed frames]))
128
129AM_CONDITIONAL(ID3_NEEDZLIB, test x$ac_cv_lib_z_uncompress = xno)
130AM_CONDITIONAL(ID3_NEEDDEBUG, test x$enable_debug = xyes)
131
132dnl Checks for header files.
133AC_HEADER_STDC
134AC_CHECK_HEADERS(zlib.h wchar.h sys/param.h unistd.h )
135
136dnl check wheter iconv is the part of libc.
137AC_CHECK_HEADERS( iconv.h, has_iconv=1,  has_iconv=0)
138
139dnl if we have iconv library, we have to decide if it
140dnl is present in libc
141
142ICONV_LIB=
143if test $has_iconv = 1; then
144  AC_MSG_CHECKING(where to find iconv_open)
145  exec 6>/dev/null
146  AC_CHECK_FUNCS(iconv_open, iconv_in_libc=1, iconv_in_libc=0)
147  AC_CHECK_LIB(iconv, iconv_open, iconv_in_iconv=1, iconv_in_iconv=0)
148  AC_CHECK_LIB(iconv, libiconv_open, libiconv_in_iconv=1, libiconv_in_iconv=0)
149  if test ! x$silent = xyes; then
150    exec 6>&1
151  fi
152  #standalone library rules over libc
153  if test $iconv_in_iconv = 1 -o $libiconv_in_iconv = 1; then
154    AC_MSG_RESULT(libiconv)
155    ICONV_LIB=-liconv
156  elif test $iconv_in_libc = 1; then
157    AC_MSG_RESULT(libc)
158  else
159    AC_MSG_RESULT(not found (panic))
160    AC_MSG_ERROR([iconv.h found, while iconv library not found])
161  fi
162  #we have iconv at this moment, better check which call to use
163  AC_MSG_CHECKING(whether iconv takes const char ** or char **)
164  AC_TRY_COMPILE([#include <iconv.h>],[
165		{
166		size_t iconv (iconv_t a, const char ** b, size_t *c, char **d, size_t *e);
167		}],
168		iconv_oldstyle=1, iconv_oldstyle=0)
169  if test $iconv_oldstyle = 1; then
170    AC_MSG_RESULT(const char **)
171    AC_DEFINE(ID3LIB_ICONV_OLDSTYLE)
172    #we'll check out the need of
173    #typecast in the call of iconv_open
174    AC_MSG_CHECKING(whether to typecast in iconv)
175    AC_TRY_COMPILE([#include <iconv.h>],[
176                   {
177                      const char *src = "nothing";
178                      char *outbuf;
179                      size_t insize = 0;
180                      size_t outsize = 0;
181                      iconv_t cd;
182                      iconv(cd, &src, &insize, &outbuf, &outsize);
183                   }],
184                   iconv_cast=0, iconv_cast=1)
185    if test $iconv_cast = 1; then
186      AC_MSG_RESULT(yes)
187      AC_DEFINE(ID3LIB_ICONV_CAST_OK)
188    else
189      AC_MSG_RESULT(no)
190    fi
191
192  else
193    AC_MSG_RESULT(char **)
194    #we'll check out the need of
195    #typecast in the call of iconv_open
196    AC_MSG_CHECKING(whether to typecast in iconv)
197    AC_TRY_COMPILE([#include <iconv.h>],[
198                   {
199                      char *src = "nothing";
200                      char *outbuf;
201                      size_t insize = 0;
202                      size_t outsize = 0;
203                      iconv_t cd;
204                      iconv(cd, &src, &insize, &outbuf, &outsize);
205                   }],
206                   iconv_cast=0, iconv_cast=1)
207    if test $iconv_cast = 1; then
208      AC_MSG_RESULT(yes)
209      AC_DEFINE(ID3LIB_ICONV_CAST_OK)
210    else
211      AC_MSG_RESULT(no)
212    fi
213  fi
214
215fi
216if test "x$ICONV_LIB" != "x"; then
217  LIBS="$LIBS $ICONV_LIB"
218fi
219
220dnl Check for c++ features
221AC_LANG_SAVE
222AC_LANG_CPLUSPLUS
223AC_CHECK_HEADERS(libcw/sys.h)
224AC_CHECK_HEADERS(cctype climits cstdio cstdlib bitset cstring)
225AC_CHECK_HEADERS(fstream iostream iomanip vector \
226	,,AC_MSG_ERROR([Missing a vital header file for id3lib - download them here: http://gcc.gnu.org/libstdc++/ or better - compile a newer compiler like gcc3.x])
227)
228AC_CHECK_HEADERS(               \
229  string                        \
230  iomanip.h                     \
231  ,,AC_MSG_ERROR([Missing a vital header file for id3lib])
232)
233
234dnl Checks for the portability of certain c++ features: the bool type and
235dnl for-loop scoping
236ID3_CXX_PORTABILITY
237
238ID3_CXX_WARNINGS
239
240AC_LANG_RESTORE
241
242ID3_DEBUG
243ID3_UNICODE
244
245dnl Check for functions.
246
247# AC_FUNC_MEMCMP
248AC_CHECK_FUNCS(getopt_long)
249AM_CONDITIONAL(ID3_NEEDGETOPT_LONG, test x$ac_cv_func_getopt_long = xno)
250
251AC_CHECK_FUNCS(mkstemp)
252AC_CHECK_FUNCS(
253  truncate                      \
254  ,,AC_MSG_ERROR([Missing a vital function for id3lib])
255)
256
257dnl Checks for typedefs, structures, and compiler characteristics.
258AC_TYPE_SIZE_T
259
260dnl
261dnl Checks with local macros
262dnl
263
264dnl Provides a --honor-std option to the configure script that honors the
265dnl std namespace.  Must be used AFTER configuring ALL compilers.
266dnl LF_HONOR_STD
267
268dnl ACCONFIG TEMPLATE
269dnl
270dnl /* config.h defines these preprocesser symbols to be used by id3lib for
271dnl  * determining internal versioning information.  The intent is that these
272dnl  * macros will be made available in the library via constants, functions,
273dnl  * or static methods.
274dnl  */
275dnl #undef HAVE_ZLIB
276dnl #undef HAVE_GETOPT_LONG
277dnl #undef _ID3LIB_NAME
278dnl #undef _ID3LIB_VERSION
279dnl #undef _ID3LIB_FULLNAME
280dnl #undef _ID3LIB_MAJOR_VERSION
281dnl #undef _ID3LIB_MINOR_VERSION
282dnl #undef _ID3LIB_PATCH_VERSION
283dnl #undef _ID3LIB_INTERFACE_AGE
284dnl #undef _ID3LIB_BINARY_AGE
285dnl #undef _ID3_COMPILED_WITH_DEBUGGING
286dnl /* */
287dnl END ACCONFIG
288
289AC_DEFINE_UNQUOTED(_ID3LIB_NAME,                 "$ID3LIB_NAME")
290AC_DEFINE_UNQUOTED(_ID3LIB_VERSION,              "$ID3LIB_VERSION")
291AC_DEFINE_UNQUOTED(_ID3LIB_FULLNAME,             "$ID3LIB_FULLNAME")
292AC_DEFINE_UNQUOTED(_ID3LIB_MAJOR_VERSION,         $ID3LIB_MAJOR_VERSION)
293AC_DEFINE_UNQUOTED(_ID3LIB_MINOR_VERSION,         $ID3LIB_MINOR_VERSION)
294AC_DEFINE_UNQUOTED(_ID3LIB_PATCH_VERSION,         $ID3LIB_PATCH_VERSION)
295AC_DEFINE_UNQUOTED(_ID3LIB_INTERFACE_AGE,         $ID3LIB_INTERFACE_AGE)
296AC_DEFINE_UNQUOTED(_ID3LIB_BINARY_AGE,            $ID3LIB_BINARY_AGE)
297AC_DEFINE_UNQUOTED(_ID3_COMPILED_WITH_DEBUGGING, "${enable_debug}")
298
299CONDITIONAL_SUBDIRS=
300if test "x$ac_cv_lib_z_uncompress" = "xno"; then
301  CONDITIONAL_SUBDIRS="$CONDITIONAL_SUBDIRS zlib"
302fi
303AC_CONFIG_SUBDIRS(zlib)
304
305CFLAGS="$CFLAGS -Wall"
306
307AC_OUTPUT(                      \
308  Makefile                      \
309  doc/Makefile                  \
310  m4/Makefile                   \
311  include/Makefile              \
312  include/id3/Makefile          \
313  id3com/Makefile               \
314  id3com/Sample/Makefile        \
315  src/Makefile                  \
316  examples/Makefile             \
317  prj/Makefile			\
318  libprj/Makefile
319)
320