summaryrefslogtreecommitdiff
path: root/xml/configure.in
blob: 45e813a4102ddd6c672277b28d875efa4a359490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
dnl
dnl "$Id: configure.in 427 2011-01-03 02:03:29Z mike $"
dnl
dnl Configuration script for Mini-XML, a small XML-like file parsing library.
dnl
dnl Copyright 2003-2011 by Michael R Sweet.
dnl
dnl These coded instructions, statements, and computer programs are the
dnl property of Michael R Sweet and are protected by Federal copyright
dnl law.  Distribution and use rights are outlined in the file "COPYING"
dnl which should have been included with this file.  If this file is
dnl missing or damaged, see the license at:
dnl
dnl     http://www.minixml.org/
dnl

dnl Specify a source file from the distribution...
AC_INIT(mxml.h)

dnl Set the name of the config header file...
AC_CONFIG_HEADER(config.h)

dnl Version number...
VERSION=2.7
AC_SUBST(VERSION)
AC_DEFINE_UNQUOTED(MXML_VERSION, "Mini-XML v$VERSION")

dnl Clear default debugging options and set normal optimization by
dnl default unless the user asks for debugging specifically.
CFLAGS="${CFLAGS:=}"
CXXFLAGS="${CXXFLAGS:=}"
LDFLAGS="${LDFLAGS:=}"
AC_SUBST(LDFLAGS)
OPTIM=""
AC_SUBST(OPTIM)

AC_ARG_WITH(ansi, [  --with-ansi             set full ANSI C mode, default=no],
	use_ansi="$withval",
	use_ansi="no")

AC_ARG_WITH(archflags, [  --with-archflags        set additional architecture flags, default=none],
	ARCHFLAGS="$withval",
	ARCHFLAGS="")
AC_SUBST(ARCHFLAGS)

AC_ARG_ENABLE(debug, [  --enable-debug          turn on debugging, default=no],
if eval "test x$enable_debug = xyes"; then
 	OPTIM="-g"
fi)

AC_ARG_WITH(docdir, [  --with-docdir           set directory for documentation, default=${prefix}/share/doc/mxml],
	docdir="$withval",
	docdir="NONE")

AC_SUBST(docdir)

AC_ARG_WITH(vsnprintf, [  --with-vsnprintf        use vsnprintf emulation functions, default=auto],
	use_vsnprintf="$withval",
	use_vsnprintf="no")

dnl Get the operating system and version number...
uname=`uname`
uversion=`uname -r | sed -e '1,$s/[[^0-9]]//g'`
if test x$uname = xIRIX64; then
	uname="IRIX"
fi

dnl Checks for programs...
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
if test "$INSTALL" = "$ac_install_sh"; then
	# Use full path to install-sh script...
	INSTALL="`pwd`/install-sh -c"
fi
AC_PROG_RANLIB
AC_PATH_PROG(AR,ar)
AC_PATH_PROG(CP,cp)
AC_PATH_PROG(LN,ln)
AC_PATH_PROG(MKDIR,mkdir)
AC_PATH_PROG(RM,rm)

dnl Flags for "ar" command...
case "$uname" in
        Darwin* | *BSD*)
                ARFLAGS="-rcv"
                ;;
        *)
                ARFLAGS="crvs"
                ;;
esac

AC_SUBST(ARFLAGS)

dnl Inline functions...
AC_C_INLINE

dnl Checks for string functions.
if test "x$use_ansi" != xyes; then
	AC_CHECK_FUNCS(strdup)
fi

if test "x$use_vsnprintf" != xyes; then
	AC_CHECK_FUNCS(snprintf vsnprintf)
fi

dnl Check for "long long" support...
AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
	[if test "$GCC" = yes; then
		ac_cv_c_long_long=yes
	else
		AC_TRY_COMPILE(,[long long int i;],
			ac_cv_c_long_long=yes,
			ac_cv_c_long_long=no)
	fi])

if test $ac_cv_c_long_long = yes; then
	AC_DEFINE(HAVE_LONG_LONG)
fi

dnl Threading support
AC_ARG_ENABLE(threads, [  --enable-threads        enable multi-threading support])

have_pthread=no
PTHREAD_FLAGS=""
PTHREAD_LIBS=""

