1dnl -*- mode: shell-script -*-
2dnl Process this file with autoconf to produce a configure script.
3
4m4_define([libidl_major_version], [0])
5m4_define([libidl_minor_version], [8])
6m4_define([libidl_micro_version], [14])
7m4_define([libidl_version], [libidl_major_version.libidl_minor_version.libidl_micro_version])
8
9# Before making a release, the LT_VERSION string should be modified.
10# The string is of the form C:R:A.
11# - If interfaces have been changed or added, but binary compatibility
12# has
13#   been preserved, change to C+1:0:A+1
14# - If binary compatibility has been broken (eg removed or changed
15# interfaces)
16#   change to C+1:0:0
17# - If the interface is the same as the previous version, change to
18# C:R+1:A
19m4_define([lt_version], [0:0:0])
20
21dnl the forth argument is because AC_INIT will lowercase the package name
22dnl if left off.
23AC_INIT([libIDL], [libidl_version],
24        [http://bugzilla.gnome.org/enter_bug.cgi?product=libIDL],
25        [libIDL])
26AC_CONFIG_SRCDIR([include/libIDL/IDL.h.in])
27
28AM_INIT_AUTOMAKE([1.9 no-define no-dist-gzip dist-bzip2])
29
30m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
31
32AC_SUBST(LIBIDL_MAJOR_VERSION, [libidl_major_version])
33AC_SUBST(LIBIDL_MINOR_VERSION, [libidl_minor_version])
34AC_SUBST(LIBIDL_MICRO_VERSION, [libidl_micro_version])
35AC_SUBST(LIBIDL_VERSION, [libidl_version])
36AC_SUBST(LT_VERSION, [lt_version])
37AC_DEFINE_UNQUOTED(LIBIDL_VERSION, ["libidl_version"],
38                   [the libIDL version number])
39
40dnl --disable-comile-warnings
41AC_ARG_ENABLE(compile-warnings,
42  AC_HELP_STRING([--enable-compile-warnings=@<:@no/yes@:>@],
43                 [Turn on compiler warnings.]),,
44  [enable_compile_warnings="yes"])
45
46dnl Make sure that $ACLOCAL_FLAGS is passed to subsequent aclocal runs.
47ACLOCAL_AMFLAGS="\${ACLOCAL_FLAGS}"
48AC_SUBST([ACLOCAL_AMFLAGS])
49
50AC_ISC_POSIX
51
52dnl Checks for programs.
53AC_PROG_CC
54AC_PROG_CPP
55AC_CPP_ACCEPT_IDL
56if [[ "$ac_cv_cpp_accept_idl" = "no" ]]; then
57	AC_MSG_WARN(CPP does not accept IDL)
58fi
59AC_CPP_PIPE_STDIN
60CPP_PROGRAM="$CPP"
61AC_DEFINE_UNQUOTED(CPP_PROGRAM, "$CPP")
62
63AM_PROG_LEX
64if [[ "$LEX" != "flex" ]]; then
65	AC_MSG_ERROR(flex is required to create the libIDL scanner)
66fi
67LFLAGS="-8"
68AC_SUBST(LFLAGS)
69
70AC_PROG_YACC
71dnl determine if a usable yacc is available on this system
72AC_CHECK_PROG(HAVE_YACC, $YACC, yes, no)
73if [[ "$HAVE_YACC" = "no" ]]; then
74	AC_MSG_ERROR($YACC is not usable as yacc - consider using bison)
75fi
76
77AC_LIBTOOL_WIN32_DLL
78AM_PROG_LIBTOOL
79AM_MAINTAINER_MODE
80
81AC_MSG_CHECKING([for Win32])
82case "$host" in
83  *-*-mingw*)
84    os_win32=yes
85    ;;
86  *)
87    os_win32=no
88
89    ;;
90esac
91AC_MSG_RESULT([$os_win32])
92AM_CONDITIONAL(OS_WIN32, [test $os_win32 = yes])
93
94dnl Checks for libraries.
95PKG_CHECK_MODULES(LIBIDL, glib-2.0 >= 2.4.0)
96
97AC_STDC_HEADERS
98AC_CHECK_HEADERS(stddef.h)
99AC_CHECK_HEADERS(unistd.h)
100AC_CHECK_HEADERS(wchar.h, HAVE_WCHAR_H=1)
101AC_CHECK_HEADERS(wcstr.h, HAVE_WCSTR_H=1)
102if test -z "$HAVE_WCHAR_H"; then
103	HAVE_WCHAR_H=0
104fi
105if test -z "$HAVE_WCSTR_H"; then
106	HAVE_WCSTR_H=0
107fi
108AC_SUBST(HAVE_WCHAR_H)
109AC_SUBST(HAVE_WCSTR_H)
110AC_CHECK_FUNCS(popen symlink access)
111
112dnl glib requires a 64-bit type
113dnl to support MSVC add __int64
114AC_CHECK_SIZEOF(long long)
115
116AC_MSG_CHECKING(for format to printf and scanf a guint64)
117AC_CACHE_VAL(libIDL_cv_long_long_format,[
118    for format in ll q I64; do
119	AC_TRY_RUN([#include <stdio.h>
120	    #include <stdlib.h>
121	    int main()
122	    {
123		long long b, a = -0x3AFAFAFAFAFAFAFALL;
124		char buffer[1000];
125		sprintf (buffer, "%${format}u", a);
126  		sscanf (buffer, "%${format}u", &b);
127		exit (b!=a);
128	    }
129	    ],
130	    libIDL_cv_long_long_format=${format}
131	    break)
132	done])
133if test -n "$libIDL_cv_long_long_format"; then
134    AC_MSG_RESULT(%${libIDL_cv_long_long_format}u)
135    IDL_LL="\"${libIDL_cv_long_long_format}\""
136    AC_SUBST(IDL_LL)
137else
138    AC_MSG_RESULT(none)
139    AC_MSG_ERROR([
140*** libIDL requires a 64 bit format type.
141])
142fi
143
144
145if test "x$GCC" = "xyes" -a "x$enable_compile_warnings" != "xno"; then
146        WARN_CFLAGS="-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations"
147else
148        WARN_CFLAGS=
149fi
150
151AC_MSG_CHECKING(what warning flags to pass to the C compiler)
152AC_MSG_RESULT($WARN_CFLAGS)
153AC_SUBST(WARN_CFLAGS)
154
155AC_CONFIG_FILES([
156Makefile
157Makefile.msc
158libIDL-zip
159include/Makefile
160include/libIDL/Makefile
161include/libIDL/IDL.h
162libIDL-config-2
163libIDL.m4
164libIDL.spec
165libIDL-2.0.pc
166libIDL-2.0-uninstalled.pc
167])
168
169AC_OUTPUT
170
171echo
172echo libIDL $LIBIDL_VERSION configuration complete
173echo
174echo "  C Preprocessor: \"$CPP_PROGRAM\""
175if [[ "$ac_cv_cpp_pipe_stdin" = "yes" ]]; then
176	echo "  Standard input supported."
177else
178	echo "  Using symlink method."
179fi
180echo
181