Modified the UGetCursor() routine to return a valid response if the
[xcircuit.git] / configure.in
blob6178645b07be1b6d5659f674007d15ce61b93704
1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(xcircuit.c,, xcircuit-dev@lists.sourceforge.net)
4 AC_PREREQ(2.52)
5 AC_CONFIG_SRCDIR(xcircuit.c)
7 AC_CANONICAL_SYSTEM
9 dnl this call will define PACKAGE and VERSION
10 dnl please use this as the primary reference for the version number
11 PACKAGE=xcircuit
13 VERSION=`cat ./VERSION | cut -d. -f1-2`
14 AM_INIT_AUTOMAKE(${PACKAGE}, ${VERSION})
16 dnl Initialize some variables
17 SUBDIRS=
18 SUBLIB=
19 STDLIBS=
20 XCIRCUIT_TARGET=
21 ALL_TARGET="undefined-target"
22 INSTALL_TARGET="undefined-install-target"
23 REVISION=`cat ./VERSION | cut -d. -f3`
24 INTERPRETER=NOINTERP
25 HAVE_LGF=NOFORMATS
27 LIB_SPECS=""
28 WISH_EXE=""
29 SHLIB_CFLAGS=""
31 dnl Default is to use Tcl; if it can't be found, then flag a warning
32 dnl and revert to the non-Tcl version.
34 dnl pass the version string on the the makefiles
35 AC_SUBST(PACKAGE)
36 AC_SUBST(VERSION)
37 AC_SUBST(REVISION)
39 dnl Setup for automake in subdirectories
40 AC_PROG_MAKE_SET
42 dnl Checks for programs.
43 AC_PROG_CC
44 AC_ISC_POSIX
45 dnl AM_C_PROTOTYPES
46 if test "x$U" != "x"; then
47   AC_MSG_ERROR(Compiler not ANSI compliant)
49 AC_PROG_INSTALL
50 AC_PROG_RANLIB
52 dnl GNU M4 is preferred due to some of the option switches.
53 AC_PATH_PROGS([M4], [gm4 gnum4 m4],)
55 case "$target_os" in
56         *cygwin*)
57                 ;;
58         *)
59                 AC_CHECK_LIB(m, sin)
60                 ;;              
61 esac    
63 dnl check size of pointer for correct behavior on 64-bit systems
64 AC_CHECK_SIZEOF([void *], 4)
65 AC_CHECK_SIZEOF([unsigned int], 4)
66 AC_CHECK_SIZEOF([unsigned long], 8)
67 AC_CHECK_SIZEOF([unsigned long long], 16)
69 dnl check for X libraries and include files
70 AC_PATH_XTRA
71 CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
72 LDFLAGS="${LDFLAGS} ${X_LIBS}"
73 LIBS="${X_PRE_LIBS} ${LIBS} -lX11"
74 AC_CHECK_LIB(Xt, XtToolkitInitialize,,[
75 AC_CHECK_LIB(Xt, XtDisplayInitialize,,,-lSM -lICE -lXpm -lX11)])
77 dnl Check for required header files
78 AC_HEADER_STDC
80 dnl Need either setenv or putenv
81 AC_CHECK_FUNCS(setenv putenv)
83 dnl Check for vfork
84 AC_CHECK_FUNC(vfork)
86 dnl Check for <dirent.h>
87 AC_CHECK_HEADERS(dirent.h)
89 dnl Check for lib64.  This is a quick hack for Fedora Core on the
90 dnl AMD Opteron;  don't know if it works with others.
91 case $target in
92   x86_64-*)
93     AC_MSG_CHECKING([for 64-bit X11 libraries])
94     AC_CHECK_FILE([/usr/X11R6/lib64], [
95         LDFLAGS="-L/usr/X11R6/lib64 ${LDFLAGS}"
96     ], )
97   ;;
98 esac
100 dnl Check for valid cflag "-Wno-pointer-sign"
101 AC_MSG_CHECKING(if -Wno-pointer-sign accepted in CFLAGS)
102 ac_save_CFLAGS="$CFLAGS"
103 CFLAGS="$CFLAGS -Wno-pointer-sign"
104 AC_TRY_COMPILE(,[
105 int foo;
106 foo = 0],[
107   AC_MSG_RESULT(yes)],[
108   CFLAGS="$ac_save_CFLAGS"
109   AC_MSG_RESULT(no)])
111 dnl Check for Flate compression routines
112 AC_CHECK_LIB(z, deflate,,,-lz)
114 dnl Check for va_copy
115 AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy,
116  AC_TRY_LINK(
117    [#include <stdarg.h>],
118    [va_list ap1, ap2;
119     va_copy(ap1,ap2);
120    ],
121    [ac_cv_c_va_copy="yes"],
122    [ac_cv_c_va_copy="no"])
124 if test "$ac_cv_c_va_copy" = "yes"
125 then
126     AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
128 AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy,
129  AC_TRY_LINK(
130    [#include <stdarg.h>],
131    [va_list ap1, ap2;
132     __va_copy(ap1,ap2);
133    ],
134    [ac_cv_c___va_copy="yes"],
135    [ac_cv_c___va_copy="no"])
137 if test "$ac_cv_c___va_copy" = "yes"
138 then
139     AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
142 AC_MSG_CHECKING(if u_char defined)
143 AC_TRY_COMPILE([#include <sys/types.h>],[
144 u_char foo;
145 foo = 0],[
146   AC_DEFINE(HAVE_U_CHAR)
147   AC_MSG_RESULT(yes)],
148   AC_MSG_RESULT(no))
150 dnl Enable compile-time Optimization?  Disable by default for debugging
151 AC_ARG_ENABLE(optimize,
152 [  --enable-optimize enable compile-time optimizer flag -O2], , [
153    CFLAGS=`echo $CFLAGS | sed -e "s/ -O2//"`
156 dnl check for Xpm library
157 AC_ARG_WITH(xpm,
158 [  --with-xpm=DIR          use Xpm include/library files in DIR], [
159   if test "$withval" != "no" -a "$withval" != "yes"; then
160     CPPFLAGS="${CPPFLAGS} -I$withval/include"
161     LDFLAGS="${LDFLAGS} -L$withval/lib"
162   fi
165 AC_CHECK_HEADERS(X11/xpm.h,
166   AC_CHECK_LIB(Xpm, XpmCreateImageFromData, [
167     LIBS="${LIBS} -lXpm"
168     AC_DEFINE(HAVE_XPM)], [
169     AC_MSG_WARN(Xpm library not found)], -lX11),
170   AC_MSG_WARN(Xpm header not found))
172 dnl Check for GNU ld.  This needs to be qualified for Solaris, which
173 dnl may use gcc for the C compiler but not for the linker.
175 dnl check if the linker is a GNU linker
177 #------------------------------------------------------------
178 # AC_PROG_LD - find the path to the GNU or non-GNU linker
179 # (This stuff ripped from libtool)
180 #------------------------------------------------------------
181 AC_DEFUN([AC_PROG_LD],
182 [AC_ARG_WITH(gnu-ld,
183 [  --with-gnu-ld           assume the C compiler uses GNU ld [[default=no]]],
184 test "$withval" = no || xc_with_gnu_ld=yes, xc_with_gnu_ld=no)
185 AC_REQUIRE([AC_PROG_CC])dnl
186 AC_REQUIRE([AC_CANONICAL_HOST])dnl
187 dnl ###not for PostgreSQL### AC_REQUIRE([AC_CANONICAL_BUILD])dnl
188 ac_prog=ld
189 if test "$GCC" = yes; then
190   # Check if gcc -print-prog-name=ld gives a path.
191   AC_MSG_CHECKING([for ld used by GCC])
192   case $host in
193   *-*-mingw*)
194     # gcc leaves a trailing carriage return which upsets mingw
195     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
196   *)
197     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
198   esac
199   case "$ac_prog" in
200     # Accept absolute paths.
201 changequote(,)dnl
202     [\\/]* | [A-Za-z]:[\\/]*)
203       re_direlt='/[^/][^/]*/\.\./'
204 changequote([,])dnl
205       # Canonicalize the path of ld
206       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
207       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
208         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
209       done
210       test -z "$LD" && LD="$ac_prog"
211       ;;
212   "")
213     # If it fails, then pretend we aren't using GCC.
214     ac_prog=ld
215     ;;
216   *)
217     # If it is relative, then search for the first ld in PATH.
218     xc_with_gnu_ld=unknown
219     ;;
220   esac
221 elif test "$xc_with_gnu_ld" = yes; then
222   AC_MSG_CHECKING([for GNU ld])
223 else
224   AC_MSG_CHECKING([for non-GNU ld])
226 AC_CACHE_VAL(ac_cv_path_LD,
227 [if test -z "$LD"; then
228   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
229   for ac_dir in $PATH; do
230     test -z "$ac_dir" && ac_dir=.
231     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
232       ac_cv_path_LD="$ac_dir/$ac_prog"
233       # Check to see if the program is GNU ld.  I'd rather use --version,
234       # but apparently some GNU ld's only accept -v.
235       # Break only if it was the GNU/non-GNU ld that we prefer.
236       if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
237         test "$xc_with_gnu_ld" != no && break
238       else
239         test "$xc_with_gnu_ld" != yes && break
240       fi
241     fi
242   done
243   IFS="$ac_save_ifs"
244 else
245   ac_cv_path_LD="$LD" # Let the user override the test with a path.
246 fi])
247 LD="$ac_cv_path_LD"
248 if test -n "$LD"; then
249   AC_MSG_RESULT($LD)
250 else
251   AC_MSG_RESULT(no)
253 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
254 AC_PROG_LD_GNU
257 AC_DEFUN([AC_PROG_LD_GNU],
258 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
259 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
260 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
261   ac_cv_prog_gnu_ld=yes
262 else
263   ac_cv_prog_gnu_ld=no
264 fi])
265 xc_with_gnu_ld=$ac_cv_prog_gnu_ld
268 AC_PROG_LD
270 dnl --- Enable TCL by default
272 xc_with_tcl="yes"
273 xc_with_tk="yes"
274 xc_with_tcl_includes=""
275 xc_with_tk_includes=""
276 xc_with_tcl_libraries=""
277 xc_with_tk_libraries=""
278 xc_with_cairo="yes"
280 dnl -----------------------------------------------------------------------
281 dnl --- Cairo library
282 dnl -----------------------------------------------------------------------
284 AC_ARG_WITH([cairo],
285   [AS_HELP_STRING([--with-cairo],
286     [Use cairo graphics library @<:@default=yes@:>@])],
287   [
288     xc_with_cairo=$withval
289     if test "$withval" == "no" -o "$withval" == "NO"; then
290         xc_with_cairo=""
291     fi
292   ], ) 
294 if test "x$xc_with_cairo" != "x" ; then
295   AC_DEFINE([HAVE_CAIRO])
296   PKG_CHECK_MODULES([cairo], [cairo])
297   PKG_CHECK_MODULES([fontconfig], [fontconfig])
298   AC_CHECK_HEADERS([ghostscript/gdevdsp.h],
299     [
300         GS_LIBS=-lgs
301         AC_DEFINE([HAVE_GS])
302     ],
303     [
304         AC_MSG_WARN([Building xcircuit without ghostscript rendering])
305         AC_MSG_WARN([Install the ghostscript-devel package to solve this])
306     ]
307   )
310 # For distributed installs, where the run-time files are installed in a
311 # place that is a temporary staging area, like DESTDIR, but unlike DESTDIR,
312 # the prefix is replaced by the destination directory, rather than appended
313 # to it.
314 DIST_DIR="\${exec_prefix}"
315 AC_ARG_WITH(distdir,
316 [  --with-distdir=DIR       install into location DIR for distribution], [
317   if test "$withval" = "no" -o "$withval" = "NO" ; then
318      DIST_DIR="\${exec_prefix}"
319   else
320      DIST_DIR=${withval}
321   fi
322 ], )
324 dnl -----------------------------------------------------------------------
325 dnl --- Tcl/Tk support
326 dnl -----------------------------------------------------------------------
327           
328 AC_ARG_WITH(tcl,
329 [  --with-tcl=DIR          Find tclConfig.sh in DIR], [
330   xc_with_tcl=$withval
331   if test "$withval" == "no" -o "$withval" == "NO"; then
332       xc_with_tcl=""
333   fi
334 ], ) 
336 dnl -----------------------------------------------------------------------
337 dnl If TCL is not disabled, do our best to find it
338 dnl -----------------------------------------------------------------------
340 AC_ARG_WITH(tk,         [  --with-tk=DIR           Find tkConfig.sh in DIR],
341   xc_with_tk=$withval)
342 AC_ARG_WITH(tclincls,   [  --with-tclincls=DIR     Find tcl.h in DIR],
343   xc_with_tcl_includes=$withval)
344 AC_ARG_WITH(tkincls,    [  --with-tkincls=DIR      Find tk.h in DIR],
345   xc_with_tk_includes=$withval)
346 AC_ARG_WITH(tcllibs,    [  --with-tcllibs=DIR      Find Tcl library in DIR],
347   xc_with_tcl_libraries=$withval)
348 AC_ARG_WITH(tklibs,     [  --with-tklibs=DIR       Find Tk library in DIR],
349   xc_with_tk_libraries=$withval)
351 # -----------------------------------------------------------------------
353 #       Find the Tcl build configuration file "tclConfig.sh"
355 # -----------------------------------------------------------------------
357 if test "x$xc_with_tcl" != "x" ; then
359   TCL_INC_DIR="."
360   TK_INC_DIR="."
362   AC_MSG_CHECKING([for tclConfig.sh])
363   tcl_config_sh=""
365   if test "$xc_with_tcl" = "no" ; then
366     xc_with_tcl=""
367   elif test "$xc_with_tcl" != "yes" ; then
368     #
369     # Verify that a tclConfig.sh file exists in the directory specified 
370     # by --with-tcl. 
371     #
372     for dir in \
373      $xc_with_tcl 
374     do
375       if test -r "$dir/tclConfig.sh" ; then
376         tcl_config_sh="$dir/tclConfig.sh"
377         break
378       elif test -r "$dir/lib/tclConfig.sh" ; then
379         tcl_config_sh="$dir/lib/tclConfig.sh"
380         break
381       fi
382     done
383   else 
384     #
385     # Otherwise, search for Tcl configuration file.  
386     #
388     #  1. Search previously named locations.
390     for dir in \
391      $prefix \
392      $exec_prefix
393     do
394       if test -r "$dir/tclConfig.sh" ; then
395         tcl_config_sh="$dir/tclConfig.sh"
396         break
397       elif test -r "$dir/lib/tclConfig.sh" ; then
398         tcl_config_sh="$dir/lib/tclConfig.sh"
399         break
400       fi
401     done
403     #  2. Search standard locations.
405     if test "x$tcl_config_sh" = "x" ; then
406       for dir in \
407        `ls -dr /usr/local/tcl/tcl[[7-9]].[[0-9]]* 2>/dev/null` \
408        /usr/local/tcl \
409        /usr/local/lib \
410        /usr/local \
411        `ls -dr /usr/share/tcltk/tcl[[7-9]].[[0-9]]* 2>/dev/null` \
412        /sw/lib \
413        /usr/lib \
414        /usr/lib64 \
415        /usr
416       do
417         if test -r "$dir/tclConfig.sh" ; then
418           tcl_config_sh="$dir/tclConfig.sh"
419           break
420         elif test -r "$dir/lib/tclConfig.sh" ; then
421           tcl_config_sh="$dir/lib/tclConfig.sh"
422           break
423         fi
424       done
425     fi
426   fi
428   AC_MSG_RESULT([${tcl_config_sh}])
430   if test "x$tcl_config_sh" = "x" ; then
431     echo "can't find Tcl configuration script \"tclConfig.sh\""
432     echo "Reverting to non-Tcl compilation"
433     xc_with_tcl=""
434   fi
437 # -----------------------------------------------------------------------
439 #       Find the Tk build configuration file "tkConfig.sh"
441 # -----------------------------------------------------------------------
443 if test "x$xc_with_tcl" != "x" ; then
444   AC_MSG_CHECKING([for tkConfig.sh])
445   tk_config_sh=""
446   if test "$xc_with_tk" != "yes"; then
447     #
448     # Verify that a tkConfig.sh file exists in the directory specified 
449     # by --with-tcl or --with-tk. 
450     #
451     for dir in \
452      $xc_with_tk \
453      $xc_with_tcl 
454     do
455       if test -r "$dir/tkConfig.sh" ; then
456         tk_config_sh="$dir/tkConfig.sh"
457         break
458       elif test -r "$dir/lib/tkConfig.sh" ; then
459         tk_config_sh="$dir/lib/tkConfig.sh"
460         break
461       fi
462     done
463   else 
464     #
465     # Search for Tk configuration file.  
466     #
468     #
469     #  1. Search previously named locations.
470     # 
471     for dir in \
472      $prefix \
473      $exec_prefix
474     do
475       if test -r "$dir/tkConfig.sh" ; then
476         tk_config_sh="$dir/tkConfig.sh"
477         break
478       elif test -r "$dir/lib/tkConfig.sh" ; then
479         tk_config_sh="$dir/lib/tkConfig.sh"
480         break
481       fi
482     done
483     #
484     #  2. Search standard locations.
485     # 
486     if test "x$tk_config_sh" = "x" ; then
487       for dir in \
488        /usr/local \
489        /usr \
490        `ls -dr /usr/local/lib/tk[[7-9]].[[0-9]]* 2>/dev/null` \
491        `ls -dr /usr/lib/tk[[7-9]].[[0-9]]* 2>/dev/null` \
492        `ls -dr /usr/local/tk/tk[[7-9]].[[0-9]]* 2>/dev/null` \
493        `ls -dr /usr/local/tk[[7-9]].[[0-9]]* 2>/dev/null` \
494        /usr/local/tk \
495        `ls -dr /usr/local/lib/tcl[[7-9]].[[0-9]]* 2>/dev/null` \
496        `ls -dr /usr/lib/tcl/tk[[7-9]].[[0-9]]* 2>/dev/null` \
497        `ls -dr /usr/local/tcl/tcl[[7-9]].[[0-9]]* 2>/dev/null` \
498        `ls -dr /usr/share/tcltk/tk[[7-9]].[[0-9]]* 2>/dev/null` \
499        /sw/lib \
500        /usr/lib \
501        /usr/lib64 \
502        ${x_libraries}
503       do
504         if test -r "$dir/tkConfig.sh" ; then
505           tk_config_sh="$dir/tkConfig.sh"
506           break
507         elif test -r "$dir/lib/tkConfig.sh" ; then
508           tk_config_sh="$dir/lib/tkConfig.sh"
509           break
510         fi
511       done
512     fi
513   fi
514   AC_MSG_RESULT([${tk_config_sh}])
516   if test "x$tk_config_sh" = "x" ; then
517     echo "can't find Tk configuration script \"tkConfig.sh\""
518     echo "Reverting to non-Tcl compilation"
519     xc_with_tcl=""
520   fi
523 # -----------------------------------------------------------------------
525 #       Source in the Tcl/Tk configuration scripts.  
527 #       This didn't work so well in the pre-8.5 days, but
528 #       seems to be okay now.
530 # -----------------------------------------------------------------------
532 if test "x$xc_with_tcl" != "x" ; then
533   . $tcl_config_sh
534   . $tk_config_sh
536   # Should probably trust the config file contents, but this configure
537   # file checks the Tcl and Tk include and lib directories.  Since
538   # the config file doesn't separate out the libraries from the strings
539   # passed to the compiler/linker, do it manually here.
540   #
541   # Extract TCL_LIB_DIR from TCL_LIB_SPEC
542   # Extract TK_LIB_DIR from TK_LIB_SPEC
543   # Extract TCL_INC_DIR from TCL_INCLUDE_SPEC
544   # Extract TK_INC_DIR from TK_INCLUDE_SPEC
545   #
546   # These will be the defaults unless overridden by configure command line
548   tmpstr=${TCL_LIB_SPEC#*-L}
549   TCL_LIB_DIR=${tmpstr% -l*}
550   tmpstr=${TK_LIB_SPEC#*-L}
551   TK_LIB_DIR=${tmpstr% -l*}
552   TCL_INC_DIR=${TCL_INCLUDE_SPEC#*-I}
553   TK_INC_DIR=${TK_INCLUDE_SPEC#*-I}
555   LIBS="${TCL_LIBS} ${LIBS}"
557   if test "$TCL_VERSION" = "$TK_VERSION" ; then
558     :
559   else
560     echo "Mismatched Tcl/Tk versions ($TCL_VERSION != $TK_VERSION)"
561     echo "Reverting to non-Tcl compilation"
562     xc_with_tcl=""
563   fi
566 # -----------------------------------------------------------------------
567 # Rely on TCL_INCLUDE_SPEC from tclConfig.sh unless "--with-tclincls"
568 # overrides.  With TCL_INCLUDE_SPEC, pull out TCL_INC_DIR
569 # -----------------------------------------------------------------------
571 if test "x$xc_with_tcl" != "x" ; then
572   if test "x${xc_with_tcl_includes}" != "x" ; then
573     if test -r "${xc_with_tcl_includes}/tcl.h" ; then
574       TCL_INC_DIR=${xc_with_tcl_includes}
575     elif test "x${TCL_INCLUDE_SPEC}" == "x" ; then
576       echo "Can't find tcl.h in \"${xc_with_tcl_includes}\""
577       echo "Reverting to non-Tcl compilation"
578       xc_with_tcl=""
579     fi
580   elif test "x${TCL_INCLUDE_SPEC}" == "x" ; then
581     for dir in \
582      ${TCL_PREFIX}/include/tcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION} \
583      ${TCL_PREFIX}/include \
584      ${TCL_SRC_DIR}/generic \
585      ${TCL_INC_DIR}
586     do
587       if test -r "$dir/tcl.h" ; then
588         TCL_INC_DIR=$dir
589         TCL_INCLUDE_SPEC="-I${TCL_INC_DIR}"
590         break
591       fi
592     done
593     if test "x${TCL_INC_DIR}" = "x" ; then
594       echo "Can't find tcl.h header file"
595       echo "Reverting to non-Tcl compilation"
596       xc_with_tcl=""
597     fi
598   else
599     TCL_INC_DIR=`echo ${TCL_INCLUDE_SPEC} | sed -e '/-I/s/-I//'`
600   fi
603 # -----------------------------------------------------------------------
604 # Rely on TK_INCLUDE_SPEC from tkConfig.sh unless "--with-tkincls"
605 # overrides.  With TK_INCLUDE_SPEC, pull out TK_INC_DIR
606 # -----------------------------------------------------------------------
608 if test "x$xc_with_tcl" != "x" ; then
609   if test "x${xc_with_tk_includes}" != "x" ; then
610     if test -r "${xc_with_tk_includes}/tk.h" ; then
611       TK_INC_DIR=${xc_with_tk_includes}
612     elif test "x${TK_INCLUDE_SPEC}" == "x" ; then
613       echo "Can't find tk.h in \"${xc_with_tk_includes}\""
614       echo "Reverting to non-Tcl compilation"
615       xc_with_tcl=""
616     fi
617   elif test "x${TK_INCLUDE_SPEC}" == "x" ; then
618     for dir in \
619      ${TK_PREFIX}/include/tcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION} \
620      ${TK_PREFIX}/include/tk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION} \
621      ${TK_PREFIX}/include \
622      ${TK_SRC_DIR}/generic \
623      ${TK_INC_DIR}
624     do
625       if test -r "$dir/tk.h" ; then
626         TK_INC_DIR=$dir
627         TK_INCLUDE_SPEC="-I${TK_INC_DIR}"
628         break
629       fi
630     done
631     if test "x${TK_INC_DIR}" = "x" ; then
632       echo "Can't find tk.h header file"
633       echo "Reverting to non-Tcl compilation"
634       xc_with_tcl=""
635     fi
636   else
637     TK_INC_DIR=`echo ${TK_INCLUDE_SPEC} | sed -e '/-I/s/-I//'`
638   fi
641 # --------------------------------------------------------------
642 # Rely on TCL_LIB_SPEC from tclConfig.sh unless "--with-tcllibs"
643 # overrides.  With TCL_LIB_SPEC, pull out TCL_LIB_DIR
644 # --------------------------------------------------------------
646 if test "x$xc_with_tcl" != "x" ; then
647   if test "x${xc_with_tcl_libraries}" != "x" ; then
648     TCL_LIB_SPEC=""
649     for libname in \
650      "${xc_with_tcl_libraries}/${TCL_LIB_FILE}" \
651      "${xc_with_tcl_libraries}/lib${TCL_LIB_NAME}${SHDLIB_EXT}"
652     do
653       if test -r "$libname" ; then
654         TCL_LIB_DIR="${xc_with_tcl_libraries}"
655         break
656       fi
657     done
658     if test "x${TCL_LIB_DIR}" == "x" ; then
659       echo "Can't find tcl library in \"${xc_with_tcl_libraries}\""
660       echo "Reverting to non-Tcl compile"
661       xc_with_tcl=""
662     fi
663   elif test "x${TCL_LIB_SPEC}" == "x" ; then
664     for libpfix in "lib64" "lib"
665     do
666       libname="${TCL_EXEC_PREFIX}/${libpfix}/lib${TCL_LIB_NAME}${SHDLIB_EXT}"
667       if test -r "$libname" ; then
668         TCL_LIB_DIR="${TCL_EXEC_PREFIX}/${libpfix}"
669         break
670       fi
671     done
672     if test "x${TCL_LIB_DIR}" = "x" ; then
673       echo "Can't find tcl library"
674       echo "Reverting to non-Tcl compile"
675       xc_with_tcl=""
676     fi
677   else
678     TCL_LIB_DIR=`echo ${TCL_LIB_SPEC} | sed -e '/-L/s/-L//' -e '/-l/s/-l.*//'`
679   fi
682 # --------------------------------------------------------------
683 # Rely on TK_LIB_SPEC from tkConfig.sh unless "--with-tklibs"
684 # overrides.  With TK_LIB_SPEC, pull out TK_LIB_DIR
685 # --------------------------------------------------------------
687 if test "x$xc_with_tcl" != "x" ; then
688   if test "x${xc_with_tk_libraries}" != "x" ; then
689     TK_LIB_SPEC=""
690     for libname in \
691      "${xc_with_tk_libraries}/${TK_LIB_FILE}" \
692      "${xc_with_tk_libraries}/lib${TK_LIB_NAME}${SHDLIB_EXT}"
693     do
694       if test -r "$libname" ; then
695         TK_LIB_DIR="${xc_with_tk_libraries}"
696         break
697       fi
698     done
699     if test "x${TK_LIB_DIR}" == "x" ; then
700       echo "Can't find tk library in \"${xc_with_tk_libraries}\""
701       echo "Reverting to non-Tcl compile"
702       xc_with_tcl=""
703     fi
704   elif test "x${TK_LIB_SPEC}" == "x" ; then
705     for libpfix in "lib64" "lib"
706     do
707       libname="${TK_EXEC_PREFIX}/${libpfix}/lib${TK_LIB_NAME}${SHDLIB_EXT}"
708       if test -r "$libname" ; then
709         TK_LIB_DIR="${TK_EXEC_PREFIX}/${libpfix}"
710         break
711       fi
712     done
713     if test "x${TK_LIB_DIR}" = "x" ; then
714       echo "Can't find tk library"
715       echo "Reverting to non-Tcl compile"
716       xc_with_tcl=""
717     fi
718   else
719     TK_LIB_DIR=`echo ${TCL_LIB_SPEC} | sed -e '/-L/s/-L//' -e '/-l/s/-l.*//'`
720   fi
723 #--------------------------------------------------------------------
724 # If TCL_LIB_SPEC and/or TK_LIB_SPEC do not exist, construct them
725 #--------------------------------------------------------------------
727 if test "x$xc_with_tcl" != "x" ; then
728   if test "x${TCL_LIB_SPEC}" == "x" ; then
729     case $target in
730       *-sunos4*|*-*-netbsd|NetBSD-*|FreeBSD-*|*-*-openbsd*|OpenBSD-*)
731         TCL_LIB_NAME="tcl${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}"
732         ;;
733       *)
734         TCL_LIB_NAME="tcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}"
735         ;;
736     esac
737     TCL_LIB_SPEC="-L${TCL_LIB_DIR} -l${TCL_LIB_NAME}"
738   fi
740   if test "x${TK_LIB_SPEC}" == "x" ; then
741     case $target in
742       *-sunos4*|*-*-netbsd|NetBSD-*|FreeBSD-*|*-*-openbsd*|OpenBSD-*)
743         TK_LIB_NAME="tk${TK_MAJOR_VERSION}${TK_MINOR_VERSION}"
744         ;;
745       *)
746         TK_LIB_NAME="tk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}"
747         ;;
748     esac
749     TK_LIB_SPEC="-L${TK_LIB_DIR} -l${TK_LIB_NAME}"
750   fi
752   # Find the version of "wish" that corresponds to TCL_EXEC_PREFIX
753   # We really ought to run "ldd" to confirm that the linked libraries match.
755   AC_MSG_CHECKING([for wish executable])
756   for dir in \
757    ${TK_EXEC_PREFIX}/bin \
758    ${TK_EXEC_PREFIX}
759   do
760     for wishexe in \
761       wish \
762       wish${TK_VERSION} \
763       wish.exe \
764       wish${TK_VERSION}.exe
765     do
766       if test -r "$dir/$wishexe" ; then
767         WISH_EXE=$dir/$wishexe
768         break
769       fi
770     done  
771     if test "x${WISH_EXE}" != "x" ; then
772       break  
773     fi
774   done
775   if test "x${WISH_EXE}" = "x" ; then
776     echo "Warning: Can't find executable for \"wish\".  You may have to"
777     echo "manually set the value for WISH_EXE in the xcircuit startup script."
778     AC_MSG_RESULT(no)
779   else
780     AC_MSG_RESULT([${WISH_EXE}])
781   fi
783   # Have to define SHDLIB_EXT here even though we have to do it below, too.
784   case $target in
785      *-hpux*)
786         SHDLIB_EXT=".sl"
787         ;;
788      *cygwin*)
789         SHDLIB_EXT=".dll.a"
790         ;;
791      *-darwin*)
792         SHDLIB_EXT=".dylib"
793         ;;
794      *-openbsd*)
795         SHDLIB_EXT=".so.${TCL_LIB_FILE##*.so.}"
796         ;;
797      *)
798         SHDLIB_EXT=".so"
799         ;;
800   esac
803 dnl End of Tcl/Tk search
804 dnl --------------------------------
806 # -----------------------------------------------------------------------
808 # Tk libraries and header files
810 # -----------------------------------------------------------------------
812 if test "x$xc_with_tcl" != "x" ; then
813   INC_SPECS="${INC_SPECS} ${TCL_INCLUDE_SPEC} ${TK_INCLUDE_SPEC}"
814   LIB_SPECS="${LIB_SPECS} ${TCL_LIB_SPEC} ${TK_LIB_SPEC}"
816   if test "x${loader_run_path}" = "x" ; then
817     loader_run_path="${TCL_LIB_DIR}"
818   else
819     loader_run_path="${TCL_LIB_DIR}:${loader_run_path}"
820   fi
822   #--------------------------------------------------------------------
823   #
824   # Check if we can generate shared libraries on this system.  Set flags 
825   # to generate shared libraries for systems that we know about.  Start 
826   # with the values found in tclConfig.sh, make changes as we know about 
827   # the different systems.
828   #
829   #--------------------------------------------------------------------
831   # Initialize shared library build variables
833   if test "x${TCL_SHLIB_SUFFIX}" == "x" ; then
834     SHDLIB_EXT=".so"
835   else
836     SHDLIB_EXT="${TCL_SHLIB_SUFFIX}"
837   fi
839   if test "x${TCL_SHLIB_LD}" == "x" ; then
841     # Construct shared library build arguments the painful way
842     # This is not expected to be necessary, so the number of
843     # supported systems has been pared down to a minimum.
845     LDDL_FLAGS="-shared"
846     LD_RUN_PATH=""
847     SHLIB_LD="${CC}"
848     EXTRA_LIB_SPECS=""
850     case $target in
851       *-darwin*)
852         SHDLIB_EXT=".dylib"
853         SHLIB_LIB_SPECS="${LIB_SPECS}"
854         if test "${xc_with_gnu_ld}" = "yes" ; then
855            LDDL_FLAGS="-dynamiclib -bind_at_load"
856         else
857            LDDL_FLAGS="-single_module -dynamiclib -flat_namespace"
858            LDDL_FLAGS="${LDDL_FLAGS} -undefined suppress -noprebind"
859            SHLIB_CFLAGS="-I/sw/include -fno-common"
860         fi
861         ;;
863       *cygwin*)
864         AC_DEFINE(CYGWIN)
865         SHDLIB_EXT=".dll.a"
866         LDDL_FLAGS="-shared -Wl,--enable-auto-image-base -Wl,-rpath,${loader_run_path}"
867         SHLIB_LIB_SPECS="${LIB_SPECS}"
868         ;;
870       *-linux*)
871         SHLIB_CFLAGS="-fPIC"
872         LDDL_FLAGS='-shared -Wl,-soname,$@'
873         LD_RUN_PATH="-Wl,-rpath,${loader_run_path}"
874     
875         EXTRA_LIB_SPECS="-ldl"
877         case $target in
878            x86_64-*)
879               # AMD 64-bit archictecture
880               # Add -fPIC to standard compile switch
881               CFLAGS="${CFLAGS} -fPIC"
882               ;;
883         esac
884         ;;
885   
886       *-netbsd*|*-freebsd*|*-openbsd*)
887         # Not available on all versions:  check for include file.
888         AC_CHECK_HEADER(dlfcn.h, test_ok=yes, test_ok=no)
889         if test "$test_ok" = yes; then
890           SHLIB_CFLAGS="-fpic"
891           SHLIB_LD="ld"
892           LDDL_FLAGS="-shared"
893         fi
894         ;;
895     esac
897     if test "$GCC" = "yes" ; then
898        CFLAGS="-fPIC ${CFLAGS}"
899     fi
901   else
903     # Rely on shared lib arguments in tclConfig.sh
905     SHLIB_LD="${TCL_SHLIB_LD}"
906     EXTRA_LIB_FLAGS=""
907     LDDL_FLAGS="${TCL_LD_FLAGS}"
908     LD_RUN_PATH=""
910     case $target in
911       *-linux*)
912         LD_RUN_PATH="-Wl,-rpath,${loader_run_path}"
913         ;;
914     esac
915   fi
917   # If we're running gcc, then set SHLIB_CFLAGS flags for compiling
918   # shared libraries for gcc, instead of those of the vendor's
919   # compiler.
921   if test "$GCC" = "yes" ; then
922     if test "x${TCL_SHLIB_CFLAGS}" = "x" ; then
923        SHLIB_CFLAGS="-fPIC ${SHLIB_CFLAGS}"
924     else
925        SHLIB_CFLAGS="${TCL_SHLIB_CFLAGS} ${SHLIB_CFLAGS}"
926     fi
927   fi
928   CFLAGS="${CFLAGS} ${SHLIB_CFLAGS}"
930   if test "${xc_with_gnu_ld}" = "yes" ; then
931     LDDL_FLAGS="${LDDL_FLAGS} -Wl,--version-script=symbol.map"
932   fi
934   AC_SUBST(SHDLIB_EXT)
935   AC_SUBST(SHLIB_LD)
936   AC_SUBST(LDDL_FLAGS)
937   AC_SUBST(SHLIB_LIB_SPECS)
938   AC_SUBST(EXTRA_LIB_SPECS)
939   AC_SUBST(LD_RUN_PATH)
940   AC_SUBST(LDFLAGS)
941   AC_SUBST(INC_SPECS)
942   AC_SUBST(LIB_SPECS)
943   AC_SUBST(TCL_LIB_DIR)
944   AC_SUBST(WISH_EXE)
945   AC_SUBST(DIST_DIR)
949 dnl Disable the ASG (automatic schematic generation) package.  Disabled by default.
950 AC_ARG_ENABLE(asg,
951 [ --enable-asg          enable support for Automatic Schematic Generation], [
952   AC_DEFINE(ASG)
953   AC_DEFINE(CONFIGURED)
954   SUBDIRS="asg spiceparser"
955   dnl Object files to link into the final executable or shared object
956   dnl These must be in the correct order!
957      SUBLIB="asg/libasg.a spiceparser/libspiceparser.a"
960 dnl Disable LGF (analog/diglog) file support.  Enabled by default.
961 AC_ARG_ENABLE(lgf,
962 [  --disable-lgf           disable support for reading Caltech tools
963                           analog simulator .lgf files], , [
964   HAVE_LGF=LGF
965   AC_DEFINE(LGF)
968 dnl Disable fix for input focus on some window managers.  Enabled by default.
969 AC_ARG_ENABLE(focus-fix,
970 [  --disable-focus-fix     disable focus fix for some window managers], , [
971   AC_DEFINE(INPUT_FOCUS)
974 dnl Path to Ghostscript
975 AC_ARG_WITH(gs,
976 [  --with-gs=DIR           path to ghostscript], [
977   if test -f "$withval"; then
978     GS_EXEC=$withval
979   else
980     GS_EXEC=gs
981   fi
982 ], [
983   AC_CHECK_PROG(GS_EXEC, gs, , gs)])
984 AC_DEFINE_UNQUOTED(GS_EXEC, "$GS_EXEC")
986 dnl Path to ngspice
987 AC_ARG_WITH(ngspice,
988 [  --with-ngspice=DIR           path to ngspice], [
989   if test -f "$withval"; then
990     SPICE_EXEC=$withval
991   else
992     SPICE_EXEC=ngspice
993   fi
994 ], [
995   AC_CHECK_PROG(SPICE_EXEC, ngspice, , ngspice)])
996 AC_DEFINE_UNQUOTED(SPICE_EXEC, "$SPICE_EXEC")
998 dnl Path to Python
1000 xc_with_python=""
1001 PYTHON=
1003 AC_ARG_WITH(python,
1004 [  --with-python=DIR       path to python interpreter],
1005   xc_with_python=$withval) 
1007 if test "x$xc_with_tcl" != "x" ; then
1008   xc_with_python=""
1009 elif test "$xc_with_python" = "no" ; then
1010   xc_with_python=""
1011 elif test "$xc_with_python" = "yes" ; then
1012   AC_PATH_PROG(PYTHON,python)
1013 elif test "x$xc_with_python" != x; then
1014   test -f "$xc_with_python" && PYTHON=$xc_with_python
1017 if test "x$PYTHON" != x; then
1018   _py_version=`$PYTHON -c 'import sys; print sys.version[[0:3]]'`
1019   _py_prefix=`$PYTHON -c 'import sys; print sys.prefix'`
1020   _py_exec_prefix=`$PYTHON -c 'import sys; print sys.exec_prefix'`
1022   _py_include="$_py_prefix/include/python$_py_version"
1023   _py_lib="$_py_exec_prefix/lib/python$_py_version/config"
1024   _py_makefile="$_py_lib/Makefile"
1026   if test $_py_version = 1.5; then
1027     echo
1028     echo "*** WARNING:" 
1029     echo "*** Python version 1.5 detected:  This version of Python has a known fatal"
1030     echo "*** bug.  Disabling Python interface.  If you want the embedded Python"
1031     echo "*** interface, you will need to get an updated version of Python."
1032     echo
1033     PYTHON=""
1034   fi
1037 if test "x$PYTHON" != x; then
1038   if test -f $_py_makefile; then
1039     _py_libs=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $_py_makefile`
1040     _py_libm=`sed -n -e 's/^LIBM=\(.*\)/\1/p' $_py_makefile`
1041   else
1042     _py_libs='-lpthread -ldl -lutil -ldb'
1043     _py_libm='-lm'
1044   fi
1045       
1046   # Now that we think we know where the python include and
1047   # library files are, make sure we can build a small
1048   # program against them.
1049   _save_CPPFLAGS=${CPPFLAGS}
1050   _save_LDFLAGS=${LDFLAGS}
1051   _save_LIBS=${LIBS}
1053   CPPFLAGS="$CPPFLAGS -I$_py_include"
1054   LDFLAGS="$LDFLAGS -L$_py_lib"
1055     
1056   case "$target_os" in
1057         *cygwin*)
1058                 PYLIB="-lpython$_py_version"
1059                 LIBS="$PYLIB.dll $LIBS $X_PRE_LIBS $_py_libs"
1060                 ;;
1061         *)
1062                 LIBS="$LIBS -lpython$_py_version $_py_libs $_py_libm"
1063                 ;;              
1064   esac    
1065     
1067   HAVE_PYTHON=0
1068   AC_CHECK_HEADER(Python.h,[
1069       AC_MSG_CHECKING([for Py_Initialize in -lpython$_py_version])
1070       AC_TRY_LINK([#include "Python.h"],[Py_Initialize();],[
1071         HAVE_PYTHON=1
1072         INTERPRETER=PYTHON
1073         AC_MSG_RESULT(yes)
1074         AC_DEFINE(HAVE_PYTHON)],
1075         AC_MSG_RESULT(no))])
1077   if test "x$HAVE_PYTHON" = x0; then
1078     CPPFLAGS=$_save_CPPFLAGS
1079     LDFLAGS=$_save_LDFLAGS
1080     LIBS=$_save_LIBS
1081     PYTHON=""
1082   fi
1085 if test "x$PYTHON" != x; then
1086   STARTUP_FILE="xcstartup.py"
1087   INTERP_PATH="python"
1088   WRAPPER_SCRIPT=""
1089   SUBDIRS="${SUBDIRS} Xw"
1090   SUBLIB="${SUBLIB} Xw/libxcXw.a"
1091   XCIRCUIT_TARGET="xcircuit"
1092 elif test "x$xc_with_tcl" != "x" ; then
1093   INTERPRETER=TCL
1094   STARTUP_FILE="xcstartup.tcl"
1095   INTERP_PATH="tcl"
1096   WRAPPER_SCRIPT="wrapper.tcl"
1097   AC_DEFINE(TCL_WRAPPER)
1098   XCIRCUIT_TARGET="tcl"
1099   ALL_TARGET="all-recursive"
1100   INSTALL_TARGET="install-recursive"
1101 else
1102   STARTUP_FILE="startup.script"
1103   INTERP_PATH="."
1104   WRAPPER_SCRIPT=""
1105   SUBDIRS="${SUBDIRS} Xw"
1106   SUBLIB="${SUBLIB} Xw/libxcXw.a"
1107   XCIRCUIT_TARGET="xcircuit"
1110 # Add -lm last to LDFLAGS, or Tcl/Tk's addition of -lieee can cause
1111 # an error.
1112 EXTRA_LIB_SPECS="$EXTRA_LIB_SPECS -lm"
1114 dnl Memory debugging:
1115 dnl The non-Tcl version uses (links to) ElectricFence.
1116 dnl Tcl must use the Tcl memory debugger.
1117 dnl Caveats:
1118 dnl We should try to ensure that ElectricFence is available, or that
1119 dnl the Tcl version used has memory debugging compiled in
1121 AC_ARG_ENABLE(memdebug,
1122 [  --enable-memdebug            enable memory debugging], [
1123    if test "x$xc_with_tcl" = "x" ; then
1124       LIBS="${LIBS} -lefence"
1125    else
1126       AC_DEFINE(TCL_MEM_DEBUG)
1127    fi
1130 AC_SUBST(SUBDIRS)
1131 AC_SUBST(SUBLIB)
1132 AC_SUBST(STDLIBS)
1133 AC_SUBST(GS_LIBS)
1134 AC_SUBST(STARTUP_FILE)
1135 AC_SUBST(INTERP_PATH)
1136 AC_SUBST(WRAPPER_SCRIPT)
1137 AC_SUBST(XCIRCUIT_TARGET)
1138 AC_SUBST(CFLAGS)
1139 AC_SUBST(LD)
1140 AC_SUBST(LDFLAGS)
1142 AC_SUBST(INTERPRETER)
1143 AC_SUBST(HAVE_LGF)
1145 AC_SUBST(ALL_TARGET)
1146 AC_SUBST(INSTALL_TARGET)
1148 dnl Automake requires these
1149 AC_SUBST(ACLOCAL)
1150 AC_SUBST(AUTOCONF)
1151 AC_SUBST(AUTOMAKE)
1152 AC_SUBST(AUTOHEADER)
1154 AC_OUTPUT(Makefile Xw/Makefile asg/Makefile spiceparser/Makefile)
1156 echo ""
1157 echo "Configuration results:"
1158 echo "----------------------------------------------------"
1159 echo ""
1161 if test "x$xc_with_tcl" == "x" ; then
1162    if test "x$PYTHON" != x; then
1163       echo "Using Python interface (not recommended)"
1164    else
1165       echo "No Tcl/Tk, using standard Xlib/Xt interface."
1166       echo "If that is not what you wanted, then make sure"
1167       echo "you have Tcl/Tk development packages installed?"
1168    fi
1169 else
1170    echo "Using Tcl/Tk interface"
1172 echo ""
1174 if test "x$xc_with_cairo" == "x" ; then
1175    echo "No Cairo graphics."
1176    echo "If that is not what you wanted, then make sure"
1177    echo "you have libcairo and fontconfig installed."
1178    echo "Try installing package cairo-devel."
1179 else
1180    echo "Using Cairo graphics"
1182 echo ""
1183 echo "CFLAGS=${CFLAGS}"