Merge branch 'master' into xcircuit-3.10
[xcircuit.git] / configure.in
bloba11d81755c03dfa39407beb57be1ae6df2a44c45
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 dnl -----------------------------------------------------------------------
311 dnl --- Tcl/Tk support
312 dnl -----------------------------------------------------------------------
313           
314 AC_ARG_WITH(tcl,
315 [  --with-tcl=DIR          Find tclConfig.sh in DIR], [
316   xc_with_tcl=$withval
317   if test "$withval" == "no" -o "$withval" == "NO"; then
318       xc_with_tcl=""
319   fi
320 ], ) 
322 dnl -----------------------------------------------------------------------
323 dnl If TCL is not disabled, do our best to find it
324 dnl -----------------------------------------------------------------------
326 AC_ARG_WITH(tk,         [  --with-tk=DIR           Find tkConfig.sh in DIR],
327   xc_with_tk=$withval)
328 AC_ARG_WITH(tclincls,   [  --with-tclincls=DIR     Find tcl.h in DIR],
329   xc_with_tcl_includes=$withval)
330 AC_ARG_WITH(tkincls,    [  --with-tkincls=DIR      Find tk.h in DIR],
331   xc_with_tk_includes=$withval)
332 AC_ARG_WITH(tcllibs,    [  --with-tcllibs=DIR      Find Tcl library in DIR],
333   xc_with_tcl_libraries=$withval)
334 AC_ARG_WITH(tklibs,     [  --with-tklibs=DIR       Find Tk library in DIR],
335   xc_with_tk_libraries=$withval)
337 # -----------------------------------------------------------------------
339 #       Find the Tcl build configuration file "tclConfig.sh"
341 # -----------------------------------------------------------------------
343 if test "x$xc_with_tcl" != "x" ; then
345   TCL_INC_DIR="."
346   TK_INC_DIR="."
348   AC_MSG_CHECKING([for tclConfig.sh])
349   tcl_config_sh=""
351   if test "$xc_with_tcl" = "no" ; then
352     xc_with_tcl=""
353   elif test "$xc_with_tcl" != "yes" ; then
354     #
355     # Verify that a tclConfig.sh file exists in the directory specified 
356     # by --with-tcl. 
357     #
358     for dir in \
359      $xc_with_tcl 
360     do
361       if test -r "$dir/tclConfig.sh" ; then
362         tcl_config_sh="$dir/tclConfig.sh"
363         break
364       elif test -r "$dir/lib/tclConfig.sh" ; then
365         tcl_config_sh="$dir/lib/tclConfig.sh"
366         break
367       fi
368     done
369   else 
370     #
371     # Otherwise, search for Tcl configuration file.  
372     #
374     #  1. Search previously named locations.
376     for dir in \
377      $prefix \
378      $exec_prefix
379     do
380       if test -r "$dir/tclConfig.sh" ; then
381         tcl_config_sh="$dir/tclConfig.sh"
382         break
383       elif test -r "$dir/lib/tclConfig.sh" ; then
384         tcl_config_sh="$dir/lib/tclConfig.sh"
385         break
386       fi
387     done
389     #  2. Search standard locations.
391     if test "x$tcl_config_sh" = "x" ; then
392       for dir in \
393        `ls -dr /usr/local/tcl/tcl[[7-9]].[[0-9]]* 2>/dev/null` \
394        /usr/local/tcl \
395        /usr/local/lib \
396        /usr/local \
397        `ls -dr /usr/share/tcltk/tcl[[7-9]].[[0-9]]* 2>/dev/null` \
398        /sw/lib \
399        /usr/lib \
400        /usr/lib64 \
401        /usr
402       do
403         if test -r "$dir/tclConfig.sh" ; then
404           tcl_config_sh="$dir/tclConfig.sh"
405           break
406         elif test -r "$dir/lib/tclConfig.sh" ; then
407           tcl_config_sh="$dir/lib/tclConfig.sh"
408           break
409         fi
410       done
411     fi
412   fi
414   AC_MSG_RESULT([${tcl_config_sh}])
416   if test "x$tcl_config_sh" = "x" ; then
417     echo "can't find Tcl configuration script \"tclConfig.sh\""
418     echo "Reverting to non-Tcl compilation"
419     xc_with_tcl=""
420   fi
423 # -----------------------------------------------------------------------
425 #       Find the Tk build configuration file "tkConfig.sh"
427 # -----------------------------------------------------------------------
429 if test "x$xc_with_tcl" != "x" ; then
430   AC_MSG_CHECKING([for tkConfig.sh])
431   tk_config_sh=""
432   if test "$xc_with_tk" != "yes"; then
433     #
434     # Verify that a tkConfig.sh file exists in the directory specified 
435     # by --with-tcl or --with-tk. 
436     #
437     for dir in \
438      $xc_with_tk \
439      $xc_with_tcl 
440     do
441       if test -r "$dir/tkConfig.sh" ; then
442         tk_config_sh="$dir/tkConfig.sh"
443         break
444       elif test -r "$dir/lib/tkConfig.sh" ; then
445         tk_config_sh="$dir/lib/tkConfig.sh"
446         break
447       fi
448     done
449   else 
450     #
451     # Search for Tk configuration file.  
452     #
454     #
455     #  1. Search previously named locations.
456     # 
457     for dir in \
458      $prefix \
459      $exec_prefix
460     do
461       if test -r "$dir/tkConfig.sh" ; then
462         tk_config_sh="$dir/tkConfig.sh"
463         break
464       elif test -r "$dir/lib/tkConfig.sh" ; then
465         tk_config_sh="$dir/lib/tkConfig.sh"
466         break
467       fi
468     done
469     #
470     #  2. Search standard locations.
471     # 
472     if test "x$tk_config_sh" = "x" ; then
473       for dir in \
474        /usr/local \
475        /usr \
476        `ls -dr /usr/local/lib/tk[[7-9]].[[0-9]]* 2>/dev/null` \
477        `ls -dr /usr/lib/tk[[7-9]].[[0-9]]* 2>/dev/null` \
478        `ls -dr /usr/local/tk/tk[[7-9]].[[0-9]]* 2>/dev/null` \
479        `ls -dr /usr/local/tk[[7-9]].[[0-9]]* 2>/dev/null` \
480        /usr/local/tk \
481        `ls -dr /usr/local/lib/tcl[[7-9]].[[0-9]]* 2>/dev/null` \
482        `ls -dr /usr/lib/tcl/tk[[7-9]].[[0-9]]* 2>/dev/null` \
483        `ls -dr /usr/local/tcl/tcl[[7-9]].[[0-9]]* 2>/dev/null` \
484        `ls -dr /usr/share/tcltk/tk[[7-9]].[[0-9]]* 2>/dev/null` \
485        /sw/lib \
486        /usr/lib \
487        /usr/lib64 \
488        ${x_libraries}
489       do
490         if test -r "$dir/tkConfig.sh" ; then
491           tk_config_sh="$dir/tkConfig.sh"
492           break
493         elif test -r "$dir/lib/tkConfig.sh" ; then
494           tk_config_sh="$dir/lib/tkConfig.sh"
495           break
496         fi
497       done
498     fi
499   fi
500   AC_MSG_RESULT([${tk_config_sh}])
502   if test "x$tk_config_sh" = "x" ; then
503     echo "can't find Tk configuration script \"tkConfig.sh\""
504     echo "Reverting to non-Tcl compilation"
505     xc_with_tcl=""
506   fi
509 # -----------------------------------------------------------------------
511 #       Source in the Tcl/Tk configuration scripts.  
513 #       This didn't work so well in the pre-8.5 days, but
514 #       seems to be okay now.
516 # -----------------------------------------------------------------------
518 if test "x$xc_with_tcl" != "x" ; then
519   . $tcl_config_sh
520   . $tk_config_sh
522   # Should probably trust the config file contents, but this configure
523   # file checks the Tcl and Tk include and lib directories.  Since
524   # the config file doesn't separate out the libraries from the strings
525   # passed to the compiler/linker, do it manually here.
526   #
527   # Extract TCL_LIB_DIR from TCL_LIB_SPEC
528   # Extract TK_LIB_DIR from TK_LIB_SPEC
529   # Extract TCL_INC_DIR from TCL_INCLUDE_SPEC
530   # Extract TK_INC_DIR from TK_INCLUDE_SPEC
531   #
532   # These will be the defaults unless overridden by configure command line
534   tmpstr=${TCL_LIB_SPEC#*-L}
535   TCL_LIB_DIR=${tmpstr% -l*}
536   tmpstr=${TK_LIB_SPEC#*-L}
537   TK_LIB_DIR=${tmpstr% -l*}
538   TCL_INC_DIR=${TCL_INCLUDE_SPEC#*-I}
539   TK_INC_DIR=${TK_INCLUDE_SPEC#*-I}
541   LIBS="${TCL_LIBS} ${LIBS}"
543   if test "$TCL_VERSION" = "$TK_VERSION" ; then
544     :
545   else
546     echo "Mismatched Tcl/Tk versions ($TCL_VERSION != $TK_VERSION)"
547     echo "Reverting to non-Tcl compilation"
548     xc_with_tcl=""
549   fi
552 # -----------------------------------------------------------------------
553 # Rely on TCL_INCLUDE_SPEC from tclConfig.sh unless "--with-tclincls"
554 # overrides.  With TCL_INCLUDE_SPEC, pull out TCL_INC_DIR
555 # -----------------------------------------------------------------------
557 if test "x$xc_with_tcl" != "x" ; then
558   if test "x${xc_with_tcl_includes}" != "x" ; then
559     if test -r "${xc_with_tcl_includes}/tcl.h" ; then
560       TCL_INC_DIR=${xc_with_tcl_includes}
561     elif test "x${TCL_INCLUDE_SPEC}" == "x" ; then
562       echo "Can't find tcl.h in \"${xc_with_tcl_includes}\""
563       echo "Reverting to non-Tcl compilation"
564       xc_with_tcl=""
565     fi
566   elif test "x${TCL_INCLUDE_SPEC}" == "x" ; then
567     for dir in \
568      ${TCL_PREFIX}/include/tcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION} \
569      ${TCL_PREFIX}/include \
570      ${TCL_SRC_DIR}/generic \
571      ${TCL_INC_DIR}
572     do
573       if test -r "$dir/tcl.h" ; then
574         TCL_INC_DIR=$dir
575         TCL_INCLUDE_SPEC="-I${TCL_INC_DIR}"
576         break
577       fi
578     done
579     if test "x${TCL_INC_DIR}" = "x" ; then
580       echo "Can't find tcl.h header file"
581       echo "Reverting to non-Tcl compilation"
582       xc_with_tcl=""
583     fi
584   else
585     TCL_INC_DIR=`echo ${TCL_INCLUDE_SPEC} | sed -e '/-I/s/-I//'`
586   fi
589 # -----------------------------------------------------------------------
590 # Rely on TK_INCLUDE_SPEC from tkConfig.sh unless "--with-tkincls"
591 # overrides.  With TK_INCLUDE_SPEC, pull out TK_INC_DIR
592 # -----------------------------------------------------------------------
594 if test "x$xc_with_tcl" != "x" ; then
595   if test "x${xc_with_tk_includes}" != "x" ; then
596     if test -r "${xc_with_tk_includes}/tk.h" ; then
597       TK_INC_DIR=${xc_with_tk_includes}
598     elif test "x${TK_INCLUDE_SPEC}" == "x" ; then
599       echo "Can't find tk.h in \"${xc_with_tk_includes}\""
600       echo "Reverting to non-Tcl compilation"
601       xc_with_tcl=""
602     fi
603   elif test "x${TK_INCLUDE_SPEC}" == "x" ; then
604     for dir in \
605      ${TK_PREFIX}/include/tcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION} \
606      ${TK_PREFIX}/include/tk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION} \
607      ${TK_PREFIX}/include \
608      ${TK_SRC_DIR}/generic \
609      ${TK_INC_DIR}
610     do
611       if test -r "$dir/tk.h" ; then
612         TK_INC_DIR=$dir
613         TK_INCLUDE_SPEC="-I${TK_INC_DIR}"
614         break
615       fi
616     done
617     if test "x${TK_INC_DIR}" = "x" ; then
618       echo "Can't find tk.h header file"
619       echo "Reverting to non-Tcl compilation"
620       xc_with_tcl=""
621     fi
622   else
623     TK_INC_DIR=`echo ${TK_INCLUDE_SPEC} | sed -e '/-I/s/-I//'`
624   fi
627 # --------------------------------------------------------------
628 # Rely on TCL_LIB_SPEC from tclConfig.sh unless "--with-tcllibs"
629 # overrides.  With TCL_LIB_SPEC, pull out TCL_LIB_DIR
630 # --------------------------------------------------------------
632 if test "x$xc_with_tcl" != "x" ; then
633   if test "x${xc_with_tcl_libraries}" != "x" ; then
634     TCL_LIB_SPEC=""
635     for libname in \
636      "${xc_with_tcl_libraries}/${TCL_LIB_FILE}" \
637      "${xc_with_tcl_libraries}/lib${TCL_LIB_NAME}${SHDLIB_EXT}"
638     do
639       if test -r "$libname" ; then
640         TCL_LIB_DIR="${xc_with_tcl_libraries}"
641         break
642       fi
643     done
644     if test "x${TCL_LIB_DIR}" == "x" ; then
645       echo "Can't find tcl library in \"${xc_with_tcl_libraries}\""
646       echo "Reverting to non-Tcl compile"
647       xc_with_tcl=""
648     fi
649   elif test "x${TCL_LIB_SPEC}" == "x" ; then
650     for libpfix in "lib64" "lib"
651     do
652       libname="${TCL_EXEC_PREFIX}/${libpfix}/lib${TCL_LIB_NAME}${SHDLIB_EXT}"
653       if test -r "$libname" ; then
654         TCL_LIB_DIR="${TCL_EXEC_PREFIX}/${libpfix}"
655         break
656       fi
657     done
658     if test "x${TCL_LIB_DIR}" = "x" ; then
659       echo "Can't find tcl library"
660       echo "Reverting to non-Tcl compile"
661       xc_with_tcl=""
662     fi
663   else
664     TCL_LIB_DIR=`echo ${TCL_LIB_SPEC} | sed -e '/-L/s/-L//' -e '/-l/s/-l.*//'`
665   fi
668 # --------------------------------------------------------------
669 # Rely on TK_LIB_SPEC from tkConfig.sh unless "--with-tklibs"
670 # overrides.  With TK_LIB_SPEC, pull out TK_LIB_DIR
671 # --------------------------------------------------------------
673 if test "x$xc_with_tcl" != "x" ; then
674   if test "x${xc_with_tk_libraries}" != "x" ; then
675     TK_LIB_SPEC=""
676     for libname in \
677      "${xc_with_tk_libraries}/${TK_LIB_FILE}" \
678      "${xc_with_tk_libraries}/lib${TK_LIB_NAME}${SHDLIB_EXT}"
679     do
680       if test -r "$libname" ; then
681         TK_LIB_DIR="${xc_with_tk_libraries}"
682         break
683       fi
684     done
685     if test "x${TK_LIB_DIR}" == "x" ; then
686       echo "Can't find tk library in \"${xc_with_tk_libraries}\""
687       echo "Reverting to non-Tcl compile"
688       xc_with_tcl=""
689     fi
690   elif test "x${TK_LIB_SPEC}" == "x" ; then
691     for libpfix in "lib64" "lib"
692     do
693       libname="${TK_EXEC_PREFIX}/${libpfix}/lib${TK_LIB_NAME}${SHDLIB_EXT}"
694       if test -r "$libname" ; then
695         TK_LIB_DIR="${TK_EXEC_PREFIX}/${libpfix}"
696         break
697       fi
698     done
699     if test "x${TK_LIB_DIR}" = "x" ; then
700       echo "Can't find tk library"
701       echo "Reverting to non-Tcl compile"
702       xc_with_tcl=""
703     fi
704   else
705     TK_LIB_DIR=`echo ${TCL_LIB_SPEC} | sed -e '/-L/s/-L//' -e '/-l/s/-l.*//'`
706   fi
709 #--------------------------------------------------------------------
710 # If TCL_LIB_SPEC and/or TK_LIB_SPEC do not exist, construct them
711 #--------------------------------------------------------------------
713 if test "x$xc_with_tcl" != "x" ; then
714   if test "x${TCL_LIB_SPEC}" == "x" ; then
715     case $target in
716       *-sunos4*|*-*-netbsd|NetBSD-*|FreeBSD-*|*-*-openbsd*|OpenBSD-*)
717         TCL_LIB_NAME="tcl${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}"
718         ;;
719       *)
720         TCL_LIB_NAME="tcl${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}"
721         ;;
722     esac
723     TCL_LIB_SPEC="-L${TCL_LIB_DIR} -l${TCL_LIB_NAME}"
724   fi
726   if test "x${TK_LIB_SPEC}" == "x" ; then
727     case $target in
728       *-sunos4*|*-*-netbsd|NetBSD-*|FreeBSD-*|*-*-openbsd*|OpenBSD-*)
729         TK_LIB_NAME="tk${TK_MAJOR_VERSION}${TK_MINOR_VERSION}"
730         ;;
731       *)
732         TK_LIB_NAME="tk${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}"
733         ;;
734     esac
735     TK_LIB_SPEC="-L${TK_LIB_DIR} -l${TK_LIB_NAME}"
736   fi
738   # Find the version of "wish" that corresponds to TCL_EXEC_PREFIX
739   # We really ought to run "ldd" to confirm that the linked libraries match.
741   AC_MSG_CHECKING([for wish executable])
742   for dir in \
743    ${TK_EXEC_PREFIX}/bin \
744    ${TK_EXEC_PREFIX}
745   do
746     for wishexe in \
747       wish \
748       wish${TK_VERSION} \
749       wish.exe \
750       wish${TK_VERSION}.exe
751     do
752       if test -r "$dir/$wishexe" ; then
753         WISH_EXE=$dir/$wishexe
754         break
755       fi
756     done  
757     if test "x${WISH_EXE}" != "x" ; then
758       break  
759     fi
760   done
761   if test "x${WISH_EXE}" = "x" ; then
762     echo "Warning: Can't find executable for \"wish\".  You may have to"
763     echo "manually set the value for WISH_EXE in the xcircuit startup script."
764     AC_MSG_RESULT(no)
765   else
766     AC_MSG_RESULT([${WISH_EXE}])
767   fi
769   # Have to define SHDLIB_EXT here even though we have to do it below, too.
770   case $target in
771      *-hpux*)
772         SHDLIB_EXT=".sl"
773         ;;
774      *cygwin*)
775         SHDLIB_EXT=".dll.a"
776         ;;
777      *-darwin*)
778         SHDLIB_EXT=".dylib"
779         ;;
780      *-openbsd*)
781         SHDLIB_EXT=".so.${TCL_LIB_FILE##*.so.}"
782         ;;
783      *)
784         SHDLIB_EXT=".so"
785         ;;
786   esac
789 dnl End of Tcl/Tk search
790 dnl --------------------------------
792 # -----------------------------------------------------------------------
794 # Tk libraries and header files
796 # -----------------------------------------------------------------------
798 if test "x$xc_with_tcl" != "x" ; then
799   INC_SPECS="${INC_SPECS} ${TCL_INCLUDE_SPEC} ${TK_INCLUDE_SPEC}"
800   LIB_SPECS="${LIB_SPECS} ${TCL_LIB_SPEC} ${TK_LIB_SPEC}"
802   if test "x${loader_run_path}" = "x" ; then
803     loader_run_path="${TCL_LIB_DIR}"
804   else
805     loader_run_path="${TCL_LIB_DIR}:${loader_run_path}"
806   fi
808   #--------------------------------------------------------------------
809   #
810   # Check if we can generate shared libraries on this system.  Set flags 
811   # to generate shared libraries for systems that we know about.  Start 
812   # with the values found in tclConfig.sh, make changes as we know about 
813   # the different systems.
814   #
815   #--------------------------------------------------------------------
817   # Initialize shared library build variables
819   if test "x${TCL_SHLIB_SUFFIX}" == "x" ; then
820     SHDLIB_EXT=".so"
821   else
822     SHDLIB_EXT="${TCL_SHLIB_SUFFIX}"
823   fi
825   if test "x${TCL_SHLIB_LD}" == "x" ; then
827     # Construct shared library build arguments the painful way
828     # This is not expected to be necessary, so the number of
829     # supported systems has been pared down to a minimum.
831     LDDL_FLAGS="-shared"
832     LD_RUN_PATH=""
833     SHLIB_LD="${CC}"
834     EXTRA_LIB_SPECS=""
836     case $target in
837       *-darwin*)
838         SHDLIB_EXT=".dylib"
839         SHLIB_LIB_SPECS="${LIB_SPECS}"
840         if test "${xc_with_gnu_ld}" = "yes" ; then
841            LDDL_FLAGS="-dynamiclib -bind_at_load"
842         else
843            LDDL_FLAGS="-single_module -dynamiclib -flat_namespace"
844            LDDL_FLAGS="${LDDL_FLAGS} -undefined suppress -noprebind"
845            SHLIB_CFLAGS="-I/sw/include -fno-common"
846         fi
847         ;;
849       *cygwin*)
850         AC_DEFINE(CYGWIN)
851         SHDLIB_EXT=".dll.a"
852         LDDL_FLAGS="-shared -Wl,--enable-auto-image-base -Wl,-rpath,${loader_run_path}"
853         SHLIB_LIB_SPECS="${LIB_SPECS}"
854         ;;
856       *-linux*)
857         SHLIB_CFLAGS="-fPIC"
858         LDDL_FLAGS='-shared -Wl,-soname,$@'
859         LD_RUN_PATH="-Wl,-rpath,${loader_run_path}"
860     
861         EXTRA_LIB_SPECS="-ldl"
863         case $target in
864            x86_64-*)
865               # AMD 64-bit archictecture
866               # Add -fPIC to standard compile switch
867               CFLAGS="${CFLAGS} -fPIC"
868               ;;
869         esac
870         ;;
871   
872       *-netbsd*|*-freebsd*|*-openbsd*)
873         # Not available on all versions:  check for include file.
874         AC_CHECK_HEADER(dlfcn.h, test_ok=yes, test_ok=no)
875         if test "$test_ok" = yes; then
876           SHLIB_CFLAGS="-fpic"
877           SHLIB_LD="ld"
878           LDDL_FLAGS="-shared"
879         fi
880         ;;
881     esac
883     if test "$GCC" = "yes" ; then
884        CFLAGS="-fPIC ${CFLAGS}"
885     fi
887   else
889     # Rely on shared lib arguments in tclConfig.sh
891     SHLIB_LD="${TCL_SHLIB_LD}"
892     EXTRA_LIB_FLAGS=""
893     LDDL_FLAGS="${TCL_LD_FLAGS}"
894     LD_RUN_PATH=""
896     case $target in
897       *-linux*)
898         LD_RUN_PATH="-Wl,-rpath,${loader_run_path}"
899         ;;
900     esac
901   fi
903   # If we're running gcc, then set SHLIB_CFLAGS flags for compiling
904   # shared libraries for gcc, instead of those of the vendor's
905   # compiler.
907   if test "$GCC" = "yes" ; then
908     if test "x${TCL_SHLIB_CFLAGS}" = "x" ; then
909        SHLIB_CFLAGS="-fPIC ${SHLIB_CFLAGS}"
910     else
911        SHLIB_CFLAGS="${TCL_SHLIB_CFLAGS} ${SHLIB_CFLAGS}"
912     fi
913   fi
914   CFLAGS="${CFLAGS} ${SHLIB_CFLAGS}"
916   if test "${xc_with_gnu_ld}" = "yes" ; then
917     LDDL_FLAGS="${LDDL_FLAGS} -Wl,--version-script=symbol.map"
918   fi
920   AC_SUBST(SHDLIB_EXT)
921   AC_SUBST(SHLIB_LD)
922   AC_SUBST(LDDL_FLAGS)
923   AC_SUBST(SHLIB_LIB_SPECS)
924   AC_SUBST(EXTRA_LIB_SPECS)
925   AC_SUBST(LD_RUN_PATH)
926   AC_SUBST(LDFLAGS)
927   AC_SUBST(INC_SPECS)
928   AC_SUBST(LIB_SPECS)
929   AC_SUBST(TCL_LIB_DIR)
930   AC_SUBST(WISH_EXE)
934 dnl Disable the ASG (automatic schematic generation) package.  Disabled by default.
935 AC_ARG_ENABLE(asg,
936 [ --enable-asg          enable support for Automatic Schematic Generation], [
937   AC_DEFINE(ASG)
938   AC_DEFINE(CONFIGURED)
939   SUBDIRS="asg spiceparser"
940   dnl Object files to link into the final executable or shared object
941   dnl These must be in the correct order!
942      SUBLIB="asg/libasg.a spiceparser/libspiceparser.a"
945 dnl Disable LGF (analog/diglog) file support.  Enabled by default.
946 AC_ARG_ENABLE(lgf,
947 [  --disable-lgf           disable support for reading Caltech tools
948                           analog simulator .lgf files], , [
949   HAVE_LGF=LGF
950   AC_DEFINE(LGF)
953 dnl Disable fix for input focus on some window managers.  Enabled by default.
954 AC_ARG_ENABLE(focus-fix,
955 [  --disable-focus-fix     disable focus fix for some window managers], , [
956   AC_DEFINE(INPUT_FOCUS)
959 dnl Path to Ghostscript
960 AC_ARG_WITH(gs,
961 [  --with-gs=DIR           path to ghostscript], [
962   if test -f "$withval"; then
963     GS_EXEC=$withval
964   else
965     GS_EXEC=gs
966   fi
967 ], [
968   AC_CHECK_PROG(GS_EXEC, gs, , gs)])
969 AC_DEFINE_UNQUOTED(GS_EXEC, "$GS_EXEC")
971 dnl Path to ngspice
972 AC_ARG_WITH(ngspice,
973 [  --with-ngspice=DIR           path to ngspice], [
974   if test -f "$withval"; then
975     SPICE_EXEC=$withval
976   else
977     SPICE_EXEC=ngspice
978   fi
979 ], [
980   AC_CHECK_PROG(SPICE_EXEC, ngspice, , ngspice)])
981 AC_DEFINE_UNQUOTED(SPICE_EXEC, "$SPICE_EXEC")
983 dnl Path to Python
985 xc_with_python=""
986 PYTHON=
988 AC_ARG_WITH(python,
989 [  --with-python=DIR       path to python interpreter],
990   xc_with_python=$withval) 
992 if test "x$xc_with_tcl" != "x" ; then
993   xc_with_python=""
994 elif test "$xc_with_python" = "no" ; then
995   xc_with_python=""
996 elif test "$xc_with_python" = "yes" ; then
997   AC_PATH_PROG(PYTHON,python)
998 elif test "x$xc_with_python" != x; then
999   test -f "$xc_with_python" && PYTHON=$xc_with_python
1002 if test "x$PYTHON" != x; then
1003   _py_version=`$PYTHON -c 'import sys; print sys.version[[0:3]]'`
1004   _py_prefix=`$PYTHON -c 'import sys; print sys.prefix'`
1005   _py_exec_prefix=`$PYTHON -c 'import sys; print sys.exec_prefix'`
1007   _py_include="$_py_prefix/include/python$_py_version"
1008   _py_lib="$_py_exec_prefix/lib/python$_py_version/config"
1009   _py_makefile="$_py_lib/Makefile"
1011   if test $_py_version = 1.5; then
1012     echo
1013     echo "*** WARNING:" 
1014     echo "*** Python version 1.5 detected:  This version of Python has a known fatal"
1015     echo "*** bug.  Disabling Python interface.  If you want the embedded Python"
1016     echo "*** interface, you will need to get an updated version of Python."
1017     echo
1018     PYTHON=""
1019   fi
1022 if test "x$PYTHON" != x; then
1023   if test -f $_py_makefile; then
1024     _py_libs=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $_py_makefile`
1025     _py_libm=`sed -n -e 's/^LIBM=\(.*\)/\1/p' $_py_makefile`
1026   else
1027     _py_libs='-lpthread -ldl -lutil -ldb'
1028     _py_libm='-lm'
1029   fi
1030       
1031   # Now that we think we know where the python include and
1032   # library files are, make sure we can build a small
1033   # program against them.
1034   _save_CPPFLAGS=${CPPFLAGS}
1035   _save_LDFLAGS=${LDFLAGS}
1036   _save_LIBS=${LIBS}
1038   CPPFLAGS="$CPPFLAGS -I$_py_include"
1039   LDFLAGS="$LDFLAGS -L$_py_lib"
1040     
1041   case "$target_os" in
1042         *cygwin*)
1043                 PYLIB="-lpython$_py_version"
1044                 LIBS="$PYLIB.dll $LIBS $X_PRE_LIBS $_py_libs"
1045                 ;;
1046         *)
1047                 LIBS="$LIBS -lpython$_py_version $_py_libs $_py_libm"
1048                 ;;              
1049   esac    
1050     
1052   HAVE_PYTHON=0
1053   AC_CHECK_HEADER(Python.h,[
1054       AC_MSG_CHECKING([for Py_Initialize in -lpython$_py_version])
1055       AC_TRY_LINK([#include "Python.h"],[Py_Initialize();],[
1056         HAVE_PYTHON=1
1057         INTERPRETER=PYTHON
1058         AC_MSG_RESULT(yes)
1059         AC_DEFINE(HAVE_PYTHON)],
1060         AC_MSG_RESULT(no))])
1062   if test "x$HAVE_PYTHON" = x0; then
1063     CPPFLAGS=$_save_CPPFLAGS
1064     LDFLAGS=$_save_LDFLAGS
1065     LIBS=$_save_LIBS
1066     PYTHON=""
1067   fi
1070 if test "x$PYTHON" != x; then
1071   STARTUP_FILE="xcstartup.py"
1072   INTERP_PATH="python"
1073   WRAPPER_SCRIPT=""
1074   SUBDIRS="${SUBDIRS} Xw"
1075   SUBLIB="${SUBLIB} Xw/libxcXw.a"
1076   XCIRCUIT_TARGET="xcircuit"
1077 elif test "x$xc_with_tcl" != "x" ; then
1078   INTERPRETER=TCL
1079   STARTUP_FILE="xcstartup.tcl"
1080   INTERP_PATH="tcl"
1081   WRAPPER_SCRIPT="wrapper.tcl"
1082   AC_DEFINE(TCL_WRAPPER)
1083   XCIRCUIT_TARGET="tcl"
1084   ALL_TARGET="all-recursive"
1085   INSTALL_TARGET="install-recursive"
1086 else
1087   STARTUP_FILE="startup.script"
1088   INTERP_PATH="."
1089   WRAPPER_SCRIPT=""
1090   SUBDIRS="${SUBDIRS} Xw"
1091   SUBLIB="${SUBLIB} Xw/libxcXw.a"
1092   XCIRCUIT_TARGET="xcircuit"
1095 # Add -lm last to LDFLAGS, or Tcl/Tk's addition of -lieee can cause
1096 # an error.
1097 EXTRA_LIB_SPECS="$EXTRA_LIB_SPECS -lm"
1099 dnl Memory debugging:
1100 dnl The non-Tcl version uses (links to) ElectricFence.
1101 dnl Tcl must use the Tcl memory debugger.
1102 dnl Caveats:
1103 dnl We should try to ensure that ElectricFence is available, or that
1104 dnl the Tcl version used has memory debugging compiled in
1106 AC_ARG_ENABLE(memdebug,
1107 [  --enable-memdebug            enable memory debugging], [
1108    if test "x$xc_with_tcl" = "x" ; then
1109       LIBS="${LIBS} -lefence"
1110    else
1111       AC_DEFINE(TCL_MEM_DEBUG)
1112    fi
1115 AC_SUBST(SUBDIRS)
1116 AC_SUBST(SUBLIB)
1117 AC_SUBST(STDLIBS)
1118 AC_SUBST(GS_LIBS)
1119 AC_SUBST(STARTUP_FILE)
1120 AC_SUBST(INTERP_PATH)
1121 AC_SUBST(WRAPPER_SCRIPT)
1122 AC_SUBST(XCIRCUIT_TARGET)
1123 AC_SUBST(CFLAGS)
1124 AC_SUBST(LD)
1125 AC_SUBST(LDFLAGS)
1127 AC_SUBST(INTERPRETER)
1128 AC_SUBST(HAVE_LGF)
1130 AC_SUBST(ALL_TARGET)
1131 AC_SUBST(INSTALL_TARGET)
1133 dnl Automake requires these
1134 AC_SUBST(ACLOCAL)
1135 AC_SUBST(AUTOCONF)
1136 AC_SUBST(AUTOMAKE)
1137 AC_SUBST(AUTOHEADER)
1139 AC_OUTPUT(Makefile Xw/Makefile asg/Makefile spiceparser/Makefile)
1141 echo ""
1142 echo "Configuration results:"
1143 echo "----------------------------------------------------"
1144 echo ""
1146 if test "x$xc_with_tcl" == "x" ; then
1147    if test "x$PYTHON" != x; then
1148       echo "Using Python interface (not recommended)"
1149    else
1150       echo "No Tcl/Tk, using standard Xlib/Xt interface."
1151       echo "If that is not what you wanted, then make sure"
1152       echo "you have Tcl/Tk development packages installed?"
1153    fi
1154 else
1155    echo "Using Tcl/Tk interface"
1157 echo ""
1159 if test "x$xc_with_cairo" == "x" ; then
1160    echo "No Cairo graphics."
1161    echo "If that is not what you wanted, then make sure"
1162    echo "you have libcairo and fontconfig installed."
1163    echo "Try installing package cairo-devel."
1164 else
1165    echo "Using Cairo graphics"
1167 echo ""
1168 echo "CFLAGS=${CFLAGS}"