1#! /bin/bash -norc
2# This file is an input file used by the GNU "autoconf" program to
3# generate the file "configure", which is run during Tk installation
4# to configure the system for the local environment.
5#
6# RCS: @(#) $Id$
7
8AC_INIT(../generic/tk.h)
9AC_PREREQ(2.59)
10
11# The following define is needed when building with Cygwin since newer
12# versions of autoconf incorrectly set SHELL to /bin/bash instead of
13# /bin/sh. The bash shell seems to suffer from some strange failures.
14SHELL=/bin/sh
15
16TK_VERSION=8.5
17TK_MAJOR_VERSION=8
18TK_MINOR_VERSION=5
19TK_PATCH_LEVEL=".9"
20VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION
21
22#------------------------------------------------------------------------
23# Handle the --prefix=... option
24#------------------------------------------------------------------------
25
26if test "${prefix}" = "NONE"; then
27    prefix=/usr/local
28fi
29if test "${exec_prefix}" = "NONE"; then
30    exec_prefix=$prefix
31fi
32# libdir must be a fully qualified path and (not ${exec_prefix}/lib)
33eval libdir="$libdir"
34
35#------------------------------------------------------------------------
36# Standard compiler checks
37#------------------------------------------------------------------------
38
39# If the user did not set CFLAGS, set it now to keep
40# the AC_PROG_CC macro from adding "-g -O2".
41if test "${CFLAGS+set}" != "set" ; then
42    CFLAGS=""
43fi
44
45AC_PROG_CC
46AC_C_INLINE
47AC_HEADER_STDC
48
49# To properly support cross-compilation, one would
50# need to use these tool checks instead of
51# the ones below and reconfigure with
52# autoconf 2.50. You can also just set
53# the CC, AR, RANLIB, and RC environment
54# variables if you want to cross compile.
55dnl AC_CHECK_TOOL(AR, ar)
56dnl AC_CHECK_TOOL(RANLIB, ranlib)
57dnl AC_CHECK_TOOL(RC, windres)
58
59if test "${GCC}" = "yes" ; then
60    AC_CHECK_PROG(AR, ar, ar)
61    AC_CHECK_PROG(RANLIB, ranlib, ranlib)
62    AC_CHECK_PROG(RC, windres, windres)
63
64    if test "${AR}" = "" ; then
65	AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
66    fi
67    if test "${RANLIB}" = "" ; then
68	AC_MSG_ERROR([Required archive index tool 'ranlib' not found on PATH.])
69    fi
70    if test "${RC}" = "" ; then
71	AC_MSG_ERROR([Required resource tool 'windres' not found on PATH.])
72    fi
73fi
74
75#--------------------------------------------------------------------
76# Checks to see if the make progeam sets the $MAKE variable.
77#--------------------------------------------------------------------
78
79AC_PROG_MAKE_SET
80
81#--------------------------------------------------------------------
82# Perform additinal compiler tests.
83#--------------------------------------------------------------------
84
85dnl Currently AC_CYGWIN is disabled since it invokes AC_CANONICAL_HOST
86dnl under autoconf 2.5X.
87dnl
88dnl AC_CYGWIN
89
90AC_CACHE_CHECK(for Cygwin version of gcc,
91    ac_cv_cygwin,
92AC_TRY_COMPILE([
93#ifdef __CYGWIN__
94#error cygwin
95#endif
96],
97[],
98        ac_cv_cygwin=no,
99        ac_cv_cygwin=yes)
100)
101if test "$ac_cv_cygwin" = "yes" ; then
102    AC_MSG_ERROR([Compiling under Cygwin is not currently supported.
103A maintainer for the Cygwin port of Tcl/Tk is needed. See the README
104file for information about building with Mingw.])
105fi
106
107#--------------------------------------------------------------------
108# Determines the correct binary file extension (.o, .obj, .exe etc.)
109#--------------------------------------------------------------------
110
111AC_OBJEXT
112AC_EXEEXT
113
114#--------------------------------------------------------------------
115# Check whether --enable-threads or --disable-threads was given.
116#--------------------------------------------------------------------
117
118SC_ENABLE_THREADS
119
120#--------------------------------------------------------------------
121# The statements below define a collection of symbols related to
122# building libtk as a shared library instead of a static library.
123#--------------------------------------------------------------------
124
125SC_ENABLE_SHARED
126
127#--------------------------------------------------------------------
128# The statements below define a collection of compile flags.  This 
129# macro depends on the value of SHARED_BUILD, and should be called
130# after SC_ENABLE_SHARED checks the configure switches.
131#--------------------------------------------------------------------
132
133SC_CONFIG_CFLAGS
134
135#--------------------------------------------------------------------
136# man2tcl needs this so that it can use errno.h
137#--------------------------------------------------------------------
138
139AC_CHECK_HEADER(errno.h, , MAN2TCLFLAGS="-DNO_ERRNO_H")
140AC_SUBST(MAN2TCLFLAGS)
141
142#--------------------------------------------------------------------
143# Windows XP theme engine header for Ttk
144#--------------------------------------------------------------------
145
146AC_CHECK_HEADER([uxtheme.h], [AC_DEFINE(HAVE_UXTHEME_H)],
147	[AC_MSG_NOTICE([xpnative theme will be unavailable])],
148	[#include <windows.h>])
149
150#--------------------------------------------------------------------
151# Set the default compiler switches based on the --enable-symbols 
152# option.  This macro depends on C flags, and should be called
153# after SC_CONFIG_CFLAGS macro is called.
154#--------------------------------------------------------------------
155
156SC_ENABLE_SYMBOLS
157
158TK_DBGX=${DBGX}
159
160#--------------------------------------------------------------------
161# Embed the manifest if we can determine how
162#--------------------------------------------------------------------
163
164SC_EMBED_MANIFEST(wish.exe.manifest)
165
166#--------------------------------------------------------------------
167# Locate and source the tclConfig.sh file.
168#--------------------------------------------------------------------
169
170SC_PATH_TCLCONFIG($TK_PATCH_LEVEL)
171SC_LOAD_TCLCONFIG
172
173SC_BUILD_TCLSH
174SC_PROG_TCLSH
175
176#------------------------------------------------------------------------
177# tkConfig.sh refers to this by a different name
178#------------------------------------------------------------------------
179
180TK_SHARED_BUILD=${SHARED_BUILD}
181
182#--------------------------------------------------------------------
183# Perform final evaluations of variables with possible substitutions.
184#--------------------------------------------------------------------
185
186TK_SHARED_LIB_SUFFIX="\${NODOT_VERSION}${DLLSUFFIX}"
187TK_UNSHARED_LIB_SUFFIX="\${NODOT_VERSION}${LIBSUFFIX}"
188TK_EXPORT_FILE_SUFFIX="\${NODOT_VERSION}${LIBSUFFIX}"
189
190eval "TK_SRC_DIR=\"`cd $srcdir/..; pwd`\""
191
192eval "TK_DLL_FILE=tk$VER${DLLSUFFIX}"
193eval "TK_LIB_FILE=${LIBPREFIX}tk$VER${LIBSUFFIX}"
194
195eval "TK_STUB_LIB_FILE=${LIBPREFIX}tkstub${VER}${LIBSUFFIX}"
196# FIXME: All of this var junk needs to be done in tcl.m4 !!!!
197# I left out the other vars that also need to get defined here.
198# we also need to double check about spaces in path names
199eval "TK_LIB_FLAG=\"-ltk${VER}${LIBFLAGSUFFIX}\""
200TK_LIB_SPEC="-L${libdir} ${TK_LIB_FLAG}"
201TK_BUILD_LIB_SPEC="-L`pwd` ${TK_LIB_FLAG}"
202
203eval "TK_STUB_LIB_FLAG=\"-ltkstub${VER}${LIBFLAGSUFFIX}\""
204TK_BUILD_STUB_LIB_SPEC="-L`pwd` ${TK_STUB_LIB_FLAG}"
205
206TK_STUB_LIB_SPEC="-L${libdir} ${TK_STUB_LIB_FLAG}"
207TK_STUB_LIB_PATH="${libdir}/${TK_STUB_LIB_FILE}"
208TK_BUILD_STUB_LIB_PATH="`pwd`/${TK_STUB_LIB_FILE}"
209
210eval "DLLSUFFIX=${DLLSUFFIX}"
211eval "LIBPREFIX=${LIBPREFIX}"
212eval "LIBSUFFIX=${LIBSUFFIX}"
213eval "EXESUFFIX=${EXESUFFIX}"
214
215CFG_TK_SHARED_LIB_SUFFIX=${TK_SHARED_LIB_SUFFIX}
216CFG_TK_UNSHARED_LIB_SUFFIX=${TK_UNSHARED_LIB_SUFFIX}
217CFG_TK_EXPORT_FILE_SUFFIX=${TK_EXPORT_FILE_SUFFIX}
218
219#--------------------------------------------------------------------
220# Adjust the defines for how the resources are built depending
221# on symbols and static vs. shared.
222#--------------------------------------------------------------------
223
224if test "$SHARED_BUILD" = 0 -o "$TCL_NEEDS_EXP_FILE" = 0; then
225    if test "${DBGX}" = "d"; then
226        RC_DEFINES="${RC_DEFINE} STATIC_BUILD ${RC_DEFINE} DEBUG"
227    else
228        RC_DEFINES="${RC_DEFINE} STATIC_BUILD"
229    fi
230    TK_RES=""
231else
232    if test "${DBGX}" = "d"; then
233        RC_DEFINES="${RC_DEFINE} DEBUG"
234    else
235        RC_DEFINES=""
236    fi
237    TK_RES='tk.$(RES)'
238fi
239
240# The wish.exe.manifest requires these
241# TK_WIN_VERSION is the 4 dotted pair Windows version format which needs
242# the release level, and must account for interim release versioning
243case "$TK_PATCH_LEVEL" in
244     *a*) TK_RELEASE_LEVEL=0 ;;
245     *b*) TK_RELEASE_LEVEL=1 ;;
246     *)   TK_RELEASE_LEVEL=2 ;;
247esac
248TK_WIN_VERSION="$TK_VERSION.$TK_RELEASE_LEVEL.`echo $TK_PATCH_LEVEL | tr -d ab.`"
249AC_SUBST(TK_WIN_VERSION)
250# X86|AMD64|IA64 for manifest
251AC_SUBST(MACHINE)
252
253AC_SUBST(TK_VERSION)
254AC_SUBST(TK_MAJOR_VERSION)
255AC_SUBST(TK_MINOR_VERSION)
256AC_SUBST(TK_PATCH_LEVEL)
257AC_SUBST(TK_DBGX)
258AC_SUBST(TK_LIB_FILE)
259AC_SUBST(TK_DLL_FILE)
260AC_SUBST(TK_STUB_LIB_FILE)
261AC_SUBST(TK_STUB_LIB_FLAG)
262AC_SUBST(TK_BUILD_STUB_LIB_SPEC)
263AC_SUBST(TK_SRC_DIR)
264AC_SUBST(TK_BIN_DIR)
265
266AC_SUBST(TCL_VERSION)
267AC_SUBST(TCL_MAJOR_VERSION)
268AC_SUBST(TCL_MINOR_VERSION)
269AC_SUBST(TCL_PATCH_LEVEL)
270AC_SUBST(TCL_SRC_DIR)
271AC_SUBST(TCL_BIN_DIR)
272AC_SUBST(TCL_DBGX)
273AC_SUBST(CFG_TK_SHARED_LIB_SUFFIX)
274AC_SUBST(CFG_TK_UNSHARED_LIB_SUFFIX)
275AC_SUBST(CFG_TK_EXPORT_FILE_SUFFIX)
276AC_SUBST(TK_SHARED_BUILD)
277
278AC_SUBST(CYGPATH)
279AC_SUBST(DEPARG)
280AC_SUBST(CFLAGS_DEFAULT)
281AC_SUBST(EXTRA_CFLAGS)
282AC_SUBST(STLIB_LD)
283AC_SUBST(SHLIB_LD)
284AC_SUBST(SHLIB_LD_LIBS)
285AC_SUBST(SHLIB_CFLAGS)
286AC_SUBST(SHLIB_SUFFIX)
287AC_SUBST(CC_OBJNAME)
288AC_SUBST(CC_EXENAME)
289AC_SUBST(LDFLAGS_DEFAULT)
290AC_SUBST(LDFLAGS_DEBUG)
291AC_SUBST(LDFLAGS_OPTIMIZE)
292AC_SUBST(LDFLAGS_CONSOLE)
293AC_SUBST(LDFLAGS_WINDOW)
294AC_SUBST(AR)
295AC_SUBST(RANLIB)
296AC_SUBST(RC)
297AC_SUBST(RC_OUT)
298AC_SUBST(RC_TYPE)
299AC_SUBST(RC_INCLUDE)
300AC_SUBST(RC_DEFINE)
301AC_SUBST(RC_DEFINES)
302AC_SUBST(TK_RES)
303AC_SUBST(RES)
304AC_SUBST(LIBS)
305AC_SUBST(LIBS_GUI)
306AC_SUBST(DLLSUFFIX)
307AC_SUBST(LIBPREFIX)
308AC_SUBST(LIBSUFFIX)
309AC_SUBST(EXESUFFIX)
310AC_SUBST(LIBRARIES)
311AC_SUBST(MAKE_LIB)
312AC_SUBST(POST_MAKE_LIB)
313AC_SUBST(MAKE_DLL)
314AC_SUBST(MAKE_EXE)
315
316AC_SUBST(TK_LIB_FLAG)
317AC_SUBST(TK_LIB_SPEC)
318AC_SUBST(TK_BUILD_LIB_SPEC)
319AC_SUBST(TK_STUB_LIB_SPEC)
320AC_SUBST(TK_STUB_LIB_PATH)
321AC_SUBST(TK_BUILD_STUB_LIB_PATH)
322
323# undefined at this point for win
324AC_SUBST(TK_CC_SEARCH_FLAGS)
325AC_SUBST(TK_LD_SEARCH_FLAGS)
326
327AC_OUTPUT([Makefile tkConfig.sh wish.exe.manifest])
328