if test "x$enable_threads" != xno; then
	AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))

	if test x$ac_cv_header_pthread_h = xyes; then
		dnl Check various threading options for the platforms we support
		for flag in -lpthreads -lpthread -pthread; do
        		AC_MSG_CHECKING([for pthread_create using $flag])
			SAVELIBS="$LIBS"
			LIBS="$flag $LIBS"
        		AC_TRY_LINK([#include <pthread.h>],
				[pthread_create(0, 0, 0, 0);],
        			have_pthread=yes)
        		AC_MSG_RESULT([$have_pthread])
			LIBS="$SAVELIBS"

			if test $have_pthread = yes; then
				PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
				PTHREAD_LIBS="$flag"

				# Solaris requires -D_POSIX_PTHREAD_SEMANTICS to
				# be POSIX-compliant... :(
				if test $uname = SunOS; then
					PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
				fi
				break
			fi
		done
	fi
fi

AC_SUBST(PTHREAD_FLAGS)
AC_SUBST(PTHREAD_LIBS)

dnl Shared library support...
DSO="${DSO:=:}"
DSOFLAGS="${DSOFLAGS:=}"

AC_ARG_ENABLE(shared, [  --enable-shared         turn on shared libraries, default=no])

if test x$enable_shared != xno; then
	AC_MSG_CHECKING(for shared library support)
	PICFLAG=1

	case "$uname" in
		SunOS* | UNIX_S*)
			AC_MSG_RESULT(yes)
			LIBMXML="libmxml.so.1.5"
			DSO="\$(CC)"
			DSOFLAGS="$DSOFLAGS -Wl,-h,libmxml.so.1 -G -R\$(libdir) \$(OPTIM)"
			LDFLAGS="$LDFLAGS -R\$(libdir)"
                	;;

		HP-UX*)
			AC_MSG_RESULT(yes)
			LIBMXML="libmxml.sl.1"
			DSO="ld"
			DSOFLAGS="$DSOFLAGS -b -z +h libmxml.sl.1 +s +b \$(libdir)"
			LDFLAGS="$LDFLAGS -Wl,+s,+b,\$(libdir)"
			;;

		IRIX)
			AC_MSG_RESULT(yes)
			LIBMXML="libmxml.so.1.5"
			DSO="\$(CC)"
			DSOFLAGS="$DSOFLAGS -Wl,-rpath,\$(libdir),-set_version,sgi1.0,-soname,libmxml.so.1 -shared \$(OPTIM)"
			;;

		OSF1* | Linux | GNU)
			AC_MSG_RESULT(yes)
			LIBMXML="libmxml.so.1.5"
			DSO="\$(CC)"
			DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-rpath,\$(libdir) -shared \$(OPTIM)"
                        LDFLAGS="$LDFLAGS -Wl,-rpath,\$(libdir)"
			;;

		*BSD*)
			AC_MSG_RESULT(yes)
			LIBMXML="libmxml.so.1.5"
			DSO="\$(CC)"
			DSOFLAGS="$DSOFLAGS -Wl,-soname,libmxml.so.1,-R\$(libdir) -shared \$(OPTIM)"
			LDFLAGS="$LDFLAGS -Wl,-R\$(libdir)"
                        ;;

		Darwin*)
			AC_MSG_RESULT(yes)
			LIBMXML="libmxml.1.dylib"
			DSO="\$(CC)"
			DSOFLAGS="$DSOFLAGS \$(RC_CFLAGS) -dynamiclib -lc"
			;;

		*)
			AC_MSG_RESULT(no)
			AC_MSG_WARN(shared libraries not supported on this platform.)
			PICFLAG=0
			LIBMXML="libmxml.a"
			;;
	esac
else
	PICFLAG=0
	LIBMXML="libmxml.a"
fi

AC_SUBST(DSO)
AC_SUBST(DSOFLAGS)
AC_SUBST(LIBMXML)
AC_SUBST(PICFLAG)

dnl Add -Wall for GCC...
if test -n "$GCC"; then
	CFLAGS="-Wall $CFLAGS"

	if test "x$OPTIM" = x; then
		OPTIM="-Os -g"
	fi

	if test "x$use_ansi" = xyes; then
		CFLAGS="-ansi -pedantic $CFLAGS"
	fi

	if test $PICFLAG = 1 -a $uname != AIX; then
    		OPTIM="-fPIC $OPTIM"
	fi
else
	case $uname in
		HP-UX*)
			CFLAGS="-Ae $CFLAGS"

			if test "x$OPTIM" = x; then
				OPTIM="-O"
			fi

			OPTIM="+DAportable $OPTIM"

			if test $PICFLAG = 1; then
				OPTIM="+z $OPTIM"
			fi
			;;

		UNIX_SVR* | SunOS*)
			if test "x$OPTIM" = x; then
				OPTIM="-O"
			fi

			if test $PICFLAG = 1; then
				OPTIM="-KPIC $OPTIM"
			fi
			;;

		*)
			if test "x$OPTIM" = x; then
				OPTIM="-O"
			fi
			;;
	esac
fi

dnl Fix "prefix" variable if it hasn't been specified...
if test "$prefix" = "NONE"; then
	prefix="/usr/local"
fi

dnl Fix "exec_prefix" variable if it hasn't been specified...
if test "$exec_prefix" = "NONE"; then
	exec_prefix="$prefix"
fi

dnl Fix "docdir" variable if it hasn't been specified...
if test "$docdir" = "NONE"; then
	docdir="$datadir/doc/mxml"
fi

dnl Fix "mandir" variable if it hasn't been specified...
if test "$mandir" = "\${prefix}/man" -a "$prefix" = "/usr"; then
	case "$uname" in
        	*BSD* | Darwin* | Linux*)
        		# BSD, Darwin (MacOS X), and Linux
        		mandir="/usr/share/man"
        		;;
        	IRIX*)
        		# SGI IRIX
        		mandir="/usr/share/catman/u_man"
        		;;
        	*)
        		# All others
        		mandir="/usr/man"
        		;;
	esac
fi

dnl pkg-config stuff...
if test "$includedir" != /usr/include; then
	PC_CFLAGS="-I$includedir"
else
	PC_CFLAGS=""
fi

if test "$libdir" != /usr/lib; then
	PC_LIBS="-L$libdir -lmxml"
else
	PC_LIBS="-lmxml"
fi

AC_SUBST(PC_CFLAGS)
AC_SUBST(PC_LIBS)

dnl Output the makefile, etc...
AC_OUTPUT(Makefile mxml.list mxml.pc)

dnl
dnl End of "$Id: configure.in 427 2011-01-03 02:03:29Z mike $".
dnl