1# configure.in for GNUstep GUI library
2# Process this file with autoconf to produce a configure script.
3#
4# Copyright (C) 1996-2015 Free Software Foundation, Inc.
5#
6# Author:  Adam Fedor <fedor@gnu.org>
7#
8# This file is part of the GNUstep GUI frontend (AppKit).
9#
10# This library is free software; you can redistribute it and/or
11# modify it under the terms of the GNU Lesser General Public
12# License as published by the Free Software Foundation; either
13# version 3 of the License, or (at your option) any later version.
14#
15# This library is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
18# Lesser General Public License for more details.
19#
20# You should have received a copy of the GNU Lesser General Public
21# License along with this library; see the file COPYING.LIB.
22# If not, see <http://www.gnu.org/licenses/> or write to the
23# Free Software Foundation, 51 Franklin Street, Fifth Floor,
24# Boston, MA 02110-1301, USA.
25#
26
27builtin(include, config/icu.m4)dnl
28builtin(include, config/pkg.m4)dnl
29
30AC_INIT
31AC_CONFIG_SRCDIR([Source/NSApplication.m])
32
33# If GNUSTEP_MAKEFILES is undefined, try to use gnustep-config to determine it.
34if test -z "$GNUSTEP_MAKEFILES"; then
35  GNUSTEP_MAKEFILES=`gnustep-config --variable=GNUSTEP_MAKEFILES 2>&5`
36fi
37
38if test -z "$GNUSTEP_MAKEFILES"; then
39  AC_MSG_ERROR([You must have the gnustep-make package installed and set up the GNUSTEP_MAKEFILES environment variable to contain the path to the makefiles directory before configuring!])
40fi
41
42#--------------------------------------------------------------------
43# Use config.guess, config.sub and install-sh provided by gnustep-make
44#--------------------------------------------------------------------
45AC_CONFIG_AUX_DIR($GNUSTEP_MAKEFILES)
46
47AC_CONFIG_HEADER(Headers/Additions/GNUstepGUI/config.h)
48
49#--------------------------------------------------------------------
50# Determine the host, build, and target systems
51#--------------------------------------------------------------------
52AC_CANONICAL_TARGET([])
53
54#--------------------------------------------------------------------
55# Find the compiler
56#--------------------------------------------------------------------
57MAKECC=`gnustep-config --variable=CC`
58MAKECPP=`gnustep-config --variable=CPP`
59MAKECXX=`gnustep-config --variable=CXX`
60if test "$CC" = ""; then
61  CC=$MAKECC
62else
63  if test "$CC" != "$MAKECC"; then
64    AC_MSG_WARN([You are running configure with the compiler ($CC) set to a different value from that used by gnustep-make ($MAKECC).  To a
65void conflicts/problems, reconfigure/reinstall gnustep-make to use $CC or run the gnustep-base configure again with your CC environment var
66iable set to $MAKECC])
67  fi
68fi
69if test "$CPP" = ""; then
70  CPP=$MAKECPP
71else
72  if test "$CPP" != "$MAKECPP"; then
73    AC_MSG_WARN([You are running configure with the preprocessor ($CPP) set to a different value from that used by gnustep-make ($MAKECPP).
74  To avoid conflicts/problems, reconfigure/reinstall gnustep-make to use $CPP or run the gnustep-base configure again with your CPP environ
75ment variable set to $MAKECPP])
76  fi
77fi
78if test "$CXX" = ""; then
79  CXX=$MAKECXX
80else
81  if test "$CXX" != "$MAKECXX"; then
82    AC_MSG_WARN([You are running configure with the compiler ($CXX) set to a different value from that used by gnustep-make ($MAKECXX).  To
83 avoid conflicts/problems, reconfigure/reinstall gnustep-make to use $CXX or run the gnustep-base configure again with your CXX environment
84 variable set to $MAKECXX])
85  fi
86fi
87AC_PROG_CC
88AC_PROG_CPP
89
90#--------------------------------------------------------------------
91# Add target OS directories as necessary
92#--------------------------------------------------------------------
93CONFIG_SYSTEM_INCL="$CPPFLAGS"
94CONFIG_SYSTEM_LIB_DIR="$LDFLAGS"
95case "$target_os" in
96  freebsd* | openbsd* )
97	      CPPFLAGS="$CPPFLAGS -I/usr/local/include"
98              LDFLAGS="$LDFLAGS -L/usr/local/lib";;
99  netbsd*)    CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
100	      LDFLAGS="$LDFLAGS -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";;
101esac
102
103AC_PATH_X	# Added for checking the existence of ungif.  Note that
104                # -gui uses the API of the underlying window system ONLY IF
105		# it is definitely necessary.
106
107#--------------------------------------------------------------------
108# The following is so that headers and custom libraries
109# in the GNUstep root are used before the standard ones
110#--------------------------------------------------------------------
111
112#
113# It looks like we ought to source the whole GNUstep.sh here, and even
114# ask it to output all variables!  That way we have access to (eg)
115# GNUSTEP_SYSTEM_HEADERS below.
116#
117GNUSTEP_SH_EXPORT_ALL_VARIABLES=yes
118. "$GNUSTEP_MAKEFILES/GNUstep.sh"
119unset GNUSTEP_SH_EXPORT_ALL_VARIABLES
120
121# For backwards compatibility, define GNUSTEP_SYSTEM_HEADERS from
122# GNUSTEP_SYSTEM_ROOT if not set yet.
123if test x"$GNUSTEP_SYSTEM_HEADERS" = x""; then
124  GNUSTEP_SYSTEM_HEADERS="$GNUSTEP_SYSTEM_ROOT/Library/Headers"
125fi
126
127if test x"$GNUSTEP_SYSTEM_LIBRARIES" = x""; then
128  GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_ROOT/Library/Libraries"
129fi
130
131if test "$GNUSTEP_IS_FLATTENED" = no; then
132  clean_target_os=`$GNUSTEP_MAKEFILES/clean_os.sh $target_os`
133  clean_target_cpu=`$GNUSTEP_MAKEFILES/clean_cpu.sh $target_cpu`
134  obj_dir=$clean_target_cpu/$clean_target_os
135  GNUSTEP_LDIR=$GNUSTEP_SYSTEM_LIBRARIES/$obj_dir
136  GNUSTEP_HDIR=$GNUSTEP_SYSTEM_HEADERS/$LIBRARY_COMBO
137else
138  GNUSTEP_LDIR=$GNUSTEP_SYSTEM_LIBRARIES
139  GNUSTEP_HDIR=$GNUSTEP_SYSTEM_HEADERS
140fi
141CPPFLAGS="$CPPFLAGS -I$GNUSTEP_HDIR"
142LDFLAGS="$LDFLAGS -L$GNUSTEP_LDIR/$LIBRARY_COMBO -L$GNUSTEP_LDIR"
143
144
145AC_CHECK_LIB(m, main)
146AC_CHECK_FUNCS(rint rintf atan2f floorf)
147
148
149#--------------------------------------------------------------------
150# Support for determining mountpoints
151#--------------------------------------------------------------------
152AC_CHECK_HEADERS(mntent.h)
153AC_CHECK_HEADERS(sys/mntent.h)
154AC_CHECK_MEMBER(struct mntent.mnt_fsname,[AC_DEFINE(MNT_FSNAME,mnt_fsname,mntent structure member name)],,[#include <mntent.h>])
155AC_CHECK_MEMBER(struct mntent.mnt_fsname,[AC_DEFINE(MNT_FSNAME,mnt_fsname,mntent structure member name)],,[#include <sys/mntent.h>])
156AC_CHECK_MEMBER(struct mntent.mnt_dir,[AC_DEFINE(MNT_MEMB,mnt_dir,mntent structure member name)],,[#include <mntent.h>])
157AC_CHECK_MEMBER(struct mntent.mnt_mountp,[AC_DEFINE(MNT_MEMB,mnt_mountp,mntent structure member name)],,[#include <sys/mntent.h>])
158AC_FUNC_GETMNTENT
159AC_CHECK_FUNCS(getmntinfo)
160AC_CHECK_FUNCS(statfs)
161AC_CHECK_FUNCS(statvfs)
162AC_CHECK_HEADERS(sys/statvfs.h)
163AC_CHECK_HEADERS(sys/vfs.h)
164
165AC_CHECK_MEMBERS([struct statfs.f_flags, struct statfs.f_owner],[],[],[
166#if	defined(HAVE_GETMNTINFO)
167#include <sys/param.h>
168#include <sys/mount.h>
169#endif
170#if defined (HAVE_SYS_STATVFS_H)
171#include <sys/statvfs.h>
172#endif
173#if defined (HAVE_SYS_VFS_H)
174#include <sys/vfs.h>
175#endif
176])
177AC_CHECK_MEMBERS([struct statvfs.f_flag, struct statvfs.f_owner],[],[],[
178#if defined (HAVE_SYS_STATVFS_H)
179#include <sys/statvfs.h>
180#endif
181])
182
183#--------------------------------------------------------------------
184# Simple way to add a bunch of paths to the flags
185#--------------------------------------------------------------------
186AC_ARG_WITH(include-flags,
187    [  --with-include-flags=FLAGS specify all include flags at once],
188    include_flags="$withval", include_flags="no")
189if test ${include_flags} != "no"; then
190    CPPFLAGS="$CPPFLAGS ${include_flags}"
191    CONFIG_SYSTEM_INCL="$CONFIG_SYSTEM_INCL ${include_flags}"
192fi
193
194AC_ARG_WITH(library-flags,
195    [  --with-library-flags=FLAGS specify all library flags at once],
196    library_flags="$withval", library_flags="no")
197if test ${library_flags} != "no"; then
198    LDFLAGS="$LDFLAGS ${library_flags}"
199    CONFIG_SYSTEM_LIB_DIR="$CONFIG_SYSTEM_LIB_DIR ${library_flags}"
200fi
201
202#--------------------------------------------------------------------
203# Find JPEG
204#--------------------------------------------------------------------
205GRAPHIC_CFLAGS=
206GRAPHIC_LFLAGS=
207
208AC_ARG_ENABLE(jpeg,
209  [  --disable-jpeg          Disable JPEG support],,
210  enable_jpeg=yes)
211
212if test $enable_jpeg = yes; then
213  AC_ARG_WITH(jpeg_library,
214             [  --with-jpeg-library=DIR JPEG library file are in DIR], ,
215             with_jpeg_library=)
216  AC_ARG_WITH(jpeg_include,
217          [  --with-jpeg-include=DIR JPEG include files are in DIR], ,
218          with_jpeg_include=)
219
220  if test -n "$with_jpeg_library"; then
221    with_jpeg_library="-L$with_jpeg_library"
222  fi
223  if test -n "$with_jpeg_include"; then
224    with_jpeg_include="-I$with_jpeg_include"
225  fi
226
227  CPPFLAGS="$with_jpeg_include ${CPPFLAGS}"
228  LDFLAGS="$with_jpeg_library ${LDFLAGS}"
229  AC_CHECK_HEADERS(jpeglib.h, have_jpeg=yes, have_jpeg=no)
230  if test "$have_jpeg" = yes; then
231    AC_CHECK_LIB(jpeg, jpeg_destroy_decompress)
232  else
233    ac_cv_lib_jpeg_jpeg_destroy_decompress=no
234  fi
235
236  if test "$ac_cv_lib_jpeg_jpeg_destroy_decompress" = yes; then
237    GRAPHIC_LFLAGS="$with_jpeg_library $GRAPHIC_LFLAGS"
238    GRAPHIC_CFLAGS="$with_jpeg_include $GRAPHIC_CFLAGS"
239  else
240    echo "GNUstep requires libjpeg to support JPEG images, but this library"
241    echo "can't be found. If you really want to compile GNUstep without"
242    echo "JPEG support, pass the --disable-jpeg option to ./configure."
243    echo "Note that this isn't recommended. For more information, see:"
244    echo "http://gnustep.made-it.com/BuildGuide/index.html#JPEG"
245    AC_MSG_ERROR([libjpeg not found.])
246  fi
247fi
248
249#--------------------------------------------------------------------
250# Find TIFF
251#--------------------------------------------------------------------
252AC_ARG_WITH(tiff_library,
253           [  --with-tiff-library=DIR TIFF library file are in DIR], ,
254           with_tiff_library=)
255AC_ARG_WITH(tiff_include,
256	[  --with-tiff-include=DIR TIFF include files are in DIR], ,
257        with_tiff_include=)
258
259if test -n "$with_tiff_library"; then
260  with_tiff_library="-L$with_tiff_library"
261fi
262if test -n "$with_tiff_include"; then
263  with_tiff_include="-I$with_tiff_include"
264fi
265
266CPPFLAGS="$with_tiff_include ${CPPFLAGS}"
267LDFLAGS="$with_tiff_library ${LDFLAGS}"
268AC_CHECK_LIB(z, main)
269AC_CHECK_HEADER(tiffio.h, have_tiff=yes, have_tiff=no)
270if test "$have_tiff" = yes; then
271  AC_CHECK_LIB(tiff, TIFFReadScanline)
272  if test "$ac_cv_lib_tiff_TIFFReadScanline" = yes; then
273    GRAPHIC_LFLAGS="$with_tiff_library $GRAPHIC_LFLAGS"
274    GRAPHIC_CFLAGS="$with_tiff_include $GRAPHIC_CFLAGS"
275  else
276    have_tiff=no
277  fi
278fi
279
280if test "$have_tiff" = no; then
281  AC_MSG_WARN(Cannot find libtiff header and/or library)
282  echo "* The GUI library reqiures the TIFF library"
283  echo "* Use --with-tiff-library to specify the tiff library"
284  echo "* directory if it is not in the usual place(s)"
285  echo "* You may also have to specify --with-jpeg-library if the jpeg"
286  echo "* library is needed by tiff",
287  AC_MSG_ERROR(gnustep-gui will not compile without tiff)
288fi
289
290#--------------------------------------------------------------------
291# Find PNG
292#--------------------------------------------------------------------
293AC_ARG_ENABLE(png,
294  [  --disable-png           Disable PNG support],,
295  enable_png=yes)
296
297if test $enable_png = yes; then
298  # use libpng-config if available
299  AC_CHECK_PROG(HAVE_LIBPNG_CONFIG, [libpng-config], yes)
300  if test "$HAVE_LIBPNG_CONFIG" = "yes"; then
301    PNG_CFLAGS="`libpng-config --I_opts`"
302    PNG_LDFLAGS="`libpng-config --ldflags`"
303    CPPFLAGS="${CPPFLAGS} $PNG_CFLAGS"
304    LDFLAGS="$PNG_LDFLAGS ${LDFLAGS}"
305    AC_CHECK_HEADERS(png.h)
306    AC_CHECK_LIB(png, png_sig_cmp)
307    if test "$ac_cv_search_png_sig_cmp" != no; then
308      GRAPHIC_CFLAGS="$PNG_CFLAGS $GRAPHIC_CFLAGS"
309      GRAPHIC_LFLAGS="$PNG_LDFLAGS $GRAPHIC_LFLAGS"
310      AC_DEFINE([HAVE_LIBPNG], [1])
311    fi
312  else
313    AC_MSG_WARN([Can't find libpng-config, guessing required headers and libraries.])
314    AC_CHECK_HEADERS(png.h)
315    AC_CHECK_LIB(png, png_sig_cmp)
316  fi
317
318
319
320  if test "$ac_cv_lib_png_png_sig_cmp" = no && test "$ac_cv_search_png_sig_cmp" = no; then
321    echo "GNUstep requires libpng to support PNG images, but this library"
322    echo "can't be found. If you really want to compile GNUstep without"
323    echo "PNG support, pass the --disable-png option to ./configure."
324    echo "Note that this isn't recommended."
325    AC_MSG_ERROR([libpng not found.])
326  fi
327fi
328
329#--------------------------------------------------------------------
330# Find additional image libs
331#--------------------------------------------------------------------
332AC_ARG_ENABLE(ungif,
333  [  --disable-ungif         Disable libungif-based GIF support],,
334  enable_ungif=yes)
335AC_ARG_ENABLE(libgif,
336  [  --enable-libgif         Enable libgif-based GIF support],,
337  enable_libgif=no)
338if test "${enable_libgif}" = yes; then
339  enable_ungif=no
340fi
341
342have_ungif=no
343if test "${enable_ungif}" = yes; then
344  AC_CHECK_LIB(ungif, DGifOpen)
345  if test "${ac_cv_lib_ungif_DGifOpen}" = yes; then
346    have_ungif=yes
347  fi
348
349  if test "${with_x}" != no && test "${ac_cv_lib_ungif_DGifOpen}" = no; then
350    orig_CPPFLAGS="${CPPFLAGS}"
351    orig_LDFLAGS="${LDFLAGS}"
352    orig_LIBS="${LIBS}"
353    AC_MSG_NOTICE([Checking if ungif is linked against -lX11])
354    # This implies either that ungif is not installed at all, or that it
355    # explicitly refers to the symbols defined in X11.  Now see if the latter
356    # is the case.
357    CPPFLAGS="${CPPFLAGS} -I${ac_x_includes}"
358    LDFLAGS="${LDFLAGS} -L${ac_x_libraries}"
359    LIBS="${LIBS} -lX11"
360
361    AC_CHECK_LIB(ungif, DGifCloseFile)
362    if test "${ac_cv_lib_ungif_DGifCloseFile}" = no; then
363      # This indicates ungif is not installed at all.  The flags reverts to
364      # the orignal value.
365      CPPFLAGS="${orig_CPPFLAGS}"
366      LDFLAGS="${orig_LDFLAGS}"
367      LIBS="${orig_LIBS}"
368    else
369      # This indicates ungif actually refers to the X11's symbols.  We modify
370      # the flags so that -gui gets linked against the X11 library to support
371      # ungif.
372      AC_MSG_NOTICE([-gui will be linked against -lX11 to support ungif images])
373      GRAPHIC_CFLAGS="-I${ac_x_includes} $GRAPHIC_CFLAGS"
374      GRAPHIC_LFLAGS="-L${ac_x_libraries} $GRAPHIC_LFLAGS"
375      have_ungif=yes
376    fi
377  fi
378fi
379
380if test "$have_ungif" = no -o "${enable_libgif}" = yes; then
381  AC_CHECK_LIB(gif, DGifOpen)
382
383  if test "${with_x}" != no && test "${ac_cv_lib_gif_DGifOpen}" = no; then
384    orig_CPPFLAGS="${CPPFLAGS}"
385    orig_LDFLAGS="${LDFLAGS}"
386    orig_LIBS="${LIBS}"
387    AC_MSG_NOTICE([Checking if libgif is linked against -lX11])
388    # This implies either that libgif is not installed at all, or that it
389    # explicitly refers to the symbols defined in X11.  Now see if the latter
390    # is the case.
391    CPPFLAGS="${CPPFLAGS} -I${ac_x_includes}"
392    LDFLAGS="${LDFLAGS} -L${ac_x_libraries}"
393    LIBS="${LIBS} -lX11"
394
395    AC_CHECK_LIB(gif, DGifCloseFile)
396    if test "${ac_cv_lib_gif_DGifCloseFile}" = no; then
397      # This indicates libgif is not installed at all.  The flags reverts to
398      # the orignal value.
399      CPPFLAGS="${orig_CPPFLAGS}"
400      LDFLAGS="${orig_LDFLAGS}"
401      LIBS="${orig_LIBS}"
402    else
403      # This indicates libgif actually refers to the X11's symbols.  We modify
404      # the flags so that -gui gets linked against the X11 library to support
405      # libgif.
406      AC_MSG_NOTICE([-gui will be linked against -lX11 to support libgif images])
407      GRAPHIC_CFLAGS="-I${ac_x_includes} $GRAPHIC_CFLAGS"
408      GRAPHIC_LFLAGS="-L${ac_x_libraries} $GRAPHIC_LFLAGS"
409    fi
410  fi
411fi
412
413# QuantizeBuffer was removed from giflib in version 4.2 but was reintroduced
414# in the 5.0 release with a new name. If this function is not present
415# we disable the support to create gif image representations.
416AC_CHECK_FUNCS(QuantizeBuffer)
417AC_CHECK_FUNCS(GifQuantizeBuffer)
418
419#--------------------------------------------------------------------
420# Find ImageMagick
421#--------------------------------------------------------------------
422
423AC_ARG_ENABLE(imagemagick,
424  [  --enable-imagemagick        Enable ImageMagick support])
425AS_IF([test "x$enable_imagemagick" = "xyes"], [
426   PKG_CHECK_MODULES([IMAGEMAGICK], [MagickCore],
427    [
428	GRAPHIC_CFLAGS="$IMAGEMAGICK_CFLAGS $GRAPHIC_CFLAGS"
429        GRAPHIC_LFLAGS="$IMAGEMAGICK_LIBS $GRAPHIC_LFLAGS"
430	AC_DEFINE([HAVE_IMAGEMAGICK], [1], [Have ImageMagick])
431    ],
432    [AC_DEFINE([HAVE_IMAGEMAGICK], [0], [Don't have ImageMagick])])
433])
434
435#--------------------------------------------------------------------
436# Check for International Components for Unicode
437# See DEPENDENCIES POLICY at the start of thsi file.
438#--------------------------------------------------------------------
439HAVE_ICU=0
440AC_ARG_ENABLE(icu,
441  [  --disable-icu		Disable International Components for Unicode],,
442  enable_icu=yes)
443
444AC_ARG_ENABLE(icu-config,
445  [  --disable-icu-config		Do not use the icu-config script to check
446				for ICU.],,
447  enable_icu_config=yes)
448
449AC_ARG_WITH(icu-library,
450  [  --with-icu-library=PATH  	library path for ICU libraries (only checked
451				if not using icu-config)],
452  icu_libdir="$withval", icu_libdir="no")
453
454if test $enable_icu = yes; then
455  if test "$enable_icu_config" = "yes"; then
456    AC_CHECK_ICU(4.0, have_icu=yes, have_icu=no)
457  else
458    have_icu=no;
459    AC_CHECKING([for libicu (icu-config disabled)])
460    if test "$icu_libdir" != "no"; then
461      ICU_LDFLAGS="-L$icu_libdir";
462    fi
463    saved_LDFLAGS="$LDFLAGS";
464    LDFLAGS="$LDFLAGS $LIBS $ICU_LDFLAGS -licui18n -licuuc -licudata -lm"
465    AC_TRY_LINK([],[], have_icu="yes", have_icu="no");
466    LDFLAGS="$saved_LDFLAGS";
467    ICU_LIBS="-licui18n -licuuc -licudata -lm"
468  fi
469
470  if test "$have_icu" = "yes"; then
471    AC_MSG_RESULT(yes)
472    AC_CHECK_HEADERS(unicode/uchar.h unicode/ustring.h)
473    GRAPHIC_LFLAGS="$ICU_LDFLAGS $ICU_LIBS $GRAPHIC_LFLAGS"
474    HAVE_ICU=1
475  else
476    AC_MSG_RESULT(no)
477    AC_MSG_WARN([The International Components for Unicode (ICU) development headers and libraries do not appear to be available on this system.])
478  fi
479fi
480AC_SUBST(HAVE_ICU)
481
482#--------------------------------------------------------------------
483# Check for the spelling lib, for the built-in spell checker...
484# Note: you might want to disable aspell on MacOSX, as it linkes in
485# Apple's libobjc.A, screwing up the links to the GNU libobjc.
486#--------------------------------------------------------------------
487AC_ARG_ENABLE(aspell,
488  [  --disable-aspell        Disable aspell for spellchecker],,
489  enable_aspell=yes)
490if test "$enable_aspell" = yes; then
491  AC_CHECK_LIB(aspell, new_aspell_document_checker)
492fi
493if test "${ac_cv_lib_aspell_new_aspell_document_checker}" = yes; then
494   AC_CHECK_HEADERS(aspell.h)
495   AC_DEFINE(HAVE_ASPELL,1,[Define if you have the aspell header])
496fi
497
498#--------------------------------------------------------------------
499# Check for ICNS library.
500#--------------------------------------------------------------------
501AC_CHECK_LIB(icns, icns_read_family_from_file)
502
503#--------------------------------------------------------------------
504# NSSound
505#--------------------------------------------------------------------
506AC_ARG_ENABLE(sound,
507  [  --disable-sound          Disable sound],,
508  enable_sound=yes)
509# Initialize to nothing...
510BUILD_SOUND=
511# Check for the headers...
512AC_CHECK_HEADERS(sndfile.h, have_sndfile=yes, have_sndfile=no)
513AC_CHECK_HEADERS(ao/ao.h, have_ao=yes, have_ao=no)
514# Only if we have both...
515if test $have_sndfile = yes -a $have_ao = yes -a $enable_sound = yes; then
516   BUILD_SOUND="sound"
517fi
518AC_SUBST(BUILD_SOUND)
519
520#--------------------------------------------------------------------
521# NSSpeechSynthesizer
522#--------------------------------------------------------------------
523AC_ARG_ENABLE(speech,
524  [  --disable-speech          Disable speech server],,
525  enable_speech=yes)
526BUILD_SPEECH=
527
528# has flite, for speech synthesis.
529AC_CHECK_LIB(flite, new_utterance, have_speech=yes, have_speech=no)
530AC_CHECK_HEADERS(flite/flite.h, have_flite=yes, have_flite=no)
531if test $have_flite = yes -a $have_speech = yes -a $enable_speech = yes; then
532   BUILD_SPEECH="speech say"
533   FLITE_BASE_LIBS="-lflite_usenglish -lflite_cmulex -lflite"
534   AC_CHECK_LIB(flite_cmu_us_kal16, register_cmu_us_kal16, have_kal16=yes, have_kal16=no, $FLITE_BASE_LIBS)
535   if test $have_kal16 = no; then
536      BUILD_SPEECH=
537   fi
538fi
539AC_SUBST(BUILD_SPEECH)
540
541#--------------------------------------------------------------------
542# NSSpeechRecognizer
543#--------------------------------------------------------------------
544AC_ARG_ENABLE(speech-recognizer,
545  [  --disable-speech-recognizer          Disable speech recognition server],,
546  enable_speech_recognizer=yes)
547BUILD_SPEECH_RECOGNIZER=
548
549# has pocketsphinx, for speech recognition.
550AC_CHECK_LIB(pocketsphinx, ps_start_utt, have_speech_recognizer=yes, have_speech_recognizer=no)
551AC_CHECK_HEADERS(pocketsphinx/pocketsphinx_export.h, have_pocketsphinx=yes, have_pocketsphinx=no)
552if test $have_pocketsphinx = yes -a $have_speech_recognizer = yes -a $enable_speech_recognizer = yes; then
553   BUILD_SPEECH_RECOGNIZER="speech_recognizer"
554   RECOGNIZER_BASE_LIBS=`pkg-config --libs pocketsphinx sphinxbase`
555   RECOGNIZER_BASE_CFLAGS=`pkg-config --cflags pocketsphinx sphinxbase`
556   RECOGNIZER_ENGINE_CLASS=PocketsphinxSpeechRecognitionEngine.m
557fi
558AC_SUBST(BUILD_SPEECH_RECOGNIZER)
559AC_SUBST(RECOGNIZER_BASE_LIBS)
560AC_SUBST(RECOGNIZER_BASE_CFLAGS)
561AC_SUBST(RECOGNIZER_ENGINE_CLASS)
562
563#--------------------------------------------------------------------
564# Find CUPS
565#--------------------------------------------------------------------
566GSCUPS_CFLAGS=
567GSCUPS_LDFLAGS=
568GSCUPS_LIBS=
569GSCUPS_DATADIR=
570BUILD_GSCUPS=NO
571
572AC_ARG_ENABLE(cups,
573  [  --disable-cups          Disable cups printing support],,
574  enable_cups=yes)
575
576if test $enable_cups = yes; then
577  BUILD_GSCUPS=YES
578  AC_CHECK_PROG(have_cups, cups-config, yes, no)
579
580  if test $have_cups = no; then
581    echo "Could not find cups-config program, cups printing support will not be built."
582    enable_cups=no
583    BUILD_GSCUPS=NO
584  else
585    GSCUPS_CFLAGS=`cups-config --cflags`
586    GSCUPS_LDFLAGS=`cups-config --ldflags`
587    GSCUPS_LIBS=`cups-config --libs`
588    GSCUPS_DATADIR=`cups-config --datadir`
589
590    orig_CPPFLAGS="${CPPFLAGS}"
591    orig_LDFLAGS="${LDFLAGS}"
592    CPPFLAGS="$GSCUPS_CFLAGS ${CPPFLAGS}"
593    LDFLAGS="$GSCUPS_LDFLAGS ${LDFLAGS}"
594
595    AC_CHECK_HEADERS(cups/cups.h, have_cups=yes, have_cups=no)
596    if test "$have_cups" = no; then
597      enable_cups=no
598      BUILD_GSCUPS=NO
599      echo "Could not find cups.h, cups printing support will not be built."
600    fi
601    AC_CHECK_LIB(cups, cupsServer, have_cups=yes, have_cups=no)
602    if test "$have_cups" = no; then
603      enable_cups=no
604      BUILD_GSCUPS=NO
605      echo "Could not find the cups library, cups printing support will not be built."
606    fi
607    CPPFLAGS="${orig_CPPFLAGS}"
608    LDFLAGS="${orig_LDFLAGS}"
609  fi
610fi
611AC_SUBST(GSCUPS_CFLAGS)
612AC_SUBST(GSCUPS_LDFLAGS)
613AC_SUBST(GSCUPS_LIBS)
614AC_SUBST(GSCUPS_DATADIR)
615AC_SUBST(BUILD_GSCUPS)
616
617#--------------------------------------------------------------------
618# Check for -Wdeclaration-after-statement
619#--------------------------------------------------------------------
620AC_MSG_CHECKING(whether the compiler supports -Wdeclaration-after-statement)
621
622saved_CFLAGS="$CFLAGS"
623CFLAGS="$CFLAGS -Wdeclaration-after-statement"
624AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],HAS_W_DECL_AFTER_STATEMENT=yes,HAS_W_DECL_AFTER_STATEMENT=no)
625CFLAGS="$saved_CFLAGS"
626
627AC_MSG_RESULT($HAS_W_DECL_AFTER_STATEMENT)
628
629if test x"$HAS_W_DECL_AFTER_STATEMENT" = x"yes"; then
630  WARN_FLAGS="-Wall -Wdeclaration-after-statement"
631else
632  WARN_FLAGS=-Wall
633fi
634
635AC_SUBST(WARN_FLAGS)
636
637#--------------------------------------------------------------------
638# Record the version
639#--------------------------------------------------------------------
640AC_MSG_CHECKING(for the version of gnustep-gui we are compiling)
641if test -f "Version"; then
642  . ./Version
643fi
644AC_MSG_RESULT($GNUSTEP_GUI_VERSION)
645AC_SUBST(GNUSTEP_GUI_VERSION)
646AC_SUBST(GNUSTEP_GUI_MAJOR_VERSION)
647AC_SUBST(GNUSTEP_GUI_MINOR_VERSION)
648AC_SUBST(GNUSTEP_GUI_SUBMINOR_VERSION)
649
650CONFIG_SYSTEM_INCL="$CONFIG_SYSTEM_INCL $GRAPHIC_CFLAGS"
651CONFIG_SYSTEM_LIB_DIR="$CONFIG_SYSTEM_LIB_DIR $GRAPHIC_LFLAGS"
652
653AC_SUBST(CONFIG_SYSTEM_LIB_DIR)
654AC_SUBST(CONFIG_SYSTEM_INCL)
655AC_SUBST(cross_compiling)
656
657#--------------------------------------------------------------------
658# Configure
659#--------------------------------------------------------------------
660AH_BOTTOM([
661/* Define for those who don't have rintf and/or rint */
662#ifndef HAVE_RINTF
663#define rintf rint
664#endif
665#ifndef HAVE_RINT
666#define DEFINE_RINT_IF_MISSING   \
667static double rint(double a)     \
668{                                \
669  return (floor(a+0.5));         \
670}
671#else
672#define DEFINE_RINT_IF_MISSING
673#endif
674])
675
676AC_CONFIG_FILES([config.make gui.make Headers/Additions/GNUstepGUI/GSVersion.h])
677AC_OUTPUT
678