1dnl Process this file with autoconf to produce a configure script.
2
3AC_INIT([pcb], [4.2.0])
4AC_CONFIG_SRCDIR([src/draw.c])
5AC_PREREQ([2.69])
6AM_INIT_AUTOMAKE([1.9])
7AC_GNU_SOURCE
8AC_CONFIG_HEADERS([config.h])
9
10##########################################################################
11#
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.
19
20pcb_sources="tarball"
21AC_MSG_CHECKING([if you are building from a git checkout])
22pcb_git_version=no
23if test -f $srcdir/.gitignore ; then
24	pcb_git_version=yes
25	AC_MSG_RESULT([yes])
26	pcb_sources="GIT"
27else
28	AC_MSG_RESULT([no])
29fi
30AM_CONDITIONAL(GIT_VERSION, test x$pcb_git_version = xyes)
31
32AC_MSG_CHECKING([if you are building from a anoncvs checkout])
33pcb_cvs_version=no
34if test -f $srcdir/CVS/Root ; then
35	pcb_cvs_version=yes
36	AC_MSG_RESULT([yes])
37	pcb_sources="CVS"
38else
39	AC_MSG_RESULT([no])
40fi
41AM_CONDITIONAL(CVS_VERSION, test x$pcb_cvs_version = xyes)
42AM_CONDITIONAL(GIT_OR_CVS_VERSION, test x$pcb_git_version = xyes -o x$pcb_cvs_version = xyes)
43
44
45##########################################################################
46#
47# See if we are supposed to build the docs
48#
49
50docs_yesno=yes
51AC_MSG_CHECKING([if the documentation should be built])
52AC_ARG_ENABLE([doc],
53[  --enable-doc            Build and install the documentation [[default=yes]]],
54[
55if test "X$enable_doc" = "Xno" ; then
56        DOC=""
57        AC_MSG_RESULT([no])
58        docs_yesno=no
59else
60        DOC=doc
61        AC_MSG_RESULT([yes])
62        docs_yesno=yes
63fi
64],
65[
66DOC=doc
67AC_MSG_RESULT([yes])
68docs_yesno=yes
69])
70AC_SUBST(DOC)
71
72
73dnl determine host type
74AC_CANONICAL_HOST
75AC_MSG_CHECKING(for windows)
76PCB_PATH_DELIMETER=":"
77PCB_DIR_SEPARATOR_S="/"
78PCB_DIR_SEPARATOR_C='/'
79case $host in
80	*-*-mingw* )
81		WIN32=yes
82		CFLAGS="$CFLAGS ${MINGW_CFLAGS:--mms-bitfields -mwindows}"
83		CPPFLAGS="$CPPFLAGS ${MINGW_CPPFLAGS}"
84		;;
85
86	* )
87		WIN32=no
88		;;
89esac
90
91AC_MSG_RESULT($WIN32)
92AC_SUBST(WIN32)
93AM_CONDITIONAL(WIN32, test x$WIN32 = xyes)
94if test "x$WIN32" = "xyes" ; then
95	PCB_PATH_DELIMETER=";"
96	PCB_DIR_SEPARATOR_S="\\\\"
97	PCB_DIR_SEPARATOR_C='\\'
98fi
99
100AC_DEFINE_UNQUOTED(PCB_DIR_SEPARATOR_C,'$PCB_DIR_SEPARATOR_C',[Directory separator char])
101AC_DEFINE_UNQUOTED(PCB_DIR_SEPARATOR_S,"$PCB_DIR_SEPARATOR_S",[Directory separator string])
102AC_DEFINE_UNQUOTED(PCB_PATH_DELIMETER,"$PCB_PATH_DELIMETER",[Search path separator string])
103
104
105dnl Checks for programs.
106AC_PROG_CC
107AC_PROG_CXX
108
109if test "x$WIN32" = "xyes" ; then
110	AC_CHECK_TOOL(WINDRES, windres, [no])
111	if test "$WINDRES" = "no" ; then
112		AC_MSG_ERROR([*** Could not find an implementation of windres in your PATH.])
113	fi
114fi
115
116# i18n
117GETTEXT_PACKAGE=$PACKAGE
118AH_TEMPLATE([GETTEXT_PACKAGE], [Name of this program's gettext domain])
119AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"])
120AC_SUBST(GETTEXT_PACKAGE)
121
122AM_GNU_GETTEXT_VERSION([0.19.3])
123AM_GNU_GETTEXT
124
125AC_MSG_CHECKING([if $MSGFMT understands msgctxt (message context)])
126cat > conftest.po <<EOF
127[#]line __oline__ "configure"
128[#]. -- Info tab
129[#]: myfile.c:lineno
130msgctxt "tab"
131msgid "Info"
132msgstr ""
133EOF
134if ($MSGFMT -o conftest.gmo conftest.po >/dev/null; exit) 2>&AS_MESSAGE_LOG_FD
135then
136dnl
137  AC_MSG_RESULT([yes])
138else
139  AC_MSG_RESULT([no])
140  AC_MSG_ERROR([It appears that your gettext tools ($MSGFMT) is too old.
141You should install a newer gettext tools (>= 0.19.3 suggested).  You may
142specify the location of the msgfmt executible with MSGFMT=/path/to/msgfmt
143on the configure command line.
144])
145fi
146rm -f conftest.po conftest.gmo
147
148IT_PROG_INTLTOOL([0.35.0])
149
150AC_C_INLINE
151AC_PROG_CC_STDC
152AC_PROG_CC_C99
153AM_PROG_CC_C_O
154AC_PROG_CPP
155
156AC_MSG_CHECKING([that C compiler supports C99])
157if test "X$ac_cv_prog_cc_c99" = "Xno"; then
158  AC_MSG_RESULT([no])
159  AC_MSG_ERROR([A C99-compliant compiler is requred])
160else
161  AC_MSG_RESULT([yes])
162fi
163
164AC_PROG_AWK
165AC_PROG_MKDIR_P
166
167AM_PROG_LEX
168AC_PATH_PROG(LEX_PATH, $LEX, [notfound])
169if test "$LEX_PATH" = "notfound" ; then
170	AC_MSG_ERROR([Couldn't find a usable lex program.
171Please install flex which is available from
172ftp://ftp.gnu.org/pub/non-gnu/flex/
173])
174fi
175
176
177AC_PROG_YACC
178AC_PATH_PROG(YACC_PATH, $YACC, [notfound])
179if test "$YACC_PATH" = "notfound" ; then
180	AC_MSG_ERROR([Couldn't find a usable yacc program.
181Please install bison which is available from
182ftp://ftp.gnu.org/pub/gnu/bison/
183])
184fi
185
186AC_PROG_INSTALL
187AC_PROG_RANLIB
188
189#
190# Used for building the icons
191#
192AC_PATH_PROG(XPMTOPPM, xpmtoppm, notfound)
193AC_PATH_PROG(PPMTOWINICON, ppmtowinicon, notfound)
194AC_PATH_PROG(CONVERT, convert, notfound)
195
196##########################################################################
197#
198#
199if test "X$docs_yesno" = "Xyes" -a "X$pcb_git_version" = "Xyes" ; then
200   AC_PATH_PROG(MKINFO, makeinfo, no)
201   if test "X$MKINFO" != "Xno"; then
202      AC_MSG_CHECKING([for GNU makeinfo version >= 4.6])
203      v=`$MKINFO --version | grep "GNU texinfo"`
204      if test $? -ne 0; then
205         AC_MSG_RESULT([non-GNU])
206         MKINFO="no"
207      fi
208   fi
209   if test "X$MKINFO" != "Xno"; then
210      vmajor=`echo "$v" | sed 's/.* \([[0-9]]*\)\.\([[0-9]]*\)$/\1/'`
211      vminor=`echo "$v" | sed 's/.* \([[0-9]]*\)\.\([[0-9]]*\)$/\2/'`
212      AC_MSG_RESULT([$vmajor.$vminor])
213      if test "$vmajor" -lt 4 \
214              || (test "$vmajor" -eq 4 && test "$vminor" -lt 6); then
215         MKINFO=no
216      fi
217   fi
218   if test "X$MKINFO" = "Xno"; then
219      AC_MSG_ERROR([You have requested a build
220of the documentation.  For this to work, you must have version 4.6 or newer of
221the GNU texinfo package.  You seem to have
222
223$v
224
225Please update to a newer version of texinfo or disable building of
226the documentation with --disable-doc
227])
228   fi
229
230   AC_PATH_PROG(TEXI2DVI, texi2dvi, no)
231   if test "X$TEXI2DVI" = "Xno"; then
232      AC_MSG_ERROR([You have requested a build
233of the documentation.  For this to work, you must have the texi2dvi program
234installed.  Alternatively, you can disable building the documentation with
235--disable-doc.])
236   fi
237
238
239	AC_PATH_PROG(PERL, perl, notfound)
240	if test "X$PERL" = "Xnotfound"; then
241			AC_MSG_ERROR([You have requested a build
242of the documentation.  For this to work, you must have perl installed.
243Alternatively, you can disable building the documentation with
244--disable-doc.
245])
246	fi
247
248
249   AC_PATH_PROG([KPSEWHICH], [kpsewhich], [no])
250   if test "X$KPSEWHICH" = "Xno"; then
251      AC_MSG_ERROR([You have requested a build
252of the documentation.  For this to work, you must have a functional install of
253TeX and LaTeX.  kpsewhich is part of TeX.
254Alternatively, you can disable building the documentation with
255--disable-doc.])
256   fi
257
258   AC_MSG_CHECKING([If your TeX installation contains epsf.tex])
259   f=`$KPSEWHICH epsf.tex`
260   if test $? -eq 0 ; then
261	AC_MSG_RESULT([yes ($f)])
262   else
263	AC_MSG_RESULT([no])
264        AC_MSG_ERROR([You have requested a build
265of the documentation.  For this to work, you must have a functional install of
266TeX and LaTeX that includes epsf.tex.  On some linux distributions this is
267part of the texlive-generic-recommended package.  On NetBSD this is is part
268of the tex-epsf package.
269Alternatively, you can disable building the documentation with
270--disable-doc.])
271   fi
272
273fi
274
275##########################################################################
276#
277#
278
279# FIXME:  for now, only try to add -rdynamic if we're using gcc.  We really
280# need to figure out what the correct test is here.  In the mean time, this
281# should let things build with SunPRO again.
282if test "x$GCC" = "xyes"; then
283AC_MSG_CHECKING([If the compiler accepts -rdynamic])
284old_LDFLAGS="$LDFLAGS"
285LDFLAGS="$LDFLAGS -rdynamic"
286AC_LINK_IFELSE([AC_LANG_PROGRAM()],
287	[AC_MSG_RESULT([yes])],
288	[LDFLAGS="$old_LDFLAGS"
289	AC_MSG_RESULT([no])
290	])
291fi
292
293# ------------- HID config -------------------
294
295hid_guis=""
296hid_printers=""
297hid_exporters=""
298hid_always=""
299
300for hid in `cd $srcdir/src/hid; echo *`; do
301    F=$srcdir/src/hid/$hid/hid.conf
302    if test -f $F
303    then
304    echo checking $F
305        . $F
306	case $type in
307	  gui ) hid_guis="$hid_guis $hid" ;;
308	  printer ) hid_printers="$hid_printers $hid" ;;
309	  export ) hid_exporters="$hid_exporters $hid" ;;
310	  always ) hid_always="$hid_always $hid" ;;
311	esac
312    fi
313done
314
315AC_MSG_CHECKING([for which gui to use])
316AC_ARG_WITH([gui],
317[  --with-gui=	          Specify the GUI to use: batch gtk lesstif [[default=gtk]]],
318[],
319[with_gui=gtk]
320)
321AC_MSG_RESULT([$with_gui])
322case " $hid_guis no none " in
323     *\ $with_gui\ * ) HIDLIST="$with_gui" ;;
324     * ) AC_MSG_ERROR([$with_gui is not a valid gui]) ;;
325esac
326
327WITHGUI="$with_gui"
328AC_SUBST(WITHGUI)
329
330if test x"$with_gui" = x"none" -o x"$with_gui" = x"no"
331then
332    HIDLIST=
333fi
334
335AC_MSG_CHECKING([whether to enable toporouter])
336AC_ARG_ENABLE([toporouter],
337 [AS_HELP_STRING([--enable-toporouter], [build toporouter [default=yes]]) ]
338)
339AS_CASE(["x$enable_toporouter"],[xyes | xno],,
340 [enable_toporouter=yes
341 ]
342)
343AC_MSG_RESULT([$enable_toporouter])
344AM_CONDITIONAL([WITH_TOPOROUTER], test $enable_toporouter != no)
345
346AC_MSG_CHECKING([whether to enable toporouter output])
347AC_ARG_ENABLE([toporouter-output],
348 [AS_HELP_STRING([--enable-toporouter-output], [enable toporouter graphical output [default=no]]) ]
349)
350AS_CASE(["z$enable_toporouter_output"],[zyes | zno],,
351 [enable_toporouter_output=no]
352)
353AC_MSG_RESULT([$enable_toporouter_output])
354AS_CASE([$enable_toporouter_output],[yes],
355 [
356  topo_output_enabled=1
357 ],
358 [
359  topo_output_enabled=0
360 ]
361)
362AC_DEFINE_UNQUOTED([TOPO_OUTPUT_ENABLED], [$topo_output_enabled],
363 [Define to 1 to enable toporouter graphical output]
364)
365
366PKG_PROG_PKG_CONFIG()
367
368if test "x$enable_toporouter_output" = "xyes"; then
369   PKG_CHECK_MODULES(CAIRO, cairo,,
370                     [AC_MSG_ERROR([Cannot find cairo, needed by the toporouter
371Please review the following errors:
372$CAIRO_PKG_ERRORS])]
373   )
374fi
375
376AC_MSG_CHECKING([for whether to use DBUS])
377AC_ARG_ENABLE([dbus],
378[  --enable-dbus           Enable DBUS IPC],
379[],[
380	case " $with_gui " in
381		*\ gtk\ *)     enable_dbus=yes ;;
382		*\ lesstif\ *) enable_dbus=yes ;;
383		* )            enable_dbus=no ;;
384	esac
385])
386
387AC_MSG_RESULT([$enable_dbus])
388AM_CONDITIONAL(WITH_DBUS, test x$enable_dbus = xyes)
389
390if test "x$enable_dbus" = "xyes"; then
391	case " $with_gui " in
392		*\ gtk\ *) ;;
393		*\ lesstif\ *) ;;
394		* ) AC_MSG_ERROR([DBUS enabled but only works with a mainloop capable GUI HID.
395Either do not use --enable-dbus or enable the gtk or lesstif GUI HID.])
396	esac
397
398	PKG_CHECK_MODULES(DBUS, dbus-1 >= 0.61,
399		[saved_LIBS="$LIBS"
400		 LIBS="$LIBS $DBUS_LIBS"
401		 AC_CHECK_FUNCS(dbus_watch_get_unix_fd)
402		 LIBS="$saved_LIBS" ],
403		[AC_MSG_ERROR([Cannot find dbus-1 >= 0.61, install it and rerun ./configure
404Please review the following errors:
405$DBUS_PKG_ERRORS])]
406	)
407	DBUS_VERSION=`$PKG_CONFIG dbus-1 --modversion`
408
409	AC_DEFINE([HAVE_DBUS], 1,
410		[Define to 1 if DBUS IPC is to be compiled in])
411
412fi
413
414
415AC_MSG_CHECKING([for whether to use GL drawing])
416AC_ARG_ENABLE([gl],
417[  --enable-gl           Enable GL drawing (with GTK HID)],
418[],[
419	case " $with_gui " in
420		*\ gtk\ *) enable_gl=yes;;
421		* ) enable_gl=no;;
422	esac
423])
424AC_MSG_RESULT([$enable_gl])
425AM_CONDITIONAL(USE_GL, test x$enable_gl = xyes)
426
427if test "x$enable_gl" = "xyes"; then
428	case " $with_gui " in
429		*\ gtk\ *) ;;
430		* ) AC_MSG_ERROR([GL drawing enabled but only works with the GTK HID.
431Either do not use --enable-gl or enable the gtk HID.])
432	;;
433	esac
434
435	AX_CHECK_GL
436	AS_IF([test X$no_gl = Xyes],
437	      [AC_MSG_FAILURE([OpenGL is required.])])
438
439	AX_CHECK_GLU
440	AS_IF([test X$no_glu = Xyes],
441	      [AC_MSG_FAILURE([The OpenGL GLU library is required.])])
442
443	AC_DEFINE([ENABLE_GL], 1,
444		[Define to 1 if GL support is to be compiled in])
445fi
446
447AC_MSG_CHECKING([for which printer to use])
448AC_ARG_WITH([printer],
449[  --with-printer= 	  Specify the printer: lpr [[default=lpr]]],
450[],[with_printer=lpr])
451AC_MSG_RESULT([$with_printer])
452case " $hid_printers " in
453     *\ $with_printer\ * )
454         HIDLIST="$HIDLIST $with_printer"
455	 ;;
456     * ) AC_MSG_ERROR([$with_printer is not a valid printer]) ;;
457esac
458
459AC_MSG_CHECKING([for which exporters to use])
460AC_ARG_WITH([exporters],
461[  --with-exporters=       Enable export devices: bom gerber gcode nelma png ps ipcd356 gsvit [[default=bom gerber gcode nelma png ps ipcd356 gsvit]]],
462[],[with_exporters=$hid_exporters])
463AC_MSG_RESULT([$with_exporters])
464for e in `echo $with_exporters | sed 's/,/ /g'`; do
465    case " $hid_exporters " in
466      *\ $e\ * )
467         HIDLIST="$HIDLIST $e"
468	 ;;
469      * ) AC_MSG_ERROR([$e is not a valid exporter]) ;;
470    esac
471done
472
473if test "X$enable_jpeg" = "Xno" -a "X$enable_gif" = "Xno" -a "X$enable_png" = "Xno" ; then
474	case " ${HIDLIST} " in
475		*\ png\ *)
476			AC_MSG_ERROR([you have requested the png HID but turned off all output
477formats!  If you do not want gif/jpeg/png output, use --with-exporters to list
478which exporters you want and do not list png there.])
479			;;
480
481		*)
482			;;
483	esac
484fi
485
486for hid in $HIDLIST; do
487    F=$srcdir/src/hid/$hid/hid.conf
488    if test -f $F ; then
489        echo checking $hid dependencies
490        deps=
491        . $F
492        for dep in $deps; do
493            if test "X`echo $HIDLIST | grep $dep`" = "X"; then
494                AC_MSG_ERROR([you have requested the $hid HID but not the $dep HID, which it depends on])
495            fi
496        done
497   fi
498done
499
500for e in $HIDLIST; do
501    HIDLIBS="$HIDLIBS lib$e.a"
502done
503
504AC_SUBST(HIDLIST)
505AC_SUBST(HIDLIBS)
506
507# ------------- end HID config -------------------
508
509######################################################################
510#
511# desktop integration
512#
513
514AC_PATH_PROG(SETENV, env, [])
515AC_PATH_PROG(GTK_UPDATE_ICON_CACHE_BIN, gtk-update-icon-path, [true])
516
517# Change default location for XDG files (MIME and Icons)
518AC_ARG_WITH(xdgdatadir, [  --with-xdgdatadir=path  Change where the theme icons
519and mime registrations are installed [[DATADIR]]], [opt_xdgdatadir=$withval])
520
521# Change default location for KDE data files (KDE MIME registrations)
522AC_ARG_WITH(kdedatadir, [  --with-kdedatadir=path  Change where the KDE mime reg
523istrations are installed [[DATADIR]]], [opt_kdedatadir=$withval])
524
525if test x$opt_xdgdatadir = x; then
526	# path was not specified with --with-xdgdatadir
527	XDGDATADIR='${datadir}'
528else
529	# path WAS specified with --with-xdgdatadir
530	XDGDATADIR="$opt_xdgdatadir"
531fi
532AC_SUBST(XDGDATADIR)
533
534if test x$opt_kdedatadir = x; then
535	# path was not specified with --with-kdedatadir
536	KDEDATADIR='${datadir}'
537else
538	# path WAS specified with --with-kdedatadir
539	KDEDATADIR="$opt_kdedatadir"
540fi
541AC_SUBST(KDEDATADIR)
542
543AC_ARG_ENABLE(update-desktop-database,
544	AC_HELP_STRING([--disable-update-desktop-database],
545	[do not update desktop database after installation]),,
546	enable_update_desktop_database=yes)
547
548AM_CONDITIONAL(ENABLE_UPDATE_DESKTOP_DATABASE, test x$enable_update_desktop_database = xyes)
549
550if test x$enable_update_desktop_database = xyes ; then
551	AC_PATH_PROG(UPDATE_DESKTOP_DATABASE, [update-desktop-database], no)
552	if test $UPDATE_DESKTOP_DATABASE = no; then
553	AC_MSG_ERROR([Cannot find update-desktop-database, make sure it is installed and in your PATH, or configure with --disable-update-desktop-database])
554	fi
555fi
556
557AC_ARG_ENABLE(update-mime-database,
558	AC_HELP_STRING([--disable-update-mime-database],
559	[do not update mime database after installation]),,
560	enable_update_mime_database=yes)
561
562AM_CONDITIONAL(ENABLE_UPDATE_MIME_DATABASE, test x$enable_update_mime_database = xyes)
563
564if test x$enable_update_mime_database = xyes ; then
565	AC_PATH_PROG(UPDATE_MIME_DATABASE, [update-mime-database], no)
566	if test $UPDATE_MIME_DATABASE = no; then
567	AC_MSG_ERROR([Cannot find update-mime-database, make sure it is installed and in your PATH, or configure with --disable-update-mime-database])
568	fi
569fi
570
571#
572######################################################################
573
574AC_PATH_PROGS(M4, gm4 m4, [none])
575if test "X$M4" = "Xnone" ; then
576	AC_MSG_ERROR([Did not find a m4 executible.  You need to make sure
577	that m4 is installed on your system and that m4 is in your path])
578fi
579AC_MSG_CHECKING([if $M4 has the division involving negative numbers bug])
580pcb_m4_r=`echo "eval(-2/2)" | $M4`
581if test "$pcb_m4_r" != "-1" ; then
582	AC_MSG_RESULT([yes])
583	AC_MSG_ERROR([It appears that $M4 has a bug involving division
584with negative numbers.  In particular it just returned the result that
585-2/2 = $pcb_m4_r instead of -1.  This is a known bug in GNU m4-1.4.9.  Please
586install a non-broken m4.])
587else
588	AC_MSG_RESULT([no])
589fi
590
591
592AC_PATH_PROGS(WISH, wish wish85 wish8.5 wish83 wish8.3 wish80 wish8.0 cygwish83 cygwish80,[none])
593if test "X$WISH" = "Xnone" ; then
594	AC_MSG_ERROR([Did not find the wish executible.  You need to make sure
595	that tcl is installed on your system and that wish is in your path])
596fi
597
598AC_DEFINE_UNQUOTED(M4,$M4,[m4 executible])
599GNUM4=$M4
600AC_SUBST(GNUM4)
601AC_DEFINE_UNQUOTED(GNUM4,"$M4",[m4 program used by pcb])
602
603AC_PATH_PROG(PDFLATEX, pdflatex, notfound)
604AM_CONDITIONAL(MISSING_PDFLATEX, test x$PDFLATEX = xnotfound)
605
606AC_PATH_PROG(TEXI2DVI, texi2dvi, notfound)
607AM_CONDITIONAL(MISSING_TEXI2DVI, test x$TEXI2DVI = xnotfound)
608
609AC_PATH_PROG(PS2PDF, ps2pdf, notfound)
610AM_CONDITIONAL(MISSING_PS2PDF, test x$PS2PDF = xnotfound)
611
612# used to build some of the getting started guide
613AC_PATH_PROG(GSCHEM, gschem, notfound)
614AM_CONDITIONAL(MISSING_GSCHEM, test x$GSCHEM = xnotfound)
615
616if test "X$docs_yesno" = "Xyes" -a "X$pcb_git_version" = "Xyes" ; then
617	if test "$PDFLATEX" = "notfound" -o "$TEXI2DVI" = "notfound" -o "$PS2PDF" = "notfound" ; then
618		AC_MSG_ERROR([It appears that you are building from a source tree obtained
619via git but you do not have the required tools installed to build the documentation.  Here
620is a list of tools and the detected values:
621PDFLATEX:  $PDFLATEX
622TEXI2DVI:  $TEXI2DVI
623PS2PDF:    $PS2PDF
624GSCHEM:    $GSCHEM
625
626Either make sure these tools are installed or disable building and installing the documentation
627by using the --disable-doc configure option.
628])
629	fi
630fi
631
632############################################################################
633#
634# These checks are for tools used by the testsuite.  It will not be fatal
635# if these are missing because this is primarily for developer use.  It is
636# possible that we might add some --enable flag in the future that forces
637# full tools for development work.
638
639# Check for ImageMagick tools used by the testsuite
640AC_PATH_PROG(IM_ANIMATE, animate, notfound)
641AC_PATH_PROG(IM_COMPARE, compare, notfound)
642AC_PATH_PROG(IM_COMPOSITE, composite, notfound)
643AC_PATH_PROG(IM_CONVERT, convert, notfound)
644AC_PATH_PROG(IM_DISPLAY, display, notfound)
645AC_PATH_PROG(IM_MONTAGE, montage, notfound)
646AC_PATH_PROG(XHOST, xhost, notfound)
647missing_magick=""
648test "${IM_ANIMATE}" != "notfound" || missing_magick="${missing_magick} animate"
649test "${IM_COMPARE}" != "notfound" || missing_magick="${missing_magick} compare"
650test "${IM_COMPOSITE}" != "notfound" || missing_magick="${missing_magick} composite"
651test "${IM_CONVERT}" != "notfound" || missing_magick="${missing_magick} convert"
652test "${IM_DISPLAY}" != "notfound" || missing_magick="${missing_magick} display"
653test "${IM_MONTAGE}" != "notfound" || missing_magick="${missing_magick} montage"
654
655AC_MSG_CHECKING([if all ImageMagick tools needed for the testsuite were found])
656if test "X${missing_magick}" != "X" ; then
657    AC_MSG_RESULT([no.  The testsuite will be disabled because the following
658tools from the ImageMagick suite were not found:
659${missing_magick}
660No loss in pcb functionality should be experienced, you just will not
661be able to run the full regression testsuite.
662])
663    have_magick=no
664else
665    AC_MSG_RESULT([yes])
666    have_magick=yes
667fi
668
669have_test_tools=yes
670
671test $have_magick = yes || have_test_tools=no
672
673# the RS274-X export HID is partially checked by looking at the result with
674# gerbv
675AC_PATH_PROG(GERBV, gerbv, notfound)
676test $GERBV != notfound || have_test_tools=no
677
678
679AM_CONDITIONAL(HAVE_TEST_TOOLS, test x$have_test_tools = xyes)
680AC_MSG_CHECKING([if all the required testsuite tools were found])
681if test x$have_test_tools = xyes ; then
682	AC_MSG_RESULT([yes])
683else
684	AC_MSG_RESULT([no -- the testsuite will be disabled])
685fi
686
687
688#
689############################################################################
690
691
692dnl Checks for libraries.
693AC_CHECK_LIB(m, sqrt)
694AC_CHECK_LIB(dl, dlopen)
695AC_CHECK_LIB(xnet, gethostbyname)
696AC_CHECK_LIB(fl, yywrap)
697
698dnl Checks for functions
699AC_CHECK_FUNCS(getline)
700AC_CHECK_FUNCS(strcasestr)
701AC_CHECK_FUNCS(strerror)
702AC_CHECK_FUNCS(regcomp re_comp)
703AC_CHECK_FUNCS(logf expf rint)
704AC_CHECK_FUNCS(vsnprintf)
705AC_CHECK_FUNCS(getpwuid getcwd)
706AC_CHECK_FUNCS(rand random)
707AC_CHECK_FUNCS(stat)
708
709AC_CHECK_FUNCS(mkdtemp)
710
711# normally used for all file i/o
712AC_CHECK_FUNCS(popen)
713
714# for lrealpath.c
715AC_CHECK_FUNCS(realpath canonicalize_file_name)
716libiberty_NEED_DECLARATION(canonicalize_file_name)
717
718# for pcb_spawnvp in action.c on Windows
719AC_CHECK_FUNCS(_spawnvp)
720
721AC_HEADER_STDC
722AC_CHECK_HEADERS(limits.h locale.h string.h sys/types.h regex.h pwd.h)
723AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h sys/param.h sys/times.h sys/wait.h)
724AC_CHECK_HEADERS(dlfcn.h)
725
726if test "x${WIN32}" = "xyes" ; then
727	AC_CHECK_HEADERS(windows.h)
728fi
729# Search for glib
730PKG_CHECK_MODULES(GLIB, glib-2.0, ,
731		[AC_MSG_RESULT([Note: cannot find glib-2.0.
732You may want to review the following errors:
733$GLIB_PKG_ERRORS])]
734)
735
736need_gdlib=no
737with_gif=no
738with_png=no
739with_jpeg=no
740
741for e in $HIDLIST; do
742    case $e in
743      lesstif )
744	AC_PATH_XTRA
745	save_CPPFLAGS="$CPPFLAGS"
746	CPPFLAGS="$X_CFLAGS"
747	AC_CHECK_LIB(X11, XOpenDisplay, , , $X_LIBS)
748	AC_CHECK_LIB(ICE, main, , , $X_LIBS)
749	AC_CHECK_LIB(SM, main, , , $X_LIBS)
750	AC_CHECK_LIB(Xext, main, , , $X_LIBS)
751	AC_CHECK_LIB(Xt, XtOpenDisplay, , , $X_LIBS)
752	AC_CHECK_LIB(Xmu, main, , , $X_LIBS)
753	AC_CHECK_LIB(Xpm, main, , , $X_LIBS)
754	AC_CHECK_LIB(Xm, XmCreateMainWindow, , , $X_LIBS)
755	CPPFLAGS="$save_CPPFLAGS"
756	case $ac_cv_lib_Xm_XmCreateMainWindow in
757	  no )
758	    AC_MSG_ERROR([You don't seem to have the Lesstif development environment installed.])
759	    ;;
760	  * ) ;;
761	esac
762	AC_CHECK_HEADERS(Xm/Xm.h)
763	case $ac_cv_header_Xm_Xm_h in
764	  no )
765	    AC_MSG_ERROR([You don't seem to have the Lesstif development environment installed.])
766	    ;;
767	  * ) ;;
768	esac
769        ;;
770
771      gtk )
772	# Check for pkg-config
773	AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
774	if test "$PKG_CONFIG" = "no"; then
775		AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
776	fi
777
778	PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.18.0, ,
779		[AC_MSG_ERROR([Cannot find gtk+ >= 2.18.0, install it and rerun ./configure
780Please review the following errors:
781$GTK_PKG_ERRORS])]
782	)
783	GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
784	GLIB_VERSION=`$PKG_CONFIG glib-2.0 --modversion`
785
786	if test "x$enable_gl" = "xyes"; then
787		# Check for GtkGLExt
788		PKG_CHECK_MODULES(GTKGLEXT, gtkglext-1.0 >= 1.0.0, , [AC_MSG_ERROR([
789*** Required version of gtkglext is not installed - please install first ***
790Please review the following errors:
791$GTKGLEXT_PKG_ERRORS])]
792		)
793	GTKGLEXT_VER=`$PKG_CONFIG gtkglext-1.0 --modversion`
794	fi
795
796	;;
797
798      png)
799	need_gdlib=yes
800	AC_MSG_CHECKING([if GIF output from the png HID is desired])
801	AC_ARG_ENABLE([gif],
802		[  --disable-gif           Disable support for gif output when the png HID is used [[default=include gif support]]],
803		[
804		if test "X$enable_gif" != "Xno" ; then
805			AC_MSG_RESULT([yes])
806			with_gif=yes
807		else
808			AC_MSG_RESULT([no])
809		fi
810		],
811		[
812		AC_MSG_RESULT([yes])
813		with_gif=yes
814		])
815
816	AC_MSG_CHECKING([if JPEG output from the png HID is desired])
817	AC_ARG_ENABLE([jpeg],
818		[  --disable-jpeg          Disable support for JPEG output when the png HID is used [[default=include JPEG support]]],
819		[
820		if test "X$enable_jpeg" != "Xno" ; then
821			AC_MSG_RESULT([yes])
822			with_jpeg=yes
823		else
824			AC_MSG_RESULT([no])
825		fi
826		],
827		[
828		AC_MSG_RESULT([yes])
829		with_jpeg=yes
830		])
831
832	AC_MSG_CHECKING([if PNG output from the png HID is desired])
833	AC_ARG_ENABLE([png],
834		[  --disable-png           Disable support for PNG output when the png HID is used [[default=include PNG support]]],
835		[
836		if test "X$enable_png" != "Xno" ; then
837			AC_MSG_RESULT([yes])
838			with_png=yes
839		else
840			AC_MSG_RESULT([no])
841		fi
842		],
843		[
844		AC_MSG_RESULT([yes])
845		with_png=yes
846		])
847	;;
848
849      gcode|nelma)
850	need_gdlib=yes
851	with_png=yes
852	;;
853
854    esac
855done
856
857if test "$need_gdlib" = "yes"; then
858	# Search for glib
859	PKG_CHECK_MODULES(GDLIB, gdlib,[found_gdlib=yes] , [found_gdlib=no])
860
861	if test "X$found_gdlib" = "Xno"; then
862		# older installs came with gdlib-config and not the .pc file
863		# to work with pkg-config
864		AC_PATH_PROG([GDLIB_CONFIG], [gdlib-config], [notfound])
865		if test "$GDLIB_CONFIG" = "notfound" ; then
866			AC_MSG_ERROR([cannot find gdlib-config.  gdlib
867is required for gcode, nelma, png HIDs
868You may want to review the following errors
869from $PKG_CONFIG:
870$GDLIB_PKG_ERRORS])
871		else
872			AC_MSG_CHECKING([for gdlib cflags])
873			GDLIB_CFLAGS=`${GDLIB_CONFIG} --cflags`
874			AC_MSG_RESULT([$GDLIB_CFLAGS])
875
876			AC_MSG_CHECKING([for gdlib libraries])
877			GDLIB_LIBS=`${GDLIB_CONFIG} --libs`
878			AC_MSG_RESULT([$GDLIB_LIBS])
879
880			AC_MSG_CHECKING([for gdlib ldflags])
881			GDLIB_LDFLAGS=`${GDLIB_CONFIG} --ldflags`
882			AC_MSG_RESULT([$GDLIB_LDFLAGS])
883		fi
884	fi
885
886	save_LIBS="$LIBS"
887	LIBS="$LIBS $GDLIB_LDFLAGS $GDLIB_LIBS"
888
889	# some older installs, Ubuntu Precise for example, leave off the "-lgd" part.
890	# try to see if it needs to be added.  However this is currently broken
891	# under cygwin cross building for mingw because of interactions with
892	# __imp__ prefix added in the libgd.a static library.  Look at the declspec
893	# stuff in the mingw gd.h file.
894if test "x$WIN32" = "xno" ; then
895	before_LIBS="$LIBS"
896	AC_SEARCH_LIBS([gdImageCreate],[gd],[],[
897			AC_MSG_ERROR([Unable to figure out how to link gd applications.
898It is likely that your system has a broken gdlib-config or gdlib.pc file used by
899pkg-config.
900])],[])
901	if test "$LIBS" != "${before_LIBS}" ; then
902		GDLIB_LIBS="${GDLIB_LIBS} -lgd"
903	fi
904fi
905
906	if test "X$with_gif" = "Xyes" ; then
907		AC_CHECK_FUNCS(gdImageGif)
908		if test "$ac_cv_func_gdImageGif" != "yes"; then
909			AC_MSG_ERROR([Your gd installation does not appear to include gif support.
910You may need to update your installation of gd or disable
911gif export with --disable-gif])
912		fi
913	fi
914
915	if test "X$with_jpeg" = "Xyes" ; then
916		AC_CHECK_FUNCS(gdImageJpeg)
917		if test "$ac_cv_func_gdImageJpeg" != "yes"; then
918			AC_MSG_ERROR([Your gd installation does not appear to include JPEG support.
919You may need to update your installation of gd or disable
920JPEG export with --disable-jpeg])
921		fi
922	fi
923
924	if test "X$with_png" = "Xyes" ; then
925		AC_CHECK_FUNCS(gdImagePng)
926		if test "$ac_cv_func_gdImagePng" != "yes"; then
927			AC_MSG_ERROR([Your gd installation does not appear to include PNG support.
928You may need to update your installation of gd or disable
929PNG export with --disable-png])
930		fi
931	fi
932	LIBS="$save_LIBS"
933fi
934
935AM_CONDITIONAL(PNG, test x$with_png = xyes)
936AM_CONDITIONAL(GIF, test x$with_gif = xyes)
937
938# ------------- check if png previews should be built for pcblib-newlib
939AC_MSG_CHECKING([if the m4lib to newlib export should create png previews])
940AC_ARG_ENABLE(
941	[m4lib-png],
942	[  --enable-m4lib-png      Enable creating png previews for the m4 library],
943	[],[enable_m4lib_png=no])
944AC_MSG_RESULT([$enable_m4lib_png])
945AM_CONDITIONAL(PNG_PREVIEW, test x$enable_m4lib_png = xyes)
946
947
948# Run away.... more ugly stuff here.  By default we don't actually build
949# pcblib-newlib from pcblib unless we are building from cvs or git sources.
950# The reason is it takes a while and requires the png HID.  The problem is,
951# what if someone wants to use --enable-m4lib-png but the tarball was built
952# without the previews.  Or, what if someone does not want the PNG previews
953# but the person building the tarball included them.  Ugh!  So what the following
954# code attempts to do is detect that mismatch situation.  Note that we only
955# want to kick this code in when *not* building from git or cvs sources.
956build_pcblib_newlib=no
957if test "$pcb_sources" = "tarball" ; then
958	AC_MSG_CHECKING([If pcblib-newlib was built with png previews])
959	stamp=$srcdir/lib/pcblib-newlib.stamp
960	if test ! -f ${stamp} ; then
961		AC_MSG_RESULT([unknown, missing ${stamp}])
962		build_pcblib_newlib=yes
963	else
964		if test "`cat ${stamp}`" = "png-preview=yes" ; then
965			AC_MSG_RESULT([yes])
966			# lib exists and built with preview.
967			# if we don't want the preview, than rebuild
968			if test x$enable_m4lib_png != xyes ; then
969				build_pcblib_newlib=yes
970			fi
971		else
972			AC_MSG_RESULT([no])
973			# lib exists and built without preview.
974			# if we want the preview, than rebuild
975			if test x$enable_m4lib_png = xyes ; then
976				build_pcblib_newlib=yes
977			fi
978		fi
979	fi
980else
981	build_pcblib_newlib=yes
982fi
983AC_MSG_CHECKING([If pcblib-newlib needs to be rebuilt])
984AC_MSG_RESULT([$build_pcblib_newlib])
985AM_CONDITIONAL(BUILD_PCBLIB_NEWLIB, test x$build_pcblib_newlib = xyes)
986
987if test "X$cross_compiling" = "Xyes" ; then
988	# we are cross compiling so we will need a build host binary for pcb
989	AC_PATH_PROG(PCB, [pcb], [notfound])
990else
991	PCB="\${top_builddir}/src/pcb"
992fi
993AC_SUBST(PCB)
994
995# now make see how essential it was that we have a pcb executable for the build
996# host
997if test "X$pcb_git_version" = "Xyes" ; then
998	if test "X$docs_yesno" = "Xyes" -o "X$enable_m4lib_png" = "Xyes" ; then
999		if test "$PCB" = "notfound" ; then
1000			AC_MSG_ERROR([You have selected a build with m4lib png
1001previews enabled and/or with building the documentation enabled but you also
1002appear to be cross-compiling.  For this to work, you must have a pcb installed that
1003can run on this machine (the build machine) because it is needed for generating
1004library footprint png previews as well as some of the figures in the documentation.
1005If you wish to skip building the documentation and the footprint previews then add
1006--disable-doc --disable-m4lib-png
1007This will allow your cross build to work.])
1008		fi
1009	fi
1010fi
1011
1012# ------------- Xrender -------------------
1013have_xrender=no
1014AC_CHECK_LIB(Xrender,XRenderQueryExtension,have_xrender=yes,have_xrender=no,$X_LIBS)
1015
1016AC_ARG_ENABLE([xrender],
1017[  --disable-xrender       Compile and link with Xrender [default=yes]])
1018case "$have_xrender:$enable_xrender" in
1019   no:* ) ;;
1020   *:no ) ;;
1021   * )
1022     X_LIBS="-lXrender $X_LIBS"
1023     AC_DEFINE([HAVE_XRENDER], 1,
1024		[Define to 1 if Xrender is available])
1025     ;;
1026esac
1027
1028# ------------- Xinerama -------------------
1029have_xinerama=no
1030AC_CHECK_LIB(Xinerama,XineramaQueryExtension,have_xinerama=yes,have_xinerama=no,$X_LIBS)
1031
1032AC_ARG_ENABLE([xinerama],
1033[  --disable-xinerama       Compile and link with Xinerama [default=yes]])
1034case "$have_xinerama:$enable_xinerama" in
1035   no:* ) ;;
1036   *:no ) ;;
1037   * )
1038     X_LIBS="-lXinerama $X_LIBS"
1039     AC_DEFINE([HAVE_XINERAMA], 1,
1040		[Define to 1 if Xinerama is available])
1041     ;;
1042esac
1043
1044# ------------- dmalloc -------------------
1045dnl dmalloc checks
1046with_dmalloc=no
1047AC_MSG_CHECKING([if dmalloc debugging should be enabled])
1048AC_ARG_ENABLE([dmalloc],
1049[  --enable-dmalloc        Compile and link with dmalloc for malloc debugging [default=no]],
1050[
1051if test "X$enable_dmalloc" != "Xno" ; then
1052	AC_MSG_RESULT([yes])
1053	AC_CHECK_HEADER(dmalloc.h,,
1054		AC_MSG_ERROR([You have requested dmalloc debugging but dmalloc.h could not be found]))
1055	AC_CHECK_LIB(dmalloc,main,,
1056		AC_MSG_ERROR([You have requested dmalloc debugging but -ldmalloc could not be found]))
1057	DMALLOC_LIBS="-ldmalloc"
1058	with_dmalloc=yes
1059else
1060	AC_MSG_RESULT([no])
1061	DMALLOC_LIBS=""
1062fi
1063],
1064[
1065	AC_MSG_RESULT([no])
1066	DMALLOC_LIBS=""
1067])
1068
1069# ------------- ElectricFence -------------------
1070dnl ElectricFence checks
1071with_efence=no
1072AC_MSG_CHECKING([if ElectricFence debugging should be enabled])
1073AC_ARG_ENABLE([efence],
1074[  --enable-efence         Link with ElectricFence for malloc debugging [default=no]],
1075[
1076if test "X$enable_efence" != "Xno" ; then
1077	AC_MSG_RESULT([yes])
1078	AC_CHECK_LIB(efence,main,,
1079		AC_MSG_ERROR([You have requested ElectricFence debugging but -lefence could not be found]))
1080	with_efence=yes
1081else
1082	AC_MSG_RESULT([no])
1083fi
1084],
1085[
1086AC_MSG_RESULT([no])
1087])
1088
1089# ------------- Enable Debug code -------------------
1090AC_MSG_CHECKING([for whether to enable debugging code])
1091AC_ARG_ENABLE([debug],
1092[  --enable-debug          Enable debugging code],
1093[],[enable_debug=no])
1094
1095AC_MSG_RESULT([$enable_debug])
1096AM_CONDITIONAL(DEBUG_BUILD, test x$enable_debug = xyes)
1097
1098# ------------- mkdir required for win32 compatibility ------------
1099# WIN32 mkdir takes only one argument, POSIX takes two.
1100# #include "misc.h" where mkdir is required.
1101m4_include([m4/m4_ax_func_mkdir.m4])
1102AX_FUNC_MKDIR
1103
1104# ------------- Type used for "Coord" type -------------------
1105
1106AC_CHECK_HEADERS(stdint.h)
1107AC_ARG_ENABLE([coord64],
1108[  --enable-coord64        Force 64-bit coordinate types],
1109[],[enable_coord64=no])
1110AC_ARG_ENABLE([coord32],
1111[  --enable-coord32        Force 32-bit coordinate types],
1112[],[enable_coord32=no])
1113
1114COORDTYPE="long"
1115
1116echo "$enable_coord32:$enable_coord64:$ac_cv_header_stdint_h"
1117case "$enable_coord32:$enable_coord64:$ac_cv_header_stdint_h" in
1118  yes:no:yes )
1119    COORD_TYPE="int32_t"
1120    COORD_MAX="INT32_MAX"
1121    ;;
1122  no:yes:yes )
1123    COORD_TYPE="int64_t"
1124    COORD_MAX="INT64_MAX"
1125    ;;
1126  yes:no:no  )
1127    COORD_TYPE="int"
1128    COORD_MAX="INT_MAX"
1129    ;;
1130  no:yes:no  )
1131    COORD_TYPE="long long"
1132    COORD_MAX="LLONG_MAX"
1133    ;;
1134  yes:yes:*  )
1135    AC_MSG_ERROR("*** cannot require both 32 and 64 bit coordinates")
1136    ;;
1137  *:*:*    )
1138    COORD_TYPE="long"
1139    COORD_MAX="LONG_MAX"
1140    ;;
1141esac
1142AC_DEFINE_UNQUOTED([COORD_TYPE],[$COORD_TYPE],
1143  [C type for Coordinates])
1144AC_DEFINE_UNQUOTED([COORD_MAX],[$COORD_MAX],
1145  [Maximum value of coordinate type])
1146
1147# ------------- Complete set of CPPFLAGS and LIBS -------------------
1148
1149CPPFLAGS="$CPPFLAGS $X_CFLAGS $DBUS_CFLAGS $GDLIB_CFLAGS $GLIB_CFLAGS $GTK_CFLAGS $GD_CFLAGS $CAIRO_CFLAGS $GTKGLEXT_CFLAGS $GLU_CFLAGS $GL_CFLAGS"
1150LIBS="$LIBS $XM_LIBS $DBUS_LIBS $X_LIBS $GDLIB_LDFLAGS $GDLIB_LIBS $GLIB_LIBS $GTK_LIBS $DMALLOC_LIBS $GD_LIBS $INTLLIBS $CAIRO_LIBS $GTKGLEXT_LIBS $GLU_LIBS $GL_LIBS"
1151
1152
1153# if we have gcc then add -Wall
1154if test "x$GCC" = "xyes"; then
1155	# see about adding some extra checks if the compiler takes them
1156	for flag in -Wall ; do
1157		case " ${CFLAGS} " in
1158			*\ ${flag}\ *)
1159				# flag is already present
1160				;;
1161			*)
1162				AC_MSG_CHECKING([if the compiler accepts ${flag}])
1163				ac_save_CFLAGS="$CFLAGS"
1164				CFLAGS="$CFLAGS ${flag}"
1165				AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1166					[AC_MSG_RESULT([yes])],
1167					[AC_MSG_RESULT([no])
1168					 CFLAGS="$ac_save_CFLAGS"
1169					]
1170				)
1171				;;
1172		esac
1173	done
1174fi
1175
1176CXXFLAGS="$CFLAGS"
1177
1178# Now add C-specific flags
1179if test "x$GCC" = "xyes"; then
1180	# see about adding some extra checks if the compiler takes them
1181	for flag in -Wdeclaration-after-statement ; do
1182		case " ${CFLAGS} " in
1183			*\ ${flag}\ *)
1184				# flag is already present
1185				;;
1186			*)
1187				AC_MSG_CHECKING([if the compiler accepts ${flag}])
1188				ac_save_CFLAGS="$CFLAGS"
1189				CFLAGS="$CFLAGS ${flag}"
1190				AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1191					[AC_MSG_RESULT([yes])],
1192					[AC_MSG_RESULT([no])
1193					 CFLAGS="$ac_save_CFLAGS"
1194					]
1195				)
1196				;;
1197		esac
1198	done
1199fi
1200
1201# See if we are building gcc with C++.
1202AC_ARG_ENABLE(build-with-cxx,
1203[  --enable-build-with-cxx build with C++ compiler instead of C compiler],
1204ENABLE_BUILD_WITH_CXX=$enableval,
1205ENABLE_BUILD_WITH_CXX=no)
1206
1207case "$ENABLE_BUILD_WITH_CXX" in
1208  yes)
1209    CC_OR_CXX="$CXX"
1210    ;;
1211  no)
1212    CC_OR_CXX="$CC"
1213    ;;
1214esac
1215AC_SUBST(CC_OR_CXX)
1216
1217# font filename
1218FONTFILENAME=${FONTFILENAME:-"default_font"}
1219AC_SUBST(FONTFILENAME)
1220AC_DEFINE_UNQUOTED(FONTFILENAME,"$FONTFILENAME",[File for default font])
1221
1222# standard autoconf variables
1223CPPFLAGS="$CPPFLAGS -DPREFIXDIR=\\\"\${prefix}\\\""
1224CPPFLAGS="$CPPFLAGS -DBINDIR=\\\"\${bindir}\\\""
1225CPPFLAGS="$CPPFLAGS -DHOST=\\\"\${host}\\\""
1226
1227# directory for old-style library and for fonts
1228PCBLIBDIR=${datadir}/pcb
1229AC_SUBST(PCBLIBDIR)
1230#AC_DEFINE_UNQUOTED(PCBLIBDIR,"$PCBLIBDIR",[Library directory])
1231CPPFLAGS="$CPPFLAGS -DPCBLIBDIR=\\\"$PCBLIBDIR\\\""
1232
1233# name for old-style library
1234LIBRARYFILENAME=pcblib
1235AC_SUBST(LIBRARYFILENAME)
1236AC_DEFINE_UNQUOTED(LIBRARYFILENAME,"$LIBRARYFILENAME",[library file name])
1237
1238
1239# directory for new library
1240PCBTREEDIR=${datadir}/pcb/newlib
1241PCBTREEPATH=${PCBTREEDIR}:${PCBLIBDIR}/pcblib-newlib
1242PCBTREEDIR=${PCBTREEDIR:-"$PCBTREEDIR"}
1243AC_SUBST(PCBTREEDIR)
1244AC_SUBST(PCBTREEPATH)
1245#AC_DEFINE_UNQUOTED(PCBTREEDIR,"$PCBLIB",[top directory for new style pcb library])
1246CPPFLAGS="$CPPFLAGS -DPCBTREEDIR=\\\"$PCBTREEDIR\\\""
1247CPPFLAGS="$CPPFLAGS -DPCBTREEPATH=\\\"$PCBTREEPATH\\\""
1248
1249# Figure out relative paths
1250AC_MSG_CHECKING([for the bindir to pcblibdir relative path])
1251adl_COMPUTE_RELATIVE_PATHS([bindir:PCBLIBDIR:bindir_to_pcblibdir])
1252adl_NORMALIZE_PATH([bindir_to_pcblibdir], [$PCB_DIR_SEPARATOR_S])
1253AC_MSG_RESULT([$bindir_to_pcblibdir])
1254AC_DEFINE_UNQUOTED(BINDIR_TO_PCBLIBDIR, "$bindir_to_pcblibdir", [Relative path from bindir to pcblibdir])
1255
1256AC_MSG_CHECKING([for the bindir to pcbtreedir relative path])
1257adl_COMPUTE_RELATIVE_PATHS([bindir:PCBTREEDIR:bindir_to_pcbtreedir])
1258adl_NORMALIZE_PATH([bindir_to_pcbtreedir], [$PCB_DIR_SEPARATOR_S])
1259AC_MSG_RESULT([$bindir_to_pcbtreedir])
1260AC_DEFINE_UNQUOTED(BINDIR_TO_PCBTREEDIR, "$bindir_to_pcbtreedir", [Relative path from bindir to pcbtreedir])
1261
1262
1263AC_MSG_CHECKING([for the bindir to exec_prefix relative path])
1264adl_COMPUTE_RELATIVE_PATHS([bindir:exec_prefix:bindir_to_execprefix])
1265adl_NORMALIZE_PATH([bindir_to_execprefix], [$PCB_DIR_SEPARATOR_S])
1266AC_MSG_RESULT([$bindir_to_execprefix])
1267AC_DEFINE_UNQUOTED(BINDIR_TO_EXECPREFIX, "$bindir_to_execprefix", [Relative path from bindir to exec_prefix])
1268
1269
1270BTNMOD=${BTNMOD:-"Mod1"}
1271AC_SUBST(BTNMOD)
1272
1273TOPDIRS=
1274for dir in src lib newlib doc example tools tutorial README_FILES
1275do
1276   test -d $dir/. && TOPDIRS="$TOPDIRS $dir"
1277done
1278AC_SUBST(TOPDIRS)
1279
1280AC_CONFIG_FILES(Makefile data/Makefile intl/Makefile po/Makefile.in)
1281
1282if test -d $srcdir/README_FILES; then
1283   AC_CONFIG_FILES(README_FILES/Makefile)
1284fi
1285if test -d $srcdir/doc; then
1286   AC_CONFIG_FILES(doc/Makefile)
1287fi
1288if test -d $srcdir/doc/gs; then
1289   AC_CONFIG_FILES(doc/gs/Makefile)
1290   AC_CONFIG_FILES(doc/gs/gafrc)
1291   AC_CONFIG_FILES(doc/gs/gschemrc)
1292fi
1293if test -d $srcdir/example; then
1294   AC_CONFIG_FILES(example/Makefile)
1295   AC_CONFIG_FILES(example/libraries/Makefile)
1296fi
1297if test -d $srcdir/lib; then
1298   AC_CONFIG_FILES(lib/CreateLibraryContents.sh)
1299   AC_CONFIG_FILES(lib/CreateLibrary.sh)
1300   AC_CONFIG_FILES(lib/ListLibraryContents.sh)
1301   AC_CONFIG_FILES(lib/Makefile)
1302   AC_CONFIG_FILES(lib/QueryLibrary.sh)
1303   AC_CONFIG_FILES(lib/qfp-ui)
1304fi
1305if test -d $srcdir/newlib; then
1306   AC_CONFIG_FILES(newlib/2_pin_thru-hole_packages/Makefile)
1307   AC_CONFIG_FILES(newlib/Makefile)
1308   AC_CONFIG_FILES(newlib/connectors/Makefile)
1309   AC_CONFIG_FILES(newlib/crystal/Makefile)
1310   AC_CONFIG_FILES(newlib/electro-optics/Makefile)
1311   AC_CONFIG_FILES(newlib/headers/Makefile)
1312   AC_CONFIG_FILES(newlib/keystone/Makefile)
1313   AC_CONFIG_FILES(newlib/msp430/Makefile)
1314   AC_CONFIG_FILES(newlib/not_vetted_ingo/Makefile)
1315   AC_CONFIG_FILES(newlib/sockets/Makefile)
1316   AC_CONFIG_FILES(newlib/tests/Makefile)
1317fi
1318AC_CONFIG_FILES(src/Makefile)
1319AC_CONFIG_FILES(src/icons/Makefile)
1320if test -d $srcdir/tools; then
1321   AC_CONFIG_FILES(tools/Makefile)
1322fi
1323if test -d $srcdir/tutorial; then
1324   AC_CONFIG_FILES(tutorial/Makefile)
1325fi
1326
1327dnl testsuite
1328AC_CONFIG_FILES(tests/Makefile)
1329
1330dnl GTS 0.7.6 - http://gts.sourceforge.net/
1331AC_CONFIG_FILES(gts/Makefile)
1332
1333dnl win32 build scripts
1334AC_CONFIG_FILES(w32/Makefile)
1335
1336dnl for building under cygwin
1337AC_CONFIG_FILES(win32/Makefile)
1338
1339AC_OUTPUT
1340
1341with_gui=`echo $with_gui`
1342with_printer=`echo $with_printer`
1343with_exporters=`echo $with_exporters | sed 's/,/ /g'`
1344
1345expandedXDGDATADIR=`eval "echo $XDGDATADIR"`
1346expandedKDEDATADIR=`eval "echo $KDEDATADIR"`
1347
1348AC_MSG_RESULT([
1349** Configuration summary for $PACKAGE $VERSION:
1350
1351   Cross Compiling:          $cross_compiling
1352   CC:                       $CC
1353   CXX:                      $CXX
1354   CPPFLAGS:                 $CPPFLAGS
1355   CFLAGS:                   $CFLAGS
1356   CXXFLAGS:                 $CXXFLAGS
1357   LIBS:                     $LIBS
1358   PCB:                      $PCB
1359
1360   GUI:                      $with_gui
1361   Printer:                  $with_printer
1362   Exporters:                $with_exporters
1363   Coordinate type:          $COORD_TYPE
1364   Source tree distribution: $pcb_sources
1365   Build documentation:      $docs_yesno
1366   Build toporouter:         $enable_toporouter
1367   Enable toporouter output: $enable_toporouter_output
1368   xdg data directory:       $expandedXDGDATADIR
1369   KDE data directory:       $expandedKDEDATADIR
1370   dmalloc debugging:        $with_dmalloc
1371   ElectricFence debugging:  $with_efence
1372   Regression tests enabled: $have_test_tools
1373])
1374