polygon1.c: Tidy up poly_Valid debug print routines to match pline_dump
[geda-pcb/gde.git] / configure.ac
blob49d771400ec3c34803e745be8d7bd954e025855e
1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT([pcb], [1.99z])
4 AC_CONFIG_SRCDIR([src/draw.c])
5 AC_PREREQ([2.60])
6 AM_INIT_AUTOMAKE([1.9])
7 AC_GNU_SOURCE
8 AM_CONFIG_HEADER([config.h])
10 ##########################################################################
12 # Try to figure out if we are building from git sources.
13 # If we are then unless building of the documentation has
14 # been disabled then just require the user have all the right
15 # tools.  Users building from a tarball won't need latex, makeinfo,
16 # etc. but if you're already downloading development sources, then
17 # it is not unreasonable to require development tools.  What motivated
18 # this is that using maintainer mode proved to cause regular confusion.
20 AC_MSG_CHECKING([if you are building from a git checkout])
21 pcb_git_version=no
22 if test -f $srcdir/.gitignore ; then
23         pcb_git_version=yes
24         AC_MSG_RESULT([yes])
25 else
26         AC_MSG_RESULT([no])
28 AM_CONDITIONAL(GIT_VERSION, test x$pcb_git_version = xyes)
30 AC_MSG_CHECKING([if you are building from a anoncvs checkout])
31 pcb_cvs_version=no
32 if test -f $srcdir/CVS/Root ; then
33         pcb_cvs_version=yes
34         AC_MSG_RESULT([yes])
35 else
36         AC_MSG_RESULT([no])
38 AM_CONDITIONAL(CVS_VERSION, test x$pcb_cvs_version = xyes)
39 AM_CONDITIONAL(GIT_OR_CVS_VERSION, test x$pcb_git_version = xyes -o x$pcb_cvs_version = xyes)
41 ##########################################################################
43 # See if we are supposed to build the docs
46 docs_yesno=yes
47 AC_MSG_CHECKING([if the documentation should be built])
48 AC_ARG_ENABLE([doc],
49 [  --enable-doc            Build and install the documentation [[default=yes]]],
51 if test "X$enable_doc" = "Xno" ; then
52         DOC=""
53         AC_MSG_RESULT([no])
54         docs_yesno=no
55 else
56         DOC=doc
57         AC_MSG_RESULT([yes])
58         docs_yesno=yes
62 DOC=doc
63 AC_MSG_RESULT([yes])
64 docs_yesno=yes
66 AC_SUBST(DOC)
69 AC_MSG_CHECKING([if maintainer mode is required])
70 if test "$docs_yesno" = "yes" -a "$pcb_git_version" = "yes" ; then
71         AC_MSG_RESULT([yes -- the documentation build is enabled and your sources are from git])
72         enable_maintainer_mode=yes
73 else
74         AC_MSG_RESULT([no])
77 AM_MAINTAINER_MODE
80 dnl determine host type
81 AC_CANONICAL_HOST
82 AC_MSG_CHECKING(for windows)
83 PCB_PATH_DELIMETER=":"
84 PCB_DIR_SEPARATOR_S="/"
85 PCB_DIR_SEPARATOR_C='/'
86 case $host in
87         *-*-cygwin* )
88                 CFLAGS="$CFLAGS ${CYGWIN_CFLAGS}"
89                 CPPFLAGS="$CPPFLAGS ${CYGWIN_CPPFLAGS}"
90                 ;;
92         *-*-mingw* )
93                 WIN32=yes
94                 CFLAGS="$CFLAGS ${MINGW_CFLAGS:--mms-bitfields -mwindows}"
95                 CPPFLAGS="$CPPFLAGS ${MINGW_CPPFLAGS:--mms-bitfields -mwindows}"
96                 ;;
98         * )
99                 WIN32=no
100                 ;;
101 esac
103 AC_MSG_RESULT($WIN32)
104 AC_SUBST(WIN32)
105 AM_CONDITIONAL(WIN32, test x$WIN32 = xyes)
106 if test "x$WIN32" = "xyes" ; then
107         PCB_PATH_DELIMETER=";"
108         PCB_DIR_SEPARATOR_S="\\\\"
109         PCB_DIR_SEPARATOR_C='\\'
112 AC_DEFINE_UNQUOTED(PCB_DIR_SEPARATOR_C,'$PCB_DIR_SEPARATOR_C',[Directory separator char])
113 AC_DEFINE_UNQUOTED(PCB_DIR_SEPARATOR_S,"$PCB_DIR_SEPARATOR_S",[Directory separator string])
114 AC_DEFINE_UNQUOTED(PCB_PATH_DELIMETER,"$PCB_PATH_DELIMETER",[Search path separator string])
117 dnl Checks for programs.
118 AC_PROG_CC
120 if test "x$WIN32" = "xyes" ; then
121         AC_CHECK_TOOL(WINDRES, windres, [no])
122         if test "$WINDRES" = "no" ; then
123                 AC_MSG_ERROR([*** Could not find an implementation of windres in your PATH.])
124         fi
127 # i18n
128 GETTEXT_PACKAGE=$PACKAGE
129 AH_TEMPLATE([GETTEXT_PACKAGE], [Name of this program's gettext domain])
130 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"])
131 AC_SUBST(GETTEXT_PACKAGE)
133 AM_GNU_GETTEXT_VERSION([0.14])
134 AM_GNU_GETTEXT
135 IT_PROG_INTLTOOL([0.35.0])
137 AC_C_INLINE
138 AC_PROG_CC_STDC
139 AM_PROG_CC_C_O
140 AC_PROG_CPP
141 AC_PROG_AWK
143 AM_PROG_LEX
144 AC_PATH_PROG(LEX_PATH, $LEX, [notfound])
145 if test "$LEX_PATH" = "notfound" ; then
146         AC_MSG_ERROR([Couldn't find a usable lex program.
147 Please install flex which is available from
148 ftp://ftp.gnu.org/pub/non-gnu/flex/
153 AC_PROG_YACC
154 AC_PATH_PROG(YACC_PATH, $YACC, [notfound])
155 if test "$YACC_PATH" = "notfound" ; then
156         AC_MSG_ERROR([Couldn't find a usable yacc program.
157 Please install bison which is available from
158 ftp://ftp.gnu.org/pub/gnu/bison/
162 AC_PROG_INSTALL
163 AC_PROG_RANLIB
166 # Used for building the icons
168 AC_PATH_PROG(XPMTOPPM, xpmtoppm, notfound)
169 AC_PATH_PROG(PPMTOWINICON, ppmtowinicon, notfound)
170 AC_PATH_PROG(CONVERT, convert, notfound)
172 ##########################################################################
175 if test "X$docs_yesno" = "Xyes" -a "X$pcb_git_version" = "Xyes" ; then
176    AC_PATH_PROG(MKINFO, makeinfo, no)
177    if test "X$MKINFO" != "Xno"; then
178       AC_MSG_CHECKING([for GNU makeinfo version >= 4.6])
179       v=`$MKINFO --version | grep "GNU texinfo"`
180       if test $? -ne 0; then
181          AC_MSG_RESULT([non-GNU])
182          MKINFO="no"
183       fi
184    fi
185    if test "X$MKINFO" != "Xno"; then
186       vmajor=`echo "$v" | sed 's/.* \([[0-9]]*\)\.\([[0-9]]*\)$/\1/'`
187       vminor=`echo "$v" | sed 's/.* \([[0-9]]*\)\.\([[0-9]]*\)$/\2/'`
188       AC_MSG_RESULT([$vmajor.$vminor])
189       if test "$vmajor" -lt 4 \
190               || (test "$vmajor" -eq 4 && test "$vminor" -lt 6); then
191          MKINFO=no
192       fi
193    fi
194    if test "X$MKINFO" = "Xno"; then
195       AC_MSG_ERROR([You have requested a build
196 of the documentation.  For this to work, you must have version 4.6 or newer of
197 the GNU texinfo package.  You seem to have
201 Please update to a newer version of texinfo or disable building of
202 the documentation with --disable-doc
204    fi
206    AC_PATH_PROG(TEXI2DVI, texi2dvi, no)
207    if test "X$TEXI2DVI" = "Xno"; then
208       AC_MSG_ERROR([You have requested a build
209 of the documentation.  For this to work, you must have the texi2dvi program
210 installed.  Alternatively, you can disable building the documentation with
211 --disable-doc.])
212    fi
215         AC_PATH_PROG(PERL, perl, notfound)
216         if test "X$PERL" = "Xnotfound"; then
217                         AC_MSG_ERROR([You have requested a build
218 of the documentation.  For this to work, you must have perl installed.
219 Alternatively, you can disable building the documentation with
220 --disable-doc.
222         fi
225 ##########################################################################
229 # FIXME:  for now, only try to add -rdynamic if we're using gcc.  We really
230 # need to figure out what the correct test is here.  In the mean time, this
231 # should let things build with SunPRO again.
232 if test "x$GCC" = "xyes"; then
233 AC_MSG_CHECKING([If the compiler accepts -rdynamic])
234 old_LDFLAGS="$LDFLAGS"
235 LDFLAGS="$LDFLAGS -rdynamic"
236 AC_LINK_IFELSE([int main(){}],
237         [AC_MSG_RESULT([yes])],
238         [LDFLAGS="$old_LDFLAGS"
239         AC_MSG_RESULT([no])
240         ])
243 # ------------- HID config -------------------
245 hid_guis=""
246 hid_printers=""
247 hid_exporters=""
248 hid_always=""
250 for hid in `cd $srcdir/src/hid; echo *`; do
251     F=$srcdir/src/hid/$hid/hid.conf
252     if test -f $F 
253     then
254     echo checking $F
255         . $F
256         case $type in
257           gui ) hid_guis="$hid_guis $hid" ;;
258           printer ) hid_printers="$hid_printers $hid" ;;
259           export ) hid_exporters="$hid_exporters $hid" ;;
260           always ) hid_always="$hid_always $hid" ;;
261         esac
262     fi
263 done
265 AC_MSG_CHECKING([for which gui to use])
266 AC_ARG_WITH([gui],
267 [  --with-gui=            Specify the GUI to use: batch gtk lesstif [[default=gtk]]],
269 [with_gui=gtk]
271 AC_MSG_RESULT([$with_gui])
272 case " $hid_guis no none " in
273      *\ $with_gui\ * ) HIDLIST="$with_gui" ;;
274      * ) AC_MSG_ERROR([$with_gui is not a valid gui]) ;;
275 esac
277 if test x"$with_gui" = x"none" -o x"$with_gui" = x"no"
278 then
279     HIDLIST=
282 AC_MSG_CHECKING([whether to enable toporouter])
283 AC_ARG_ENABLE([toporouter],
284  [AS_HELP_STRING([--enable-toporouter], [build toporouter [default=yes]]) ]
286 AS_CASE(["x$enable_toporouter"],[xyes | xno],,
287  [enable_toporouter=yes
290 AC_MSG_RESULT([$enable_toporouter])
291 AM_CONDITIONAL([WITH_TOPOROUTER], test $enable_toporouter != no)
293 AC_MSG_CHECKING([whether to enable toporouter output])
294 AC_ARG_ENABLE([toporouter-output],
295  [AS_HELP_STRING([--enable-toporouter-output], [enable toporouter graphical output [default=no]]) ]
297 AS_CASE(["z$enable_toporouter_output"],[zyes | zno],,
298  [enable_toporouter_output=no]
300 AC_MSG_RESULT([$enable_toporouter_output])
301 AS_CASE([$enable_toporouter_output],[yes],
303   topo_output_enabled=1
304  ],
306   topo_output_enabled=0
309 AC_DEFINE_UNQUOTED([TOPO_OUTPUT_ENABLED], [$topo_output_enabled],
310  [Define to 1 to enable toporouter graphical output]
313 PKG_PROG_PKG_CONFIG()
315 if test "x$enable_toporouter_output" = "xyes"; then
316    PKG_CHECK_MODULES(CAIRO, cairo,,
317                      [AC_MSG_ERROR([Cannot find cairo, needed by the toporouter
318 Please review the following errors:
319 $CAIRO_PKG_ERRORS])]
320    )
323 AC_MSG_CHECKING([for whether to use DBUS])
324 AC_ARG_ENABLE([dbus],
325 [  --enable-dbus           Enable DBUS IPC],
326 [],[enable_dbus=no])
328 AC_MSG_RESULT([$enable_dbus])
329 AM_CONDITIONAL(WITH_DBUS, test x$enable_dbus = xyes)
331 if test "x$enable_dbus" = "xyes"; then
332         case " $with_gui " in
333                 *\ gtk\ *) ;;
334                 *\ lesstif\ *) ;;
335                 * ) AC_MSG_ERROR([DBUS enabled but only works with a mainloop capable GUI HID.
336 Either do not use --enable-dbus or enable the gtk or lesstif GUI HID.])
337         esac
338         
339         PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.61,
340                 [saved_LIBS="$LIBS"
341                  LIBS="$LIBS $DBUS_LIBS"
342                  AC_CHECK_FUNCS(dbus_watch_get_unix_fd)
343                  LIBS="$saved_LIBS" ],
344                 [AC_MSG_ERROR([Cannot find dbus-1 >= 0.61, install it and rerun ./configure
345 Please review the following errors:
346 $DBUS_PKG_ERRORS])]
347         )
348         DBUS_VERSION=`$PKG_CONFIG dbus-1 --modversion`
349         
350         AC_DEFINE([HAVE_DBUS], 1,
351                 [Define to 1 if DBUS IPC is to be compiled in])
355 AC_MSG_CHECKING([for which printer to use])
356 AC_ARG_WITH([printer],
357 [  --with-printer=        Specify the printer: lpr [[default=lpr]]],
358 [],[with_printer=lpr])
359 AC_MSG_RESULT([$with_printer])
360 case " $hid_printers " in
361      *\ $with_printer\ * )
362          HIDLIST="$HIDLIST $with_printer"
363          ;;
364      * ) AC_MSG_ERROR([$with_printer is not a valid printer]) ;;
365 esac
367 AC_MSG_CHECKING([for which exporters to use])
368 AC_ARG_WITH([exporters],
369 [  --with-exporters=       Enable export devices: bom gerber nelma png ps [[default=bom gerber nelma png ps]]],
370 [],[with_exporters=$hid_exporters])
371 AC_MSG_RESULT([$with_exporters])
372 for e in `echo $with_exporters | sed 's/,/ /g'`; do
373     case " $hid_exporters " in
374       *\ $e\ * )
375          HIDLIST="$HIDLIST $e"
376          ;;
377       * ) AC_MSG_ERROR([$e is not a valid exporter]) ;;
378     esac
379 done
381 if test "X$enable_jpeg" = "Xno" -a "X$enable_gif" = "Xno" -a "X$enable_png" = "Xno" ; then
382         case " ${HIDLIST} " in
383                 *\ png\ *)
384                         AC_MSG_ERROR([you have requested the png HID but turned off all output
385 formats!  If you do not want gif/jpeg/png output, use --with-exporters to list
386 which exporters you want and do not list png there.])
387                         ;;
389                 *)
390                         ;;
391         esac
394 for hid in $HIDLIST; do
395     F=$srcdir/src/hid/$hid/hid.conf
396     if test -f $F ; then
397         echo checking $hid depedencies
398         deps=
399         . $F
400         for dep in $deps; do
401             if test "X`echo $HIDLIST | grep $dep`" = "X"; then
402                 AC_MSG_ERROR([you have requested the $hid HID but not the $dep HID, which it depends on])
403             fi
404         done
405    fi
406 done
408 for e in $HIDLIST; do
409     HIDLIBS="$HIDLIBS lib$e.a"
410 done
412 AC_SUBST(HIDLIST)
413 AC_SUBST(HIDLIBS)
415 # ------------- end HID config -------------------
417 ######################################################################
419 # desktop integration
422 AC_PATH_PROG(SETENV, env, [])
423 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE_BIN, gtk-update-icon-path, [true])
425 # Change default location for XDG files (MIME and Icons)
426 AC_ARG_WITH(xdgdatadir, [  --with-xdgdatadir=path  Change where the theme icons 
427 and mime registrations are installed [[DATADIR]]], [opt_xdgdatadir=$withval])
429 # Change default location for KDE data files (KDE MIME registrations)
430 AC_ARG_WITH(kdedatadir, [  --with-kdedatadir=path  Change where the KDE mime reg
431 istrations are installed [[DATADIR]]], [opt_kdedatadir=$withval])
433 if test x$opt_xdgdatadir = x; then
434         # path was not specified with --with-xdgdatadir
435         XDGDATADIR='${datadir}'
436 else
437         # path WAS specified with --with-xdgdatadir
438         XDGDATADIR="$opt_xdgdatadir"
440 AC_SUBST(XDGDATADIR)
442 if test x$opt_kdedatadir = x; then
443         # path was not specified with --with-kdedatadir
444         KDEDATADIR='${datadir}'
445 else
446         # path WAS specified with --with-kdedatadir
447         KDEDATADIR="$opt_kdedatadir"
449 AC_SUBST(KDEDATADIR)
451 AC_ARG_ENABLE(update-desktop-database,
452         AC_HELP_STRING([--disable-update-desktop-database],
453         [do not update desktop database after installation]),,
454         enable_update_desktop_database=yes)
456 AM_CONDITIONAL(ENABLE_UPDATE_DESKTOP_DATABASE, test x$enable_update_desktop_database = xyes)
458 if test x$enable_update_desktop_database = xyes ; then
459         AC_PATH_PROG(UPDATE_DESKTOP_DATABASE, [update-desktop-database], no)
460         if test $UPDATE_DESKTOP_DATABASE = no; then
461         AC_MSG_ERROR([Cannot find update-desktop-database, make sure it is installed and in your PATH, or configure with --disable-update-desktop-database])
462         fi
465 AC_ARG_ENABLE(update-mime-database,
466         AC_HELP_STRING([--disable-update-mime-database],
467         [do not update mime database after installation]),,
468         enable_update_mime_database=yes)
470 AM_CONDITIONAL(ENABLE_UPDATE_MIME_DATABASE, test x$enable_update_mime_database = xyes)
472 if test x$enable_update_mime_database = xyes ; then
473         AC_PATH_PROG(UPDATE_MIME_DATABASE, [update-mime-database], no)
474         if test $UPDATE_MIME_DATABASE = no; then
475         AC_MSG_ERROR([Cannot find update-mime-database, make sure it is installed and in your PATH, or configure with --disable-update-mime-database])
476         fi
480 ######################################################################
482 AC_PATH_PROGS(M4, gm4 m4, [none])
483 if test "X$M4" = "Xnone" ; then
484         AC_MSG_ERROR([Did not find a m4 executible.  You need to make sure
485         that m4 is installed on your system and that m4 is in your path])
487 AC_MSG_CHECKING([if $M4 has the division involving negative numbers bug])
488 pcb_m4_r=`echo "eval(-2/2)" | $M4`
489 if test "$pcb_m4_r" != "-1" ; then
490         AC_MSG_RESULT([yes])
491         AC_MSG_ERROR([It appears that $M4 has a bug involving division
492 with negative numbers.  In particular it just returned the result that
493 -2/2 = $pcb_m4_r instead of -1.  This is a known bug in GNU m4-1.4.9.  Please
494 install a non-broken m4.])
495 else
496         AC_MSG_RESULT([no])
500 AC_PATH_PROGS(WISH, wish wish83 wish8.3 wish80 wish8.0 cygwish83 cygwish80,[none])
501 if test "X$WISH" = "Xnone" ; then
502         AC_MSG_ERROR([Did not find the wish executible.  You need to make sure
503         that tcl is installed on your system and that wish is in your path])
506 AC_DEFINE_UNQUOTED(M4,$M4,[m4 executible])
507 GNUM4=$M4
508 AC_SUBST(GNUM4)
509 AC_DEFINE_UNQUOTED(GNUM4,"$M4",[m4 program used by pcb])
511 AC_PATH_PROG(LATEX, latex, notfound)
512 AM_CONDITIONAL(MISSING_LATEX, test x$LATEX = xnotfound)
514 AC_PATH_PROG(PDFLATEX, pdflatex, notfound)
515 AM_CONDITIONAL(MISSING_PDFLATEX, test x$PDFLATEX = xnotfound)
517 AC_PATH_PROG(DVIPS, dvips, notfound)
518 AM_CONDITIONAL(MISSING_DVIPS, test x$DVIPS = xnotfound)
520 AC_PATH_PROG(TEXI2DVI, texi2dvi, notfound)
521 AM_CONDITIONAL(MISSING_TEXI2DVI, test x$TEXI2DVI = xnotfound)
523 AC_PATH_PROG(PS2PDF, ps2pdf, notfound)
524 AM_CONDITIONAL(MISSING_PS2PDF, test x$PS2PDF = xnotfound)
526 # used to build some of the getting started guide
527 AC_PATH_PROG(GSCHEM, gschem, notfound)
528 AM_CONDITIONAL(MISSING_GSCHEM, test x$GSCHEM = xnotfound)
530 if test "X$docs_yesno" = "Xyes" -a "X$pcb_git_version" = "Xyes" ; then
531         if test "$LATEX" = "notfound" -o "$PDFLATEX" = "notfound" -o "$DVIPS" = "notfound" -o "$TEXI2DVI" = "notfound" -o "$PS2PDF" = "notfound" ; then
532                 AC_MSG_ERROR([It appears that you are building from a source tree obtained
533 via git but you do not have the required tools installed to build the documentation.  Here
534 is a list of tools and the detected values:
535 LATEX:  $LATEX
536 PDFLATEX:  $PDFLATEX
537 DVIPS:     $DVIPS
538 TEXI2DVI:  $TEXI2DVI
539 PS2PDF:    $PS2PDF
540 GSCHEM:    $GSCHEM
542 Either make sure these tools are installed or disable building and installing the documentation
543 by using the --disable-doc configure option.
545         fi
548 ############################################################################
550 # These checks are for tools used by the testsuite.  It will not be fatal
551 # if these are missing because this is primarily for developer use.  It is
552 # possible that we might add some --enable flag in the future that forces
553 # full tools for development work.
555 # Check for ImageMagick tools used by the testsuite
556 AC_PATH_PROG(IM_ANIMATE, animate, notfound)
557 AC_PATH_PROG(IM_COMPARE, compare, notfound)
558 AC_PATH_PROG(IM_COMPOSITE, composite, notfound)
559 AC_PATH_PROG(IM_CONVERT, convert, notfound)
560 AC_PATH_PROG(IM_DISPLAY, display, notfound)
561 AC_PATH_PROG(IM_MONTAGE, montage, notfound)
562 missing_magick=""
563 test "${IM_ANIMATE}" != "notfound" || missing_magick="${missing_magick} animate"
564 test "${IM_COMPARE}" != "notfound" || missing_magick="${missing_magick} compare"
565 test "${IM_COMPOSITE}" != "notfound" || missing_magick="${missing_magick} composite"
566 test "${IM_CONVERT}" != "notfound" || missing_magick="${missing_magick} convert"
567 test "${IM_DISPLAY}" != "notfound" || missing_magick="${missing_magick} display"
568 test "${IM_MONTAGE}" != "notfound" || missing_magick="${missing_magick} montage"
570 AC_MSG_CHECKING([if all ImageMagick tools needed for the testsuite were found])
571 if test "X${missing_magick}" != "X" ; then
572     AC_MSG_RESULT([no.  The testsuite will be disabled because the following
573 tools from the ImageMagick suite were not found:
574 ${missing_magick}
575 No loss in pcb functionality should be experienced, you just will not
576 be able to run the full regression testsuite.
578     have_magick=no
579 else
580     AC_MSG_RESULT([yes])
581     have_magick=yes
584 have_test_tools=yes
586 test $have_magick = yes || have_test_tools=no
588 # the RS274-X export HID is partially checked by looking at the result with
589 # gerbv
590 AC_PATH_PROG(GERBV, gerbv, notfound)
591 test $GERBV != notfound || have_test_tools=no
594 AM_CONDITIONAL(HAVE_TEST_TOOLS, test x$have_test_tools = xyes)
595 AC_MSG_CHECKING([if all the requried testsuite tools were found])
596 if test x$have_test_tools = xyes ; then
597         AC_MSG_RESULT([yes])
598 else
599         AC_MSG_RESULT([no -- the testsuite will be disabled])
604 ############################################################################
607 dnl Checks for libraries.
608 AC_CHECK_LIB(m, sqrt)
609 AC_CHECK_LIB(dl, dlopen)
610 AC_CHECK_LIB(xnet, gethostbyname)
611 AC_CHECK_LIB(fl, yywrap)
612 AC_CHECK_FUNCS(strerror)
613 AC_CHECK_FUNCS(regcomp re_comp)
614 AC_CHECK_FUNCS(logf expf rint)
615 AC_CHECK_FUNCS(vsnprintf)
616 AC_CHECK_FUNCS(getpwuid gethostname getcwd)
617 AC_CHECK_FUNCS(random)
618 AC_CHECK_FUNCS(stat)
620 # normally used for all file i/o
621 AC_CHECK_FUNCS(popen)
623 # for lrealpath.c
624 AC_CHECK_FUNCS(realpath canonicalize_file_name)
625 libiberty_NEED_DECLARATION(canonicalize_file_name)
627 AC_HEADER_STDC
628 AC_CHECK_HEADERS(limits.h locale.h string.h sys/types.h regex.h pwd.h)
629 AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h sys/param.h sys/times.h)
630 AC_CHECK_HEADERS(dlfcn.h)
632 if test "x${WIN32}" = "xyes" ; then
633         AC_CHECK_HEADERS(windows.h)
635 # Search for glib
636 PKG_CHECK_MODULES(GLIB, glib-2.0, ,
637                 [AC_MSG_RESULT([Note: cannot find glib-2.0.
638 You may want to review the following errors:
639 $GLIB_PKG_ERRORS])]
642 for e in $HIDLIST; do
643     case $e in
644       lesstif )
645         AC_PATH_XTRA
646         CPPFLAGS="$CFLAGS $X_CFLAGS"
647         AC_CHECK_LIB(X11, XOpenDisplay, , , $X_LIBS)
648         AC_CHECK_LIB(ICE, main, , , $X_LIBS)
649         AC_CHECK_LIB(SM, main, , , $X_LIBS)
650         AC_CHECK_LIB(Xext, main, , , $X_LIBS)
651         AC_CHECK_LIB(Xt, XtOpenDisplay, , , $X_LIBS)
652         AC_CHECK_LIB(Xmu, main, , , $X_LIBS)
653         AC_CHECK_LIB(Xpm, main, , , $X_LIBS)
654         AC_CHECK_LIB(Xm, XmCreateMainWindow, , , $X_LIBS)
655         case $ac_cv_lib_Xm_XmCreateMainWindow in
656           no )
657             AC_MSG_ERROR([You don't seem to have the Lesstif development environment installed.])
658             ;;
659           * ) ;;
660         esac
661         AC_CHECK_HEADERS(Xm/Xm.h)
662         case $ac_cv_header_Xm_Xm_h in
663           no )
664             AC_MSG_ERROR([You don't seem to have the Lesstif development environment installed.])
665             ;;
666           * ) ;;
667         esac
668         ;;
670       gtk )
671         # Check for pkg-config
672         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
673         if test "$PKG_CONFIG" = "no"; then
674                 AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
675         fi
677         PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.4.0, , 
678                 [AC_MSG_ERROR([Cannot find gtk+ >= 2.4.0, install it and rerun ./configure
679 Please review the following errors:
680 $GTK_PKG_ERRORS])]
681         )
682         GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
683         
684         # if we are building for gtk >= 2.8.0, we can use gdk_display_warp_pointer()
685         # otherwise we need XWarpPointer and we'll pull in the required headers with
686         # gdk/gdkx.h and we'll need to link with X11
687         if ! $PKG_CONFIG gtk+-2.0 --atleast-version=2.8.0 ; then
688                 CPPFLAGS="$CFLAGS $GTK_CFLAGS"
689                 AC_CHECK_HEADERS([gdk/gdkx.h])
690         fi
692         GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
693         ;;
695       nelma|png )
696         # Check for gdlib-config for gd (www.boutell.com/gd)
697         AC_PATH_PROG(GDLIB_CONFIG, gdlib-config, no)
698         if test "$GDLIB_CONFIG" = "no"; then
699                 AC_MSG_RESULT([Cannot find gdlib-config.
700 Make sure it is installed and in your PATH.
701 gdlib-config is part of the GD library available from www.boutell.com/gd.
702 This is needed for the png HID.  I will look for libgd anyway and maybe
703 you will get lucky.
705                 if test "$WIN32" != "yes" ; then
706                         AC_CHECK_LIB(gd,main,,
707                         AC_MSG_ERROR([You have requested the nelma and/or png HID  but -lgd could not be found]))
708                 else 
709                         AC_CHECK_LIB(bgd,main,,
710                         AC_MSG_ERROR([You have requested the nelma and/or png HID  but -lbgd could not be found]))
711                 fi
712         else
713                 if test "$WIN32" = "yes" ; then
714                         GD=bgd
715                 else
716                         GD=gd
717                 fi
718                 AC_MSG_CHECKING([for libgd cflags])
719                 GD_CFLAGS="`$GDLIB_CONFIG --cflags`"
720                 AC_MSG_RESULT([$GD_CFLAGS])
721                 AC_MSG_CHECKING([for libgd libs])
722                 GD_LIBS="`$GDLIB_CONFIG --ldflags` `$GDLIB_CONFIG --libs` -l${GD}"
723                 AC_MSG_RESULT([$GD_LIBS])
724         fi
725    
726         # since some linux systems evidently install gdlib-config but fail to
727         # install the headers (nice), check for the header too and fail if it
728         # is not there.
729         CFLAGS="$CFLAGS $GD_CFLAGS"
730         CPPFLAGS="$CPPFLAGS $GD_CFLAGS"
731         AC_CHECK_HEADERS(gd.h)
732         case $ac_cv_header_gd_h in
733              no )
734                 AC_MSG_ERROR([
735 You evidentally do not have a complete installation of the GD library available from www.boutell.com/gd.
736 This is needed for the nelma and/or png HID.
738                 ;;
739              * ) ;;
740         esac
741         
742         # Some versions of gd (prior to the expiration of the
743         # patent related to gif compression) do not support
744         # gif output.  Check for that here.
745         save_LIBS="$LIBS"
746         LIBS="$save_LIBS $GD_LIBS $X_LIBS"
748         AC_MSG_CHECKING([if GIF output from the png HID is desired])
749         AC_ARG_ENABLE([gif],
750                 [  --disable-gif           Disable support for gif output when the png HID is used [[default=include gif support]]],
751                 [
752                 if test "X$enable_gif" != "Xno" ; then
753                         AC_MSG_RESULT([yes])
754                         with_gif=yes
755                 else
756                         AC_MSG_RESULT([no])
757                         with_gif=no
758                 fi
759                 ],
760                 [
761                 AC_MSG_RESULT([yes])
762                 with_gif=yes
763                 ])
764         if test "X$with_gif" = "Xyes" ; then
765                 AC_CHECK_FUNCS(gdImageGif)
766                 if test "$ac_cv_func_gdImageGif" != "yes"; then
767                         AC_MSG_ERROR([Your gd installation does not appear to include gif support.
768 You may need to update your installation of gd or disable
769 gif export with --disable-gif])
770                 fi
771         fi
773         AC_MSG_CHECKING([if JPEG output from the png HID is desired])
774         AC_ARG_ENABLE([jpeg],
775                 [  --disable-jpeg          Disable support for JPEG output when the png HID is used [[default=include JPEG support]]],
776                 [
777                 if test "X$enable_jpeg" != "Xno" ; then
778                         AC_MSG_RESULT([yes])
779                         with_jpeg=yes
780                 else
781                         AC_MSG_RESULT([no])
782                         with_jpeg=no
783                 fi
784                 ],
785                 [
786                 AC_MSG_RESULT([yes])
787                 with_jpeg=yes
788                 ])
789         if test "X$with_jpeg" = "Xyes" ; then
790                 AC_CHECK_FUNCS(gdImageJpeg)
791                 if test "$ac_cv_func_gdImageJpeg" != "yes"; then
792                         AC_MSG_ERROR([Your gd installation does not appear to include JPEG support.
793 You may need to update your installation of gd or disable
794 JPEG export with --disable-jpeg])
795                 fi
796         fi
799         AC_MSG_CHECKING([if PNG output from the png HID is desired])
800         AC_ARG_ENABLE([png],
801                 [  --disable-png           Disable support for PNG output when the png HID is used [[default=include PNG support]]],
802                 [
803                 if test "X$enable_png" != "Xno" ; then
804                         AC_MSG_RESULT([yes])
805                         with_png=yes
806                 else
807                         AC_MSG_RESULT([no])
808                         with_png=no
809                 fi
810                 ],
811                 [
812                 AC_MSG_RESULT([yes])
813                 with_png=yes
814                 ])
815         if test "X$with_png" = "Xyes" ; then
816                 AC_CHECK_FUNCS(gdImagePng)
817                 if test "$ac_cv_func_gdImagePng" != "yes"; then
818                         AC_MSG_ERROR([Your gd installation does not appear to include PNG support.
819 You may need to update your installation of gd or disable
820 PNG export with --disable-png])
821                 fi
822         fi
823         LIBS="$save_LIBS"
824         ;;
826     esac
827 done
830 AM_CONDITIONAL(PNG, test x$with_png = xyes)
831 AM_CONDITIONAL(GIF, test x$with_gif = xyes)
833 # ------------- check if png previews should be built for pcblib-newlib
834 AC_MSG_CHECKING([if the m4lib to newlib export should create png previews])
835 AC_ARG_ENABLE(
836         [m4lib-png],
837         [  --enable-m4lib-png      Enable creating png previews for the m4 library],
838         [],[enable_m4lib_png=no])
839 AC_MSG_RESULT([$enable_m4lib_png])
840 AM_CONDITIONAL(PNG_PREVIEW, test x$enable_m4lib_png = xyes)
842 if test "X$cross_compiling" = "Xyes" ; then
843         # we are cross compiling so we will need a build host binary for pcb
844         AC_PATH_PROG(PCB, [pcb], [notfound])
845 else
846         PCB="\${top_builddir}/src/pcb"
848 AC_SUBST(PCB)
850 # now make see how essential it was that we have a pcb executable for the build
851 # host
852 if test "X$pcb_git_version" = "Xyes" ; then
853         if test "X$docs_yesno" = "Xyes" -o "X$enable_m4lib_png" = "Xyes" ; then
854                 if test "$PCB" = "notfound" ; then
855                         AC_MSG_ERROR([You have selected a build with m4lib png
856 previews enabled and/or with building the documentation enabled but you also
857 appear to be cross-compiling.  For this to work, you must have a pcb installed that
858 can run on this machine (the build machine) because it is needed for generating
859 library footprint png previews as well as some of the figures in the documentation.
860 If you wish to skip building the documentation and the footprint previews then add
861 --disable-doc --disable-m4lib-png
862 This will allow your cross build to work.])
863                 fi
864         fi
867 # ------------- Xrender -------------------
868 have_xrender=no
869 AC_CHECK_LIB(Xrender,XRenderQueryExtension,have_xrender=yes,have_xrender=no,$X_LIBS)
871 AC_ARG_ENABLE([xrender],
872 [  --disable-xrender       Compile and link with Xrender [default=yes]])
873 case "$have_xrender:$enable_xrender" in
874    no:* ) ;;
875    *:no ) ;;
876    * )
877      X_LIBS="-lXrender $X_LIBS"
878      AC_DEFINE([HAVE_XRENDER], 1,
879                 [Define to 1 if Xrender is available])
880      ;;
881 esac
883 # ------------- dmalloc -------------------
884 dnl dmalloc checks
885 with_dmalloc=no
886 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
887 AC_ARG_ENABLE([dmalloc],
888 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [default=no]],
890 if test "X$enable_dmalloc" != "Xno" ; then
891         AC_MSG_RESULT([yes])
892         AC_CHECK_HEADER(dmalloc.h,,
893                 AC_MSG_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
894         AC_CHECK_LIB(dmalloc,main,,
895                 AC_MSG_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
896         DMALLOC_LIBS="-ldmalloc"
897         with_dmalloc=yes
898 else
899         AC_MSG_RESULT([no])
900         DMALLOC_LIBS=""
904         AC_MSG_RESULT([no])
905         DMALLOC_LIBS=""
908 # ------------- ElectricFence -------------------
909 dnl ElectricFence checks
910 with_efence=no
911 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
912 AC_ARG_ENABLE([efence],
913 [  --enable-efence         Link with ElectricFence for malloc debugging [default=no]],
915 if test "X$enable_efence" != "Xno" ; then
916         AC_MSG_RESULT([yes])
917         AC_CHECK_LIB(efence,main,,
918                 AC_MSG_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
919         with_efence=yes
920 else
921         AC_MSG_RESULT([no])
925 AC_MSG_RESULT([no])
928 # ------------- Enable Debug code -------------------
929 AC_MSG_CHECKING([for whether to enable debugging code])
930 AC_ARG_ENABLE([debug],
931 [  --enable-debug          Enable debugging code],
932 [],[enable_debug=no])
934 AC_MSG_RESULT([$enable_debug])
935 AM_CONDITIONAL(DEBUG_BUILD, test x$enable_debug = xyes)
938 # ------------- Complete set of CFLAGS and LIBS -------------------
940 CFLAGS="$CFLAGS $X_CFLAGS $DBUS_CFLAGS $GLIB_CFLAGS $GTK_CFLAGS $CAIRO_CFLAGS"
941 LIBS="$LIBS $XM_LIBS $DBUS_LIBS $X_LIBS $GLIB_LIBS $GTK_LIBS $DMALLOC_LIBS $GD_LIBS $INTLLIBS $CAIRO_LIBS"
944 # if we have gcc then add -Wall
945 if test "x$GCC" = "xyes"; then
946         # see about adding some extra checks if the compiler takes them
947         for flag in -Wall -Wdeclaration-after-statement ; do
948                 case " ${CFLAGS} " in
949                         *\ ${flag}\ *)
950                                 # flag is already present
951                                 ;;
952                         *)
953                                 AC_MSG_CHECKING([if the compiler accepts ${flag}])
954                                 ac_save_CFLAGS="$CFLAGS"
955                                 CFLAGS="$CFLAGS ${flag}"
956                                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
957                                         [AC_MSG_RESULT([yes])],
958                                         [AC_MSG_RESULT([no])
959                                          CFLAGS="$ac_save_CFLAGS"
960                                         ]
961                                 )
962                                 ;;
963                 esac
964         done
967 # font filename
968 FONTFILENAME=${FONTFILENAME:-"default_font"}
969 AC_SUBST(FONTFILENAME)
970 AC_DEFINE_UNQUOTED(FONTFILENAME,"$FONTFILENAME",[File for default font])
972 # standard autoconf variables
973 CPPFLAGS="$CPPFLAGS -DPREFIXDIR=\\\"\${prefix}\\\""
974 CPPFLAGS="$CPPFLAGS -DBINDIR=\\\"\${bindir}\\\""
975 CPPFLAGS="$CPPFLAGS -DHOST=\\\"\${host}\\\""
977 # directory for old-style library and for fonts
978 PCBLIBDIR=${datadir}/pcb
979 AC_SUBST(PCBLIBDIR)
980 #AC_DEFINE_UNQUOTED(PCBLIBDIR,"$PCBLIBDIR",[Library directory])
981 CPPFLAGS="$CPPFLAGS -DPCBLIBDIR=\\\"$PCBLIBDIR\\\""
983 # name for old-style library
984 LIBRARYFILENAME=pcblib
985 AC_SUBST(LIBRARYFILENAME)
986 AC_DEFINE_UNQUOTED(LIBRARYFILENAME,"$LIBRARYFILENAME",[library file name])
989 # directory for new library
990 PCBTREEDIR=${datadir}/pcb/newlib
991 PCBTREEPATH=${PCBTREEDIR}:${PCBLIBDIR}/pcblib-newlib
992 PCBTREEDIR=${PCBTREEDIR:-"$PCBTREEDIR"}
993 AC_SUBST(PCBTREEDIR)
994 AC_SUBST(PCBTREEPATH)
995 #AC_DEFINE_UNQUOTED(PCBTREEDIR,"$PCBLIB",[top directory for new style pcb library])
996 CPPFLAGS="$CPPFLAGS -DPCBTREEDIR=\\\"$PCBTREEDIR\\\""
997 CPPFLAGS="$CPPFLAGS -DPCBTREEPATH=\\\"$PCBTREEPATH\\\""
999 # Figure out relative paths
1000 AC_MSG_CHECKING([for the bindir to pcblibdir relative path])
1001 adl_COMPUTE_RELATIVE_PATHS([bindir:PCBLIBDIR:bindir_to_pcblibdir])
1002 adl_NORMALIZE_PATH([bindir_to_pcblibdir], [$PCB_DIR_SEPARATOR_S])
1003 AC_MSG_RESULT([$bindir_to_pcblibdir])
1004 AC_DEFINE_UNQUOTED(BINDIR_TO_PCBLIBDIR, "$bindir_to_pcblibdir", [Relative path from bindir to pcblibdir])
1006 AC_MSG_CHECKING([for the bindir to pcbtreedir relative path])
1007 adl_COMPUTE_RELATIVE_PATHS([bindir:PCBTREEDIR:bindir_to_pcbtreedir])
1008 adl_NORMALIZE_PATH([bindir_to_pcbtreedir], [$PCB_DIR_SEPARATOR_S])
1009 AC_MSG_RESULT([$bindir_to_pcbtreedir])
1010 AC_DEFINE_UNQUOTED(BINDIR_TO_PCBTREEDIR, "$bindir_to_pcbtreedir", [Relative path from bindir to pcbtreedir])
1013 AC_MSG_CHECKING([for the bindir to exec_prefix relative path])
1014 adl_COMPUTE_RELATIVE_PATHS([bindir:exec_prefix:bindir_to_execprefix])
1015 adl_NORMALIZE_PATH([bindir_to_execprefix], [$PCB_DIR_SEPARATOR_S])
1016 AC_MSG_RESULT([$bindir_to_execprefix])
1017 AC_DEFINE_UNQUOTED(BINDIR_TO_EXECPREFIX, "$bindir_to_execprefix", [Relative path from bindir to exec_prefix])
1020 BTNMOD=${BTNMOD:-"Mod1"}
1021 AC_SUBST(BTNMOD)
1023 TOPDIRS=
1024 for dir in src lib newlib doc example tools tutorial README_FILES
1026    test -d $dir/. && TOPDIRS="$TOPDIRS $dir"
1027 done
1028 AC_SUBST(TOPDIRS)
1030 AC_CONFIG_FILES(Makefile data/Makefile intl/Makefile po/Makefile.in)
1032 if test -d $srcdir/README_FILES; then
1033    AC_CONFIG_FILES(README_FILES/Makefile)
1035 if test -d $srcdir/doc; then
1036    AC_CONFIG_FILES(doc/Makefile)
1038 if test -d $srcdir/doc/gs; then
1039    AC_CONFIG_FILES(doc/gs/Makefile)
1040    AC_CONFIG_FILES(doc/gs/gafrc)
1041    AC_CONFIG_FILES(doc/gs/gschemrc)
1043 if test -d $srcdir/example; then
1044    AC_CONFIG_FILES(example/Makefile)
1045    AC_CONFIG_FILES(example/libraries/Makefile)
1047 if test -d $srcdir/lib; then
1048    AC_CONFIG_FILES(lib/CreateLibraryContents.sh)
1049    AC_CONFIG_FILES(lib/CreateLibrary.sh)
1050    AC_CONFIG_FILES(lib/ListLibraryContents.sh)
1051    AC_CONFIG_FILES(lib/Makefile)
1052    AC_CONFIG_FILES(lib/QueryLibrary.sh)
1053    AC_CONFIG_FILES(lib/qfp-ui)
1055 if test -d $srcdir/newlib; then
1056    AC_CONFIG_FILES(newlib/2_pin_thru-hole_packages/Makefile)
1057    AC_CONFIG_FILES(newlib/Makefile)
1058    AC_CONFIG_FILES(newlib/connectors/Makefile)
1059    AC_CONFIG_FILES(newlib/crystal/Makefile)
1060    AC_CONFIG_FILES(newlib/electro-optics/Makefile)
1061    AC_CONFIG_FILES(newlib/headers/Makefile)
1062    AC_CONFIG_FILES(newlib/keystone/Makefile)
1063    AC_CONFIG_FILES(newlib/msp430/Makefile)
1064    AC_CONFIG_FILES(newlib/not_vetted_ingo/Makefile)
1065    AC_CONFIG_FILES(newlib/sockets/Makefile)
1066    AC_CONFIG_FILES(newlib/tests/Makefile)
1068 AC_CONFIG_FILES(src/Makefile)
1069 AC_CONFIG_FILES(src/icons/Makefile)
1070 if test -d $srcdir/tools; then
1071    AC_CONFIG_FILES(tools/Makefile)
1073 if test -d $srcdir/tutorial; then
1074    AC_CONFIG_FILES(tutorial/Makefile)
1077 dnl testsuite
1078 AC_CONFIG_FILES(tests/inputs/Makefile)
1079 AC_CONFIG_FILES(tests/golden/Makefile)
1080 AC_CONFIG_FILES(tests/golden/hid_bom1/Makefile)
1081 AC_CONFIG_FILES(tests/golden/hid_bom2/Makefile)
1082 AC_CONFIG_FILES(tests/golden/hid_bom3/Makefile)
1083 AC_CONFIG_FILES(tests/golden/hid_bom4/Makefile)
1084 AC_CONFIG_FILES(tests/golden/hid_gerber1/Makefile)
1085 AC_CONFIG_FILES(tests/golden/hid_gerber2/Makefile)
1086 AC_CONFIG_FILES(tests/golden/hid_png1/Makefile)
1087 AC_CONFIG_FILES(tests/Makefile)
1089 dnl win32 build scripts
1090 AC_CONFIG_FILES(win32/Makefile)
1092 AC_OUTPUT
1094 with_gui=`echo $with_gui`
1095 with_printer=`echo $with_printer`
1096 with_exporters=`echo $with_exporters | sed 's/,/ /g'`
1098 expandedXDGDATADIR=`eval "echo $XDGDATADIR"`
1099 expandedKDEDATADIR=`eval "echo $KDEDATADIR"`
1101 if test "X$pcb_git_version" = "Xyes" ; then
1102         pcb_sources="GIT"
1103 else
1104         pcb_sources="tarball"
1107 AC_MSG_RESULT([
1108 ** Configuration summary for $PACKAGE $VERSION:
1110    GUI:                      $with_gui
1111    Printer:                  $with_printer
1112    Exporters:                $with_exporters
1113    Source tree distribution: $pcb_sources
1114    Build documentation:      $docs_yesno
1115    Build toporouter:         $enable_toporouter
1116    Enable toporouter output: $enable_toporouter_output
1117    xdg data directory:       $expandedXDGDATADIR
1118    KDE data directory:       $expandedKDEDATADIR
1119    dmalloc debugging:        $with_dmalloc
1120    ElectricFence debugging:  $with_efence
1122    Cross Compiling:          $cross_compiling
1123    CC:                       $CC
1124    CPPFLAGS:                 $CPPFLAGS
1125    CFLAGS:                   $CFLAGS
1126    LIBS:                     $LIBS
1127    PCB:                      $PCB