Fix IsPointInBox to work with wide as well as tall boxes
[geda-pcb/gde.git] / configure.ac
blob6337dfd70d21d35db1f58cf1f07023fdea7805c7
1 dnl $Id$
2 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT([pcb], [1.99x])
5 AC_CONFIG_SRCDIR([src/draw.c])
6 AC_PREREQ([2.59])
7 AM_INIT_AUTOMAKE([1.9])
8 AC_GNU_SOURCE
9 AM_CONFIG_HEADER([config.h])
11 AM_MAINTAINER_MODE
13 dnl determine host type
14 AC_CANONICAL_HOST
15 AC_MSG_CHECKING(for windows)
16 PCB_PATH_DELIMETER=":"
17 PCB_DIR_SEPARATOR_S="/"
18 PCB_DIR_SEPARATOR_C='/'
19 case $host in
20         *-*-cygwin* )
21                 CFLAGS="$CFLAGS ${CYGWIN_CFLAGS}"
22                 CPPFLAGS="$CPPFLAGS ${CYGWIN_CPPFLAGS}"
23                 ;;
25         *-*-mingw* )
26                 WIN32=yes
27                 CFLAGS="$CFLAGS ${MINGW_CFLAGS:--mms-bitfields -mwindows}"
28                 CPPFLAGS="$CPPFLAGS ${MINGW_CPPFLAGS:--mms-bitfields -mwindows}"
29                 ;;
31         * )
32                 WIN32=no
33                 ;;
34 esac
36 AC_MSG_RESULT($WIN32)
37 AC_SUBST(WIN32)
38 AM_CONDITIONAL(WIN32, test x$WIN32 = xyes)
39 if test "x$WIN32" = "xyes" ; then
40         PCB_PATH_DELIMETER=";"
41         PCB_DIR_SEPARATOR_S="\\\\"
42         PCB_DIR_SEPARATOR_C='\\'
45 AC_DEFINE_UNQUOTED(PCB_DIR_SEPARATOR_C,'$PCB_DIR_SEPARATOR_C',[Directory separator char])
46 AC_DEFINE_UNQUOTED(PCB_DIR_SEPARATOR_S,"$PCB_DIR_SEPARATOR_S",[Directory separator string])
47 AC_DEFINE_UNQUOTED(PCB_PATH_DELIMETER,"$PCB_PATH_DELIMETER",[Search path separator string])
50 dnl Checks for programs.
51 AC_PROG_CC
53 # i18n
54 GETTEXT_PACKAGE=$PACKAGE
55 AH_TEMPLATE([GETTEXT_PACKAGE], [Name of this program's gettext domain])
56 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"])
57 AC_SUBST(GETTEXT_PACKAGE)
59 AM_GNU_GETTEXT_VERSION([0.14])
60 AM_GNU_GETTEXT
61 IT_PROG_INTLTOOL([0.35.0])
63 AC_C_INLINE
64 AC_PROG_CC_STDC
65 AM_PROG_CC_C_O
66 AC_PROG_CPP
67 AC_PROG_AWK
69 AM_PROG_LEX
70 AC_PATH_PROG(LEX_PATH, $LEX, [notfound])
71 if test "$LEX_PATH" = "notfound" ; then
72         AC_MSG_ERROR([Couldn't find a usable lex program.
73 Please install flex which is available from
74 ftp://ftp.gnu.org/pub/non-gnu/flex/
79 AC_PROG_YACC
80 AC_PATH_PROG(YACC_PATH, $YACC, [notfound])
81 if test "$YACC_PATH" = "notfound" ; then
82         AC_MSG_ERROR([Couldn't find a usable yacc program.
83 Please install bison which is available from
84 ftp://ftp.gnu.org/pub/gnu/bison/
88 AC_PROG_INSTALL
89 AC_PROG_RANLIB
92 # Used for building the icons
94 AC_PATH_PROG(XPMTOPPM, xpmtoppm, notfound)
95 AC_PATH_PROG(PPMTOWINICON, ppmtowinicon, notfound)
96 AC_PATH_PROG(CONVERT, convert, notfound)
98 docs_yesno=yes
100 AC_MSG_CHECKING([if the documentation should be built])
101 AC_ARG_ENABLE([doc],
102 [  --enable-doc            Build and install the documentation [[default=yes]]],
104 if test "X$enable_doc" = "Xno" ; then
105         DOC=""
106         AC_MSG_RESULT([no])
107         docs_yesno=no
108 else
109         DOC=doc
110         AC_MSG_RESULT([yes])
111         docs_yesno=yes
115 DOC=doc
116 AC_MSG_RESULT([yes])
117 docs_yesno=yes
119 AC_SUBST(DOC)
121 if test "X$docs_yesno" = "Xyes" -a "X$USE_MAINTAINER_MODE" = "Xyes" ; then
122    AC_CHECK_PROGS(MKINFO, makeinfo, no)
123    if test "X$MKINFO" != "Xno"; then
124       AC_MSG_CHECKING([for GNU makeinfo version >= 4.6])
125       v=`$MKINFO --version | grep "GNU texinfo"`
126       if test $? -ne 0; then
127          AC_MSG_RESULT([non-GNU])
128          MKINFO="no"
129       fi
130    fi
131    if test "X$MKINFO" != "Xno"; then
132       vmajor=`echo "$v" | sed 's/.* \([[0-9]]*\)\.\([[0-9]]*\)$/\1/'`
133       vminor=`echo "$v" | sed 's/.* \([[0-9]]*\)\.\([[0-9]]*\)$/\2/'`
134       AC_MSG_RESULT([$vmajor.$vminor])
135       if test "$vmajor" -lt 4 \
136               || (test "$vmajor" -eq 4 && test "$vminor" -lt 6); then
137          MKINFO=no
138       fi
139    fi
140    if test "X$MKINFO" = "Xno"; then
141       AC_MSG_ERROR([You have requested a maintainer-mode build and a build
142 of the documentation.  For this to work, you must have version 4.6 or newer of
143 the GNU texinfo package.  You seem to have
148    fi
150    AC_CHECK_PROGS(TEXI2DVI, texi2dvi, no)
151    if test "X$TEXI2DVI" = "Xno"; then
152       AC_MSG_ERROR([You have requested a maintainer-mode build and a build
153 of the documentation.  For this to work, you must have the texi2dvi program
154 installed.])
155    fi
158         AC_PATH_PROG(PERL, perl, notfound)
159         if test "X$PERL" = "Xnotfound"; then
160                         AC_MSG_ERROR([You have requested a maintainer-mode build and a build
161 of the documentation.  For this to work, you must have perl installed.
163         fi
166 # FIXME:  for now, only try to add -rdynamic if we're using gcc.  We really
167 # need to figure out what the correct test is here.  In the mean time, this
168 # should let things build with SunPRO again.
169 if test "x$GCC" = "xyes"; then
170 AC_MSG_CHECKING([If the compiler accepts -rdynamic])
171 old_LDFLAGS="$LDFLAGS"
172 LDFLAGS="$LDFLAGS -rdynamic"
173 AC_LINK_IFELSE([int main(){}],
174         [AC_MSG_RESULT([yes])],
175         [LDFLAGS="$old_LDFLAGS"
176         AC_MSG_RESULT([no])
177         ])
180 # ------------- HID config -------------------
182 hid_guis=""
183 hid_printers=""
184 hid_exporters=""
185 hid_always=""
187 for hid in `cd $srcdir/src/hid; echo *`; do
188     F=$srcdir/src/hid/$hid/hid.conf
189     if test -f $F 
190     then
191     echo checking $F
192         . $F
193         case $type in
194           gui ) hid_guis="$hid_guis $hid" ;;
195           printer ) hid_printers="$hid_printers $hid" ;;
196           export ) hid_exporters="$hid_exporters $hid" ;;
197           always ) hid_always="$hid_always $hid" ;;
198         esac
199     fi
200 done
202 AC_MSG_CHECKING([for which gui to use])
203 AC_ARG_WITH([gui],
204 [  --with-gui=            Specify the GUI to use: batch gtk lesstif [[default=gtk]]],
206 [with_gui=gtk]
208 AC_MSG_RESULT([$with_gui])
209 case " $hid_guis no none " in
210      *\ $with_gui\ * ) HIDLIST="$with_gui" ;;
211      * ) AC_MSG_ERROR([$with_gui is not a valid gui]) ;;
212 esac
214 if test x"$with_gui" = x"none" -o x"$with_gui" = x"no"
215 then
216     HIDLIST=
219 AC_MSG_CHECKING([for whether to use DBUS])
220 AC_ARG_ENABLE([dbus],
221 [  --enable-dbus           Enable DBUS IPC],
222 [],[enable_dbus=no])
224 AC_MSG_RESULT([$enable_dbus])
225 AM_CONDITIONAL(WITH_DBUS, test x$enable_dbus = xyes)
227 if test "x$enable_dbus" = "xyes"; then
228         case " $with_gui " in
229                 *\ gtk\ *) ;;
230                 *\ lesstif\ *) ;;
231                 * ) AC_MSG_ERROR([DBUS enabled but only works with a mainloop capable GUI HID.
232 Either do not use --enable-dbus or enable the gtk or lesstif GUI HID.])
233         esac
234         
235         # Check for pkg-config
236         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
237         if test "$PKG_CONFIG" = "no"; then
238                 AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
239         fi
241         PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.61,
242                 [saved_LIBS="$LIBS"
243                  LIBS="$LIBS $DBUS_LIBS"
244                  AC_CHECK_FUNCS(dbus_watch_get_unix_fd)
245                  LIBS="$saved_LIBS" ],
246                 [AC_MSG_ERROR([Cannot find dbus-1 >= 0.61, install it and rerun ./configure
247 Please review the following errors:
248 $DBUS_PKG_ERRORS])]
249         )
250         DBUS_VERSION=`$PKG_CONFIG dbus-1 --modversion`
251         
252         AC_DEFINE([HAVE_DBUS], 1,
253                 [Define to 1 if DBUS IPC is to be compiled in])
257 AC_MSG_CHECKING([for which printer to use])
258 AC_ARG_WITH([printer],
259 [  --with-printer=        Specify the printer: lpr [[default=lpr]]],
260 [],[with_printer=lpr])
261 AC_MSG_RESULT([$with_printer])
262 case " $hid_printers " in
263      *\ $with_printer\ * )
264          HIDLIST="$HIDLIST $with_printer"
265          ;;
266      * ) AC_MSG_ERROR([$with_printer is not a valid printer]) ;;
267 esac
269 AC_MSG_CHECKING([for which exporters to use])
270 AC_ARG_WITH([exporters],
271 [  --with-exporters=       Enable export devices: bom gerber nelma png ps [[default=bom gerber nelma png ps]]],
272 [],[with_exporters=$hid_exporters])
273 AC_MSG_RESULT([$with_exporters])
274 for e in `echo $with_exporters | sed 's/,/ /g'`; do
275     case " $hid_exporters " in
276       *\ $e\ * )
277          HIDLIST="$HIDLIST $e"
278          ;;
279       * ) AC_MSG_ERROR([$e is not a valid exporter]) ;;
280     esac
281 done
283 if test "X$enable_jpeg" = "Xno" -a "X$enable_gif" = "Xno" -a "X$enable_png" = "Xno" ; then
284         case " ${HIDLIST} " in
285                 *\ png\ *)
286                         AC_MSG_ERROR([you have requested the png HID but turned off all output
287 formats!  If you do not want gif/jpeg/png output, use --with-exporters to list
288 which exporters you want and do not list png there.])
289                         ;;
291                 *)
292                         ;;
293         esac
296 for e in $HIDLIST; do
297     HIDLIBS="$HIDLIBS lib$e.a"
298 done
300 AC_SUBST(HIDLIST)
301 AC_SUBST(HIDLIBS)
303 # ------------- end HID config -------------------
305 ######################################################################
307 # desktop integration
310 AC_PATH_PROG(SETENV, env, [])
311 AC_PATH_PROG(GTK_UPDATE_ICON_CACHE_BIN, gtk-update-icon-path, [true])
313 # Change default location for XDG files (MIME and Icons)
314 AC_ARG_WITH(xdgdatadir, [  --with-xdgdatadir=path  Change where the theme icons 
315 and mime registrations are installed [[DATADIR]]], [opt_xdgdatadir=$withval])
317 # Change default location for KDE data files (KDE MIME registrations)
318 AC_ARG_WITH(kdedatadir, [  --with-kdedatadir=path  Change where the KDE mime reg
319 istrations are installed [[DATADIR]]], [opt_kdedatadir=$withval])
321 if test x$opt_xdgdatadir = x; then
322         # path was not specified with --with-xdgdatadir
323         XDGDATADIR='${datadir}'
324 else
325         # path WAS specified with --with-xdgdatadir
326         XDGDATADIR="$opt_xdgdatadir"
328 AC_SUBST(XDGDATADIR)
330 if test x$opt_kdedatadir = x; then
331         # path was not specified with --with-kdedatadir
332         KDEDATADIR='${datadir}'
333 else
334         # path WAS specified with --with-kdedatadir
335         KDEDATADIR="$opt_kdedatadir"
337 AC_SUBST(KDEDATADIR)
339 AC_ARG_ENABLE(update-desktop-database,
340         AC_HELP_STRING([--disable-update-desktop-database],
341         [do not update desktop database after installation]),,
342         enable_update_desktop_database=yes)
344 AM_CONDITIONAL(ENABLE_UPDATE_DESKTOP_DATABASE, test x$enable_update_desktop_database = xyes)
346 if test x$enable_update_desktop_database = xyes ; then
347         AC_PATH_PROG(UPDATE_DESKTOP_DATABASE, [update-desktop-database], no)
348         if test $UPDATE_DESKTOP_DATABASE = no; then
349         AC_MSG_ERROR([Cannot find update-desktop-database, make sure it is installed and in your PATH, or configure with --disable-update-desktop-database])
350         fi
353 AC_ARG_ENABLE(update-mime-database,
354         AC_HELP_STRING([--disable-update-mime-database],
355         [do not update mime database after installation]),,
356         enable_update_mime_database=yes)
358 AM_CONDITIONAL(ENABLE_UPDATE_MIME_DATABASE, test x$enable_update_mime_database = xyes)
360 if test x$enable_update_mime_database = xyes ; then
361         AC_PATH_PROG(UPDATE_MIME_DATABASE, [update-mime-database], no)
362         if test $UPDATE_MIME_DATABASE = no; then
363         AC_MSG_ERROR([Cannot find update-mime-database, make sure it is installed and in your PATH, or configure with --disable-update-mime-database])
364         fi
368 ######################################################################
370 AC_PATH_PROGS(M4, gm4 m4, [none])
371 if test "X$M4" = "Xnone" ; then
372         AC_MSG_ERROR([Did not find a m4 executible.  You need to make sure
373         that m4 is installed on your system and that m4 is in your path])
375 AC_MSG_CHECKING([if $M4 has the division involving negative numbers bug])
376 pcb_m4_r=`echo "eval(-2/2)" | $M4`
377 if test "$pcb_m4_r" != "-1" ; then
378         AC_MSG_RESULT([yes])
379         AC_MSG_ERROR([It appears that $M4 has a bug involving division
380 with negative numbers.  In particular it just returned the result that
381 -2/2 = $pcb_m4_r instead of -1.  This is a known bug in GNU m4-1.4.9.  Please
382 install a non-broken m4.])
383 else
384         AC_MSG_RESULT([no])
388 AC_PATH_PROGS(WISH, wish wish83 wish8.3 wish80 wish8.0 cygwish83 cygwish80,[none])
389 if test "X$WISH" = "Xnone" ; then
390         AC_MSG_ERROR([Did not find the wish executible.  You need to make sure
391         that tcl is installed on your system and that wish is in your path])
394 AC_DEFINE_UNQUOTED(M4,$M4,[m4 executible])
395 GNUM4=$M4
396 AC_SUBST(GNUM4)
397 AC_DEFINE_UNQUOTED(GNUM4,"$M4",[m4 program used by pcb])
399 AC_CHECK_PROGS(LATEX, latex, notfound)
400 AM_CONDITIONAL(MISSING_LATEX, test x$LATEX = xnotfound)
402 AC_CHECK_PROGS(PDFLATEX, pdflatex, notfound)
403 AM_CONDITIONAL(MISSING_PDFLATEX, test x$PDFLATEX = xnotfound)
405 AC_CHECK_PROGS(DVIPS, dvips, notfound)
406 AM_CONDITIONAL(MISSING_DVIPS, test x$DVIPS = xnotfound)
408 AC_CHECK_PROGS(PS2PDF, ps2pdf, notfound)
409 AM_CONDITIONAL(MISSING_PS2PDF, test x$PS2PDF = xnotfound)
411 dnl Checks for libraries.
412 AC_CHECK_LIB(m, sqrt)
413 AC_CHECK_LIB(dl, dlopen)
414 AC_CHECK_LIB(xnet, gethostbyname)
415 AC_CHECK_LIB(fl, yywrap)
416 AC_CHECK_FUNCS(strerror)
417 AC_CHECK_FUNCS(regcomp re_comp)
418 AC_CHECK_FUNCS(logf expf rint)
419 AC_CHECK_FUNCS(vsnprintf)
420 AC_CHECK_FUNCS(getpwuid gethostname getcwd)
421 AC_CHECK_FUNCS(random)
422 AC_CHECK_FUNCS(stat)
424 # normally used for all file i/o
425 AC_CHECK_FUNCS(popen)
427 # for lrealpath.c
428 AC_CHECK_FUNCS(realpath canonicalize_file_name)
429 libiberty_NEED_DECLARATION(canonicalize_file_name)
431 AC_HEADER_STDC
432 AC_CHECK_HEADERS(limits.h locale.h string.h sys/types.h regex.h pwd.h)
433 AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h sys/param.h sys/times.h)
434 AC_CHECK_HEADERS(dlfcn.h)
436 if test "x${WIN32}" = "xyes" ; then
437         AC_CHECK_HEADERS(windows.h)
440 for e in $HIDLIST; do
441     case $e in
442       lesstif )
443         AC_PATH_XTRA
444         CPPFLAGS="$CFLAGS $X_CFLAGS"
445         AC_CHECK_LIB(X11, XOpenDisplay, , , $X_LIBS)
446         AC_CHECK_LIB(ICE, main, , , $X_LIBS)
447         AC_CHECK_LIB(SM, main, , , $X_LIBS)
448         AC_CHECK_LIB(Xext, main, , , $X_LIBS)
449         AC_CHECK_LIB(Xt, XtOpenDisplay, , , $X_LIBS)
450         AC_CHECK_LIB(Xmu, main, , , $X_LIBS)
451         AC_CHECK_LIB(Xpm, main, , , $X_LIBS)
452         AC_CHECK_LIB(Xm, XmCreateMainWindow, , , $X_LIBS)
453         case $ac_cv_lib_Xm_XmCreateMainWindow in
454           no )
455             AC_MSG_ERROR([You don't seem to have the Lesstif development environment installed.])
456             ;;
457           * ) ;;
458         esac
459         AC_CHECK_HEADERS(Xm/Xm.h)
460         case $ac_cv_header_Xm_Xm_h in
461           no )
462             AC_MSG_ERROR([You don't seem to have the Lesstif development environment installed.])
463             ;;
464           * ) ;;
465         esac
466         ;;
468       gtk )
469         # Check for pkg-config
470         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
471         if test "$PKG_CONFIG" = "no"; then
472                 AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
473         fi
475         PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.4.0, , 
476                 [AC_MSG_ERROR([Cannot find gtk+ >= 2.4.0, install it and rerun ./configure
477 Please review the following errors:
478 $GTK_PKG_ERRORS])]
479         )
480         GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
481         
482         # if we are building for gtk >= 2.8.0, we can use gdk_display_warp_pointer()
483         # otherwise we need XWarpPointer and we'll pull in the required headers with
484         # gdk/gdkx.h and we'll need to link with X11
485         if ! $PKG_CONFIG gtk+-2.0 --atleast-version=2.8.0 ; then
486                 CPPFLAGS="$CFLAGS $GTK_CFLAGS"
487                 AC_CHECK_HEADERS([gdk/gdkx.h])
488         fi
490         # Search for glib
491         PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.4.0, , 
492                 [AC_MSG_ERROR([Cannot find glib >= 2.4.0, install it and rerun ./configure.
493 Please review the following errors:
494 $GLIB_PKG_ERRORS])]
495         )
496         GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
497         ;;
499       nelma|png )
500         # Check for gdlib-config for gd (www.boutell.com/gd)
501         AC_PATH_PROG(GDLIB_CONFIG, gdlib-config, no)
502         if test "$GDLIB_CONFIG" = "no"; then
503                 AC_MSG_RESULT([Cannot find gdlib-config.
504 Make sure it is installed and in your PATH.
505 gdlib-config is part of the GD library available from www.boutell.com/gd.
506 This is needed for the png HID.  I will look for libgd anyway and maybe
507 you will get lucky.
509                 if test "$WIN32" != "yes" ; then
510                         AC_CHECK_LIB(gd,main,,
511                         AC_MSG_ERROR([You have requested the nelma and/or png HID  but -lgd could not be found]))
512                 else 
513                         AC_CHECK_LIB(bgd,main,,
514                         AC_MSG_ERROR([You have requested the nelma and/or png HID  but -lbgd could not be found]))
515                 fi
516         else
517                 if test "$WIN32" = "yes" ; then
518                         GD=bgd
519                 else
520                         GD=gd
521                 fi
522                 AC_MSG_CHECKING([for libgd cflags])
523                 GD_CFLAGS="`$GDLIB_CONFIG --cflags`"
524                 AC_MSG_RESULT([$GD_CFLAGS])
525                 AC_MSG_CHECKING([for libgd libs])
526                 GD_LIBS="`$GDLIB_CONFIG --ldflags` `$GDLIB_CONFIG --libs` -l${GD}"
527                 AC_MSG_RESULT([$GD_LIBS])
528         fi
529    
530         # since some linux systems evidently install gdlib-config but fail to
531         # install the headers (nice), check for the header too and fail if it
532         # is not there.
533         CFLAGS="$CFLAGS $GD_CFLAGS"
534         CPPFLAGS="$CPPFLAGS $GD_CFLAGS"
535         AC_CHECK_HEADERS(gd.h)
536         case $ac_cv_header_gd_h in
537              no )
538                 AC_MSG_ERROR([
539 You evidentally do not have a complete installation of the GD library available from www.boutell.com/gd.
540 This is needed for the nelma and/or png HID.
542                 ;;
543              * ) ;;
544         esac
545         
546         # Some versions of gd (prior to the expiration of the
547         # patent related to gif compression) do not support
548         # gif output.  Check for that here.
549         save_LIBS="$LIBS"
550         LIBS="$save_LIBS $GD_LIBS $X_LIBS"
552         AC_MSG_CHECKING([if GIF output from the png HID is desired])
553         AC_ARG_ENABLE([gif],
554                 [  --disable-gif           Disable support for gif output when the png HID is used [[default=include gif support]]],
555                 [
556                 if test "X$enable_gif" != "Xno" ; then
557                         AC_MSG_RESULT([yes])
558                         with_gif=yes
559                 else
560                         AC_MSG_RESULT([no])
561                         with_gif=no
562                 fi
563                 ],
564                 [
565                 AC_MSG_RESULT([yes])
566                 with_gif=yes
567                 ])
568         if test "X$with_gif" = "Xyes" ; then
569                 AC_CHECK_FUNCS(gdImageGif)
570                 if test "$ac_cv_func_gdImageGif" != "yes"; then
571                         AC_MSG_ERROR([Your gd installation does not appear to include gif support.
572 You may need to update your installation of gd or disable
573 gif export with --disable-gif])
574                 fi
575         fi
577         AC_MSG_CHECKING([if JPEG output from the png HID is desired])
578         AC_ARG_ENABLE([jpeg],
579                 [  --disable-jpeg          Disable support for JPEG output when the png HID is used [[default=include JPEG support]]],
580                 [
581                 if test "X$enable_jpeg" != "Xno" ; then
582                         AC_MSG_RESULT([yes])
583                         with_jpeg=yes
584                 else
585                         AC_MSG_RESULT([no])
586                         with_jpeg=no
587                 fi
588                 ],
589                 [
590                 AC_MSG_RESULT([yes])
591                 with_jpeg=yes
592                 ])
593         if test "X$with_jpeg" = "Xyes" ; then
594                 AC_CHECK_FUNCS(gdImageJpeg)
595                 if test "$ac_cv_func_gdImageJpeg" != "yes"; then
596                         AC_MSG_ERROR([Your gd installation does not appear to include JPEG support.
597 You may need to update your installation of gd or disable
598 JPEG export with --disable-jpeg])
599                 fi
600         fi
603         AC_MSG_CHECKING([if PNG output from the png HID is desired])
604         AC_ARG_ENABLE([png],
605                 [  --disable-png           Disable support for PNG output when the png HID is used [[default=include PNG support]]],
606                 [
607                 if test "X$enable_png" != "Xno" ; then
608                         AC_MSG_RESULT([yes])
609                         with_png=yes
610                 else
611                         AC_MSG_RESULT([no])
612                         with_png=no
613                 fi
614                 ],
615                 [
616                 AC_MSG_RESULT([yes])
617                 with_png=yes
618                 ])
619         if test "X$with_png" = "Xyes" ; then
620                 AC_CHECK_FUNCS(gdImagePng)
621                 if test "$ac_cv_func_gdImagePng" != "yes"; then
622                         AC_MSG_ERROR([Your gd installation does not appear to include PNG support.
623 You may need to update your installation of gd or disable
624 PNG export with --disable-png])
625                 fi
626         fi
627         LIBS="$save_LIBS"
628         ;;
630     esac
631 done
634 AM_CONDITIONAL(PNG, test x$with_png = xyes)
635 AM_CONDITIONAL(GIF, test x$with_gif = xyes)
638 # ------------- Xrender -------------------
639 have_xrender=no
640 AC_CHECK_LIB(Xrender,XRenderQueryExtension,have_xrender=yes,have_xrender=no,$X_LIBS)
642 AC_ARG_ENABLE([xrender],
643 [  --disable-xrender        Compile and link with Xrender [default=yes]])
644 case "$have_xrender:$enable_xrender" in
645    no:* ) ;;
646    *:no ) ;;
647    * )
648      X_LIBS="-lXrender $X_LIBS"
649      AC_DEFINE([HAVE_XRENDER], 1,
650                 [Define to 1 if Xrender is available])
651      ;;
652 esac
654 # ------------- dmalloc -------------------
655 dnl dmalloc checks
656 with_dmalloc=no
657 AC_MSG_CHECKING([if dmalloc debugging should be enabled])
658 AC_ARG_ENABLE([dmalloc],
659 [  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [default=no]],
661 if test "X$enable_dmalloc" != "Xno" ; then
662         AC_MSG_RESULT([yes])
663         AC_CHECK_HEADER(dmalloc.h,,
664                 AC_MSG_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
665         AC_CHECK_LIB(dmalloc,main,,
666                 AC_MSG_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
667         DMALLOC_LIBS="-ldmalloc"
668         with_dmalloc=yes
669 else
670         AC_MSG_RESULT([no])
671         DMALLOC_LIBS=""
675         AC_MSG_RESULT([no])
676         DMALLOC_LIBS=""
679 # ------------- ElectricFence -------------------
680 dnl ElectricFence checks
681 with_efence=no
682 AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
683 AC_ARG_ENABLE([efence],
684 [  --enable-efence         Link with ElectricFence for malloc debugging [default=no]],
686 if test "X$enable_efence" != "Xno" ; then
687         AC_MSG_RESULT([yes])
688         AC_CHECK_LIB(efence,main,,
689                 AC_MSG_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
690         with_efence=yes
691 else
692         AC_MSG_RESULT([no])
696 AC_MSG_RESULT([no])
699 # ------------- Enable Debug code -------------------
700 AC_MSG_CHECKING([for whether to enable debugging code])
701 AC_ARG_ENABLE([debug],
702 [  --enable-debug          Enable debugging code],
703 [],[enable_debug=no])
705 AC_MSG_RESULT([$enable_debug])
706 AM_CONDITIONAL(DEBUG_BUILD, test x$enable_debug = xyes)
709 # ------------- Complete set of CFLAGS and LIBS -------------------
711 CFLAGS="$CFLAGS $X_CFLAGS $DBUS_CFLAGS $GTK_CFLAGS"
712 LIBS="$LIBS $XM_LIBS $DBUS_LIBS $X_LIBS $GTK_LIBS $DMALLOC_LIBS $GD_LIBS $INTLLIBS"
715 # if we have gcc then add -Wall
716 if test "x$GCC" = "xyes"; then
717         # see about adding some extra checks if the compiler takes them
718         for flag in -Wall -Wdeclaration-after-statement ; do
719                 case " ${CFLAGS} " in
720                         *\ ${flag}\ *)
721                                 # flag is already present
722                                 ;;
723                         *)
724                                 AC_MSG_CHECKING([if the compiler accepts ${flag}])
725                                 ac_save_CFLAGS="$CFLAGS"
726                                 CFLAGS="$CFLAGS ${flag}"
727                                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
728                                         [AC_MSG_RESULT([yes])],
729                                         [AC_MSG_RESULT([no])
730                                          CFLAGS="$ac_save_CFLAGS"
731                                         ]
732                                 )
733                                 ;;
734                 esac
735         done
738 # font filename
739 FONTFILENAME=${FONTFILENAME:-"default_font"}
740 AC_SUBST(FONTFILENAME)
741 AC_DEFINE_UNQUOTED(FONTFILENAME,"$FONTFILENAME",[File for default font])
743 # standard autoconf variables
744 CPPFLAGS="$CPPFLAGS -DPREFIXDIR=\\\"\${prefix}\\\""
745 CPPFLAGS="$CPPFLAGS -DBINDIR=\\\"\${bindir}\\\""
746 CPPFLAGS="$CPPFLAGS -DHOST=\\\"\${host}\\\""
748 # directory for old-style library and for fonts
749 PCBLIBDIR=${datadir}/pcb
750 AC_SUBST(PCBLIBDIR)
751 #AC_DEFINE_UNQUOTED(PCBLIBDIR,"$PCBLIBDIR",[Library directory])
752 CPPFLAGS="$CPPFLAGS -DPCBLIBDIR=\\\"$PCBLIBDIR\\\""
754 # name for old-style library
755 LIBRARYFILENAME=pcblib
756 AC_SUBST(LIBRARYFILENAME)
757 AC_DEFINE_UNQUOTED(LIBRARYFILENAME,"$LIBRARYFILENAME",[library file name])
760 # directory for new library
761 PCBTREEDIR=${datadir}/pcb/newlib
762 PCBTREEPATH=${PCBTREEDIR}:${PCBLIBDIR}/pcblib-newlib
763 PCBTREEDIR=${PCBTREEDIR:-"$PCBTREEDIR"}
764 AC_SUBST(PCBTREEDIR)
765 AC_SUBST(PCBTREEPATH)
766 #AC_DEFINE_UNQUOTED(PCBTREEDIR,"$PCBLIB",[top directory for new style pcb library])
767 CPPFLAGS="$CPPFLAGS -DPCBTREEDIR=\\\"$PCBTREEDIR\\\""
768 CPPFLAGS="$CPPFLAGS -DPCBTREEPATH=\\\"$PCBTREEPATH\\\""
770 # Figure out relative paths
771 AC_MSG_CHECKING([for the bindir to pcblibdir relative path])
772 adl_COMPUTE_RELATIVE_PATHS([bindir:PCBLIBDIR:bindir_to_pcblibdir])
773 adl_NORMALIZE_PATH([bindir_to_pcblibdir], [$PCB_DIR_SEPARATOR_S])
774 AC_MSG_RESULT([$bindir_to_pcblibdir])
775 AC_DEFINE_UNQUOTED(BINDIR_TO_PCBLIBDIR, "$bindir_to_pcblibdir", [Relative path from bindir to pcblibdir])
777 AC_MSG_CHECKING([for the bindir to pcbtreedir relative path])
778 adl_COMPUTE_RELATIVE_PATHS([bindir:PCBTREEDIR:bindir_to_pcbtreedir])
779 adl_NORMALIZE_PATH([bindir_to_pcbtreedir], [$PCB_DIR_SEPARATOR_S])
780 AC_MSG_RESULT([$bindir_to_pcbtreedir])
781 AC_DEFINE_UNQUOTED(BINDIR_TO_PCBTREEDIR, "$bindir_to_pcbtreedir", [Relative path from bindir to pcbtreedir])
784 AC_MSG_CHECKING([for the bindir to exec_prefix relative path])
785 adl_COMPUTE_RELATIVE_PATHS([bindir:exec_prefix:bindir_to_execprefix])
786 adl_NORMALIZE_PATH([bindir_to_execprefix], [$PCB_DIR_SEPARATOR_S])
787 AC_MSG_RESULT([$bindir_to_execprefix])
788 AC_DEFINE_UNQUOTED(BINDIR_TO_EXECPREFIX, "$bindir_to_execprefix", [Relative path from bindir to exec_prefix])
791 BTNMOD=${BTNMOD:-"Mod1"}
792 AC_SUBST(BTNMOD)
794 TOPDIRS=
795 for dir in src lib newlib doc example tools tutorial README_FILES
797    test -d $dir/. && TOPDIRS="$TOPDIRS $dir"
798 done
799 AC_SUBST(TOPDIRS)
801 AC_CONFIG_FILES(Makefile data/Makefile intl/Makefile po/Makefile.in)
803 if test -d $srcdir/README_FILES; then
804    AC_CONFIG_FILES(README_FILES/Makefile)
806 if test -d $srcdir/doc; then
807    AC_CONFIG_FILES(doc/Makefile)
809 if test -d $srcdir/example; then
810    AC_CONFIG_FILES(example/Makefile)
811    AC_CONFIG_FILES(example/libraries/Makefile)
813 if test -d $srcdir/lib; then
814    AC_CONFIG_FILES(lib/CreateLibraryContents.sh)
815    AC_CONFIG_FILES(lib/CreateLibrary.sh)
816    AC_CONFIG_FILES(lib/ListLibraryContents.sh)
817    AC_CONFIG_FILES(lib/Makefile)
818    AC_CONFIG_FILES(lib/QueryLibrary.sh)
819    AC_CONFIG_FILES(lib/m4lib_to_newlib.sh)
820    AC_CONFIG_FILES(lib/qfp-ui)
822 if test -d $srcdir/newlib; then
823    AC_CONFIG_FILES(newlib/2_pin_thru-hole_packages/Makefile)
824    AC_CONFIG_FILES(newlib/Makefile)
825    AC_CONFIG_FILES(newlib/analog-devices/Makefile)
826    AC_CONFIG_FILES(newlib/burr-brown/Makefile)
827    AC_CONFIG_FILES(newlib/connectors/Makefile)
828    AC_CONFIG_FILES(newlib/crystal/Makefile)
829    AC_CONFIG_FILES(newlib/electro-optics/Makefile)
830    AC_CONFIG_FILES(newlib/headers/Makefile)
831    AC_CONFIG_FILES(newlib/keystone/Makefile)
832    AC_CONFIG_FILES(newlib/msp430/Makefile)
833    AC_CONFIG_FILES(newlib/not_vetted_ingo/Makefile)
834    AC_CONFIG_FILES(newlib/sockets/Makefile)
835    AC_CONFIG_FILES(newlib/tests/Makefile)
837 AC_CONFIG_FILES(src/Makefile)
838 AC_CONFIG_FILES(src/icons/Makefile)
839 if test -d $srcdir/tools; then
840    AC_CONFIG_FILES(tools/Makefile)
842 if test -d $srcdir/tutorial; then
843    AC_CONFIG_FILES(tutorial/Makefile)
846 AC_CONFIG_FILES(win32/Makefile)
848 AC_OUTPUT
850 with_gui=`echo $with_gui`
851 with_printer=`echo $with_printer`
852 with_exporters=`echo $with_exporters | sed 's/,/ /g'`
854 expandedXDGDATADIR=`eval "echo $XDGDATADIR"`
855 expandedKDEDATADIR=`eval "echo $KDEDATADIR"`
857 AC_MSG_RESULT([
858 ** Configuration summary for $PACKAGE $VERSION:
860    GUI:                      $with_gui
861    Printer:                  $with_printer
862    Exporters:                $with_exporters
863    Build documentation:      $docs_yesno
864    xdg data directory:       $expandedXDGDATADIR
865    KDE data directory:       $expandedKDEDATADIR
866    dmalloc debugging:        $with_dmalloc
867    ElectricFence debugging:  $with_efence
868    CPPFLAGS:                 $CPPFLAGS
869    CFLAGS:                   $CFLAGS
870    LIBS:                     $LIBS