resetting manifest requested domain to floor
[platform/upstream/expect.git] / configure.in
1 dnl
2 dnl Process this file with autoconf to produce a configure script.
3 dnl
4 AC_REVISION($Id: configure.in,v 5.80 2010/08/27 21:51:53 hobbs Exp $)
5
6 AC_INIT([expect],[5.45])
7
8 TEA_INIT([3.9])
9
10 AC_CONFIG_AUX_DIR(tclconfig)
11
12 #--------------------------------------------------------------------
13 # Configure script for package 'Expect'.
14 # TEA compliant.
15 #--------------------------------------------------------------------
16
17 #--------------------------------------------------------------------
18 # Load the tclConfig.sh file
19 #--------------------------------------------------------------------
20
21 TEA_PATH_TCLCONFIG
22 TEA_LOAD_TCLCONFIG
23
24 # expectk has been removed from the distribution as Tcl has supported
25 # dynamic extensions everywhere for a while.  We still allow 'expect'
26 # to be built for the die-hard users, but expectk is just wish with
27 # package require Expect
28 if test "${with_tk+set}" = set ; then
29     AC_MSG_WARN([With Tk request ignored - use package require Tk & Expect])
30 fi
31
32 #-----------------------------------------------------------------------
33 # Handle the --prefix=... option by defaulting to what Tcl gave.
34 # Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER.
35 #-----------------------------------------------------------------------
36
37 TEA_PREFIX
38
39 #-----------------------------------------------------------------------
40 # Standard compiler checks.
41 # This sets up CC by using the CC env var, or looks for gcc otherwise.
42 # This also calls AC_PROG_CC, AC_PROG_INSTALL and a few others to create
43 # the basic setup necessary to compile executables.
44 #-----------------------------------------------------------------------
45
46 TEA_SETUP_COMPILER
47
48 #--------------------------------------------------------------------
49 # __CHANGE__
50 # Choose which headers you need.  Extension authors should try very
51 # hard to only rely on the Tcl public header files.  Internal headers
52 # contain private data structures and are subject to change without
53 # notice.
54 # This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG
55 #--------------------------------------------------------------------
56
57 #TEA_PUBLIC_TCL_HEADERS
58 TEA_PRIVATE_TCL_HEADERS
59
60 #--------------------------------------------------------------------
61 # You can add more files to clean if your extension creates any extra
62 # files by extending CLEANFILES.
63 # Add pkgIndex.tcl if it is generated in the Makefile instead of ./configure
64 # and change Makefile.in to move it from CONFIG_CLEAN_FILES to BINARIES var.
65 #
66 # A few miscellaneous platform-specific items:
67 # TEA_ADD_* any platform specific compiler/build info here.
68 #--------------------------------------------------------------------
69
70 TEA_ADD_CLEANFILES([pkgIndex.tcl])
71
72 #--------------------------------------------------------------------
73 # Check whether --enable-threads or --disable-threads was given.
74 # So far only Tcl responds to this one.
75 #
76 # Hook for when threading is supported in Expect.  The --enable-threads
77 # flag currently has no effect.
78 #------------------------------------------------------------------------
79
80 TEA_ENABLE_THREADS
81
82 #--------------------------------------------------------------------
83 # The statement below defines a collection of symbols related to
84 # building as a shared library instead of a static library.
85 #--------------------------------------------------------------------
86
87 TEA_ENABLE_SHARED
88
89 #--------------------------------------------------------------------
90 # This macro figures out what flags to use with the compiler/linker
91 # when building shared/static debug/optimized objects.  This information
92 # can be taken from the tclConfig.sh file, but this figures it all out.
93 #--------------------------------------------------------------------
94
95 TEA_CONFIG_CFLAGS
96
97 #--------------------------------------------------------------------
98 # Set the default compiler switches based on the --enable-symbols option.
99 #--------------------------------------------------------------------
100
101 TEA_ENABLE_SYMBOLS
102
103 #--------------------------------------------------------------------
104 # Everyone should be linking against the Tcl stub library.  If you
105 # can't for some reason, remove this definition.  If you aren't using
106 # stubs, you also need to modify the SHLIB_LD_LIBS setting below to
107 # link against the non-stubbed Tcl library.
108 #--------------------------------------------------------------------
109
110 AC_DEFINE(USE_TCL_STUBS)
111 AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs])
112
113 #-------------------------------------------------------------------------
114 # Check for system header files.
115 #-------------------------------------------------------------------------
116
117 AC_CHECK_HEADER(sys/select.h,    AC_DEFINE(HAVE_SYS_SELECT_H))
118 AC_CHECK_HEADER(sys/sysmacros.h, AC_DEFINE(HAVE_SYSMACROS_H))
119
120 # Oddly, some systems have stdarg but don't support prototypes
121 # Tcl avoids the whole issue by not using stdarg on UNIX at all!
122
123 dnl AC_CHECK_HEADER(stdarg.h, AC_DEFINE(HAVE_STDARG_H))
124
125 AC_CHECK_HEADER(varargs.h, AC_DEFINE(HAVE_VARARGS_H))
126
127 # If no stropts.h, then the svr4 implementation is broken.
128 # At least it is on my Debian "potato" system. - Rob Savoye
129
130 AC_CHECK_HEADER(sys/stropts.h,   AC_DEFINE(HAVE_STROPTS_H), svr4_ptys_broken=1)
131 AC_CHECK_HEADER(sys/sysconfig.h, AC_DEFINE(HAVE_SYSCONF_H))
132 AC_CHECK_HEADER(sys/fcntl.h,     AC_DEFINE(HAVE_SYS_FCNTL_H))
133 AC_CHECK_HEADER(sys/ptem.h,      AC_DEFINE(HAVE_SYS_PTEM_H))
134 AC_CHECK_HEADER(sys/strredir.h,  AC_DEFINE(HAVE_STRREDIR_H))
135 AC_CHECK_HEADER(sys/strpty.h,    AC_DEFINE(HAVE_STRPTY_H))
136
137 AC_MSG_CHECKING([for sys/bsdtypes.h])
138 if test "ISC_${ISC}" = "ISC_1"   ;    then
139    AC_MSG_RESULT(yes)
140    # if on ISC 1, we need <sys/bsdtypes.h> to get FD_SET macros
141    AC_HAVE_HEADERS(sys/bsdtypes.h)
142 else
143    AC_MSG_RESULT(no)
144 fi
145
146 #-------------------------------------------------------------------------
147 # What type do signals return?
148 #-------------------------------------------------------------------------
149
150 AC_TYPE_SIGNAL
151
152 #-------------------------------------------------------------------------
153 #       Find out all about time handling differences.
154 #-------------------------------------------------------------------------
155
156 TEA_TIME_HANDLER
157
158 #--------------------------------------------------------------------
159 #       The check below checks whether <sys/wait.h> defines the type
160 #       "union wait" correctly.  It's needed because of weirdness in
161 #       HP-UX where "union wait" is defined in both the BSD and SYS-V
162 #       environments.  Checking the usability of WIFEXITED seems to do
163 #       the trick.
164 #--------------------------------------------------------------------
165
166 AC_MSG_CHECKING([union wait])
167 AC_CACHE_VAL(tcl_cv_union_wait,
168     AC_TRY_LINK([#include <sys/types.h> 
169 #include <sys/wait.h>], [
170 union wait x;
171 WIFEXITED(x);   /* Generates compiler error if WIFEXITED uses an int. */
172                          ], tcl_cv_union_wait=yes, tcl_cv_union_wait=no))
173 AC_MSG_RESULT($tcl_cv_union_wait)
174 if test $tcl_cv_union_wait = no; then
175     AC_DEFINE(NO_UNION_WAIT)
176 fi
177
178 ######################################################################
179 # required by Sequent ptx2
180
181 AC_CHECK_FUNC(gethostname, gethostname=1 , gethostname=0)
182 if test $gethostname -eq 0 ; then
183   AC_CHECK_LIB(inet, gethostname, LIBS="$LIBS -linet")
184 fi
185
186 ######################################################################
187 # required by Fischman's ISC 4.0
188
189 AC_CHECK_FUNC(socket, socket=1 , socket=0)
190 if test $socket -eq 0 ; then
191   AC_CHECK_LIB(inet, socket, LIBS="$LIBS -linet")
192 fi
193
194 ######################################################################
195
196 AC_CHECK_FUNC(select, select=1 , select=0)
197 if test $select -eq 0 ; then
198   AC_CHECK_LIB(inet, select, LIBS="$LIBS -linet")
199 fi
200
201 ######################################################################
202
203 AC_CHECK_FUNC(getpseudotty, getpseudotty=1 , getpseudotty=0)
204 if test $getpseudotty -eq 0 ; then
205   AC_CHECK_LIB(seq, getpseudotty)
206 fi
207
208 ######################################################################
209 # Check for FreeBSD/NetBSD openpty()
210 unset ac_cv_func_openpty
211
212 AC_CHECK_FUNC(openpty, AC_DEFINE(HAVE_OPENPTY) openpty=1 , openpty=0)
213 if test $openpty -eq 0 ; then
214   AC_CHECK_LIB(util, openpty, [
215         # we only need to define OPENPTY once, but since we are overriding
216         # the default behavior, we must also handle augment LIBS too.
217         # This needn't be done in the 2nd and 3rd tests.
218         AC_DEFINE(HAVE_OPENPTY)
219         LIBS="$LIBS -lutil"
220   ])
221 fi
222
223 ######################################################################
224 # End of library/func checking
225 ######################################################################
226
227 # Hand patches to library/func checking.
228 dnl From: Michael Kuhl <mkuhl@legato.com>
229 dnl To get expect to compile on a Sequent NUMA-Q running DYNIX/ptx v4.4.2.
230
231 AC_MSG_CHECKING([if running Sequent running SVR4])
232 if test "$host_alias" = "i386-sequent-sysv4" ; then
233  LIBS="-lnsl -lsocket -lm"
234  AC_MSG_RESULT(yes)
235 else
236  AC_MSG_RESULT(no)
237 fi
238
239 #--------------------------------------------------------------------
240 #--------------------------------------------------------------------
241 #--------------------------------------------------------------------
242 #--------------------------------------------------------------------
243 # From here on comes original expect configure code.
244 # At the end we will have another section of TEA 3.2 code.
245 #
246 # Note specialities
247 #
248 # - Runs a sub configure (Dbgconfigure) for the expect tcl debugger
249 #
250 #--------------------------------------------------------------------
251 #--------------------------------------------------------------------
252
253 dnl AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
254 AC_CANONICAL_SYSTEM
255
256 # If `configure' is invoked (in)directly via `make', ensure that it
257 # encounters no `make' conflicts.
258 #
259
260 dnl unset MFLAGS MAKEFLAGS
261 MFLAGS=
262 MAKEFLAGS=
263
264 # An explanation is in order for the strange things going on with the
265 # various LIBS.  There are three separate definitions for LIBS.  The
266 # reason is that some systems require shared libraries include
267 # references to their dependent libraries, i.e., any additional
268 # libraries that must be linked to.  And some systems get upset if the
269 # references are repeated on the link line.  So therefore, we create
270 # one for Expect, one for Expect and Tcl, and one for building Expect's own
271 # shared library.  Tcl's tclConfig.sh insists that any shared libs
272 # that it "helps" build must pass the libraries as LIBS (see comment
273 # near end of this configure file).  I would do but since we're close
274 # to hitting config's max symbols, we take one short cut and pack the
275 # LIBS into EXP_SHLIB_LD_LIBS (which is basically what Tcl wants to do
276 # for us).  The point, however, is that there's no separate LIBS or
277 # EXP_LIBS symbol passed out of configure.  One additional point for
278 # confusion is that LIBS is what configure uses to do all library
279 # tests, so we have to swap definitions of LIBS periodically.  When we
280 # are swapping out the one for Expect's shared library, we save it in
281 # EXP_LIBS.  Sigh.
282
283 eval "LIBS=\"$TCL_LIBS\""
284
285 if test "${with_tcl+set}" = set ; then
286     case "${with_tcl}" in
287         ..*)
288             AC_MSG_WARN([Specify absolute path to --with-tcl for subdir configuration])
289             ;;
290     esac
291 fi
292
293 # these are the other subdirectories we need to configure
294 AC_CONFIG_SUBDIRS(testsuite)
295
296 AC_TYPE_PID_T
297
298 AC_MSG_CHECKING([if running Mach])
299 mach=0
300 case "${host}" in
301   # Both Next and pure Mach behave identically with respect
302   # to a few things, so just lump them together as "mach"
303   *-*-mach*)            mach=1 ;;
304   *-*-next*)            mach=1 ; next=1 ;;
305 esac
306
307 if test $mach -eq 1 ; then
308   AC_MSG_RESULT(yes)
309 else
310   AC_MSG_RESULT(no)
311 fi
312
313 AC_MSG_CHECKING([if running MachTen])
314 # yet another Mach clone
315 if test -r /MachTen ; then
316   AC_MSG_RESULT(yes)
317   mach=1
318 else
319   AC_MSG_RESULT(no)
320 fi
321
322 AC_MSG_CHECKING([if on Pyramid])
323 if test -r /bin/pyr ; then
324   AC_MSG_RESULT(yes)
325   pyr=1
326 else
327   AC_MSG_RESULT(no)
328   pyr=0
329 fi
330
331 AC_MSG_CHECKING([if on Apollo])
332 if test -r /usr/apollo/bin ; then
333   AC_MSG_RESULT(yes)
334   apollo=1
335 else
336   AC_MSG_RESULT(no)
337   apollo=0
338 fi
339
340 AC_MSG_CHECKING([if on Interactive])
341 if test "x`(uname -s) 2>/dev/null`" = xIUNIX; then
342   AC_MSG_RESULT(yes)
343   iunix=1
344 else
345   AC_MSG_RESULT(no)
346   iunix=0
347 fi
348
349 AC_MSG_CHECKING([stty to use])
350 if test -r /usr/local/bin/stty ; then
351   STTY_BIN=/usr/local/bin/stty
352 else
353   STTY_BIN=/bin/stty
354 fi
355 AC_MSG_RESULT($STTY_BIN)
356
357 AC_MSG_CHECKING([if stty reads stdout])
358
359 # On some systems stty can't be run in the background (svr4) or get it
360 # wrong because they fail to complain (next, mach), so don't attempt
361 # the test on some systems.
362
363 stty_reads_stdout=""
364 case "${host}" in
365   *-*-solaris*)         stty_reads_stdout=0 ;;
366   *-*-irix*)            stty_reads_stdout=0 ;;
367   *-*-sco3.2v[[45]]*)   stty_reads_stdout=1 ;;
368   i[[3456]]86-*-sysv4.2MP)      stty_reads_stdout=0 ;;
369   *-*-linux*)           stty_reads_stdout=0 ;;
370   # Not sure about old convex but 5.2 definitely reads from stdout
371   c[[12]]-*-*)          stty_reads_stdout=1 ;;
372   *-*-aix[[34]]*)       stty_reads_stdout=0 ;;
373   *-*-hpux9*)           stty_reads_stdout=0 ;;
374   *-*-hpux10*)          stty_reads_stdout=0 ;;
375   *-*-osf[[234]]*)      stty_reads_stdout=0 ;;
376   *-*-ultrix4.4)        stty_reads_stdout=0 ;;
377   *-*-dgux*)            stty_reads_stdout=0 ;;
378 esac
379
380 if test $mach -eq 1 ; then
381   stty_reads_stdout=1
382 fi
383 if test $apollo -eq 1 ; then
384   stty_reads_stdout=1
385 fi
386 if test $pyr -eq 1 ; then
387   stty_reads_stdout=1
388 fi
389
390 # if we still don't know, test
391 if test x"${stty_reads_stdout}" = x"" ; then
392   $STTY_BIN > /dev/null             2> /dev/null ; a=$?
393   $STTY_BIN < /dev/tty  > /dev/null 2> /dev/null ; b=$?
394   if test $a -ne 0 -a $b -ne 0; then
395     stty_reads_stdout=1
396   else
397     stty_reads_stdout=0
398   fi
399 fi
400
401 if test ${stty_reads_stdout} -eq 1 ; then
402   AC_MSG_RESULT(yes)
403   AC_DEFINE(STTY_READS_STDOUT)
404 else
405   AC_MSG_RESULT(no)
406 fi
407
408 # Solaris 2.4 and later requires __EXTENSIONS__ in order to see all sorts
409 # of traditional but nonstandard stuff in header files.
410 AC_MSG_CHECKING([if running Solaris])
411 solaris=0
412 case "${host}" in
413   *-*-solaris*)         solaris=1;;
414 esac
415
416 if test $solaris -eq 1 ; then
417   AC_MSG_RESULT(yes)
418   AC_DEFINE(SOLARIS)
419 else
420   AC_MSG_RESULT(no)
421 fi
422
423 # On Interactive UNIX, -Xp must be added to LIBS in order to find strftime.
424 # This test should really be done by Tcl.  So just check Tcl's definition.
425 # If defective, add to all three LIBS.  (It's not actually necessary for
426 # EXP_LIBS since -Xp will just be ignored the way that EXP_LIBS is used in
427 # the Makefile, but we include it for consistency.)
428
429 if test $iunix -eq 1 ; then
430   AC_CHECK_FUNC(strftime, , [
431         LIBS="${LIBS} -Xp" 
432         ])
433 fi
434
435 ######################################################################
436 #
437 # Look for various header files
438 #
439
440 #
441 # Look for functions that may be missing
442 #
443 dnl AC_CHECK_FUNC(memcpy, AC_DEFINE(HAVE_MEMCPY))
444 AC_CHECK_FUNC(memmove, AC_DEFINE(HAVE_MEMMOVE))
445 AC_CHECK_FUNC(sysconf, AC_DEFINE(HAVE_SYSCONF))
446 AC_CHECK_FUNC(strftime, AC_DEFINE(HAVE_STRFTIME))
447 AC_CHECK_FUNC(strchr, AC_DEFINE(HAVE_STRCHR))
448 AC_CHECK_FUNC(timezone, AC_DEFINE(HAVE_TIMEZONE))
449 AC_CHECK_FUNC(siglongjmp, AC_DEFINE(HAVE_SIGLONGJMP))
450
451 # dnl check for memcpy by hand
452 # because Unixware 2.0 handles it specially and refuses to compile
453 # autoconf's automatic test that is a call with no arguments
454 AC_MSG_CHECKING([for memcpy])
455 AC_TRY_LINK(,[
456 char *s1, *s2;
457 memcpy(s1,s2,0);
458 ],
459         AC_MSG_RESULT(yes)
460         AC_DEFINE(HAVE_MEMCPY)
461         ,
462         AC_MSG_RESULT(no)
463 )
464
465 # Some systems only define WNOHANG if _POSIX_SOURCE is defined
466 # The following merely tests that sys/wait.h can be included
467 # and if so that WNOHANG is not defined.  The only place I've
468 # seen this is ISC.
469 AC_MSG_CHECKING([if WNOHANG requires _POSIX_SOURCE])
470 AC_TRY_RUN([
471 #include <sys/wait.h>
472 main() {
473 #ifndef WNOHANG
474         return 0;
475 #else
476         return 1;
477 #endif
478 }],
479         AC_MSG_RESULT(yes)
480         AC_DEFINE(WNOHANG_REQUIRES_POSIX_SOURCE)
481 ,
482         AC_MSG_RESULT(no)
483 ,
484         AC_MSG_ERROR([Expect can't be cross compiled])
485 )
486
487 AC_MSG_CHECKING([if any value exists for WNOHANG])
488 rm -rf wnohang
489 AC_TRY_RUN([
490 #include <stdio.h>
491 #include <sys/wait.h>
492 main() {
493 #ifdef WNOHANG
494         FILE *fp = fopen("wnohang","w");
495         fprintf(fp,"%d",WNOHANG);
496         fclose(fp);
497         return 0;
498 #else
499         return 1;
500 #endif
501 }],
502         AC_MSG_RESULT(yes)
503         AC_DEFINE_UNQUOTED(WNOHANG_BACKUP_VALUE, `cat wnohang`)
504         rm -f wnohang
505 ,
506         AC_MSG_RESULT(no)
507         AC_DEFINE(WNOHANG_BACKUP_VALUE, 1)
508 ,
509         AC_MSG_ERROR([Expect can't be cross compiled])
510 )
511
512 #
513 # check how signals work
514 #
515
516 # Check for the data type of the mask used in select().
517 # This picks up HP braindamage which defines fd_set and then 
518 # proceeds to ignore it and use int.
519 # Pattern matching on int could be loosened.
520 # Can't use ac_header_egrep since that doesn't see prototypes with K&R cpp.
521 AC_MSG_CHECKING([mask type of select])
522 if egrep "select\(size_t, int" /usr/include/sys/time.h >/dev/null 2>&1; then
523   AC_MSG_RESULT(int)
524   AC_DEFINE(SELECT_MASK_TYPE, int)
525 else
526   AC_MSG_RESULT(none)
527   AC_DEFINE(SELECT_MASK_TYPE, fd_set)
528 fi
529
530 dnl # Check for the data type of the function used in signal(). This
531 dnl # must be before the test for rearming.
532 dnl # echo checking return type of signal handlers
533 dnl AC_HEADER_EGREP([(void|sighandler_t).*signal], signal.h, retsigtype=void,AC_DEFINE(RETSIGTYPE, int) retsigtype=int)
534
535 # FIXME: check if alarm exists
536 AC_MSG_CHECKING([if signals need to be re-armed])
537 AC_TRY_RUN([
538 #include <signal.h>
539 #define RETSIGTYPE $retsigtype
540
541 int signal_rearms = 0;
542
543 RETSIGTYPE
544 child_sigint_handler(n)
545 int n;
546 {
547 }
548
549 RETSIGTYPE
550 parent_sigint_handler(n)
551 int n;
552 {
553 signal_rearms++;
554 }
555
556 main()
557 {
558         signal(SIGINT,parent_sigint_handler);
559
560         if (0 == fork()) {
561                 signal(SIGINT,child_sigint_handler);
562                 kill(getpid(),SIGINT);
563                 kill(getpid(),SIGINT);
564                 kill(getppid(),SIGINT);
565         } else {
566                 int status;
567
568                 wait(&status);
569                 unlink("core");
570                 exit(signal_rearms);
571         }
572 }],
573         AC_MSG_RESULT(yes)
574         AC_DEFINE(REARM_SIG)
575 ,
576         AC_MSG_RESULT(no)
577 , AC_MSG_WARN([Expect can't be cross compiled])
578 )
579
580 # HPUX7 has trouble with the big cat so split it
581 # Owen Rees <rtor@ansa.co.uk> 29Mar93 
582 SEDDEFS="${SEDDEFS}CONFEOF
583 cat >> conftest.sed <<CONFEOF
584 "
585 #
586
587 # There are multiple versions of getpty, alas.
588 # I don't remember who has the first one, but Convex just added one
589 # so check for it.  Unfortunately, there is no header so the only
590 # reasonable way to make sure is to look it we are on a Convex.
591 AC_MSG_CHECKING([if on Convex])
592 convex=0
593 case "${host}" in
594   c[[12]]-*-*)          convex=1;;
595 esac
596
597 if test $convex -eq 1 ; then
598   AC_MSG_RESULT(yes)
599   AC_DEFINE(CONVEX)
600 else
601   AC_MSG_RESULT(no)
602 fi
603
604
605 AC_MSG_CHECKING([if on HP])
606 if test "x`(uname) 2>/dev/null`" = xHP-UX; then
607   AC_MSG_RESULT(yes)
608   hp=1
609 else
610   AC_MSG_RESULT(no)
611   hp=0
612 fi
613
614 AC_MSG_CHECKING([sane default stty arguments])
615 DEFAULT_STTY_ARGS="sane"
616
617 if test $mach -eq 1 ; then
618         DEFAULT_STTY_ARGS="cooked"
619 fi
620
621 if test $hp -eq 1 ; then
622         DEFAULT_STTY_ARGS="sane kill \15"
623 fi
624
625 AC_MSG_RESULT($DEFAULT_STTY_ARG)
626
627 # Look for various features to determine what kind of pty
628 # we have. For some weird reason, ac_compile_check would not
629 # work, but ac_test_program does.
630 #
631 AC_MSG_CHECKING([for HP style pty allocation])
632 # following test fails on DECstations and other things that don't grok -c
633 # but that's ok, since they don't have PTYMs anyway
634 if test -r /dev/ptym/ptyp0 2>/dev/null ; then
635     AC_MSG_RESULT(yes)
636     AC_DEFINE(HAVE_PTYM)
637 else
638     AC_MSG_RESULT(no)
639 fi
640
641 AC_MSG_CHECKING([for HP style pty trapping])
642 AC_HEADER_EGREP([struct.*request_info], sys/ptyio.h,
643         AC_MSG_RESULT(yes)
644         AC_DEFINE(HAVE_PTYTRAP)
645 ,
646         AC_MSG_RESULT(no)
647 )
648
649 AC_MSG_CHECKING([for AIX new-style pty allocation])
650 if test -r /dev/ptc -a -r /dev/pts ; then
651     AC_MSG_RESULT(yes)
652     AC_DEFINE(HAVE_PTC_PTS)
653 else
654     AC_MSG_RESULT(no)
655 fi
656
657 AC_MSG_CHECKING([for SGI old-style pty allocation])
658 if test -r /dev/ptc -a ! -r /dev/pts ; then
659     AC_MSG_RESULT(yes)
660     AC_DEFINE(HAVE_PTC)
661 else
662     AC_MSG_RESULT(no)
663 fi
664
665 # On SCO OpenServer, two types of ptys are available: SVR4 streams and c-list.
666 # The library routines to open the SVR4 ptys are broken on certain systems and
667 # the SCO command to increase the number of ptys only configure c-list ones
668 # anyway.  So we chose these, which have a special numbering scheme.
669 #
670 AC_MSG_CHECKING([for SCO style pty allocation])
671 sco_ptys=""
672 case "${host}" in
673   *-sco3.2v[[45]]*)     sco_clist_ptys=1 svr4_ptys_broken=1;;
674 esac
675
676 if test x"${sco_clist_ptys}" != x"" ; then
677   AC_MSG_RESULT(yes)
678   AC_DEFINE(HAVE_SCO_CLIST_PTYS)
679 else
680   AC_MSG_RESULT(no)
681 fi
682
683 AC_MSG_CHECKING([for SVR4 style pty allocation])
684 if test -r /dev/ptmx -a "x$svr4_ptys_broken" = x ; then
685   AC_MSG_RESULT(yes)
686   AC_DEFINE(HAVE_PTMX)
687   # aargg. Some systems need libpt.a to use /dev/ptmx
688   AC_CHECK_LIB(pt, libpts="-lpt", libpts="")
689   AC_CHECK_FUNC(ptsname, , LIBS="${LIBS} $libpts")
690 else
691   AC_MSG_RESULT(no)
692 fi
693
694 # In OSF/1 case, SVR4 are somewhat different.
695 # Gregory Depp <depp@osf.org> 17Aug93
696 AC_MSG_CHECKING([for OSF/1 style pty allocation])
697 if test -r /dev/ptmx_bsd ; then
698     AC_DEFINE(HAVE_PTMX_BSD)
699     AC_MSG_RESULT(yes)
700 else
701     AC_MSG_RESULT(no)
702 fi
703
704 tcgetattr=0
705 tcsetattr=0
706 AC_CHECK_FUNC(tcgetattr, tcgetattr=1)
707 AC_CHECK_FUNC(tcsetattr, tcsetattr=1)
708 if test $tcgetattr -eq 1 -a $tcsetattr -eq 1 ; then
709     AC_DEFINE(HAVE_TCSETATTR)
710     AC_DEFINE(POSIX)
711 fi
712
713 # first check for the pure bsd
714 AC_MSG_CHECKING([for struct sgttyb])
715 AC_TRY_RUN([
716 #include <sgtty.h>
717 main()
718 {
719   struct sgttyb tmp;
720   exit(0);
721 }],
722         AC_MSG_RESULT(yes)
723         AC_DEFINE(HAVE_SGTTYB)
724         PTY_TYPE=sgttyb
725 ,
726         AC_MSG_RESULT(no)
727 ,
728         AC_MSG_ERROR([Expect can't be cross compiled])
729 )
730
731 # mach systems have include files for unimplemented features
732 # so avoid doing following test on those systems
733 if test $mach -eq 0 ; then
734
735   # next check for the older style ttys
736   # note that if we detect termio.h (only), we still set PTY_TYPE=termios
737   # since that just controls which of pty_XXXX.c file is use and
738   # pty_termios.c is set up to handle pty_termio.
739   AC_MSG_CHECKING([for struct termio])
740   AC_TRY_RUN([#include <termio.h>
741   main()
742   {
743     struct termio tmp;
744     exit(0);
745   }],
746         AC_DEFINE(HAVE_TERMIO)
747         PTY_TYPE=termios
748         AC_MSG_RESULT(yes)
749 ,
750         AC_MSG_RESULT(no)
751 ,
752         AC_MSG_ERROR([Expect can't be cross compiled])
753 )
754
755   # now check for the new style ttys (not yet posix)
756   AC_MSG_CHECKING([for struct termios])
757   AC_TRY_RUN([
758   /* including termios.h on Solaris 5.6 fails unless inttypes.h included */
759 #  ifdef HAVE_INTTYPES_H
760 #  include <inttypes.h>
761 #  endif
762 #  include <termios.h>
763   main()
764   {
765     struct termios tmp;
766     exit(0);
767   }],
768         AC_DEFINE(HAVE_TERMIOS)
769         PTY_TYPE=termios
770         AC_MSG_RESULT(yes)
771   ,
772         AC_MSG_RESULT(no)
773   ,
774         AC_MSG_ERROR([Expect can't be cross compiled])
775   )
776 fi
777
778 AC_MSG_CHECKING([if TCGETS or TCGETA in termios.h])
779 AC_TRY_RUN([
780 /* including termios.h on Solaris 5.6 fails unless inttypes.h included */
781 #ifdef HAVE_INTTYPES_H
782 #include <inttypes.h>
783 #endif
784 #include <termios.h>
785 main() {
786 #if defined(TCGETS) || defined(TCGETA)
787         return 0;
788 #else
789         return 1;
790 #endif
791 }],
792         AC_DEFINE(HAVE_TCGETS_OR_TCGETA_IN_TERMIOS_H)
793         AC_MSG_RESULT(yes)
794 ,
795         AC_MSG_RESULT(no)
796 ,
797         AC_MSG_ERROR([Expect can't be cross compiled])
798 )
799
800 AC_MSG_CHECKING([if TIOCGWINSZ in termios.h])
801 AC_TRY_RUN([
802 /* including termios.h on Solaris 5.6 fails unless inttypes.h included */
803 #ifdef HAVE_INTTYPES_H
804 #include <inttypes.h>
805 #endif
806 #include <termios.h>
807 main() {
808 #ifdef TIOCGWINSZ
809         return 0;
810 #else
811         return 1;
812 #endif
813 }],
814         AC_DEFINE(HAVE_TIOCGWINSZ_IN_TERMIOS_H)
815         AC_MSG_RESULT(yes)
816 ,
817         AC_MSG_RESULT(no)
818 ,
819         AC_MSG_ERROR([Expect can't be cross compiled])
820 )
821
822 # finally check for Cray style ttys
823 AC_MSG_CHECKING([for Cray-style ptys])
824 SETUID=":"
825 AC_TRY_RUN([
826 main(){
827 #ifdef CRAY
828         return 0;
829 #else
830         return 1;
831 #endif
832 }
833 ],
834         PTY_TYPE=unicos
835         SETUID="chmod u+s"
836         AC_MSG_RESULT(yes)
837 ,
838         AC_MSG_RESULT(no)
839 ,
840         AC_MSG_ERROR([Expect can't be cross compiled])
841 )
842
843 #
844 # Check for select and/or poll. If both exist, we prefer select.
845 # if neither exists, define SIMPLE_EVENT.
846 #
847 select=0
848 poll=0
849 unset ac_cv_func_select
850 AC_CHECK_FUNC(select, select=1)
851 AC_CHECK_FUNC(poll,   poll=1)
852 AC_MSG_CHECKING([event handling])
853 if test $select -eq 1 ; then
854   EVENT_TYPE=select
855   EVENT_ABLE=event
856   AC_MSG_RESULT(via select)
857 elif test $poll -eq 1 ; then
858   EVENT_TYPE=poll
859   EVENT_ABLE=event
860   AC_MSG_RESULT(via poll)
861 else
862   EVENT_TYPE=simple
863   EVENT_ABLE=noevent
864   AC_MSG_RESULT(none)
865   AC_DEFINE(SIMPLE_EVENT)
866 fi
867
868 AC_HAVE_FUNCS(_getpty)
869 AC_HAVE_FUNCS(getpty)
870
871 # following test sets SETPGRP_VOID if setpgrp takes 0 args, else takes 2
872 AC_FUNC_SETPGRP
873
874 #
875 # check for timezones
876 #
877 AC_MSG_CHECKING([for SV-style timezone])
878 AC_TRY_RUN([
879 extern char *tzname[2];
880 extern int daylight;
881 main()
882 {
883   int *x = &daylight;
884   char **y = tzname;
885
886   exit(0);
887 }],
888         AC_DEFINE(HAVE_SV_TIMEZONE)
889         AC_MSG_RESULT(yes),
890         AC_MSG_RESULT(no)
891 ,
892         AC_MSG_ERROR([Expect can't be cross compiled])
893 )
894
895
896 # Following comment stolen from Tcl's configure.in:
897 #   Note:  in the following variable, it's important to use the absolute
898 #   path name of the Tcl directory rather than "..":  this is because
899 #   AIX remembers this path and will attempt to use it at run-time to look
900 #   up the Tcl library.
901
902 PACKAGE_VERSION_NODOTS="`echo $PACKAGE_VERSION | sed -e 's/\.//g'`"
903
904 if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
905     EXP_LIB_VERSION=$PACKAGE_VERSION
906 else
907     EXP_LIB_VERSION=$PACKAGE_VERSION_NODOTS
908 fi
909 if test $iunix -eq 1 ; then
910     EXP_LIB_VERSION=$PACKAGE_VERSION_NODOTS
911 fi
912
913 # also remove dots on systems that don't support filenames > 14
914 # (are there systems which support shared libs and restrict filename lengths!?)
915 AC_SYS_LONG_FILE_NAMES
916 if test $ac_cv_sys_long_file_names = no; then
917     EXP_LIB_VERSION=$PACKAGE_VERSION_NODOTS
918 fi
919
920 if test "$FRAMEWORK_BUILD" = "1" ; then
921     EXP_BUILD_LIB_SPEC="-F`pwd` -framework Expect"
922     EXP_LIB_SPEC="-framework Expect"
923     EXP_LIB_FILE="Expect"
924     AC_DEFINE(EXP_FRAMEWORK)
925 else
926     if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
927         EXP_LIB_FLAG="-lexpect${EXP_LIB_VERSION}"
928     else
929         EXP_LIB_FLAG="-lexpect`echo ${EXP_LIB_VERSION} | tr -d .`"
930     fi
931     EXP_BUILD_LIB_SPEC="-L`pwd` ${EXP_LIB_FLAG}"
932     EXP_LIB_SPEC="-L${libdir} ${EXP_LIB_FLAG}"
933 fi
934
935 #--------------------------------------------------------------------
936 # This section is based on analogous thing in Tk installation. - DEL
937 #       Various manipulations on the search path used at runtime to
938 #       find shared libraries:
939 #       2. On systems such as AIX and Ultrix that use "-L" as the
940 #          search path option, colons cannot be used to separate
941 #          directories from each other. Change colons to " -L".
942 #       3. Create two sets of search flags, one for use in cc lines
943 #          and the other for when the linker is invoked directly.  In
944 #          the second case, '-Wl,' must be stripped off and commas must
945 #          be replaced by spaces.
946 #--------------------------------------------------------------------
947
948 LIB_RUNTIME_DIR='${LIB_RUNTIME_DIR}/${PACKAGE_NAME}${PACKAGE_VERSION}'
949
950 # If Tcl and Expect are installed in different places, adjust the library
951 # search path to reflect this.
952
953 if test "$TCL_EXEC_PREFIX" != "$exec_prefix"; then
954     LIB_RUNTIME_DIR="${LIB_RUNTIME_DIR}:${TCL_EXEC_PREFIX}/lib"
955 fi
956
957 if test "${TCL_LD_SEARCH_FLAGS}" = '-L${LIB_RUNTIME_DIR}'; then
958     LIB_RUNTIME_DIR=`echo ${LIB_RUNTIME_DIR} |sed -e 's/:/ -L/g'`
959 fi
960
961 # The eval below is tricky!  It *evaluates* the string in
962 # ..._CC_SEARCH_FLAGS, which causes a substitution of the
963 # variable LIB_RUNTIME_DIR.
964
965 eval "EXP_CC_SEARCH_FLAGS=\"$TCL_CC_SEARCH_FLAGS\""
966
967 # now broken out into EXP_AND_TCL_LIBS.  Had to do this
968 # in order to avoid repeating lib specs to which some systems object.
969
970 LIBS="$LIBS $LD_SEARCH_FLAGS"
971
972 #
973 # Set up makefile substitutions
974 #
975 AC_SUBST(EXP_BUILD_LIB_SPEC)
976 AC_SUBST(EXP_CC_SEARCH_FLAGS)
977 AC_SUBST(SETUID)
978 AC_SUBST(SETPGRP_VOID)
979 AC_SUBST(DEFAULT_STTY_ARGS)
980 # Expect uses these from tclConfig.sh to make the main executable
981 AC_SUBST(TCL_DL_LIBS)
982 AC_SUBST(TCL_CC_SEARCH_FLAGS)
983
984 #--------------------------------------------------------------------
985 # More TEA code based on data we got from the original expect
986 # configure code.
987 #--------------------------------------------------------------------
988
989 #-----------------------------------------------------------------------
990 # Specify the C source files to compile in TEA_ADD_SOURCES,
991 # public headers that need to be installed in TEA_ADD_HEADERS,
992 # stub library C source files to compile in TEA_ADD_STUB_SOURCES,
993 # and runtime Tcl library files in TEA_ADD_TCL_SOURCES.
994 # This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS
995 # and PKG_TCL_SOURCES.
996 #-----------------------------------------------------------------------
997
998 TEA_ADD_SOURCES([
999         exp_command.c expect.c exp_inter.c exp_regexp.c exp_tty.c
1000         exp_log.c exp_main_sub.c exp_pty.c exp_trap.c exp_strf.c
1001         exp_console.c exp_glob.c exp_win.c exp_clib.c exp_closetcl.c
1002         exp_memmove.c exp_tty_comm.c exp_chan.c Dbg.c
1003 ])
1004
1005 # Variant sources. Comments in the Makefile indicate that the
1006 # event_type/able stuff can be overidden in the Makefile, and should
1007 # be for particular systems. IMHO this requires a configure option.
1008 #
1009 # See at the end, where we select the sources based on the collect
1010 # information.
1011
1012 TEA_ADD_SOURCES([
1013         pty_${PTY_TYPE}.c
1014         exp_${EVENT_TYPE}.c
1015         exp_${EVENT_ABLE}.c
1016 ])
1017
1018 TEA_ADD_HEADERS([expect.h expect_tcl.h expect_comm.h tcldbg.h])
1019
1020 TEA_ADD_INCLUDES([-I.])
1021 TEA_ADD_INCLUDES([-I\"`\${CYGPATH} \${srcdir}`\"])
1022
1023 TEA_ADD_LIBS([])
1024 TEA_ADD_CFLAGS([-DTCL_DEBUGGER -DUSE_NON_CONST])
1025 TEA_ADD_CFLAGS([-DSCRIPTDIR=\\\"\${DESTDIR}\${prefix}/lib/\${PKG_DIR}\\\"])
1026 TEA_ADD_CFLAGS([-DEXECSCRIPTDIR=\\\"\${DESTDIR}\${pkglibdir}\\\"])
1027 TEA_ADD_CFLAGS([-DSTTY_BIN=\\\"${STTY_BIN}\\\"])
1028 TEA_ADD_CFLAGS([-DDFLT_STTY=\"\\\"$DEFAULT_STTY_ARGS\\\"\"])
1029
1030 TEA_ADD_STUB_SOURCES([])
1031 TEA_ADD_TCL_SOURCES([])
1032
1033 #--------------------------------------------------------------------
1034 # This macro generates a line to use when building a library.  It
1035 # depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS,
1036 # and TEA_LOAD_TCLCONFIG macros above.
1037 #--------------------------------------------------------------------
1038
1039 TEA_MAKE_LIB
1040
1041 #--------------------------------------------------------------------
1042 # Find tclsh so that we can run pkg_mkIndex to generate the pkgIndex.tcl
1043 # file during the install process.  Don't run the TCLSH_PROG through
1044 # ${CYGPATH} because it's being used directly by make.
1045 # Require that we use a tclsh shell version 8.2 or later since earlier
1046 # versions have bugs in the pkg_mkIndex routine.
1047 # Add WISH as well if this is a Tk extension.
1048 #--------------------------------------------------------------------
1049
1050 TEA_PROG_TCLSH
1051
1052 #--------------------------------------------------------------------
1053 # Finally, substitute all of the various values into the Makefile.
1054 # You may alternatively have a special pkgIndex.tcl.in or other files
1055 # which require substituting th AC variables in.  Include these here.
1056 #--------------------------------------------------------------------
1057
1058 touch expect_cf.h
1059 AC_OUTPUT([Makefile], chmod +x ${srcdir}/install-sh)