and now with the correct filenames
[asterisk/asterisk.git] / mxml / configure.in
1 dnl
2 dnl "$Id$"
3 dnl
4 dnl Configuration script for Mini-XML, a small XML-like file parsing library.
5 dnl
6 dnl Copyright 2003-2005 by Michael Sweet.
7 dnl
8 dnl This program is free software; you can redistribute it and/or
9 dnl modify it under the terms of the GNU Library General Public
10 dnl License as published by the Free Software Foundation; either
11 dnl version 2, or (at your option) any later version.
12 dnl
13 dnl This program is distributed in the hope that it will be useful,
14 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 dnl GNU General Public License for more details.
17 dnl
18
19 dnl Specify a source file from the distribution...
20 AC_INIT(mxml.h)
21
22 dnl Set the name of the config header file...
23 AC_CONFIG_HEADER(config.h)
24
25 dnl Version number...
26 VERSION=2.2.2
27 AC_SUBST(VERSION)
28 AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION")
29
30 dnl Clear default debugging options and set normal optimization by
31 dnl default unless the user asks for debugging specifically.
32 CFLAGS="${CFLAGS:=}"
33 CXXFLAGS="${CXXFLAGS:=}"
34 LDFLAGS="${LDFLAGS:=}"
35 AC_SUBST(LDFLAGS)
36 OPTIM="-O"
37 AC_SUBST(OPTIM)
38
39 AC_ARG_WITH(ansi, [  --with-ansi             set full ANSI C mode, default=no],
40         use_ansi="$withval",
41         use_ansi="no")
42
43 AC_ARG_ENABLE(debug, [  --enable-debug          turn on debugging, default=no],
44 if eval "test x$enable_debug = xyes"; then
45         OPTIM="-g"
46 else
47         LDFLAGS="$LDFLAGS -s"
48 fi)
49
50 AC_ARG_WITH(docdir, [  --with-docdir           set directory for documentation, default=${prefix}/share/doc/mxml],
51         docdir="$withval",
52         docdir="NONE")
53
54 AC_SUBST(docdir)
55
56 AC_ARG_WITH(vsnprintf, [  --with-vsnprintf        use vsnprintf emulation functions, default=auto],
57         use_vsnprintf="$withval",
58         use_vsnprintf="no")
59
60 dnl Get the operating system and version number...
61 uname=`uname`
62 uversion=`uname -r | sed -e '1,$s/[[^0-9]]//g'`
63 if test x$uname = xIRIX64; then
64         uname="IRIX"
65 fi
66
67 dnl Checks for programs...
68 AC_PROG_CC
69 AC_PROG_CXX
70 AC_PROG_INSTALL
71 if test "$INSTALL" = "$ac_install_sh"; then
72         # Use full path to install-sh script...
73         INSTALL="`pwd`/install-sh -c"
74 fi
75 AC_PROG_RANLIB
76 AC_PATH_PROG(AR,ar)
77 AC_PATH_PROG(CP,cp)
78 AC_PATH_PROG(LN,ln)
79 AC_PATH_PROG(MKDIR,mkdir)
80 AC_PATH_PROG(NROFF,nroff)
81 if test x$NROFF = x; then
82         AC_PATH_PROG(GROFF,groff)
83         if test x$GROFF = x; then
84                 NROFF="echo"
85         else
86                 NROFF="$GROFF -T ascii"
87         fi
88 fi
89 AC_PATH_PROG(RM,rm)
90
91 dnl Flags for "ar" command...
92 case "$uname" in
93         Darwin* | *BSD*)
94                 ARFLAGS="-rcv"
95                 ;;
96         *)
97                 ARFLAGS="crvs"
98                 ;;
99 esac
100
101 AC_SUBST(ARFLAGS)
102
103 dnl Checks for string functions.
104 if test "x$use_ansi" != xyes; then
105         AC_CHECK_FUNCS(strdup)
106 fi
107
108 if test "x$use_vsnprintf" != xyes; then
109         AC_CHECK_FUNCS(vsnprintf)
110 fi
111
112 dnl Shared library support...
113 DSO="${DSO:=:}"
114 DSOFLAGS="${DSOFLAGS:=}"
115
116 AC_ARG_ENABLE(shared, [  --enable-shared         turn on shared libraries, default=no])
117
118 if test x$enable_shared = xyes; then
119         AC_MSG_CHECKING(for shared library support)
120         PICFLAG=1
121
122         case "$uname" in
123                 SunOS* | UNIX_S*)
124                         AC_MSG_RESULT(yes)
125                         LIBMXML="libmxml.so.1.0"
126                         DSO="\$(CC)"
127                         DSOFLAGS="$DSOFLAGS -Wl,-h,libmxml.so.1 -G -R\$(libdir) \$(OPTIM)"
128                         LDFLAGS="$LDFLAGS -R\$(libdir)"
129                         ;;
130
131                 HP-UX*)
132                         AC_MSG_RESULT(yes)
133                         LIBMXML="libmxml.sl.1"
134                         DSO="ld"
135                         DSOFLAGS="$DSOFLAGS -b -z +h libmxml.sl.1 +s +b \$(libdir)"
136                         LDFLAGS="$LDFLAGS -Wl,+s,+b,\$(libdir)"
137                         ;;
138
139                 IRIX)
140                         AC_MSG_RESULT(yes)
141                         LIBMXML="libmxml.so.1.0"
142                         DSO="\$(CC)"
143                         DSOFLAGS="$DSOFLAGS -Wl,-rpath,\$(libdir),-set_version,sgi1.0,-soname,libmxml.so.1 -shared \$(OPTIM)"
144                         ;;
145
146                 OSF1* | Linux | GNU)
147                         AC_MSG_RESULT(yes)
148                         LIBMXML="libmxml.so.1.0"
149                         DSO="\$(CC)"
150                         DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-rpath,\$(libdir) -shared \$(OPTIM)"
151                         LDFLAGS="$LDFLAGS -Wl,-rpath,\$(libdir)"
152                         ;;
153
154                 *BSD*)
155                         AC_MSG_RESULT(yes)
156                         LIBMXML="libmxml.so.1.0"
157                         DSO="\$(CC)"
158                         DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-R\$(libdir) -shared \$(OPTIM)"
159                         LDFLAGS="$LDFLAGS -Wl,-R\$(libdir)"
160                         ;;
161
162                 Darwin*)
163                         AC_MSG_RESULT(yes)
164                         LIBMXML="libmxml.1.dylib"
165                         DSO="\$(CC)"
166                         DSOFLAGS="$DSOFLAGS \$(RC_CFLAGS) -dynamiclib -lc"
167                         ;;
168
169                 *)
170                         AC_MSG_RESULT(no)
171                         AC_MSG_WARN(shared libraries not supported on this platform.)
172                         PICFLAG=0
173                         LIBMXML="libmxml.a"
174                         ;;
175         esac
176 else
177         PICFLAG=0
178         LIBMXML="libmxml.a"
179 fi
180
181 AC_SUBST(DSO)
182 AC_SUBST(DSOFLAGS)
183 AC_SUBST(LIBMXML)
184 AC_SUBST(PICFLAG)
185
186 dnl Add -Wall for GCC...
187 if test -n "$GCC"; then
188         CFLAGS="-Wall $CFLAGS"
189
190         if test "x$use_ansi" = xyes; then
191                 CFLAGS="-ansi -pedantic $CFLAGS"
192         fi
193
194         if test $PICFLAG = 1 -a $uname != AIX; then
195                 OPTIM="-fPIC $OPTIM"
196         fi
197 else
198         case $uname in
199                 HP-UX*)
200                         CFLAGS="-Ae $CFLAGS"
201                         OPTIM="+DAportable $OPTIM"
202
203                         if test $PICFLAG = 1; then
204                                 OPTIM="+z $OPTIM"
205                         fi
206                         ;;
207
208                 UNIX_SVR* | SunOS*)
209                         if test $PICFLAG = 1; then
210                                 OPTIM="-KPIC $OPTIM"
211                         fi
212                         ;;
213         esac
214 fi
215
216 dnl Fix "prefix" variable if it hasn't been specified...
217 if test "$prefix" = "NONE"; then
218         prefix="/usr/local"
219 fi
220
221 dnl Fix "exec_prefix" variable if it hasn't been specified...
222 if test "$exec_prefix" = "NONE"; then
223         exec_prefix="$prefix"
224 fi
225
226 dnl Fix "docdir" variable if it hasn't been specified...
227 if test "$docdir" = "NONE"; then
228         docdir="$datadir/doc/mxml"
229 fi
230
231 dnl Fix "mandir" variable if it hasn't been specified...
232 if test "$mandir" = "\${prefix}/man" -a "$prefix" = "/usr"; then
233         case "$uname" in
234                 *BSD* | Darwin* | Linux*)
235                         # BSD, Darwin (MacOS X), and Linux
236                         mandir="/usr/share/man"
237                         ;;
238                 IRIX*)
239                         # SGI IRIX
240                         mandir="/usr/share/catman/u_man"
241                         ;;
242                 *)
243                         # All others
244                         mandir="/usr/man"
245                         ;;
246         esac
247 fi
248
249 dnl More manpage stuff...
250 case "$uname" in
251         *BSD* | Darwin*)
252                 # *BSD
253                 CAT1EXT="0"
254                 MAN1EXT="1"
255                 CAT3EXT="0"
256                 MAN3EXT="3"
257                 ;;
258         *)
259                 # All others
260                 CAT1EXT="1"
261                 MAN1EXT="1"
262                 CAT3EXT="3"
263                 MAN3EXT="3"
264                 ;;
265 esac
266
267 AC_SUBST(CAT1EXT)
268 AC_SUBST(CAT3EXT)
269 AC_SUBST(MAN1EXT)
270 AC_SUBST(MAN3EXT)
271
272 dnl pkg-config stuff...
273 if test "$includedir" != /usr/include; then
274         PC_CFLAGS="-I$includedir"
275 else
276         PC_CFLAGS=""
277 fi
278
279 if test "$libdir" != /usr/lib; then
280         PC_LIBS="-L$libdir -lmxml"
281 else
282         PC_LIBS="-lmxml"
283 fi
284
285 AC_SUBST(PC_CFLAGS)
286 AC_SUBST(PC_LIBS)
287
288 dnl Output the makefile, etc...
289 AC_OUTPUT(Makefile mxml.list mxml.pc)
290
291 dnl
292 dnl End of "$Id$".
293 dnl