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.106.2.43 2008/04/11 16:57:41 dgp Exp $
7
8AC_INIT(../generic/tcl.h)
9AC_PREREQ(2.13)
10
11TCL_VERSION=8.4
12TCL_MAJOR_VERSION=8
13TCL_MINOR_VERSION=4
14TCL_PATCH_LEVEL=".19"
15VERSION=${TCL_VERSION}
16
17#------------------------------------------------------------------------
18# Handle the --prefix=... option
19#------------------------------------------------------------------------
20
21if test "${prefix}" = "NONE"; then
22    prefix=/usr/local
23fi
24if test "${exec_prefix}" = "NONE"; then
25    exec_prefix=$prefix
26fi
27# Make sure srcdir is fully qualified!
28srcdir=`cd $srcdir ; pwd`
29TCL_SRC_DIR=`cd $srcdir/..; pwd`
30
31#------------------------------------------------------------------------
32# Compress and/or soft link the manpages?
33#------------------------------------------------------------------------
34
35SC_CONFIG_MANPAGES([tcl])
36
37#------------------------------------------------------------------------
38# Standard compiler checks
39#------------------------------------------------------------------------
40
41# If the user did not set CFLAGS, set it now to keep
42# the AC_PROG_CC macro from adding "-g -O2".
43if test "${CFLAGS+set}" != "set" ; then
44    CFLAGS=""
45fi
46
47AC_PROG_CC
48
49#--------------------------------------------------------------------
50# Supply substitutes for missing POSIX header files.  Special notes:
51#	- stdlib.h doesn't define strtol, strtoul, or
52#	  strtod insome versions of SunOS
53#	- some versions of string.h don't declare procedures such
54#	  as strstr
55# Do this early, otherwise an autoconf bug throws errors on configure
56#--------------------------------------------------------------------
57
58SC_MISSING_POSIX_HEADERS
59
60#------------------------------------------------------------------------
61# If we're using GCC, see if the compiler understands -pipe.  If so, use it.
62# It makes compiling go faster.  (This is only a performance feature.)
63#------------------------------------------------------------------------
64
65if test -z "$no_pipe" && test -n "$GCC"; then
66    AC_CACHE_CHECK([if the compiler understands -pipe],
67	tcl_cv_cc_pipe, [
68	hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe"
69	AC_TRY_COMPILE(,, tcl_cv_cc_pipe=yes, tcl_cv_cc_pipe=no)
70	CFLAGS=$hold_cflags])
71    if test $tcl_cv_cc_pipe = yes; then
72	CFLAGS="$CFLAGS -pipe"
73    fi
74fi
75
76#------------------------------------------------------------------------
77# Threads support
78#------------------------------------------------------------------------
79
80SC_ENABLE_THREADS
81
82#--------------------------------------------------------------------
83# Look for libraries that we will need when compiling the Tcl shell
84#--------------------------------------------------------------------
85
86SC_TCL_LINK_LIBS
87
88# Add the threads support libraries
89LIBS="$LIBS$THREADS_LIBS"
90
91SC_ENABLE_SHARED
92
93#--------------------------------------------------------------------
94# The statements below define a collection of compile flags.  This
95# macro depends on the value of SHARED_BUILD, and should be called
96# after SC_ENABLE_SHARED checks the configure switches.
97#--------------------------------------------------------------------
98
99SC_CONFIG_CFLAGS
100
101SC_ENABLE_SYMBOLS
102
103TCL_DBGX=${DBGX}
104
105#--------------------------------------------------------------------
106#	Detect what compiler flags to set for 64-bit support.
107#--------------------------------------------------------------------
108
109SC_TCL_EARLY_FLAGS
110
111SC_TCL_64BIT_FLAGS
112
113#--------------------------------------------------------------------
114#	Check endianness because we can optimize comparisons of
115#	Tcl_UniChar strings to memcmp on big-endian systems.
116#--------------------------------------------------------------------
117
118AC_C_BIGENDIAN
119
120#--------------------------------------------------------------------
121#	Supply substitutes for missing POSIX library procedures, or
122#	set flags so Tcl uses alternate procedures.
123#--------------------------------------------------------------------
124
125# Check if Posix compliant getcwd exists, if not we'll use getwd.
126AC_CHECK_FUNCS(getcwd, , [AC_DEFINE(USEGETWD)])
127# Nb: if getcwd uses popen and pwd(1) (like SunOS 4) we should really
128# define USEGETWD even if the posix getcwd exists. Add a test ?
129
130AC_REPLACE_FUNCS(opendir strstr strtol strtoll strtoull tmpnam waitpid)
131AC_CHECK_FUNC(strerror, , [AC_DEFINE(NO_STRERROR)])
132AC_CHECK_FUNC(getwd, , [AC_DEFINE(NO_GETWD)])
133AC_CHECK_FUNC(wait3, , [AC_DEFINE(NO_WAIT3)])
134AC_CHECK_FUNC(uname, , [AC_DEFINE(NO_UNAME)])
135
136if test "`uname -s`" = "Darwin" && test "${TCL_THREADS}" = 1 && \
137	test "`uname -r | awk -F. '{print [$]1}'`" -lt 7; then
138    # prior to Darwin 7, realpath is not threadsafe, so don't
139    # use it when threads are enabled, c.f. bug # 711232
140    ac_cv_func_realpath=no
141fi
142AC_CHECK_FUNC(realpath, , [AC_DEFINE(NO_REALPATH)])
143
144#--------------------------------------------------------------------
145#	Look for thread-safe variants of some library functions.
146#--------------------------------------------------------------------
147
148if test "${TCL_THREADS}" = 1; then
149    SC_TCL_GETPWUID_R
150    SC_TCL_GETPWNAM_R
151    SC_TCL_GETGRGID_R
152    SC_TCL_GETGRNAM_R
153    if test "`uname -s`" = "Darwin" && \
154	    test "`uname -r | awk -F. '{print [$]1}'`" -gt 5; then
155	# Starting with Darwin 6 (Mac OSX 10.2), gethostbyX 
156	# are actually MT-safe as they always return pointers
157	# from the TSD instead of the static storage.
158	AC_DEFINE(HAVE_MTSAFE_GETHOSTBYNAME)
159	AC_DEFINE(HAVE_MTSAFE_GETHOSTBYADDR)
160    elif test "`uname -s`" = "HP-UX" && \
161	      test "`uname -r|sed -e 's|B\.||' -e 's|\..*$||'`" -gt 10; then
162        # Starting with HPUX 11.00 (we believe), gethostbyX
163        # are actually MT-safe as they always return pointers
164	# from TSD instead of static storage.
165	AC_DEFINE(HAVE_MTSAFE_GETHOSTBYNAME)
166	AC_DEFINE(HAVE_MTSAFE_GETHOSTBYADDR)
167    else
168	SC_TCL_GETHOSTBYNAME_R
169	SC_TCL_GETHOSTBYADDR_R
170    fi
171fi
172
173#---------------------------------------------------------------------------
174#	Determine which interface to use to talk to the serial port.
175#	Note that #include lines must begin in leftmost column for
176#	some compilers to recognize them as preprocessor directives.
177#---------------------------------------------------------------------------
178
179SC_SERIAL_PORT
180
181#--------------------------------------------------------------------
182#	Include sys/select.h if it exists and if it supplies things
183#	that appear to be useful and aren't already in sys/types.h.
184#	This appears to be true only on the RS/6000 under AIX.  Some
185#	systems like OSF/1 have a sys/select.h that's of no use, and
186#	other systems like SCO UNIX have a sys/select.h that's
187#	pernicious.  If "fd_set" isn't defined anywhere then set a
188#	special flag.
189#--------------------------------------------------------------------
190
191AC_CACHE_CHECK([for fd_set in sys/types], tcl_cv_type_fd_set, [
192    AC_TRY_COMPILE([#include <sys/types.h>],[fd_set readMask, writeMask;],
193	tcl_cv_type_fd_set=yes, tcl_cv_type_fd_set=no)])
194tcl_ok=$tcl_cv_type_fd_set
195if test $tcl_ok = no; then
196    AC_CACHE_CHECK([for fd_mask in sys/select], tcl_cv_grep_fd_mask, [
197	AC_EGREP_HEADER(fd_mask, sys/select.h,
198	     tcl_cv_grep_fd_mask=present, tcl_cv_grep_fd_mask=missing)])
199    if test $tcl_cv_grep_fd_mask = present; then
200	AC_DEFINE(HAVE_SYS_SELECT_H)
201	tcl_ok=yes
202    fi
203fi
204if test $tcl_ok = no; then
205    AC_DEFINE(NO_FD_SET)
206fi
207
208#------------------------------------------------------------------------------
209#       Find out all about time handling differences.
210#------------------------------------------------------------------------------
211
212SC_TIME_HANDLER
213
214#--------------------------------------------------------------------
215#	Some systems (e.g., IRIX 4.0.5) lack the st_blksize field
216#	in struct stat.  But we might be able to use fstatfs instead.
217#--------------------------------------------------------------------
218AC_STRUCT_ST_BLKSIZE
219AC_CHECK_FUNC(fstatfs, , [AC_DEFINE(NO_FSTATFS)])
220
221#--------------------------------------------------------------------
222#       Some system have no memcmp or it does not work with 8 bit
223#       data, this checks it and add memcmp.o to LIBOBJS if needed
224#--------------------------------------------------------------------
225AC_FUNC_MEMCMP
226
227#--------------------------------------------------------------------
228#       Some system like SunOS 4 and other BSD like systems
229#       have no memmove (we assume they have bcopy instead).
230#       {The replacement define is in compat/string.h}
231#--------------------------------------------------------------------
232AC_CHECK_FUNC(memmove, , [AC_DEFINE(NO_MEMMOVE) AC_DEFINE(NO_STRING_H)])
233
234#--------------------------------------------------------------------
235#	On some systems strstr is broken: it returns a pointer even
236#	even if the original string is empty.
237#--------------------------------------------------------------------
238dnl only run if AC_REPLACE_FUNCS(strstr) hasn't already added strstr.o
239if test "x${ac_cv_func_strstr}" = "xyes"; then
240    AC_CACHE_CHECK([proper strstr implementation], tcl_cv_strstr_unbroken, [
241	AC_TRY_RUN([
242	extern int strstr();
243	int main()
244	{
245	    exit(strstr("\0test", "test") ? 1 : 0);
246	}], tcl_cv_strstr_unbroken=ok, tcl_cv_strstr_unbroken=broken,
247	    tcl_cv_strstr_unbroken=broken)])
248    if test $tcl_cv_strstr_unbroken = broken; then
249        LIBOBJS="$LIBOBJS strstr.o"
250    fi
251fi
252
253#--------------------------------------------------------------------
254#	Check for strtoul function.  This is tricky because under some
255#	versions of AIX strtoul returns an incorrect terminator
256#	pointer for the string "0".
257#--------------------------------------------------------------------
258
259AC_CHECK_FUNC(strtoul, tcl_ok=1, tcl_ok=0)
260if test $tcl_ok = 1; then
261    AC_CACHE_CHECK([proper strtoul implementation], tcl_cv_strtoul_unbroken, [
262	AC_TRY_RUN([
263	extern int strtoul();
264	int main()
265	{
266	    char *string = "0";
267	    char *term;
268	    int value;
269	    value = strtoul(string, &term, 0);
270	    if ((value != 0) || (term != (string+1))) {
271		exit(1);
272	    }
273	    exit(0);
274	}], tcl_cv_strtoul_unbroken=ok , tcl_cv_strtoul_unbroken=broken,
275	    tcl_cv_strtoul_unbroken=broken)])
276    if test $tcl_cv_strtoul_unbroken = broken; then
277	tcl_ok=0
278    fi
279fi
280if test $tcl_ok = 0; then
281    LIBOBJS="$LIBOBJS strtoul.o"
282fi
283
284#--------------------------------------------------------------------
285#	Check for the strtod function.  This is tricky because in some
286#	versions of Linux strtod mis-parses strings starting with "+".
287#--------------------------------------------------------------------
288
289AC_CHECK_FUNC(strtod, tcl_ok=1, tcl_ok=0)
290if test $tcl_ok = 1; then
291    AC_CACHE_CHECK([proper strtod implementation], tcl_cv_strtod_unbroken, [
292	AC_TRY_RUN([
293	extern double strtod();
294	int main()
295	{
296	    char *string = " +69";
297	    char *term;
298	    double value;
299	    value = strtod(string, &term);
300	    if ((value != 69) || (term != (string+4))) {
301		exit(1);
302	    }
303	    exit(0);
304	}], tcl_cv_strtod_unbroken=ok , tcl_cv_strtod_unbroken=broken,
305	    tcl_cv_strtod_unbroken=broken)])
306    if test $tcl_cv_strtod_unbroken = broken; then
307	tcl_ok=0
308    fi
309fi
310if test $tcl_ok = 0; then
311    LIBOBJS="$LIBOBJS strtod.o"
312fi
313
314#--------------------------------------------------------------------
315#	Under Solaris 2.4, strtod returns the wrong value for the
316#	terminating character under some conditions.  Check for this
317#	and if the problem exists use a substitute procedure
318#	"fixstrtod" that corrects the error.
319#--------------------------------------------------------------------
320
321SC_BUGGY_STRTOD
322
323#--------------------------------------------------------------------
324#	Check for various typedefs and provide substitutes if
325#	they don't exist.
326#--------------------------------------------------------------------
327
328AC_TYPE_MODE_T
329AC_TYPE_PID_T
330AC_TYPE_SIZE_T
331AC_TYPE_UID_T
332
333AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t, [
334    AC_EGREP_CPP(changequote(<<,>>)dnl
335<<(^|[^a-zA-Z_0-9])socklen_t[^a-zA-Z_0-9]>>dnl
336changequote([,]),[
337    #include <sys/types.h>
338    #include <sys/socket.h>
339    #if STDC_HEADERS
340    #include <stdlib.h>
341    #include <stddef.h>
342    #endif
343    ], ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no)])
344if test $ac_cv_type_socklen_t = no; then
345    AC_DEFINE(socklen_t, unsigned)
346fi
347
348#--------------------------------------------------------------------
349#	If a system doesn't have an opendir function (man, that's old!)
350#	then we have to supply a different version of dirent.h which
351#	is compatible with the substitute version of opendir that's
352#	provided.  This version only works with V7-style directories.
353#--------------------------------------------------------------------
354
355AC_CHECK_FUNC(opendir, , [AC_DEFINE(USE_DIRENT2_H)])
356
357#--------------------------------------------------------------------
358#	The check below checks whether <sys/wait.h> defines the type
359#	"union wait" correctly.  It's needed because of weirdness in
360#	HP-UX where "union wait" is defined in both the BSD and SYS-V
361#	environments.  Checking the usability of WIFEXITED seems to do
362#	the trick.
363#--------------------------------------------------------------------
364
365AC_CACHE_CHECK([union wait], tcl_cv_union_wait, [
366    AC_TRY_LINK([#include <sys/types.h> 
367#include <sys/wait.h>], [
368union wait x;
369WIFEXITED(x);		/* Generates compiler error if WIFEXITED
370			 * uses an int. */
371    ], tcl_cv_union_wait=yes, tcl_cv_union_wait=no)])
372if test $tcl_cv_union_wait = no; then
373    AC_DEFINE(NO_UNION_WAIT)
374fi
375
376#--------------------------------------------------------------------
377#	Check whether there is an strncasecmp function on this system.
378#	This is a bit tricky because under SCO it's in -lsocket and
379#	under Sequent Dynix it's in -linet.
380#--------------------------------------------------------------------
381
382AC_CHECK_FUNC(strncasecmp, tcl_ok=1, tcl_ok=0)
383if test "$tcl_ok" = 0; then
384    AC_CHECK_LIB(socket, strncasecmp, tcl_ok=1, tcl_ok=0)
385fi
386if test "$tcl_ok" = 0; then
387    AC_CHECK_LIB(inet, strncasecmp, tcl_ok=1, tcl_ok=0)
388fi
389if test "$tcl_ok" = 0; then
390    LIBOBJS="$LIBOBJS strncasecmp.o"
391fi
392
393#--------------------------------------------------------------------
394#	The code below deals with several issues related to gettimeofday:
395#	1. Some systems don't provide a gettimeofday function at all
396#	   (set NO_GETTOD if this is the case).
397#	2. SGI systems don't use the BSD form of the gettimeofday function,
398#	   but they have a BSDgettimeofday function that can be used instead.
399#	3. See if gettimeofday is declared in the <sys/time.h> header file.
400#	   if not, set the GETTOD_NOT_DECLARED flag so that tclPort.h can
401#	   declare it.
402#--------------------------------------------------------------------
403
404AC_CHECK_FUNC(BSDgettimeofday,
405    [AC_DEFINE(HAVE_BSDGETTIMEOFDAY)], [
406    AC_CHECK_FUNC(gettimeofday, , [AC_DEFINE(NO_GETTOD)])
407])
408AC_CACHE_CHECK([for gettimeofday declaration], tcl_cv_grep_gettimeofday, [
409    AC_EGREP_HEADER(gettimeofday, sys/time.h,
410	tcl_cv_grep_gettimeofday=present, tcl_cv_grep_gettimeofday=missing)])
411if test $tcl_cv_grep_gettimeofday = missing ; then
412    AC_DEFINE(GETTOD_NOT_DECLARED)
413fi
414
415#--------------------------------------------------------------------
416#	The following code checks to see whether it is possible to get
417#	signed chars on this platform.  This is needed in order to
418#	properly generate sign-extended ints from character values.
419#--------------------------------------------------------------------
420
421AC_C_CHAR_UNSIGNED
422AC_CACHE_CHECK([signed char declarations], tcl_cv_char_signed, [
423    AC_TRY_COMPILE(, [
424	signed char *p;
425	p = 0;
426	], tcl_cv_char_signed=yes, tcl_cv_char_signed=no)])
427if test $tcl_cv_char_signed = yes; then
428    AC_DEFINE(HAVE_SIGNED_CHAR)
429fi
430
431#--------------------------------------------------------------------
432#  Does putenv() copy or not?  We need to know to avoid memory leaks.
433#--------------------------------------------------------------------
434
435AC_CACHE_CHECK([for a putenv() that copies the buffer], tcl_cv_putenv_copy, [
436    AC_TRY_RUN([
437	#include <stdlib.h>
438	#define OURVAR "havecopy=yes"
439	int main (int argc, char *argv[])
440	{
441	    char *foo, *bar;
442	    foo = (char *)strdup(OURVAR);
443	    putenv(foo);
444	    strcpy((char *)(strchr(foo, '=') + 1), "no");
445	    bar = getenv("havecopy");
446	    if (!strcmp(bar, "no")) {
447		/* doesnt copy */
448		return 0;
449	    } else {
450		/* does copy */
451		return 1;
452	    }
453	}
454    ],
455    tcl_cv_putenv_copy=no,
456    tcl_cv_putenv_copy=yes,
457    tcl_cv_putenv_copy=no)])
458if test $tcl_cv_putenv_copy = yes; then
459    AC_DEFINE(HAVE_PUTENV_THAT_COPIES)
460fi
461
462#--------------------------------------------------------------------
463# Check for support of nl_langinfo function
464#--------------------------------------------------------------------
465
466SC_ENABLE_LANGINFO
467
468#--------------------------------------------------------------------
469# Darwin specific API checks and defines
470#--------------------------------------------------------------------
471
472if test "`uname -s`" = "Darwin" ; then
473    AC_CHECK_HEADERS(copyfile.h)
474    AC_CHECK_FUNCS(copyfile)
475    if test $tcl_corefoundation = yes; then
476	AC_CHECK_HEADERS(libkern/OSAtomic.h)
477	AC_CHECK_FUNCS(OSSpinLockLock)
478	AC_CHECK_FUNCS(pthread_atfork)
479    fi
480    AC_DEFINE(USE_VFORK)
481    AC_DEFINE(TCL_DEFAULT_ENCODING, "utf-8")
482    AC_DEFINE(TCL_LOAD_FROM_MEMORY)
483    AC_CHECK_HEADERS(AvailabilityMacros.h)
484    if test "$ac_cv_header_AvailabilityMacros_h" = yes; then
485	AC_CACHE_CHECK([if weak import is available], tcl_cv_cc_weak_import, [
486	    hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
487	    AC_TRY_LINK([
488		    #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
489		    #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1020
490		    #error __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1020
491		    #endif
492		    #elif MAC_OS_X_VERSION_MIN_REQUIRED < 1020
493		    #error MAC_OS_X_VERSION_MIN_REQUIRED < 1020
494		    #endif
495		    int rand(void) __attribute__((weak_import));
496		], [rand();],
497		tcl_cv_cc_weak_import=yes, tcl_cv_cc_weak_import=no)
498	    CFLAGS=$hold_cflags])
499	if test $tcl_cv_cc_weak_import = yes; then
500	    AC_DEFINE(HAVE_WEAK_IMPORT)
501	fi
502    fi
503fi
504
505#--------------------------------------------------------------------
506# Check for support of fts functions (readdir replacement)
507#--------------------------------------------------------------------
508
509AC_CACHE_CHECK([for fts], tcl_cv_api_fts, [
510    AC_TRY_LINK([
511	    #include <sys/param.h>
512	    #include <sys/stat.h>
513	    #include <fts.h>
514	], [
515	    char*const p[2] = {"/", NULL};
516	    FTS *f = fts_open(p, FTS_PHYSICAL|FTS_NOCHDIR|FTS_NOSTAT, NULL);
517	    FTSENT *e = fts_read(f); fts_close(f);
518	], tcl_cv_api_fts=yes, tcl_cv_api_fts=no)])
519if test $tcl_cv_api_fts = yes; then
520    AC_DEFINE(HAVE_FTS)
521fi
522
523#--------------------------------------------------------------------
524#	The statements below check for systems where POSIX-style
525#	non-blocking I/O (O_NONBLOCK) doesn't work or is unimplemented. 
526#	On these systems (mostly older ones), use the old BSD-style
527#	FIONBIO approach instead.
528#--------------------------------------------------------------------
529
530SC_BLOCKING_STYLE
531
532#--------------------------------------------------------------------
533#	DTrace support
534#--------------------------------------------------------------------
535
536AC_ARG_ENABLE(dtrace,
537    [  --enable-dtrace         build with DTrace support [--disable-dtrace]],
538    [tcl_ok=$enableval], [tcl_ok=no])
539if test $tcl_ok = yes; then
540    AC_CHECK_HEADER(sys/sdt.h, [tcl_ok=yes], [tcl_ok=no])
541fi
542if test $tcl_ok = yes; then
543    AC_PATH_PROG(DTRACE, dtrace,, [$PATH:/usr/sbin])
544    test -z "$ac_cv_path_DTRACE" && tcl_ok=no
545fi
546AC_MSG_CHECKING([whether to enable DTrace support])
547MAKEFILE_SHELL='/bin/sh'
548if test $tcl_ok = yes; then
549    AC_DEFINE(USE_DTRACE)
550    DTRACE_SRC="\${DTRACE_SRC}"
551    DTRACE_HDR="\${DTRACE_HDR}"
552    if test "`uname -s`" != "Darwin" ; then
553	DTRACE_OBJ="\${DTRACE_OBJ}"
554	if test "`uname -s`" = "SunOS" -a "$SHARED_BUILD" = "0" ; then
555	    # Need to create an intermediate object file to ensure tclDTrace.o
556	    # gets included when linking against the static tcl library.
557	    STLIB_LD='stlib_ld () { /usr/ccs/bin/ld -r -o $${1%.a}.o "$${@:2}" && '"${STLIB_LD}"' $${1} $${1%.a}.o ; } && stlib_ld'
558	    MAKEFILE_SHELL='/bin/bash'
559	    # Force use of Sun ar and ranlib, the GNU versions choke on
560	    # tclDTrace.o and the combined object file above.
561	    AR='/usr/ccs/bin/ar'
562	    RANLIB='/usr/ccs/bin/ranlib'
563	fi
564    fi
565fi
566AC_MSG_RESULT([$tcl_ok])
567
568#--------------------------------------------------------------------
569#	The statements below define a collection of symbols related to
570#	building libtcl as a shared library instead of a static library.
571#--------------------------------------------------------------------
572
573TCL_UNSHARED_LIB_SUFFIX=${UNSHARED_LIB_SUFFIX}
574TCL_SHARED_LIB_SUFFIX=${SHARED_LIB_SUFFIX}
575eval "TCL_LIB_FILE=libtcl${LIB_SUFFIX}"
576
577# tclConfig.sh needs a version of the _LIB_SUFFIX that has been eval'ed
578# so that the backslashes quoting the DBX braces are dropped.
579
580# Trick to replace DBGX with TCL_DBGX
581DBGX='${TCL_DBGX}'
582eval "TCL_LIB_FILE=${TCL_LIB_FILE}"
583
584TCL_LIBRARY='$(prefix)/lib/tcl$(VERSION)'
585PRIVATE_INCLUDE_DIR='$(includedir)'
586HTML_DIR='$(DISTDIR)/html'
587
588# Note:  in the following variable, it's important to use the absolute
589# path name of the Tcl directory rather than "..":  this is because
590# AIX remembers this path and will attempt to use it at run-time to look
591# up the Tcl library.
592
593if test "`uname -s`" = "Darwin" ; then
594    SC_ENABLE_FRAMEWORK
595    TCL_SHLIB_LD_EXTRAS="-compatibility_version ${TCL_VERSION} -current_version ${TCL_VERSION}`echo ${TCL_PATCH_LEVEL} | awk ['{match($0, "\\\.[0-9]+"); print substr($0,RSTART,RLENGTH)}']`"
596    TCL_SHLIB_LD_EXTRAS="${TCL_SHLIB_LD_EXTRAS}"' -install_name ${DYLIB_INSTALL_DIR}/${TCL_LIB_FILE}'
597    echo "$LDFLAGS " | grep -q -- '-prebind ' && TCL_SHLIB_LD_EXTRAS="${TCL_SHLIB_LD_EXTRAS}"' -seg1addr 0xa000000'
598    TCL_SHLIB_LD_EXTRAS="${TCL_SHLIB_LD_EXTRAS}"' -sectcreate __TEXT __info_plist Tcl-Info.plist'
599    EXTRA_TCLSH_LIBS='-sectcreate __TEXT __info_plist Tclsh-Info.plist'
600    EXTRA_APP_CC_SWITCHES='-mdynamic-no-pic'
601    tcl_config_files="${tcl_config_files} [Tcl-Info.plist:../macosx/Tcl-Info.plist.in Tclsh-Info.plist:../macosx/Tclsh-Info.plist.in]"
602    TCL_YEAR="`date +%Y`"
603fi
604
605if test "$FRAMEWORK_BUILD" = "1" ; then
606    AC_DEFINE(TCL_FRAMEWORK)
607    # Construct a fake local framework structure to make linking with
608    # '-framework Tcl' and running of tcltest work
609    AC_OUTPUT_COMMANDS([test "$FRAMEWORK_BUILD" = "1" && n=Tcl &&
610	f=$n.framework && v=Versions/$VERSION &&
611	echo "creating $f" && rm -rf $f && mkdir -p $f/$v/Resources &&
612	ln -s $v/$n $v/Resources $f && ln -s ../../../$n $f/$v &&
613	ln -s ../../../../$n-Info.plist $f/$v/Resources/Info.plist &&
614	unset n f v
615    ], [VERSION=${TCL_VERSION} FRAMEWORK_BUILD=${FRAMEWORK_BUILD}])
616    LD_LIBRARY_PATH_VAR="DYLD_FRAMEWORK_PATH"
617    if test "${libdir}" = '${exec_prefix}/lib'; then
618        # override libdir default
619        libdir="/Library/Frameworks"
620    fi
621    TCL_LIB_FILE="Tcl"
622    TCL_LIB_FLAG="-framework Tcl"
623    TCL_BUILD_LIB_SPEC="-F`pwd` -framework Tcl"
624    TCL_LIB_SPEC="-F${libdir} -framework Tcl"
625    libdir="${libdir}/Tcl.framework/Versions/\${VERSION}"
626    TCL_LIBRARY="${libdir}/Resources/Scripts"
627    includedir="${libdir}/Headers"
628    PRIVATE_INCLUDE_DIR="${libdir}/PrivateHeaders"
629    HTML_DIR="${libdir}/Resources/Documentation/Reference/Tcl"
630    EXTRA_INSTALL="install-private-headers html-tcl"
631    EXTRA_BUILD_HTML='@ln -fs contents.htm $(HTML_INSTALL_DIR)/TclTOC.html' 
632    EXTRA_INSTALL_BINARIES='@echo "Installing Info.plist to $(LIB_INSTALL_DIR)/Resources" && mkdir -p "$(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) Tcl-Info.plist "$(LIB_INSTALL_DIR)/Resources/Info.plist"'
633    EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Installing license.terms to $(LIB_INSTALL_DIR)/Resources" && $(INSTALL_DATA) "$(TOP_DIR)/license.terms" "$(LIB_INSTALL_DIR)/Resources"'
634    EXTRA_INSTALL_BINARIES="$EXTRA_INSTALL_BINARIES"' && echo "Finalizing Tcl.framework" && rm -f "$(LIB_INSTALL_DIR)/../Current" && ln -s "$(VERSION)" "$(LIB_INSTALL_DIR)/../Current" && for f in "$(LIB_FILE)" tclConfig.sh Resources Headers PrivateHeaders; do rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/Current/$$f" "$(LIB_INSTALL_DIR)/../.."; done && f="$(STUB_LIB_FILE)" && rm -f "$(LIB_INSTALL_DIR)/../../$$f" && ln -s "Versions/$(VERSION)/$$f" "$(LIB_INSTALL_DIR)/../.."'
635    # Don't use AC_DEFINE for the following as the framework version define 
636    # needs to go into the Makefile even when using autoheader, so that we  
637    # can pick up a potential make override of VERSION. Also, don't put this
638    # into CFLAGS as it should not go into tclConfig.sh
639    EXTRA_CC_SWITCHES='-DTCL_FRAMEWORK_VERSION=\"$(VERSION)\"'
640else
641    # libdir must be a fully qualified path and not ${exec_prefix}/lib
642    eval libdir="$libdir"
643    if test "$SHARED_BUILD" = "0" || test "$TCL_NEEDS_EXP_FILE" = "0"; then
644        if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
645            TCL_LIB_FLAG="-ltcl${TCL_VERSION}\${TCL_DBGX}"
646        else
647            TCL_LIB_FLAG="-ltcl`echo ${TCL_VERSION} | tr -d .`\${TCL_DBGX}"
648        fi
649        TCL_BUILD_LIB_SPEC="-L`pwd` ${TCL_LIB_FLAG}"
650        TCL_LIB_SPEC="-L${libdir} ${TCL_LIB_FLAG}"
651    else
652        TCL_BUILD_EXP_FILE="lib.exp"
653        eval "TCL_EXP_FILE=libtcl${TCL_EXPORT_FILE_SUFFIX}"
654    
655        # Replace DBGX with TCL_DBGX
656        eval "TCL_EXP_FILE=\"${TCL_EXP_FILE}\""
657        
658        if test "$GCC" = "yes" ; then
659            TCL_BUILD_LIB_SPEC="-Wl,-bI:`pwd`/${TCL_BUILD_EXP_FILE} -L`pwd`"
660            TCL_LIB_SPEC="-Wl,-bI:${libdir}/${TCL_EXP_FILE} -L`pwd`"
661        else
662            TCL_BUILD_LIB_SPEC="-bI:`pwd`/${TCL_BUILD_EXP_FILE}"
663            TCL_LIB_SPEC="-bI:${libdir}/${TCL_EXP_FILE}"
664        fi
665    fi
666fi
667VERSION='${VERSION}'
668eval "CFG_TCL_SHARED_LIB_SUFFIX=${TCL_SHARED_LIB_SUFFIX}"
669eval "CFG_TCL_UNSHARED_LIB_SUFFIX=${TCL_UNSHARED_LIB_SUFFIX}"
670eval "CFG_TCL_EXPORT_FILE_SUFFIX=${TCL_EXPORT_FILE_SUFFIX}"
671VERSION=${TCL_VERSION}
672
673#--------------------------------------------------------------------
674#	The statements below define the symbol TCL_PACKAGE_PATH, which
675#	gives a list of directories that may contain packages.  The list
676#	consists of one directory for machine-dependent binaries and
677#	another for platform-independent scripts.
678#--------------------------------------------------------------------
679
680if test "$FRAMEWORK_BUILD" = "1" ; then
681    test -z "$TCL_PACKAGE_PATH" && \
682        TCL_PACKAGE_PATH="~/Library/Tcl /Library/Tcl /Network/Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /Network/Library/Frameworks /System/Library/Frameworks"
683elif test "$prefix" != "$exec_prefix"; then
684    TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}"
685else
686    TCL_PACKAGE_PATH="${prefix}/lib ${TCL_PACKAGE_PATH}"
687fi
688
689#--------------------------------------------------------------------
690#       The statements below define various symbols relating to Tcl
691#       stub support.
692#--------------------------------------------------------------------
693
694# Replace ${VERSION} with contents of ${TCL_VERSION}
695eval "TCL_STUB_LIB_FILE=libtclstub${TCL_UNSHARED_LIB_SUFFIX}"
696# Replace DBGX with TCL_DBGX
697eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
698eval "TCL_STUB_LIB_DIR=${libdir}"
699
700if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
701    TCL_STUB_LIB_FLAG="-ltclstub${TCL_VERSION}\${TCL_DBGX}"
702else
703    TCL_STUB_LIB_FLAG="-ltclstub`echo ${TCL_VERSION} | tr -d .`\${TCL_DBGX}"
704fi
705
706TCL_BUILD_STUB_LIB_SPEC="-L`pwd` ${TCL_STUB_LIB_FLAG}"
707TCL_STUB_LIB_SPEC="-L${TCL_STUB_LIB_DIR} ${TCL_STUB_LIB_FLAG}"
708TCL_BUILD_STUB_LIB_PATH="`pwd`/${TCL_STUB_LIB_FILE}"
709TCL_STUB_LIB_PATH="${TCL_STUB_LIB_DIR}/${TCL_STUB_LIB_FILE}"
710
711# Install time header dir can be set via --includedir
712eval "TCL_INCLUDE_SPEC=\"-I${includedir}\""
713
714#------------------------------------------------------------------------
715# tclConfig.sh refers to this by a different name
716#------------------------------------------------------------------------
717
718TCL_SHARED_BUILD=${SHARED_BUILD}
719
720AC_SUBST(TCL_VERSION)
721AC_SUBST(TCL_MAJOR_VERSION)
722AC_SUBST(TCL_MINOR_VERSION)
723AC_SUBST(TCL_PATCH_LEVEL)
724AC_SUBST(TCL_YEAR)
725
726AC_SUBST(TCL_LIB_FILE)
727AC_SUBST(TCL_LIB_FLAG)
728AC_SUBST(TCL_LIB_SPEC)
729AC_SUBST(TCL_STUB_LIB_FILE)
730AC_SUBST(TCL_STUB_LIB_FLAG)
731AC_SUBST(TCL_STUB_LIB_SPEC)
732AC_SUBST(TCL_STUB_LIB_PATH)
733AC_SUBST(TCL_INCLUDE_SPEC)
734AC_SUBST(TCL_BUILD_STUB_LIB_SPEC)
735AC_SUBST(TCL_BUILD_STUB_LIB_PATH)
736
737AC_SUBST(TCL_SRC_DIR)
738AC_SUBST(TCL_DBGX)
739AC_SUBST(CFG_TCL_SHARED_LIB_SUFFIX)
740AC_SUBST(CFG_TCL_UNSHARED_LIB_SUFFIX)
741AC_SUBST(CFG_TCL_EXPORT_FILE_SUFFIX)
742
743AC_SUBST(TCL_SHARED_BUILD)
744AC_SUBST(LD_LIBRARY_PATH_VAR)
745
746AC_SUBST(TCL_BUILD_LIB_SPEC)
747AC_SUBST(TCL_NEEDS_EXP_FILE)
748AC_SUBST(TCL_BUILD_EXP_FILE)
749AC_SUBST(TCL_EXP_FILE)
750
751AC_SUBST(TCL_LIB_VERSIONS_OK)
752AC_SUBST(TCL_SHARED_LIB_SUFFIX)
753AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
754
755AC_SUBST(TCL_HAS_LONGLONG)
756
757AC_SUBST(DTRACE_SRC)
758AC_SUBST(DTRACE_HDR)
759AC_SUBST(DTRACE_OBJ)
760AC_SUBST(MAKEFILE_SHELL)
761
762AC_SUBST(BUILD_DLTEST)
763AC_SUBST(TCL_PACKAGE_PATH)
764
765AC_SUBST(TCL_LIBRARY)
766AC_SUBST(PRIVATE_INCLUDE_DIR)
767AC_SUBST(HTML_DIR)
768
769AC_SUBST(EXTRA_CC_SWITCHES)
770AC_SUBST(EXTRA_APP_CC_SWITCHES)
771AC_SUBST(EXTRA_INSTALL)
772AC_SUBST(EXTRA_INSTALL_BINARIES)
773AC_SUBST(EXTRA_BUILD_HTML)
774AC_SUBST(EXTRA_TCLSH_LIBS)
775
776SC_OUTPUT_COMMANDS_PRE
777
778tcl_config_files="${tcl_config_files} [Makefile dltest/Makefile tclConfig.sh]"
779AC_OUTPUT([${tcl_config_files}])
780