1#!/bin/bash -norc
2dnl	This file is an input file used by the GNU "autoconf" program to
3dnl	generate the file "configure", which is run during Tcl installation
4dnl	to configure the system for the local environment.
5#
6# RCS: @(#) $Id: configure.in,v 1.47 2007/02/09 19:06:47 hobbs Exp $
7
8#-----------------------------------------------------------------------
9# Set your package name and version numbers here.
10#
11# This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION
12# set as provided.  These will also be added as -D defs in your Makefile
13# so you can encode the package version directly into the source files.
14#-----------------------------------------------------------------------
15
16AC_INIT([Ffidl], [0.6.1])
17
18AC_PREREQ(2.60)
19
20#-----------------------------------------------------------------------
21# Ffidl TEA configure
22#
23# Copyright (c) 2005-2008 Daniel A. Steffen.
24#
25# See the file "license.terms" for information on usage and redistribution
26# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
27#-----------------------------------------------------------------------
28
29AC_DEFINE_UNQUOTED([FFIDL_VERSION], ["$PACKAGE_VERSION"], [Ffidl version])
30
31if test "`uname -s`" != "Darwin" -o "`uname -r | cut -f 1 -d .`" -lt 9; then
32    AC_MSG_ERROR([Mac OS X 10.5 or later required!])
33fi
34
35#--------------------------------------------------------------------
36# Call TEA_INIT as the first TEA_ macro to set up initial vars.
37# This will define a ${TEA_PLATFORM} variable == "unix" or "windows"
38# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
39#--------------------------------------------------------------------
40
41TEA_INIT([3.9])
42
43AC_CONFIG_AUX_DIR(tclconfig)
44
45#--------------------------------------------------------------------
46# ffidl autoheader
47#--------------------------------------------------------------------
48
49AC_CONFIG_HEADERS([ffidlConfig.h])
50TEA_ADD_INCLUDES([-imacros ffidlConfig.h])
51CONFIG_CLEAN_FILES=ffidlConfig.h
52AC_SUBST(CONFIG_CLEAN_FILES)
53
54AH_BOTTOM([
55/* override */ #undef WORDS_BIGENDIAN
56#if defined(__BIG_ENDIAN__)
57/* override */ #define WORDS_BIGENDIAN 1
58#endif
59/* override */ #undef SIZEOF_LONG
60/* override */ #undef ALIGNOF_LONG
61/* override */ #undef SIZEOF_VOID_P
62/* override */ #undef ALIGNOF_VOID_P
63/* override */ #undef ALIGNOF_LONG_LONG
64/* override */ #undef ALIGNOF_DOUBLE
65#if defined(__LP64__)
66/* override */ #define SIZEOF_LONG 8
67/* override */ #define ALIGNOF_LONG 8
68/* override */ #define SIZEOF_VOID_P 8
69/* override */ #define ALIGNOF_VOID_P 8
70/* override */ #define ALIGNOF_LONG_LONG 8
71/* override */ #define ALIGNOF_DOUBLE 8
72#else
73/* override */ #define SIZEOF_LONG 4
74/* override */ #define ALIGNOF_LONG 4
75/* override */ #define SIZEOF_VOID_P 4
76/* override */ #define ALIGNOF_VOID_P 4
77/* override */ #define ALIGNOF_LONG_LONG 4
78/* override */ #define ALIGNOF_DOUBLE 4
79#endif
80/* override */ #undef PACKAGE_BUGREPORT
81/* override */ #undef PACKAGE_NAME
82/* override */ #undef PACKAGE_STRING
83/* override */ #undef PACKAGE_TARNAME
84/* override */ #undef PACKAGE_VERSION
85])
86
87#--------------------------------------------------------------------
88# Load the tclConfig.sh file
89#--------------------------------------------------------------------
90
91TEA_PATH_TCLCONFIG
92TEA_LOAD_TCLCONFIG
93
94#-----------------------------------------------------------------------
95# Handle the --prefix=... option by defaulting to what Tcl gave.
96# Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER.
97#-----------------------------------------------------------------------
98
99TEA_PREFIX
100
101#-----------------------------------------------------------------------
102# Standard compiler checks.
103# This sets up CC by using the CC env var, or looks for gcc otherwise.
104# This also calls AC_PROG_CC, AC_PROG_INSTALL and a few others to create
105# the basic setup necessary to compile executables.
106#-----------------------------------------------------------------------
107
108TEA_SETUP_COMPILER
109
110#-----------------------------------------------------------------------
111# Specify the C source files to compile in TEA_ADD_SOURCES,
112# public headers that need to be installed in TEA_ADD_HEADERS,
113# stub library C source files to compile in TEA_ADD_STUB_SOURCES,
114# and runtime Tcl library files in TEA_ADD_TCL_SOURCES.
115# This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS
116# and PKG_TCL_SOURCES.
117#-----------------------------------------------------------------------
118
119TEA_ADD_SOURCES([ffidl.c])
120TEA_ADD_HEADERS([])
121TEA_ADD_INCLUDES([])
122TEA_ADD_LIBS([])
123TEA_ADD_CFLAGS([-DMACOSX])
124TEA_ADD_STUB_SOURCES([])
125TEA_ADD_TCL_SOURCES([library/ffidlrt.tcl])
126AC_DEFINE(LOOKUP_TK_STUBS, 1, 
127    [ffidl::stubsymbol can lookup in Tk stubs tables])
128
129#--------------------------------------------------------------------
130# TEA_ADD_* any platform specific compiler/build info here.
131#--------------------------------------------------------------------
132
133AC_SUBST(CLEANFILES)
134
135#--------------------------------------------------------------------
136# Choose which headers you need.  Extension authors should try very
137# hard to only rely on the Tcl public header files.  Internal headers
138# contain private data structures and are subject to change without
139# notice.
140# This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG
141#--------------------------------------------------------------------
142
143#TEA_PUBLIC_TCL_HEADERS
144TEA_PRIVATE_TCL_HEADERS
145
146#--------------------------------------------------------------------
147# ffidl specific configuration
148#--------------------------------------------------------------------
149
150AC_ARG_WITH(libffi-include,
151    AC_HELP_STRING([--with-libffi-include],
152	[directory containing libffi headers]),
153    [with_libffi_include=${withval}])
154AC_CACHE_CHECK([for directory with ffi.h], tcl_cv_path_ffi_h, [
155    l="$with_libffi_include $prefix/include $prefix/include/ffi /usr/local/include /usr/local/include/ffi /usr/include /usr/include/ffi"
156    for d in $l; do if test -r "$d/ffi.h"; then
157	tcl_cv_path_ffi_h="$d"; break; fi; done])
158if test -n "$tcl_cv_path_ffi_h"; then
159    TEA_ADD_INCLUDES([-I$tcl_cv_path_ffi_h])
160else
161    AC_MSG_ERROR([ffi.h not found!])
162fi
163
164AC_ARG_WITH(libffi-lib,
165    AC_HELP_STRING([--with-libffi-lib],
166	[directory containing libffi library]),
167    [with_libffi_lib=${withval}])
168AC_CACHE_CHECK([for directory with libffi library], tcl_cv_path_libffi, [
169    l="$with_libffi_lib $exec_prefix/lib $prefix/lib /usr/local/lib /usr/lib"
170    for d in $l; do if test -r "$d/libffi.dylib" -o -r "$d/libffi.a"; then
171	tcl_cv_path_libffi="$d"; break; fi; done])
172if test "$tcl_cv_path_libffi" != "built-in"; then
173    TEA_ADD_LIBS([-L$tcl_cv_path_libffi -lffi])
174else
175    AC_MSG_ERROR([libffi not found!])
176fi
177
178AC_MSG_CHECKING([whether to implement callbacks])
179AC_ARG_ENABLE(callbacks, 
180    AC_HELP_STRING([--enable-callbacks],
181        [implement callbacks, if possible (default: on)]), 
182    [tcl_ok=$enableval], [tcl_ok=yes])
183AC_MSG_RESULT([$tcl_ok])
184if test "$tcl_ok" = "yes"; then
185    AC_DEFINE(USE_CALLBACKS, 1, [Implement callbacks])
186fi
187
188AC_MSG_CHECKING([whether to build ffidl test functions])
189AC_ARG_ENABLE(test, 
190    AC_HELP_STRING([--enable-test],
191        [build ffidl test functions (default: off)]), 
192    [tcl_ok=$enableval], [tcl_ok=no])
193AC_MSG_RESULT([$tcl_ok])
194if test "$tcl_ok" = "yes"; then
195    TEA_ADD_SOURCES([ffidl_test.c])
196    FFIDL_TEST=1
197fi
198AC_SUBST(FFIDL_TEST)
199
200AC_C_CHAR_UNSIGNED
201AC_CHECK_SIZEOF(char)
202AC_CHECK_ALIGNOF(char)
203AC_CHECK_SIZEOF(short)
204AC_CHECK_ALIGNOF(short)
205AC_CHECK_SIZEOF(int)
206AC_CHECK_ALIGNOF(int)
207AC_CHECK_SIZEOF(long)
208AC_CHECK_ALIGNOF(long)
209AC_CHECK_TYPES(long long)
210AC_CHECK_SIZEOF(long long)
211AC_CHECK_ALIGNOF(long long)
212AC_CHECK_SIZEOF(float)
213AC_CHECK_ALIGNOF(float)
214AC_CHECK_SIZEOF(double)
215AC_CHECK_ALIGNOF(double)
216AC_C_LONG_DOUBLE
217AC_CHECK_SIZEOF(long double)
218AC_CHECK_ALIGNOF(long double)
219AC_CHECK_SIZEOF(void *)
220AC_CHECK_ALIGNOF(void *)
221
222AC_CANONICAL_HOST
223eval AC_DEFINE_UNQUOTED(CANONICAL_HOST, "${host}", 
224    [Canonical host name])
225
226#--------------------------------------------------------------------
227# Check whether --enable-threads or --disable-threads was given.
228# This auto-enables if Tcl was compiled threaded.
229#--------------------------------------------------------------------
230
231TEA_ENABLE_THREADS
232
233#--------------------------------------------------------------------
234# The statement below defines a collection of symbols related to
235# building as a shared library instead of a static library.
236#--------------------------------------------------------------------
237
238TEA_ENABLE_SHARED
239
240#--------------------------------------------------------------------
241# This macro figures out what flags to use with the compiler/linker
242# when building shared/static debug/optimized objects.  This information
243# can be taken from the tclConfig.sh file, but this figures it all out.
244#--------------------------------------------------------------------
245
246TEA_CONFIG_CFLAGS
247
248#--------------------------------------------------------------------
249# Set the default compiler switches based on the --enable-symbols option.
250#--------------------------------------------------------------------
251
252TEA_ENABLE_SYMBOLS
253
254#--------------------------------------------------------------------
255# Everyone should be linking against the Tcl stub library.  If you
256# can't for some reason, remove this definition.  If you aren't using
257# stubs, you also need to modify the SHLIB_LD_LIBS setting below to
258# link against the non-stubbed Tcl library.  Add Tk too if necessary.
259#--------------------------------------------------------------------
260
261AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs])
262
263#--------------------------------------------------------------------
264# This macro generates a line to use when building a library.  It
265# depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS,
266# and TEA_LOAD_TCLCONFIG macros above.
267#--------------------------------------------------------------------
268
269TEA_MAKE_LIB
270
271#--------------------------------------------------------------------
272# Determine the name of the tclsh and/or wish executables in the
273# Tcl and Tk build directories or the location they were installed
274# into. These paths are used to support running test cases only,
275# the Makefile should not be making use of these paths to generate
276# a pkgIndex.tcl file or anything else at extension build time.
277#--------------------------------------------------------------------
278
279TEA_PROG_TCLSH
280
281#--------------------------------------------------------------------
282# Finally, substitute all of the various values into the Makefile.
283# You may alternatively have a special pkgIndex.tcl.in or other files
284# which require substituting th AC variables in.  Include these here.
285#--------------------------------------------------------------------
286
287AC_OUTPUT([GNUmakefile pkgIndex.tcl])
288