1define([AC_CACHE_LOAD], )dnl
2define([AC_CACHE_SAVE], )dnl
3AC_INIT(generic/bltInit.c)
4AC_CONFIG_HEADER(generic/bltConfig.h)
5AC_CONFIG_AUX_DIR(cf)
6AC_PREREQ(2.0)
7
8# -----------------------------------------------------------------------
9#
10# 	Handle command line options
11#
12#		--with-tcl=DIR
13#		--with-tk=DIR
14#		--with-cc=CC
15#		--with-cflags=flags	This is probably for me only
16#		--with-gnu-ld
17#
18# -----------------------------------------------------------------------
19
20INC_SPECS=""
21LIB_SPECS=""
22TCL_ONLY_LIB_SPECS=""
23loader_run_path=""
24DEFINES=""
25
26blt_with_tcl=""
27blt_with_tk=""
28blt_enable_jpeg="no"
29blt_enable_cygwin="yes"
30blt_with_cc=""
31blt_with_cflags="$CFLAGS"
32blt_with_gnu_ld="no"
33blt_with_tcl_includes=""
34blt_with_tk_includes=""
35blt_with_tcl_libraries=""
36blt_with_tk_libraries=""
37blt_with_scriptdir=""
38
39AC_ARG_WITH(blt,	[  --with-blt=DIR          Install BLT scripts in DIR],
40  blt_with_scriptdir=$withval)
41AC_ARG_WITH(tcl,	[  --with-tcl=DIR          Find tclConfig.sh in DIR],
42  blt_with_tcl=$withval)
43AC_ARG_WITH(tk,		[  --with-tk=DIR           Find tkConfig.sh in DIR],
44  blt_with_tk=$withval)
45AC_ARG_WITH(tclincls,   [  --with-tclincls=DIR     Find tcl.h in DIR],
46  blt_with_tcl_includes=$withval)
47AC_ARG_WITH(tkincls,	[  --with-tkincls=DIR      Find tk.h in DIR],
48  blt_with_tk_includes=$withval)
49AC_ARG_WITH(tcllibs,	[  --with-tcllibs=DIR      Find Tcl library in DIR],
50  blt_with_tcl_libraries=$withval)
51AC_ARG_WITH(tklibs,	[  --with-tklibs=DIR       Find Tk library in DIR],
52  blt_with_tk_libraries=$withval)
53AC_ARG_ENABLE(jpeg,	[  --enable-jpeg=DIR       Find JPEG headers and libraries in DIR], [
54  unset ac_cv_header_jpeglib_h
55  unset ac_cv_lib_jpeg ac_cv_lib_jpeg_jpeg_read_header
56  blt_enable_jpeg=$enableval ])
57AC_ARG_ENABLE(cygwin,	[  --enable-cygwin         Use cygwin Tcl/Tk libraries. Requires cygwin1.dll], [
58  blt_enable_cygwin=$enableval ])
59AC_ARG_WITH(cc,		[  --with-cc=CC            Set C compiler to CC], [
60  blt_with_cc=$with_cc
61  unset ac_cv_prog_CC
62  unset ac_cv_prog_CPP ])
63AC_ARG_WITH(cflags,	[  --with-cflags=FLAGS     Set compiler flags to FLAGS],
64  blt_with_cflags="$with_cflags")
65AC_ARG_WITH(gnu_ld,	[  --with-gnu-ld           Use GNU linker],
66  blt_with_gnu_ld="yes")
67
68AC_CANONICAL_SYSTEM
69AC_PREFIX_PROGRAM(wish)
70
71# -----------------------------------------------------------------------
72#
73# 	Set a variable containing current working directory if /bin/sh
74#	doesn't do it already.
75#
76# -----------------------------------------------------------------------
77
78PWD=`pwd`
79
80# -----------------------------------------------------------------------
81#
82# 	C compiler and debugging flags
83#
84# -----------------------------------------------------------------------
85
86BLT_ENV_CC=$CC
87
88#
89# CC search order
90#
91#  1. command line (--with-cc)
92#  2. environment variable ($CC)
93#  3. cached variable ($blt_cv_prog_cc)
94#  4. check for program (AC_PROG_CC)
95#  4. default to cc
96#
97
98AC_MSG_CHECKING([which C compiler])
99if test "x${blt_with_cc}" != "x" ; then
100  CC=${blt_with_cc}
101  unset ac_cv_prog_CPP
102  unset ac_cv_prog_CC
103elif test "x${BLT_ENV_CC}" != "x" ; then
104  unset ac_cv_prog_CPP
105  unset ac_cv_prog_CC
106elif test "x${blt_cv_prog_cc}" != "x" ; then
107  CC=${blt_cv_prog_cc}
108  unset ac_cv_prog_CC
109else
110  AC_PROG_CC
111fi
112if test "x${CC}" = "x" ; then
113  CC=cc
114fi
115
116case $target in
117  *-*-cygwin*|*-*-mingw*)
118    if test "${blt_enable_cygwin}" = "no" ; then
119      CC="${CC} -mno-cygwin"
120    fi
121    ;;
122esac
123
124AC_MSG_RESULT([$CC])
125
126unset blt_cv_prog_cc
127AC_CACHE_VAL(blt_cv_prog_cc, blt_cv_prog_cc=$CC)
128AC_SUBST(CC)
129AC_PROG_CPP
130if test "x${GCC}" != "x" ; then
131  blt_have_gcc="yes"
132else
133  AC_MSG_CHECKING([if C compiler is really gcc])
134    AC_EGREP_CPP(_cc_is_gcc_, [
135#ifdef __GNUC__
136    _cc_is_gcc_
137#endif
138],      [blt_have_gcc=yes], [blt_have_gcc=no])
139  AC_MSG_RESULT([$blt_have_gcc])
140fi
141
142#
143# CFLAGS search order
144#
145#  1. command line (--with-cflags)
146#  2. cached variable ($blt_cv_prog_cflags)
147#  3. set to "-O6" if using gcc ($blt_have_gcc)
148#  4. otherwise, default to "-O"
149#
150AC_MSG_CHECKING([default compiler flags])
151if test  "x${blt_with_cflags}" != "x" ; then
152  CFLAGS=${blt_with_cflags}
153elif test "x${blt_cv_prog_cflags}" != "x" ; then
154  CFLAGS=${blt_cv_prog_cflags}
155elif test "${blt_have_gcc}" = "yes" ; then
156  CFLAGS=-O6
157else
158  CFLAGS=-O
159fi
160AC_MSG_RESULT([$CFLAGS])
161unset blt_cv_prog_cflags
162AC_CACHE_VAL(blt_cv_prog_cflags, blt_cv_prog_cflags=$CFLAGS)
163AC_SUBST(CFLAGS)
164
165GCCFLAGS=""
166if test "${blt_have_gcc}" = "yes" ; then
167  GCCFLAGS="-Wall"
168  if test "${CFLAGS}" = "-g" ; then
169    GCCFLAGS="-Wshadow -Winline -Wpointer-arith ${GCCFLAGS}"
170  fi
171fi
172AC_SUBST(GCCFLAGS)
173
174AC_CYGWIN
175
176blt_lib_prefix="lib"
177case $target in
178  *-*-cygwin*|*-*-mingw*)
179    blt_platform="win"
180    if test "$ac_cv_cygwin" = "yes" ; then
181      blt_lib_prefix="cyg"
182    else
183      blt_lib_prefix=""
184    fi
185    ;;
186  *-*-macosx)
187    blt_platform="macosx"
188    ;;
189  *)
190    blt_platform="unix"
191    ;;
192esac
193
194
195# -----------------------------------------------------------------------
196#
197# Programs:	Check for existence of ranlib and install programs
198#
199# -----------------------------------------------------------------------
200AC_PROG_AWK
201AC_PROG_INSTALL
202AC_PROG_RANLIB
203AC_PROG_LN_S
204
205# -----------------------------------------------------------------------
206#
207# Libraries:	Check for libraries used
208#
209# -----------------------------------------------------------------------
210AC_CHECK_LIB(socket, main)
211AC_CHECK_LIB(nsl, main)
212AC_CHECK_LIB(m, main)
213# -----------------------------------------------------------------------
214#
215# Headers:	Check for header files used
216#
217# -----------------------------------------------------------------------
218
219AC_HEADER_STDC
220AC_HEADER_SYS_WAIT
221AC_HEADER_TIME
222
223AC_CHECK_HEADERS(inttypes.h)
224if test "${ac_cv_header_inttypes_h}" = "yes" ; then
225  HAVE_INTTYPES_H=1
226else
227  HAVE_INTTYPES_H=0
228fi
229AC_SUBST(HAVE_INTTYPES_H)
230
231AC_CHECK_HEADERS(limits.h sys/param.h)
232AC_CHECK_HEADERS(string.h ctype.h)
233AC_CHECK_HEADERS(errno.h float.h math.h ieeefp.h)
234AC_CHECK_HEADERS(sys/time.h waitflags.h sys/wait.h)
235AC_CHECK_HEADERS(malloc.h memory.h)
236AC_CHECK_HEADERS(setjmp.h)
237
238if test "${blt_enable_jpeg}" != "no" ; then
239  jpeg_save_CPPFLAGS=${CPPFLAGS}
240  CPPFLAGS=""
241  if test "${blt_enable_jpeg}" != "yes" ; then
242    CPPFLAGS="-I${blt_enable_jpeg}/include"
243  fi
244  AC_CHECK_HEADERS(jpeglib.h, [JPEG_INC_SPEC="${CPPFLAGS}"], [JPEG_INC_SPEC=""])
245  CPPFLAGS=${jpeg_save_CPPFLAGS}
246fi
247
248# Run this check after jpeglib.h because jpeglib.h sets HAVE_STDLIB_H
249AC_CHECK_HEADERS(stdlib.h unistd.h)
250
251# -----------------------------------------------------------------------
252#
253# Types:	Check for existence of types of size_t and pid_t
254#
255# -----------------------------------------------------------------------
256AC_TYPE_SIZE_T
257AC_TYPE_PID_T
258
259AC_MSG_CHECKING([whether union wait is defined correctly])
260AC_CACHE_VAL(blt_cv_struct_wait_works,
261    AC_TRY_COMPILE([#include <sys/types.h>
262#include <sys/wait.h>], [
263    /*
264     *	Check whether <sys/wait.h> defines the type "union wait"
265     *	correctly.  It's needed because of weirdness in HP-UX where
266     *	"union wait" is defined in both the BSD and SYS-V  environments.
267     *	Checking the usability of WIFEXITED seems to do	the trick.
268     */
269    union wait x;
270    WIFEXITED(x);	/* Generates compiler error if WIFEXITED
271			 * uses an int. */
272],
273    	[blt_cv_struct_wait_works="yes"],
274	[blt_cv_struct_wait_works="no"]))
275
276if test "${blt_cv_struct_wait_works}" = "yes"; then
277    AC_DEFINE(HAVE_UNION_WAIT)
278fi
279AC_MSG_RESULT([$blt_cv_struct_wait_works])
280
281# -----------------------------------------------------------------------
282#
283# Compiler characteristics:
284#		Check for existence of types of size_t and pid_t
285#
286# -----------------------------------------------------------------------
287
288AC_C_BIGENDIAN
289AC_CHECK_SIZEOF(int)
290AC_CHECK_SIZEOF(long)
291AC_CHECK_SIZEOF(long long)
292AC_CHECK_SIZEOF(void *)
293
294SIZEOF_LONG="${ac_cv_sizeof_long}"
295SIZEOF_LONG_LONG="${ac_cv_sizeof_long_long}"
296SIZEOF_VOID_P="${ac_cv_sizeof_void_p}"
297SIZEOF_INT="${ac_cv_sizeof_int}"
298AC_SUBST(SIZEOF_INT)
299AC_SUBST(SIZEOF_LONG)
300AC_SUBST(SIZEOF_LONG_LONG)
301AC_SUBST(SIZEOF_VOID_P)
302
303# -----------------------------------------------------------------------
304#
305# Library Functions: 	Check for  strdup, drand48, and srand48.
306#
307# -----------------------------------------------------------------------
308
309AC_HAVE_FUNCS(strdup strcasecmp strncasecmp drand48 srand48 finite isnan)
310
311# For HPUX it's a little more complicated to search for isfinite
312AC_MSG_CHECKING([for isfinite])
313AC_CACHE_VAL(blt_cv_have_isfinite,
314    AC_TRY_LINK([#include <math.h>], [
315double x = 1.0;
316if (isfinite(x)) {
317   return 0;
318}
319], [blt_cv_have_isfinite="yes"], [blt_cv_have_isfinite="no"]))
320
321if test "${blt_cv_have_isfinite}" = "yes"; then
322    AC_DEFINE(HAVE_ISFINITE)
323fi
324AC_MSG_RESULT([$blt_cv_have_isfinite])
325
326# -----------------------------------------------------------------------
327#
328# 	Check the smallest value such that 1.0 + x != 1.0.
329#	For ANSI compilers this is DBL_EPSILON in float.h
330#
331#--------------------------------------------------------------------
332
333AC_MSG_CHECKING([whether DBL_EPSILON is defined in float.h])
334AC_CACHE_VAL(blt_cv_found_dbl_epsilon,
335    AC_EGREP_CPP(yes,
336   [
337#ifdef HAVE_FLOAT_H
338#include <float.h>
339#endif
340#ifdef DBL_EPSILON
341 yes
342#endif
343], blt_cv_found_dbl_epsilon=yes, blt_cv_found_dbl_epsilon=no)
344)
345AC_MSG_RESULT([${blt_cv_found_dbl_epsilon}])
346
347if test "${blt_cv_found_dbl_epsilon}" = "no" ; then
348  AC_CACHE_VAL(blt_cv_dbl_epsilon,
349  old_flags="$CFLAGS"
350  CFLAGS="-g -lm"
351  AC_MSG_CHECKING([whether DBL_EPSILON can be computed])
352  AC_TRY_RUN_WITH_OUTPUT(blt_cv_dbl_epsilon, [
353main () {
354    double e, u;
355    /*
356     *	Check the smallest value such that 1.0 + x != 1.0.
357     *	For ANSI compilers this is DBL_EPSILON in float.h
358     */
359    u = 1.0;
360    for(;;) {
361       u *= 0.5;
362       if ((1.0 + u) == 1.0) {
363	   break;
364       }
365    }
366    e = u * 2.0;
367    printf("%.17e\n", e);
368    exit(0);
369}])
370    CFLAGS="$old_flags"
371    AC_DEFINE_UNQUOTED(BLT_DBL_EPSILON, ${blt_cv_dbl_epsilon})
372    AC_MSG_RESULT([${blt_cv_dbl_epsilon}])
373)
374fi
375
376
377AC_MSG_CHECKING([whether declaration is needed for strdup])
378AC_CACHE_VAL(blt_cv_nedd_decl_strdup,
379    AC_EGREP_CPP(strdup, [
380#ifdef HAVE_STDLIB_H
381#include <stdlib.h>
382#endif
383#ifdef HAVE_STRING_H
384#include <string.h>
385#endif
386#ifdef HAVE_UNISTD_H
387#include <unistd.h>
388#endif /* HAVE_UNISTD_H */
389],      [blt_cv_need_decl_strdup=no], [blt_cv_need_decl_strdup=yes]))
390
391if test "${blt_cv_need_decl_strdup}" = "yes"; then
392    AC_DEFINE(NEED_DECL_STRDUP)
393fi
394AC_MSG_RESULT([$blt_cv_need_decl_strdup])
395
396AC_MSG_CHECKING([whether declaration is needed for drand48])
397AC_CACHE_VAL(blt_cv_need_decl_drand48,
398    AC_EGREP_CPP(drand48, [
399#ifdef HAVE_STDLIB_H
400#include <stdlib.h>
401#endif
402#ifdef HAVE_MATH_H
403#include <math.h>
404#endif
405#ifdef HAVE_UNISTD_H
406#include <unistd.h>
407#endif /* HAVE_UNISTD_H */
408],      [blt_cv_need_decl_drand48=no], [blt_cv_need_decl_drand48=yes]))
409
410if test "${blt_cv_need_decl_drand48}" = "yes"; then
411    AC_DEFINE(NEED_DECL_DRAND48)
412fi
413AC_MSG_RESULT([$blt_cv_need_decl_drand48])
414
415AC_MSG_CHECKING([whether declaration is needed for srand48])
416AC_CACHE_VAL(blt_cv_need_decl_srand48,
417    AC_EGREP_CPP(srand48, [
418#ifdef HAVE_STDLIB_H
419#include <stdlib.h>
420#endif
421#ifdef HAVE_MATH_H
422#include <math.h>
423#endif
424#ifdef HAVE_UNISTD_H
425#include <unistd.h>
426#endif /* HAVE_UNISTD_H */
427],      [blt_cv_need_decl_srand48=no], [blt_cv_need_decl_srand48=yes]))
428
429if test "${blt_cv_need_decl_srand48}" = "yes"; then
430    AC_DEFINE(NEED_DECL_SRAND48)
431fi
432AC_MSG_RESULT([$blt_cv_need_decl_srand48])
433
434AC_MSG_CHECKING([whether declaration is needed for j1])
435AC_CACHE_VAL(blt_cv_need_decl_j1,
436    AC_EGREP_CPP(j1, [
437#ifdef HAVE_STDLIB_H
438#include <stdlib.h>
439#endif
440#ifdef HAVE_MATH_H
441#include <math.h>
442#endif
443#ifdef HAVE_UNISTD_H
444#include <unistd.h>
445#endif /* HAVE_UNISTD_H */
446],      [blt_cv_need_decl_j1=no], [blt_cv_need_decl_j1=yes]))
447
448if test "${blt_cv_need_decl_j1}" = "yes"; then
449    AC_DEFINE(NEED_DECL_J1)
450fi
451AC_MSG_RESULT([$blt_cv_need_decl_j1])
452
453# -----------------------------------------------------------------------
454#
455# System services: 	X, Tcl, Tk
456#
457# -----------------------------------------------------------------------
458AC_PATH_X
459
460# -----------------------------------------------------------------------
461#
462#	Find the Tcl build configuration file "tclConfig.sh"
463#
464# -----------------------------------------------------------------------
465
466AC_MSG_CHECKING([for tclConfig.sh])
467tcl_config_sh=""
468if test "x$blt_with_tcl" != "x" ; then
469
470  # Verify that a tclConfig.sh file exists in the directory specified
471  # by --with-tcl.
472
473  for dir in \
474   $blt_with_tcl
475  do
476    if test -r "$dir/tclConfig.sh" ; then
477      tcl_config_sh="$dir/tclConfig.sh"
478      break
479    elif test -r "$dir/lib/tclConfig.sh" ; then
480      tcl_config_sh="$dir/lib/tclConfig.sh"
481      break
482    elif test -r "$dir/$blt_platform/tclConfig.sh" ; then
483      tcl_config_sh="$dir/$blt_platform/tclConfig.sh"
484      break
485    fi
486  done
487else
488
489  # Otherwise, search for Tcl configuration file.
490
491  #  1. Search previously named locations.
492
493  for dir in \
494   $prefix \
495   $exec_prefix \
496   $blt_cv_tcl_lib
497  do
498    if test -r "$dir/tclConfig.sh" ; then
499      tcl_config_sh="$dir/tclConfig.sh"
500      break
501    elif test -r "$dir/lib/tclConfig.sh" ; then
502      tcl_config_sh="$dir/lib/tclConfig.sh"
503      break
504    elif test -r "$dir/$blt_platform/tclConfig.sh" ; then
505      tcl_config_sh="$dir/$blt_platform/tclConfig.sh"
506      break
507    fi
508  done
509
510  #  2. Search source directories.
511
512  if test "x$tcl_config_sh" = "x" ; then
513    for dir in \
514     `ls -dr ../tcl[[7-9]].[[0-9]]* 2>/dev/null` \
515     ../tcl \
516     `ls -dr ../../tcl[[7-9]].[[0-9]]* 2>/dev/null` \
517     ../../tcl \
518     `ls -dr ../../../tcl[[7-9]].[[0-9]]* 2>/dev/null` \
519     ../../../tcl
520    do
521      if test -r "$dir/$blt_platform/tclConfig.sh" ; then
522	tcl_config_sh="$dir/$blt_platform/tclConfig.sh"
523	break
524      fi
525    done
526  fi
527
528  #  3. Search standard locations.
529
530  if test "x$tcl_config_sh" = "x" ; then
531    for dir in \
532     `ls -dr /usr/local/tcl/tcl[[7-9]].[[0-9]]* 2>/dev/null` \
533     /usr/local/tcl \
534     /usr/local \
535     /usr
536    do
537      if test -r "$dir/tclConfig.sh" ; then
538	tcl_config_sh="$dir/tclConfig.sh"
539	break
540      elif test -r "$dir/lib/tclConfig.sh" ; then
541	tcl_config_sh="$dir/lib/tclConfig.sh"
542	break
543      fi
544    done
545  fi
546fi
547
548AC_MSG_RESULT([${tcl_config_sh}])
549
550if test "x$tcl_config_sh" = "x" ; then
551  echo "can't find Tcl configuration script \"tclConfig.sh\""
552  exit 1
553fi
554
555# -----------------------------------------------------------------------
556#
557#	Find the Tk build configuration file "tkConfig.sh"
558#
559# -----------------------------------------------------------------------
560
561AC_MSG_CHECKING([for tkConfig.sh])
562tk_config_sh=""
563if test "x$blt_with_tk" != "x" -o "x$blt_with_tcl" != "x"; then
564
565  # Verify that a tkConfig.sh file exists in the directory specified
566  # by --with-tcl or --with-tk.
567
568  for dir in \
569   $blt_with_tk \
570   $blt_with_tcl
571  do
572    if test -r "$dir/tkConfig.sh" ; then
573      tk_config_sh="$dir/tkConfig.sh"
574      break
575    elif test -r "$dir/lib/tkConfig.sh" ; then
576      tk_config_sh="$dir/lib/tkConfig.sh"
577      break
578    elif test -r "$dir/$blt_platform/tkConfig.sh" ; then
579      tk_config_sh="$dir/$blt_platform/tkConfig.sh"
580      break
581    fi
582  done
583else
584
585  # Search for Tk configuration file.
586
587  #  1. Search previously named locations.
588
589  for dir in \
590   $prefix \
591   $exec_prefix \
592   $blt_cv_tk_lib \
593   $blt_cv_tcl_lib
594  do
595    if test -r "$dir/tkConfig.sh" ; then
596      tk_config_sh="$dir/tkConfig.sh"
597      break
598    elif test -r "$dir/lib/tkConfig.sh" ; then
599      tk_config_sh="$dir/lib/tkConfig.sh"
600      break
601    elif test -r "$dir/$blt_platform/tkConfig.sh" ; then
602      tk_config_sh="$dir/$blt_platform/tkConfig.sh"
603      break
604    fi
605  done
606
607  #  2. Search source directories.
608
609  if test "x$tk_config_sh" = "x" ; then
610    for dir in \
611     ../tcl \
612     `ls -dr ../tk[[4-9]].[[0-9]]* 2>/dev/null` \
613     ../../tcl \
614     `ls -dr ../../tk[[4-9]].[[0-9]]* 2>/dev/null` \
615     ../../../tcl \
616     `ls -dr ../../../tk[[4-9]].[[0-9]]* 2>/dev/null`
617    do
618      if test -r "$dir/$blt_platform/tkConfig.sh"; then
619	tk_config_sh="$dir/$blt_platform/tkConfig.sh"
620	break
621      fi
622    done
623  fi
624
625  #  3. Search standard locations.
626
627  if test "x$tk_config_sh" = "x" ; then
628    for dir in \
629     `ls -dr /usr/local/tcl/tcl[[7-9]].[[0-9]]* 2>/dev/null` \
630     /usr/local/tcl \
631     /usr/local \
632     ${x_libraries} \
633     /usr
634    do
635      if test -r "$dir/tkConfig.sh" ; then
636	tk_config_sh="$dir/tkConfig.sh"
637	break
638      elif test -r "$dir/lib/tkConfig.sh" ; then
639	tk_config_sh="$dir/lib/tkConfig.sh"
640	break
641      fi
642    done
643  fi
644fi
645AC_MSG_RESULT([${tk_config_sh}])
646
647if test "x$tk_config_sh" = "x" ; then
648  echo "can't find Tk configuration script \"tkConfig.sh\""
649  exit 1
650fi
651
652# -----------------------------------------------------------------------
653#
654#	Source in the Tcl/Tk configuration scripts.
655#
656# -----------------------------------------------------------------------
657
658. $tcl_config_sh
659. $tk_config_sh
660
661TCL_INC_DIR=""
662TK_INC_DIR=""
663
664if test "x${blt_with_tcl_includes}" != "x" ; then
665  if test -r "${blt_with_tcl_includes}/tcl.h" ; then
666    TCL_INC_DIR=${blt_with_tcl_includes}
667  else
668    echo "Can't find tcl.h in \"${blt_with_tcl_includes}\""
669    exit 1
670  fi
671else
672  for dir in \
673   ${TCL_PREFIX}/include/tcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION} \
674   ${TCL_PREFIX}/include \
675   ${TCL_SRC_DIR}/generic
676  do
677    if test -r "$dir/tcl.h" ; then
678      TCL_INC_DIR=$dir
679      break
680    fi
681  done
682  if test "x${TCL_INC_DIR}" = "x" ; then
683    echo "Can't find tcl.h header file"
684    exit 1
685  fi
686fi
687
688if test "x${blt_with_tk_includes}" != "x" ; then
689  if test -r "${blt_with_tk_includes}/tk.h" ; then
690    TK_INC_DIR=${blt_with_tk_includes}
691  else
692    echo "Can't find tk.h in \"${blt_with_tk_includes}\""
693    exit 1
694  fi
695else
696  for dir in \
697   ${TK_PREFIX}/include/tk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION} \
698   ${TK_PREFIX}/include \
699   ${TK_SRC_DIR}/generic \
700   ${TCL_INC_DIR}
701  do
702    if test -r "$dir/tk.h" ; then
703      TK_INC_DIR=$dir
704      break
705    fi
706  done
707  if test "x${TK_INC_DIR}" = "x" ; then
708    echo "Can't find tk.h header file"
709    exit 1
710  fi
711fi
712
713case $target in
714  *-sunos4*|*-*-netbsd|NetBSD-*|FreeBSD-*|OpenBSD-*|*-*-cygwin*|*-*-mingw*)
715    TCL_LIB_NAME="tcl${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}"
716    TK_LIB_NAME="tk${TK_MAJOR_VERSION}${TK_MINOR_VERSION}"
717    ;;
718  *)
719    TCL_LIB_NAME="tcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}"
720    TK_LIB_NAME="tk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}"
721    ;;
722esac
723
724TCL_LIB_SPEC="-l${TCL_LIB_NAME}"
725TK_LIB_SPEC="-l${TK_LIB_NAME}"
726
727case $target in
728  *-hpux*)
729    SHLIB_SUFFIX="sl"
730    ;;
731  *)
732    SHLIB_SUFFIX="so"
733    ;;
734esac
735
736TCL_LIB_DIR="${TCL_SRC_DIR}/$blt_platform"
737TK_LIB_DIR="${TK_SRC_DIR}/$blt_platform"
738
739if test "x${blt_with_tcl_libraries}" != "x" ; then
740  for libname in \
741   "${blt_with_tcl_libraries}/lib${TCL_LIB_NAME}.${SHLIB_SUFFIX}" \
742   "${blt_with_tcl_libraries}/lib${TCL_LIB_NAME}.a"
743  do
744    if test -r "$libname" ; then
745      TCL_LIB_DIR="${blt_with_tcl_libraries}"
746      break
747    fi
748  done
749  if test "x${TCL_LIB_DIR}" = "x" ; then
750    echo "Can't find tcl library in \"${blt_with_tcl_libraries}\""
751    exit 1
752  fi
753else
754  for libname in \
755   "${TCL_EXEC_PREFIX}/lib/lib${TCL_LIB_NAME}.${SHLIB_SUFFIX}" \
756   "${TCL_EXEC_PREFIX}/lib/lib${TCL_LIB_NAME}.a"
757  do
758    if test -r "$libname" ; then
759      TCL_LIB_DIR="${TCL_EXEC_PREFIX}/lib"
760      break
761    fi
762  done
763  if test "x${TCL_LIB_DIR}" = "x" ; then
764    echo "Can't find tcl library"
765    exit 1
766  fi
767fi
768
769if test "x${blt_with_tk_libraries}" != "x" ; then
770  for libname in \
771   "${blt_with_tk_libraries}/lib${TK_LIB_NAME}.${SHLIB_SUFFIX}" \
772   "${blt_with_tk_libraries}/lib${TK_LIB_NAME}.a"
773  do
774    if test -r "$libname" ; then
775      TK_LIB_DIR="${blt_with_tk_libraries}"
776      break
777    fi
778  done
779  if test "x${TK_LIB_DIR}" = "x" ; then
780    echo "Can't find tk library in \"${blt_with_tk_libraries}\""
781    exit 1
782  fi
783else
784  for libname in \
785   "${TK_EXEC_PREFIX}/lib/lib${TK_LIB_NAME}.${SHLIB_SUFFIX}" \
786   "${TK_EXEC_PREFIX}/lib/lib${TK_LIB_NAME}.a"
787  do
788    if test -r "$libname" ; then
789      TK_LIB_DIR="${TK_EXEC_PREFIX}/lib"
790      break
791    fi
792  done
793  if test "x${TK_LIB_DIR}" = "x" ; then
794    echo "Can't find tk library"
795    exit 1
796  fi
797fi
798
799# -----------------------------------------------------------------------
800#
801# Include files
802#
803#	Append to INC_SPECS the various include files specifications
804#	(built fromt the include directory information).
805#
806# -----------------------------------------------------------------------
807
808# JPEG include files
809if test "${blt_enable_jpeg}" != "no" ; then
810  if test "x${JPEG_INC_SPEC}" != "x" ; then
811    INC_SPECS="${INC_SPECS} ${JPEG_INC_SPEC}"
812  fi
813fi
814
815# Tk include files
816if test "${TK_INC_DIR}" != "/usr/include" ; then
817  INC_SPECS="${INC_SPECS} -I${TK_INC_DIR}"
818fi
819
820# Tcl include files
821#
822#	Add the include directory specification only if the Tcl
823#	headers reside in a different directory from Tk's.
824if test "${TCL_INC_DIR}" != "/usr/include" -a \
825	"${TCL_INC_DIR}" != "${TK_INC_DIR}" ; then
826  INC_SPECS="${INC_SPECS} -I${TCL_INC_DIR}"
827fi
828
829
830# On Windows, override the default include directory with our own.
831if test "${blt_platform}" = "win"; then
832   x_includes="NONE"
833fi
834
835# X11 include files
836if test "x${x_includes}" != "x" -a \
837	"${x_includes}" != "NONE" -a \
838	"${x_includes}" != "/usr/include" -a \
839	"${x_includes}" != "${TK_INC_DIR}" -a \
840	"${x_includes}" != "${TCL_INC_DIR}" ; then
841  INC_SPECS="${INC_SPECS} -I${x_includes}"
842fi
843
844# -----------------------------------------------------------------------
845#
846# Libraries
847#
848#	Append to LIB the various library specifications
849#	(built from the library directory information).
850#
851# -----------------------------------------------------------------------
852
853# Tk libraries
854if test "${TK_LIB_DIR}" = "/usr/lib" ; then
855  LIB_SPECS="${LIB_SPECS} ${TK_LIB_SPEC}"
856else
857  LIB_SPECS="${LIB_SPECS} -L${TK_LIB_DIR} ${TK_LIB_SPEC}"
858  if test "x${loader_run_path}" = "x" ; then
859    loader_run_path="${TK_LIB_DIR}"
860  else
861    loader_run_path="${TK_LIB_DIR}:${loader_run_path}"
862  fi
863fi
864
865# Tcl libraries
866if test "${TCL_LIB_DIR}" = "/usr/lib" -o \
867	"${TCL_LIB_DIR}" = "${TK_LIB_DIR}" ; then
868  LIB_SPECS="${LIB_SPECS} ${TCL_LIB_SPEC}"
869else
870  LIB_SPECS="${LIB_SPECS} -L${TCL_LIB_DIR} ${TCL_LIB_SPEC}"
871  if test "x${loader_run_path}" = "x" ; then
872    loader_run_path="${TCL_LIB_DIR}"
873  else
874    loader_run_path="${TCL_LIB_DIR}:${loader_run_path}"
875  fi
876fi
877
878if test "${TCL_LIB_DIR}" = "/usr/lib" ; then
879  TCL_ONLY_LIB_SPECS="${TCL_LIB_SPEC}"
880else
881  TCL_ONLY_LIB_SPECS="-L${TCL_LIB_DIR} ${TCL_LIB_SPEC}"
882fi
883
884
885# Collect the libraries for AIX that aren't using stubs.
886aix_lib_specs=""
887
888
889if test "${blt_platform}" = "win"; then
890  LIB_SPECS="${LIB_SPECS} -mwindows"
891elif test "${blt_platform}" = "unix"; then
892
893  # Add specification for X11 library only on Unix platforms.
894
895  if test "x${x_libraries}" = "x"  -o \
896	  "x${x_libraries}" = "NONE"  -o \
897  	  "${x_libraries}" = "/usr/lib" -o  \
898	  "${x_libraries}" = "${TK_LIB_DIR}"  -o \
899	  "${x_libraries}" = "${TCL_LIB_DIR}" ; then
900    LIB_SPECS="${LIB_SPECS} -lX11"
901    aix_lib_specs="${aix_lib_specs} -lX11"
902  else
903    LIB_SPECS="${LIB_SPECS} -L${x_libraries} -lX11"
904    aix_lib_specs="${aix_lib_specs} -L${x_libraries} -lX11"
905    if test "x${loader_run_path}" = "x" ; then
906      loader_run_path="${x_libraries}"
907    else
908      loader_run_path="${loader_run_path}:${x_libraries}"
909    fi
910  fi
911fi
912
913# JPEG library
914if test "${blt_enable_jpeg}" != "no" ; then
915  jpeg_save_LDFlags="${LDFLAGS}"
916  JPEG_LIB_SPEC="-ljpeg"
917  JPEG_LIB_DIR=""
918  if test "${blt_enable_jpeg}" != "yes" ; then
919    JPEG_LIB_DIR="${blt_enable_jpeg}/lib"
920    JPEG_LIB_SPEC="-L${JPEG_LIB_DIR} ${JPEG_LIB_SPEC}"
921    LDFLAGS="-L${JPEG_LIB_DIR} ${LDFLAGS}"
922  fi
923  AC_CHECK_LIB(jpeg, jpeg_read_header, [found=yes], [found=no], )
924  if test "${found}" = "yes" ; then
925    LIB_SPECS="${LIB_SPECS} ${JPEG_LIB_SPEC}"
926    aix_lib_specs="${aix_lib_specs} ${JPEG_LIB_SPEC}"
927    if test "x${JPEG_LIB_DIR}" != "x" ; then
928      loader_run_path="${loader_run_path}:${JPEG_LIB_DIR}"
929    fi
930  fi
931  LDFLAGS=${jpeg_save_LDFlags}
932fi
933
934save_libs=$LIBS
935LIBS="$LIB_SPECS $LIBS"
936AC_CHECK_FUNCS(XExtendedMaxRequestSize)
937LIBS=$save_libs
938
939# -----------------------------------------------------------------------
940#
941# 	Set up a new default prefix to installation path.  The ways
942#	the prefix can be set and their precedence are as follows:
943#
944#	1. --prefix option given to ./configure. (prefix != NONE)
945#       2. use previously configured Tk prefix
946#
947# -----------------------------------------------------------------------
948
949if test "$prefix" = "NONE" ; then
950  prefix=${TCL_PREFIX}
951fi
952
953if test "$exec_prefix" = "NONE" ; then
954  exec_prefix=$prefix
955fi
956
957# -------------------------------------------------------------------------
958#
959#	Extract the BLT version number for the blt.h header
960#
961# -------------------------------------------------------------------------
962AC_MSG_CHECKING([BLT_MAJOR_VERSION])
963AC_CACHE_VAL(blt_cv_major_version,
964AC_GREP_SYMBOL(blt_cv_major_version, BLT_MAJOR_VERSION, ${srcdir}/generic/blt.h)
965)
966BLT_MAJOR_VERSION=${blt_cv_major_version}
967AC_MSG_RESULT([$blt_cv_major_version])
968
969AC_MSG_CHECKING([BLT_MINOR_VERSION])
970AC_CACHE_VAL(blt_cv_minor_version,
971AC_GREP_SYMBOL(blt_cv_minor_version, BLT_MINOR_VERSION, ${srcdir}/generic/blt.h)
972)
973AC_MSG_RESULT([$blt_cv_minor_version])
974BLT_MINOR_VERSION=${blt_cv_minor_version}
975
976BLT_VERSION=${BLT_MAJOR_VERSION}.${BLT_MINOR_VERSION}
977
978# Add BLT to the run path
979libdir=${exec_prefix}/lib
980
981if test "x${libdir}" != "x"  -a \
982	"${libdir}" != "/usr/lib" -a  \
983	"${libdir}" != "${x_libraries}" -a  \
984	"${libdir}" != "${TK_LIB_DIR}"  -a \
985	"${libdir}" != "${TCL_LIB_DIR}" ; then
986  if test "x${loader_run_path}" = "x" ; then
987    loader_run_path="${libdir}"
988  else
989    loader_run_path="${libdir}:${loader_run_path}"
990  fi
991fi
992
993aix_lib_specs="${aix_lib_specs} ${LIBS}"
994LIB_SPECS="${LIB_SPECS} ${LIBS}"
995TCL_ONLY_LIB_SPECS="${TCL_ONLY_LIB_SPECS} ${LIBS}"
996
997# -------------------------------------------------------------------------
998#
999#	Extract the Tcl version number for the tcl.h header
1000#
1001# -------------------------------------------------------------------------
1002AC_MSG_CHECKING([TCL_VERSION in tcl.h])
1003AC_CACHE_VAL(blt_cv_tcl_h_version,
1004AC_GREP_SYMBOL(blt_cv_tcl_h_version, [TCL_VERSION], ${TCL_INC_DIR}/tcl.h)
1005)
1006eval TCL_H_VERSION=${blt_cv_tcl_h_version}
1007AC_MSG_RESULT([$TCL_H_VERSION])
1008if test "${TCL_H_VERSION}" != "${TCL_VERSION}" ; then
1009  echo "Error: Tcl version mismatch. "
1010  echo "	${TCL_VERSION} ${tcl_config_sh}"
1011  echo "	${TCL_H_VERSION} ${TCL_INC_DIR}/tcl.h"
1012  exit 1
1013fi
1014AC_MSG_CHECKING([TK_VERSION in tk.h])
1015AC_CACHE_VAL(blt_cv_tk_h_version,
1016AC_GREP_SYMBOL(blt_cv_tk_h_version, [TK_VERSION], ${TK_INC_DIR}/tk.h)
1017)
1018eval TK_H_VERSION=${blt_cv_tk_h_version}
1019AC_MSG_RESULT([$TK_H_VERSION])
1020if test "${TK_H_VERSION}" != "${TK_VERSION}" ; then
1021  echo "Error: Tk version mismatch."
1022  echo "	${TK_VERSION} ${tk_config_sh}"
1023  echo "	${TK_H_VERSION} ${TK_INC_DIR}/tk.h"
1024  exit 1
1025fi
1026
1027if test "$TCL_VERSION" = "7.6" -a "$TK_VERSION" = "4.2" ; then
1028  :
1029elif test "$TCL_VERSION" = "7.5" -a "$TK_VERSION" = "4.1" ; then
1030  :
1031elif test "$TCL_VERSION" = "$TK_VERSION" ; then
1032  :
1033else
1034  echo "Mismatched Tcl/Tk versions ($TCL_VERSION != $TK_VERSION)"
1035  exit 1
1036fi
1037
1038#--------------------------------------------------------------------
1039#
1040# Check if we can generate shared libraries on this system.  Set flags
1041# to generate shared libraries for systems that we know about.  Start
1042# with the values found in tclConfig.sh, make changes as we know about
1043# the different systems.
1044#
1045#--------------------------------------------------------------------
1046
1047LIB_BASE_NAME=libBLT
1048
1049# Initialize shared library build variables
1050
1051SHLIB_CFLAGS="$TCL_SHLIB_CFLAGS"
1052SHLIB_LD="$TCL_SHLIB_LD"
1053SHLIB_LD_FLAGS="$TCL_LD_FLAGS"
1054SHLIB_RUNPATH="$TCL_LD_SEARCH_FLAGS"
1055
1056SHLIB_SUFFIX=".so"
1057SHLIB_TARGET=""
1058SHLIB_CFLAGS=""
1059SHLIB_LIB_SPECS="${JPEG_LIB_SPEC}"
1060SHLIB_TCL_ONLY_LIB_SPECS="${TCL_ONLY_LIB_SPECS}"
1061SHLIB_TCL_ONLY_LIB_SPECS=""
1062LDFLAGS=""
1063LD_RUN_PATH=""
1064EXTRA_LIB_SPECS=""
1065
1066build_shared="yes"
1067library_name=libBLT${BLT_MAJOR_VERSION}${BLT_MINOR_VERSION}
1068
1069case $target in
1070  *-aix4.[[2-9]]*)
1071    # No Position-Independent flags needed
1072    SHLIB_CFLAGS=""
1073
1074    # Use the installed export file or the one found in the source directory.
1075
1076    if test -r "${TCL_LIB_DIR}/lib${TCL_LIB_NAME}.exp" ; then
1077      tcl_exp="${TCL_LIB_DIR}/lib${TCL_LIB_NAME}.exp"
1078    else
1079      tcl_exp="${TCL_SRC_DIR}/unix/lib.exp"
1080    fi
1081    if test -r "${TK_LIB_DIR}/lib${TK_LIB_NAME}.exp" ; then
1082      tk_exp="${TK_LIB_DIR}/lib${TK_LIB_NAME}.exp"
1083    else
1084      tk_exp="${TK_SRC_DIR}/unix/lib.exp"
1085    fi
1086
1087    full_src_path=`cd ${srcdir}; pwd`
1088
1089    # Use shell-script to link shared library
1090    SHLIB_LD="${full_src_path}/cf/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry -bI:${tk_exp} -bI:${tcl_exp}"
1091
1092    SHLIB_LIB_SPECS="${aix_lib_specs} -lc"
1093
1094    LDFLAGS="-L${loader_run_path}"
1095    EXTRA_LIB_SPECS="-ldl"
1096    ;;
1097
1098  *-aix*)
1099    # No Position-Independent flags needed
1100    SHLIB_CFLAGS=""
1101
1102    # Use the installed export file or the one found in the source directory.
1103
1104    if test -r "${TCL_LIB_DIR}/lib${TCL_LIB_NAME}.exp" ; then
1105      tcl_exp="${TCL_LIB_DIR}/lib${TCL_LIB_NAME}.exp"
1106    else
1107      tcl_exp="${TCL_SRC_DIR}/unix/lib.exp"
1108    fi
1109    if test -r "${TK_LIB_DIR}/lib${TK_LIB_NAME}.exp" ; then
1110      tk_exp="${TK_LIB_DIR}/lib${TK_LIB_NAME}.exp"
1111    else
1112      tk_exp="${TK_SRC_DIR}/unix/lib.exp"
1113    fi
1114
1115    full_src_path=`cd ${srcdir}/cf; pwd`
1116
1117    # Use shell-script to link shared library
1118
1119    SHLIB_LD="${full_src_path}/ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry -bI:${tk_exp} -bI:${tcl_exp}"
1120
1121    SHLIB_LIB_SPECS="${aix_lib_specs} -lc"
1122
1123    LDFLAGS="-L${loader_run_path}"
1124    EXTRA_LIB_SPECS="-lld"
1125    ;;
1126
1127  *-bsdi2*|*-bsdi3*)
1128    SHLIB_CFLAGS=""
1129    SHLIB_LD="shlicc"
1130    SHLIB_LD_FLAGS="-r"
1131
1132    EXTRA_LIB_SPECS="-ldl"
1133    ;;
1134
1135  *-bsdi4*)
1136    SHLIB_CFLAGS="-export-dynamic -fPIC"
1137    SHLIB_LD="${CC}"
1138    SHLIB_LD_FLAGS='-shared -Wl,-E -Wl,-soname,$@'
1139    ;;
1140
1141  *-*-cygwin* | *-*-mingw*)
1142    SHLIB_LD="${CC}"
1143    SHLIB_LD_FLAGS='-shared -Wl,-E -Wl,--out-implib,$@'
1144    EXTRA_LIB_SPECS="-lwinspool"
1145    LDFLAGS=""
1146    ;;
1147
1148  *-dgux*)
1149    SHLIB_CFLAGS="-K PIC"
1150    SHLIB_LD="cc"
1151    SHLIB_LD_FLAGS="-G"
1152
1153    EXTRA_LIB_SPECS="-ldl"
1154    ;;
1155
1156  *-hpux*)
1157    if test "$blt_have_gcc" = "no" ; then
1158      DEFINES="$DEFINES -D_HPUX_SOURCE"
1159    fi
1160    AC_CHECK_LIB(dld, shl_load, [found=yes], [found=no])
1161    if test "${found}" = "yes" ; then
1162      SHLIB_CFLAGS="+Z"
1163      SHLIB_LD="ld"
1164      SHLIB_LD_FLAGS="-b -E -n +s +b,${loader_run_path}:."
1165      SHLIB_SUFFIX=".sl"
1166
1167      # The run path is included in both LDFLAGS and SHLIB_LD_FLAGS
1168      # because SHLIB_LD is ld and LD is cc/gcc.
1169
1170      LDFLAGS="-Wl,-E -Wl,+s,+b,${loader_run_path}:."
1171      EXTRA_LIB_SPECS="-ldld"
1172    fi
1173    ;;
1174
1175  *-irix64-6.5*)
1176    SHLIB_CFLAGS=""
1177    SHLIB_LD="ld"
1178    SHLIB_LD_FLAGS="-32 -shared -rdata_shared"
1179    LD_RUN_PATH="-Wl,-rpath,${loader_run_path}"
1180    ;;
1181
1182  *-irix-[56].*|*-irix64-*)
1183    SHLIB_CFLAGS=""
1184    SHLIB_LD="ld"
1185    SHLIB_LD_FLAGS="-shared -rdata_shared"
1186    LD_RUN_PATH="-Wl,-rpath,${loader_run_path}"
1187    LDFLAGS=""
1188    if test "$blt_have_gcc" = "yes" ; then
1189      SHLIB_CFLAGS="-mabi=n32 $SHLIB_CFLAGS"
1190      SHLIB_LD_FLAGS="-mabi=n32 $SHLIB_LD_FLAGS"
1191      LDFLAGS="-mabi=n32 $LDFLAGS"
1192    else
1193      CFLAGS="-n32 $CFLAGS"
1194      LDFLAGS="-n32 $LDFLAGS"
1195    fi
1196    ;;
1197
1198  *-linux*)
1199    SHLIB_CFLAGS="-fPIC"
1200    SHLIB_LD="${CC}"
1201    SHLIB_LD_FLAGS='-rdynamic -shared -Wl,-E -Wl,-soname,$@'
1202    LD_RUN_PATH="-Wl,-rpath,${loader_run_path}"
1203
1204    LDFLAGS=""
1205    EXTRA_LIB_SPECS="-ldl"
1206    ;;
1207
1208  *-mp-ras-02*)
1209    SHLIB_CFLAGS="-G -K PIC"
1210    SHLIB_LD="${CC}"
1211    SHLIB_LD_FLAGS=""
1212    ;;
1213
1214  *-mp-ras-*)
1215    SHLIB_CFLAGS="-G -K PIC"
1216    SHLIB_LD="${CC}"
1217    SHLIB_LD_FLAGS="-Wl,-Bexport"
1218    ;;
1219
1220  *-ncr-sysv4-*2*)
1221    SHLIB_CFLAGS="-K PIC"
1222    SHLIB_LD="cc"
1223    SHLIB_LD_FLAGS="-G"
1224
1225    EXTRA_LIB_SPECS="-ldl"
1226    ;;
1227
1228  *-ncr-sysv4*)
1229    SHLIB_CFLAGS="-K PIC"
1230    SHLIB_LD="cc"
1231    SHLIB_LD_FLAGS="-G -Wl,-Bexport"
1232
1233    LDFLAGS="-Wl,-Bexport"
1234    EXTRA_LIB_SPECS="-ldl"
1235    ;;
1236
1237  *-netbsd*|*-freebsd*|*-openbsd*)
1238    # Not available on all versions:  check for include file.
1239    AC_CHECK_HEADER(dlfcn.h, test_ok=yes, test_ok=no)
1240    if test "$test_ok" = yes; then
1241      SHLIB_CFLAGS="-fpic"
1242      SHLIB_LD="ld"
1243      SHLIB_LD_FLAGS="-Bshareable -x"
1244    fi
1245    ;;
1246
1247  *-nextstep*)
1248    SHLIB_CFLAGS=""
1249    SHLIB_LD="cc"
1250    SHLIB_LD_FLAGS="-nostdlib -r"
1251    ;;
1252
1253  *-osf1-1.[012]*)
1254    # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
1255
1256    SHLIB_CFLAGS=""
1257
1258    # Warning: Ugly Makefile Hack
1259    #	Make package name same as library name
1260
1261    SHLIB_LD='ld -R -export $@:'
1262    ;;
1263
1264  *-osf1-1.*)
1265    # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
1266
1267    SHLIB_CFLAGS="-fpic"
1268    SHLIB_LD="ld -shared"
1269    ;;
1270
1271  *-osf1V*)
1272    # Digital OSF/1
1273
1274    SHLIB_CFLAGS=""
1275    SHLIB_LD='ld'
1276    SHLIB_LD_FLAGS='-shared -expect_unresolved "*"'
1277    LD_RUN_PATH="-Wl,-rpath,${loader_run_path}"
1278    LDFLAGS=""
1279    ;;
1280
1281  *-sco*)
1282    # Note, dlopen is available only on SCO 3.2.5 and greater.  However,
1283    # this test works, since "uname -s" was non-standard in 3.2.4 and
1284    # below.
1285
1286    SHLIB_CFLAGS="-Kpic -belf"
1287    SHLIB_LD="ld"
1288    SHLIB_LD_FLAGS="-G"
1289    LDFLAGS="-belf -Wl,-Bexport"
1290    ;;
1291
1292  *-sni-sysv*)
1293
1294    SHLIB_CFLAGS="-K PIC"
1295    SHLIB_LD="cc"
1296    SHLIB_LD_FLAGS="-G"
1297
1298    EXTRA_LIB_SPECS="-ldl"
1299    ;;
1300
1301  *-sunos4*)
1302
1303    SHLIB_CFLAGS="-PIC"
1304    SHLIB_LD="ld"
1305    SHLIB_LD_FLAGS="-assert pure-text"
1306
1307    EXTRA_LIB_SPECS="-ldl"
1308    ;;
1309
1310  *-solaris2*)
1311
1312    SHLIB_CFLAGS="-KPIC"
1313    if test "${blt_with_gnu_ld}" = "yes" -a "$blt_have_gcc" = "yes" ; then
1314      SHLIB_LD="gcc"
1315      SHLIB_LD_FLAGS='-rdynamic -shared -Wl,-E -Wl,-soname,$@'
1316      LD_RUN_PATH="-Wl,-rpath,${loader_run_path}"
1317    else
1318      SHLIB_LD="/usr/ccs/bin/ld"
1319      SHLIB_LD_FLAGS="-G -z text"
1320      LD_RUN_PATH="-R ${loader_run_path}"
1321    fi
1322    EXTRA_LIB_SPECS="-ldl"
1323  ;;
1324
1325  *-mips-dde-sysv*)
1326
1327    SHLIB_CFLAGS="-KPIC"
1328    SHLIB_LD="cc"
1329    SHLIB_LD_FLAGS="-G"
1330
1331    EXTRA_LIB_SPECS="-ldl"
1332    ;;
1333
1334  *-pc-sysv4* | *-unixware-5*)
1335    SHLIB_CFLAGS="-G -KPIC"
1336    SHLIB_LD="${CC}"
1337    SHLIB_LD_FLAGS=" -Wl,-Bexport"
1338    ;;
1339
1340  *)
1341    build_shared="no"
1342    ;;
1343
1344esac
1345
1346# If we're running gcc, then set SHLIB_CFLAGS flags for compiling
1347# shared libraries for gcc, instead of those of the vendor's
1348# compiler.
1349
1350
1351if test "$blt_have_gcc" = "yes" ; then
1352  SHLIB_CFLAGS="-fPIC"
1353fi
1354
1355# We can't back link against static versions of Tcl/Tk.
1356# If # ${TCL_SHARED_BUILD} can't be found or isn't "1", assume that
1357# shared libraies weren't built.
1358
1359if test "${TCL_SHARED_BUILD}" != "1" ; then
1360  SHLIB_LIB_SPECS=""
1361fi
1362
1363if test "${build_shared}" = "yes" ; then
1364  SHLIB_TARGET="build_shared"
1365  AC_SUBST(SHLIB_CFLAGS)
1366  AC_SUBST(SHLIB_TARGET)
1367  AC_SUBST(SHLIB_LD)
1368  AC_SUBST(SHLIB_LD_FLAGS)
1369  AC_SUBST(SHLIB_LIB_SPECS)
1370  AC_SUBST(SHLIB_TCL_ONLY_LIB_SPECS)
1371  AC_SUBST(SHLIB_SUFFIX)
1372fi
1373
1374AC_SUBST(LDFLAGS)
1375AC_SUBST(LD_RUN_PATH)
1376
1377LIBS=${LIB_SPECS}
1378AC_SUBST(LIB_SPECS)
1379AC_SUBST(TCL_ONLY_LIB_SPECS)
1380AC_SUBST(EXTRA_LIB_SPECS)
1381
1382INCLUDES=${INC_SPECS}
1383AC_SUBST(INCLUDES)
1384AC_SUBST(DEFINES)
1385AC_SUBST(BLT_MAJOR_VERSION)
1386AC_SUBST(BLT_MINOR_VERSION)
1387AC_SUBST(BLT_VERSION)
1388AC_SUBST(AUX_LIBS)
1389AC_SUBST(TCL_LIB_DIR)
1390AC_SUBST(TCL_VERSION)
1391BLT_LIB_PREFIX=${blt_lib_prefix}
1392AC_SUBST(BLT_LIB_PREFIX)
1393
1394#--------------------------------------------------------------------
1395#	The BLT script directory was either specified or we
1396#	assume <prefix>/lib
1397#--------------------------------------------------------------------
1398if test "x${blt_with_scriptdir}" = "x" ; then
1399  BLT_LIBRARY="${prefix}/lib/blt${BLT_VERSION}"
1400else
1401  BLT_LIBRARY="${blt_with_scriptdir}/blt${BLT_VERSION}"
1402fi
1403AC_SUBST(BLT_LIBRARY)
1404
1405#--------------------------------------------------------------------
1406#	Print out some of the more important settings
1407#--------------------------------------------------------------------
1408echo ""
1409echo "Configuration results:"
1410echo ""
1411echo "  tcl.h      found in  $TCL_INC_DIR"
1412echo "  tk.h       found in  $TK_INC_DIR"
1413echo "  X11/Xlib.h found in  $x_includes"
1414echo "  lib${TCL_LIB_NAME}  found in  $TCL_LIB_DIR"
1415echo "  lib${TK_LIB_NAME}   found in  $TK_LIB_DIR"
1416echo "  libX11     found in  $x_libraries"
1417echo ""
1418echo "Directories where BLT is to be installed:"
1419echo ""
1420echo "  \"\$prefix\" is $prefix"
1421echo "  \"\$exec_prefix\" is $exec_prefix"
1422echo ""
1423echo "  bltwish      to be installed in  $bindir"
1424echo "  libBLT.a     to be installed in  $libdir"
1425echo "  scripts      to be installed in  $BLT_LIBRARY"
1426echo "  manual pages to be installed in  $mandir"
1427echo ""
1428
1429#--------------------------------------------------------------------
1430#
1431#	Generate the following Makefiles
1432#
1433#	   ./Makefile
1434#	   ./generic/Makefile
1435#	   ./generic/shared/Makefile
1436#	   ./man/Makefile
1437#	   ./library/Makefile
1438#	   ./demos/Makefile
1439#
1440#--------------------------------------------------------------------
1441src_Makefile="generic/Makefile"
1442if test "${blt_platform}" = "win"; then
1443    src_Makefile="generic/Makefile:generic/Makefile-cyg.in"
1444fi
1445AC_OUTPUT(Makefile ${src_Makefile} generic/bltHash.h generic/shared/Makefile man/Makefile library/Makefile demos/Makefile)
1446
1447