1dnl $Id: configure.in,v 1.1 2000/11/03 00:27:15 idiscovery Exp $
2dnl	This file is an input file used by the GNU "autoconf" program to
3dnl	generate the file "configure", which is run to configure the
4dnl	Makefile in this directory.
5
6AC_INIT(../../generic/tixInit.c)
7
8#--------------------------------------------------------------------
9#	Remove the ./config.cache file and rerun configure if
10#	the cache file belong to a different architecture
11#----------------------------------------------------------------------
12AC_CHECK_PROG(UNAME, uname -a, [uname -a], "")
13if test "$UNAME" = ""; then
14    AC_CHECK_PROG(UNAME, uname, [uname], "")
15fi
16
17if test "$UNAME" != ""; then
18    uname=`$UNAME`
19    AC_MSG_CHECKING([cached value of \$uname])
20    AC_CACHE_VAL(ac_cv_prog_uname, [nocached=1 ac_cv_prog_uname=`$UNAME`])
21    if test "$nocached" = "1"; then
22	AC_MSG_RESULT(no)
23    else
24	AC_MSG_RESULT(yes)
25    fi
26
27    if test "$uname" != "$ac_cv_prog_uname"; then
28        echo "Running on a different machine/architecture. Can't use cached values"
29	echo "Removing config.cache and running configure again ..."
30	rm -f config.cache
31        CMDLINE="$0 $*"
32	exec $CMDLINE
33    fi
34fi
35
36#----------------------------------------------------------------------
37# We don't want to use any relative path because we need to generate
38# Makefile's in subdirectories
39#----------------------------------------------------------------------
40if test "$INSTALL" = "./install.sh"; then
41    INSTALL=`pwd`/install.sh
42fi
43
44# Itcl version number.
45ITCL_VERSION=3.1
46ITCL_MAJOR_VERSION=3
47ITCL_MINOR_VERSION=2
48
49#--------------------------------------------------------------------
50#	Version information about this TIX release.
51#--------------------------------------------------------------------
52
53TIX_VERSION=8.1
54TIX_MAJOR_VERSION=8
55TIX_MINOR_VERSION=1
56
57#--------------------------------------------------------------------
58#	See if user wants to use gcc to compile Tix. This option must
59#	be used before any checking that uses the C compiler.
60#--------------------------------------------------------------------
61
62AC_ARG_ENABLE(gcc, [  --enable-gcc            allow use of gcc if available],
63    [tix_ok=$enableval], [tix_ok=no])
64if test "$tix_ok" = "yes"; then
65    AC_PROG_CC
66else
67    CC=${CC-cc}
68AC_SUBST(CC)
69fi
70
71AC_PROG_INSTALL
72AC_PROG_RANLIB
73AC_HAVE_HEADERS(unistd.h limits.h)
74AC_PROG_MAKE_SET
75
76#--------------------------------------------------------------------
77#	unsigned char is not supported by some non-ANSI compilers.
78#--------------------------------------------------------------------
79
80AC_MSG_CHECKING([unsigned char])
81AC_TRY_COMPILE([#include <stdio.h>],[
82     unsigned char c = 'c';
83], tcl_ok=supported, tcl_ok=notsupported)
84
85AC_MSG_RESULT($tcl_ok)
86if test $tcl_ok = supported; then
87    AC_DEFINE(UCHAR_SUPPORTED)
88fi
89
90#--------------------------------------------------------------------
91#	Check whether there is an strcasecmp function on this system.
92#	This is a bit tricky because under SCO it's in -lsocket and
93#	under Sequent Dynix it's in -linet.
94#--------------------------------------------------------------------
95
96AC_CHECK_FUNC(strcasecmp, tcl_ok=1, tcl_ok=0)
97if test "$tcl_ok" = 0; then
98    AC_CHECK_LIB(socket, strcasecmp, tcl_ok=1, tcl_ok=0)
99fi
100if test "$tcl_ok" = 0; then
101    AC_CHECK_LIB(inet, strcasecmp, tcl_ok=1, tcl_ok=0)
102fi
103if test "$tcl_ok" = 0; then
104    AC_DEFINE(NO_STRCASECMP)
105fi
106
107#--------------------------------------------------------------------
108#	See if there was a command-line option for where ITcl is;  if
109#	not, assume that its top-level directory is a sibling of ours.
110#--------------------------------------------------------------------
111
112AC_ARG_WITH(itcl, [  --with-itcl=DIR           use ITcl 3.1 source from DIR],
113   val=$withval, val="")
114
115AC_MSG_CHECKING([ITcl source directory])
116
117if test "$val" != ""; then
118    ITCL_SRC_DIR=$val
119    if test ! -d $ITCL_SRC_DIR; then
120        AC_MSG_ERROR(Directory $ITCL_SRC_DIR doesn't exist)
121        AC_MSG_ERROR(Please install the source code of ITcl 3.1)
122        exit 1
123    fi
124else
125    dirs="../../../itcl3.1"
126    ITCL_SRC_DIR="no-no"
127    for i in $dirs; do
128        if test -d $i; then
129	    ITCL_SRC_DIR=`cd $i; pwd`
130        fi
131    done
132
133    if test ! -d $ITCL_SRC_DIR; then
134        AC_MSG_ERROR(Cannot locate ITcl source directory in $dirs)
135        AC_MSG_ERROR(Please install the source code of ITcl 3.1)
136        exit 1
137    fi
138fi
139AC_MSG_RESULT($ITCL_SRC_DIR)
140
141ITCL_ROOT_DIR=$ITCL_SRC_DIR
142
143# Check for Tcl and Tk.
144CYG_AC_PATH_TCLCONFIG
145CYG_AC_LOAD_TCLCONFIG
146CYG_AC_PATH_TKCONFIG
147CYG_AC_LOAD_TKCONFIG
148CYG_AC_PATH_TCLH
149# FIXME: consider only doing this if --with-x given.
150CYG_AC_PATH_TKH
151
152BIN_VERSION=${TIX_VERSION}.${TCL_VERSION}
153VERSION=${BIN_VERSION}
154
155#--------------------------------------------------------------------
156#	Find out the top level source directory of the Tix package.
157#--------------------------------------------------------------------
158TIX_SRC_DIR=`cd ${srcdir}/../..; pwd`
159
160#--------------------------------------------------------------------
161#	See if we should compile SAM
162#--------------------------------------------------------------------
163
164AC_ARG_ENABLE(sam,
165    [  --enable-sam            build stand-alone modules],
166    [ok=$enableval], [ok=no])
167
168if test "$ok" = "yes"; then
169    TIX_BUILD_SAM="yes"
170    TIX_SAM_TARGETS='$(SAM_TARGETS)'
171else
172    TIX_BUILD_SAM="no"
173fi
174
175	    TIX_SAM_INSTALL=_install_sam_lib_
176
177AC_DEFINE(ITCL_2)
178AC_DEFINE(ITCL_3)
179IS_ITCL=1
180TIX_EXE_FILE=tixwish
181TCL_SAMEXE_FILE=satclsh
182TK_SAMEXE_FILE=sawish
183TIX_SAMEXE_FILE=satixwish
184
185#--------------------------------------------------------------------
186#	Read in configuration information generated by Tcl for shared
187#	libraries, and arrange for it to be substituted into our
188#	Makefile.
189#--------------------------------------------------------------------
190
191CC=$TCL_CC
192SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
193SHLIB_LD=$TCL_SHLIB_LD
194SHLIB_LD_LIBS=$TCL_SHLIB_LD_LIBS
195SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
196SHLIB_VERSION=$TCL_SHLIB_VERSION
197
198DL_LIBS=$TCL_DL_LIBS
199LD_FLAGS=$TCL_LD_FLAGS
200TIX_LD_SEARCH_FLAGS=$TK_LD_SEARCH_FLAGS
201
202#--------------------------------------------------------------------
203#	Read in configuration information generated by Tk and arrange
204#	for it to be substituted into our Makefile.
205#--------------------------------------------------------------------
206
207TIX_DEFS="$TK_DEFS $TCL_DEFS"
208
209# Note:  in the following variable, it's important to use the absolute
210# path name of the Tcl directory rather than "..":  this is because
211# AIX remembers this path and will attempt to use it at run-time to look
212# up the Tcl library.
213
214if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
215    TIX_BUILD_LIB_SPEC="-L`pwd` -ltix${VERSION}"
216    TIX_BUILD_SAM_SPEC="-L`pwd` -ltixsam${VERSION}"
217    TCL_BUILD_SAM_SPEC="-L`pwd` -ltclsam${TCL_VERSION}"
218    TK_BUILD_SAM_SPEC="-L`pwd` -ltksam${TK_VERSION}"
219    TIX_LIB_SPEC="-L${exec_prefix}/lib -ltix${VERSION}"
220else
221    TIX_BUILD_LIB_SPEC="-L`pwd` -ltix`echo ${VERSION} | tr -d .`"
222    TIX_BUILD_SAM_SPEC="-L`pwd` -ltixsam`echo ${VERSION} | tr -d .`"
223    TCL_BUILD_SAM_SPEC="-L`pwd` -ltclsam`echo ${TCL_VERSION} | tr -d .`"
224    TK_BUILD_SAM_SPEC="-L`pwd` -ltksam`echo ${TK_VERSION} | tr -d .`"
225    TIX_LIB_SPEC="-L${exec_prefix}/lib -ltix`echo ${VERSION} | tr -d .`"
226fi
227
228#--------------------------------------------------------------------
229#	See if we should compile shared library.
230#--------------------------------------------------------------------
231
232AC_ARG_ENABLE(shared,
233    [  --enable-shared         build libtix as a shared library],
234    [ok=$enableval], [ok=no])
235
236if test "$ok" = "yes" -a "${SHLIB_SUFFIX}" != ""; then
237    TIX_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
238    TIX_RANLIB=":"
239
240    # The main Tix library
241    #
242    eval "TIX_LIB_FILE=libtix${TCL_SHARED_LIB_SUFFIX}"
243    TIX_MAKE_LIB="\${SHLIB_LD} -o ${TIX_LIB_FILE} \${OBJS} ${SHLIB_LD_LIBS}"
244
245    # The Tcl SAM library
246    #
247    VERSION=${TCL_VERSION}
248    eval "TCL_SAM_FILE=libtclsam${TCL_SHARED_LIB_SUFFIX}"
249    TCL_MAKE_SAM="\${SHLIB_LD} -o ${TCL_SAM_FILE} \${TCL_SAM_OBJS} ${SHLIB_LD_LIBS}"
250
251    # The Tk SAM library
252    #
253    VERSION=${TCL_VERSION}
254    eval "TK_SAM_FILE=libtksam${TCL_SHARED_LIB_SUFFIX}"
255    TK_MAKE_SAM="\${SHLIB_LD} -o ${TK_SAM_FILE} \${TK_SAM_OBJS} ${SHLIB_LD_LIBS}"
256
257    # The Tix SAM library
258    #
259    VERSION=${BIN_VERSION}
260    eval "TIX_SAM_FILE=libtixsam${TCL_SHARED_LIB_SUFFIX}"
261    TIX_MAKE_SAM="\${SHLIB_LD} -o ${TIX_SAM_FILE} \${TIX_SAM_OBJS} ${SHLIB_LD_LIBS}"
262
263else
264    TIX_SHLIB_CFLAGS=""
265    TIX_RANLIB='$(RANLIB)'
266
267    # The main Tix library
268    #
269    eval "TIX_LIB_FILE=libtix${TCL_UNSHARED_LIB_SUFFIX}"
270    TIX_MAKE_LIB="ar cr ${TIX_LIB_FILE} \${OBJS}"
271
272    # The Tcl SAM library
273
274    VERSION=${TCL_VERSION}
275    eval "TCL_SAM_FILE=libtclsam${TCL_UNSHARED_LIB_SUFFIX}"
276    TCL_MAKE_SAM="ar cr ${TCL_SAM_FILE} \${TCL_SAM_OBJS}"
277
278    # The Tk SAM library
279    #
280    VERSION=${TCL_VERSION}
281    eval "TK_SAM_FILE=libtksam${TCL_UNSHARED_LIB_SUFFIX}"
282    TK_MAKE_SAM="ar cr ${TK_SAM_FILE} \${TK_SAM_OBJS}"
283
284    # The Tix SAM library
285    #
286    VERSION=${BIN_VERSION}
287    eval "TIX_SAM_FILE=libtixsam${TCL_UNSHARED_LIB_SUFFIX}"
288    TIX_MAKE_SAM="ar cr ${TIX_SAM_FILE} \${TIX_SAM_OBJS}"
289fi
290
291ITCL_LIB_FILE=libitcl${ITCL_VERSION}.a
292ITCL_BUILD_LIB_SPEC='-L$(ITCL_ROOT_DIR)/itcl -litcl${ITCL_VERSION}'
293#--------------------------------------------------------------------
294#	Read in configuration information generated by ITcl
295#	and arrange for it to be substituted into our Makefile.
296#	This seems to be missing in itcl 3.1, so provide defaults
297#--------------------------------------------------------------------
298file=$ITCL_ROOT_DIR/itcl/unix/itclConfig.sh
299if test -f $file ; then
300. $file
301else
302echo "$file not found - using default library values..."
303fi
304
305ITK_LIB_FILE=libitk${ITCL_VERSION}.a
306ITK_BUILD_LIB_SPEC='-L$(ITCL_ROOT_DIR)/itk -litk${ITCL_VERSION}'
307#--------------------------------------------------------------------
308#	Read in configuration information generated by ITk
309#	and arrange for it to be substituted into our Makefile.
310#--------------------------------------------------------------------
311file=$ITCL_ROOT_DIR/itk/unix/itkConfig.sh
312if test -f $file ; then
313. $file
314else
315echo "$file not found - using default library values..."
316fi
317
318#--------------------------------------------------------------------
319#	Check for the existence of the -lsocket and -lnsl libraries.
320#	The order here is important, so that they end up in the right
321#	order in the command line generated by make.  Here are some
322#	special considerations:
323#	1. Use "connect" and "accept" to check for -lsocket, and
324#	   "gethostbyname" to check for -lnsl.
325#	2. Use each function name only once:  can't redo a check because
326#	   autoconf caches the results of the last check and won't redo it.
327#	3. Use -lnsl and -lsocket only if they supply procedures that
328#	   aren't already present in the normal libraries.  This is because
329#	   IRIX 5.2 has libraries, but they aren't needed and they're
330#	   bogus:  they goof up name resolution if used.
331#	4. On some SVR4 systems, can't use -lsocket without -lnsl too.
332#	   To get around this problem, check for both libraries together
333#	   if -lsocket doesn't work by itself.
334#--------------------------------------------------------------------
335
336checked=0
337for i in $TK_LIBS; do
338    if test "$i" = "-lsocket"; then
339	checked=1
340    fi
341done
342
343if test "$checked" = "0"; then
344    tcl_checkBoth=0
345    AC_CHECK_FUNC(connect, tcl_checkSocket=0, tcl_checkSocket=1)
346    if test "$tcl_checkSocket" = 1; then
347        AC_CHECK_LIB(socket, main, TK_LIBS="$TK_LIBS -lsocket",
348	    tcl_checkBoth=1)
349    fi
350    if test "$tcl_checkBoth" = 1; then
351        tk_oldLibs=$TK_LIBS
352        TK_LIBS="$TK_LIBS -lsocket -lnsl"
353        AC_CHECK_FUNC(accept, tcl_checkNsl=0, [TK_LIBS=$tk_oldLibs])
354    fi
355    AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main,
356        [TK_LIBS="$TK_LIBS -lnsl"]))
357fi
358
359#----------------------------------------------------------------------
360#	Substitution strings exported by TIX
361#----------------------------------------------------------------------
362AC_SUBST(SHELL)
363AC_SUBST(CC)
364AC_SUBST(RANLIB)
365AC_SUBST(TIX_RANLIB)
366AC_SUBST(SHLIB_CFLAGS)
367AC_SUBST(SHLIB_LD)
368AC_SUBST(SHLIB_LD_LIBS)
369AC_SUBST(SHLIB_SUFFIX)
370AC_SUBST(SHLIB_VERSION)
371AC_SUBST(DL_LIBS)
372AC_SUBST(LD_FLAGS)
373AC_SUBST(TCL_BUILD_LIB_SPEC)
374AC_SUBST(TCL_LIBS)
375AC_SUBST(TCL_VERSION)
376AC_SUBST(TCL_SRC_DIR)
377AC_SUBST(TCL_BIN_DIR)
378AC_SUBST(ITCL_BUILD_LIB_SPEC)
379AC_SUBST(TK_BUILD_LIB_SPEC)
380AC_SUBST(TK_LIBS)
381AC_SUBST(TK_VERSION)
382AC_SUBST(TK_SRC_DIR)
383AC_SUBST(TK_BIN_DIR)
384AC_SUBST(TK_XINCLUDES)
385AC_SUBST(ITK_BUILD_LIB_SPEC)
386AC_SUBST(TIX_LD_SEARCH_FLAGS)
387AC_SUBST(TIX_MAJOR_VERSION)
388AC_SUBST(TIX_MINOR_VERSION)
389AC_SUBST(TIX_VERSION)
390AC_SUBST(TIX_SRC_DIR)
391AC_SUBST(TIX_SHLIB_CFLAGS)
392AC_SUBST(TIX_MAKE_LIB)
393AC_SUBST(TIX_LIB_FILE)
394AC_SUBST(TIX_BUILD_LIB_SPEC)
395AC_SUBST(TIX_LIB_SPEC)
396AC_SUBST(TIX_EXE_FILE)
397AC_SUBST(TIX_SAM_TARGETS)
398AC_SUBST(TIX_SAM_INSTALL)
399AC_SUBST(TCL_SAM_FILE)
400AC_SUBST(TCL_MAKE_SAM)
401AC_SUBST(TK_SAM_FILE)
402AC_SUBST(TK_MAKE_SAM)
403AC_SUBST(TIX_SAM_FILE)
404AC_SUBST(TIX_MAKE_SAM)
405AC_SUBST(TIX_DEFS)
406AC_SUBST(ITCL_BUILD_LIB_SPEC)
407AC_SUBST(ITK_BUILD_LIB_SPEC)
408AC_SUBST(ITCL_VERSION)
409AC_SUBST(TCL_SAMEXE_FILE)
410AC_SUBST(TK_SAMEXE_FILE)
411AC_SUBST(TIX_SAMEXE_FILE)
412AC_SUBST(TCL_BUILD_SAM_SPEC)
413AC_SUBST(TK_BUILD_SAM_SPEC)
414AC_SUBST(TIX_BUILD_SAM_SPEC)
415AC_SUBST(TCL_PACKAGE_PATH)
416
417# The "binary version" of Tix (see docs/Pkg.txt)
418TIX_VERSION_PKG=${BIN_VERSION}
419AC_SUBST(TIX_VERSION_PKG)
420
421TIXSAM_PKG_FILE="[[file join [file dirname \$dir] ${TIX_SAM_FILE}]]"
422# Add this anyway as we are building the SAM library, and it wont hurt
423# if test "$TIX_BUILD_SAM" = "yes"; then
424    TIX_SAM_PACKAGE_IFNEEDED="package ifneeded Tixsam ${TIX_VERSION_PKG} [[list load \"${TIXSAM_PKG_FILE}\" Tixsam]]"
425# fi
426
427# The package file, usually a shared library
428TIX_PKG_FILE="[[file join [file dirname \$dir] ${TIX_LIB_FILE}]]"
429AC_SUBST(TIX_PKG_FILE)
430AC_SUBST(TIX_SAM_PACKAGE_IFNEEDED)
431
432AC_SUBST(ITCL_ROOT_DIR)
433
434AC_OUTPUT(Makefile pkgIndex.tcl ../../tixConfig.sh)
435
436