1dnl Process this file with autoconf to produce a configure script.
2dnl
3dnl This program is free software; you can redistribute it and/or modify
4dnl it under the terms of the GNU General Public License as published by
5dnl the Free Software Foundation; either version 2 of the License, or
6dnl (at your option) any later version.
7dnl
8dnl This program is distributed in the hope that it will be useful,
9dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11dnl GNU General Public License for more details.
12dnl
13dnl You should have received a copy of the GNU General Public License
14dnl along with this program; if not, write to the Free Software
15dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16
17AC_INIT([worker], [4.10.0])
18AC_CONFIG_SRCDIR([src/worker.cc])
19AM_CONFIG_HEADER(src/aguix/aguixconfig.h)
20AM_INIT_AUTOMAKE
21dnl AM_MAINTAINER_MODE
22AC_CONFIG_MACRO_DIR([m4])
23
24dnl Checks for programs.
25AC_PROG_CC
26AC_PROG_CXX
27AM_PROG_LEX
28AC_PROG_YACC
29
30AC_LANG([C++])
31AC_TRY_COMPILE([],
32               [ int test=0; test=5; ],
33               [],
34               [ AC_MSG_ERROR([The C++ compiler doesn't work or doesn't exists at all!
35*********************************************************************
36* Check your C++ installation (many distributions have a separate   *
37* package for the C++ compiler).                                    *
38*********************************************************************])
39               ])
40
41AC_ARG_ENABLE(cxx-check,
42	AS_HELP_STRING([--disable-cxx-check],[skip compiler tests]),
43	[cxx_check=$enableval],
44        [cxx_check=yes])
45
46AX_COMPILER_VENDOR
47
48if test "$cxx_check" = "yes"; then
49    old_CXXFLAGS="$CXXFLAGS"
50    cxx14="no"
51
52    case "$ax_cv_cxx_compiler_vendor" in
53    gnu)
54      AX_GXX_VERSION
55      if test -n "$GXX_VERSION"; then
56         gxx_version_major=$(echo $GXX_VERSION | $AWK -F. '{print int($1)}')
57         gxx_version_minor=$(echo $GXX_VERSION | $AWK -F. '{print int($2)}')
58         gxx_version_patch=$(echo $GXX_VERSION | $AWK -F. '{print int($3)}')
59         if test "$gxx_version_major" -lt "4" -o \( "$gxx_version_major" -eq "4" -a "$gxx_version_minor" -lt "6" \); then
60             AC_MSG_ERROR([
61*********************************************************************
62* GCC versions lower than 4.6.0 are not supported!                  *
63*********************************************************************])
64         fi
65
66         dnl 4.9.0/4.9.1 generate wrong code, maybe because of undefined behavior in Worker or a bug in gcc
67
68         if test "$gxx_version_major" -eq "4" -a "$gxx_version_minor" -eq "9" -a "$gxx_version_patch" -lt "2"; then
69             AC_MSG_ERROR([
70*********************************************************************
71* Due to a code optimizer problem, GCC 4.9.0/1 is not supported.    *
72* You may install a different compiler version and rerun this       *
73* script like "CXX=g++-4.8 ./configure ..." to use that version.    *
74*********************************************************************])
75         fi
76      fi
77      ;;
78    clang)
79      AC_MSG_CHECKING([whether Clang is new enough])
80      AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
81      #if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
82      #error Old clang
83      #endif
84      ]])],
85                        [ AC_MSG_RESULT([yes]) ],
86                        [ AC_MSG_RESULT([no])
87                          AC_MSG_ERROR([
88*********************************************************************
89* Compiling Worker has been tested only with Clang 3.4 and 3.5.     *
90* Use either those or later versions.                               *
91* You can disable this check with "--disable-cxx-check"             *
92*********************************************************************
93])])
94      ;;
95    *)
96      AC_MSG_ERROR([GNU C++ or Clang compiler is required
97You can disable this check with "--disable-cxx-check" if your C++ compiler is able to compile C++14 code.
98      ])
99      ;;
100    esac
101
102    CXXFLAGS="$CXXFLAGS -std=c++14"
103    AC_MSG_CHECKING([whether the C++ works with "-std=c++14"])
104    AC_TRY_COMPILE([],
105                   [ int test=0; test=5; ],
106                   [ AC_MSG_RESULT(yes)
107                     cxx14=yes ],
108                   [ AC_MSG_RESULT(no)
109                     CXXFLAGS="$old_CXXFLAGS"
110                   ])
111
112    if test "$cxx14" = "no"; then
113      AC_MSG_ERROR([Your version of the GNU C++ compiler does not seem to be C++14 compatible.
114You can disable this check with "--disable-cxx-check" if your C++ compiler is able to compile C++14 code
115      ])
116    fi
117fi
118
119AC_PROG_INSTALL
120dnl AC_PROG_RANLIB
121AC_PROG_AWK
122AC_PROG_LIBTOOL
123
124AC_LIBTOOL_SYS_MAX_CMD_LEN
125
126AS_IF([expr \( 0 + $lt_cv_sys_max_cmd_len \) '>=' -1 >/dev/null],
127      [max_cmd_len_to_use=$lt_cv_sys_max_cmd_len],
128      [max_cmd_len_to_use=256
129       AS_BOX([WARNING: Maximum command line length could not be determined, assuming 256!])
130      ])
131
132AC_DEFINE_UNQUOTED(MAX_CMD_LEN, $max_cmd_len_to_use, [Set to the maximum length of the command line])
133
134AC_DEFINE(_GNU_SOURCE, 1, [Try to use GNU extensions])
135
136PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [usetests=yes], [usetests=no])
137AM_CONDITIONAL([USE_TESTS], [test x$usetests = xyes])
138
139dnl Checks for header files.
140AC_PATH_X
141AC_PATH_XTRA
142
143if test "$no_x"; then
144	AC_MSG_ERROR([X Window libraries and headers not found!
145*********************************************************************
146* Check your X installation (many distributions have these files in *
147* the ...devel-packages (e.g. libx11-dev or libX11-devel)).         *
148*********************************************************************])
149fi
150
151dnl rtti test for visualage compiler on aix
152if test "$GCC" != "yes"; then
153  case "$CXX" in
154    *xlc*|*xlC*)
155      CXXFLAGS="-qrtti=all $CXXFLAGS"
156    ;;
157  esac
158fi
159
160AVFS_LDFLAGS=""
161
162ac_cv_have_avfs=no
163avfs_too_old=no
164avfs_insecure_version=no
165
166AC_ARG_WITH(avfs,AC_HELP_STRING([--with-avfs],[use avfs (default is YES)]),
167              ac_cv_use_avfs=$withval, ac_cv_use_avfs=yes)
168if test "$ac_cv_use_avfs" = "yes"; then
169  AC_ARG_WITH(avfs-path,AC_HELP_STRING([--with-avfs-path=PATH],[PATH to avfsconfig (default: autoconfig)]),
170              p="$withval:$PATH", p="$PATH")
171  AC_PATH_PROG(avfsconf,avfs-config,,[$p])
172  if test -x "$avfsconf"; then
173    avfs_version=$($avfsconf --version)
174    avfs_version_major=$(echo $avfs_version | $AWK -F. '{print int($1)}')
175    avfs_version_minor=$(echo $avfs_version | $AWK -F. '{print int($2)}')
176    avfs_version_patch=$(echo $avfs_version | $AWK -F. '{print int($3)}')
177    if test "$avfs_version_major" -gt "0" -o \
178            \( "$avfs_version_major" -eq "0" -a "$avfs_version_minor" -gt "9" \) -o \
179            \( "$avfs_version_major" -eq "0" -a "$avfs_version_minor" -eq "9" -a "$avfs_version_patch" -gt "3" \); then
180      CPPFLAGS="$CPPFLAGS $($avfsconf --cflags)"
181      AVFS_LDFLAGS="$($avfsconf --libs)"
182      AC_DEFINE(HAVE_AVFS, 1, [Define to 1 if your system supports avfs])
183      ac_cv_have_avfs=yes
184    else
185      avfs_too_old=yes
186    fi
187
188    if test "$avfs_version_major" -lt "1" -o \
189            \( "$avfs_version_major" -eq "1" -a "$avfs_version_minor" -lt "1" \) -o \
190            \( "$avfs_version_major" -eq "1" -a "$avfs_version_minor" -eq "1" -a "$avfs_version_patch" -lt "1" \); then
191      avfs_insecure_version=yes
192    else
193      avfs_insecure_version=no
194    fi
195  fi
196fi
197
198if test "$ac_cv_have_avfs" != "yes"; then
199  AC_SYS_LARGEFILE
200fi
201
202AC_HEADER_DIRENT
203AC_HEADER_STDC
204AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h)
205
206dnl Checks for libraries.
207dnl AC_CHECK_LIB(X11,XCreateWindow)
208AC_CHECK_LIB(m,pow)
209
210dnl Checks for typedefs, structures, and compiler characteristics.
211AC_C_CONST
212AC_TYPE_UID_T
213AC_TYPE_MODE_T
214AC_TYPE_SIZE_T
215AC_HEADER_TIME
216AC_STRUCT_TM
217
218AC_TYPE_OFF_T
219AC_CHECK_SIZEOF(off_t)
220
221dnl The next one is more difficult
222dnl When loff_t isn't available it should be 64bit wide
223dnl When off_t is already 64bit use it otherwise test for
224dnl 64bit wide long long  and use as fallback off_t no matter
225dnl how wide it is
226AC_CHECK_TYPE(loff_t,[AC_CHECK_SIZEOF(loff_t)],
227                     [use_off_t=1
228                      AC_TRY_COMPILE([
229#if ( SIZEOF_OFF_T == 8 )
230#  include <unistd.h>
231#else
232#  error
233#endif
234                                     ],
235                                     [int i],
236                                     [],
237                                     [AC_CHECK_TYPE(long long,
238                                                    [AC_CHECK_SIZEOF(long long)
239                                                     AC_TRY_COMPILE([
240#if ( SIZEOF_LONG_LONG == 8 )
241#  include <unistd.h>
242#else
243#  error
244#endif
245                                                                    ],
246                                                                    [int i],
247                                                                    [use_off_t=0
248                                                                     AC_DEFINE([loff_t], [long long],
249                                                                               [Define to `long long' if <sys/types.h> does not define.])
250                                                                     AC_DEFINE([SIZEOF_LOFF_T], [SIZEOF_LONG_LONG])
251                                                                    ],[])
252                                                    ],[])
253                                     ])
254                      if test "$use_off_t" = "1"; then
255                        AC_DEFINE([loff_t], [off_t],
256                                  [Define to `off_t' if <sys/types.h> does not define.])
257                        AC_DEFINE([SIZEOF_LOFF_T], [SIZEOF_OFF_T])
258                      fi
259                     ])
260
261dnl To support large files I need at least this prerequisites
262dnl 1.sizeof(loff_t) == 8
263dnl 2.1.sizeof(off_t) == 8 OR
264dnl 2.2.defining _LARGEFILE64_SOURCE results in defined _LFS64_... stuff
265dnl     which means nothing other then there are stat64/open64...
266dnl     which big values I can store in loff_t
267
268support_lfs=no
269if test "$enable_largefile" != no; then
270  AC_MSG_CHECKING(whether we can support large files)
271  dnl first test: Can we support it at all?
272  AC_TRY_COMPILE([
273#if ( SIZEOF_LOFF_T == 8 )
274#  include <unistd.h>
275#else
276#  error
277#endif],
278  [int i],
279  can_lfs=yes,
280  can_lfs=no)
281
282  if test "$can_lfs" = "yes"; then
283    dnl second test: do we need additional defines
284    AC_TRY_COMPILE([
285#if ( SIZEOF_OFF_T == 8 )
286#  include <unistd.h>
287#else
288#  error
289#endif],
290    [int i],
291    native_lfs=yes,
292    native_lfs=no)
293
294    if test "$native_lfs" = "yes"; then
295      support_lfs=yes
296    elif test "$ac_cv_have_avfs" != "yes"; then
297      dnl third test: do we get support when requesting?
298      dnl applies only when not using avfs
299      AC_TRY_COMPILE([
300#define _LARGEFILE64_SOURCE 1
301#define _LARGEFILE_SOURCE 1
302#include <unistd.h>
303#ifndef _LFS_LARGEFILE
304#  error
305#endif
306#ifndef _LFS64_LARGEFILE
307#  error
308#endif
309#ifndef _LFS64_STDIO
310#  error
311#endif
312#include <sys/types.h>
313#include <sys/stat.h>
314#include <fcntl.h>
315#include <dirent.h>
316#include <sys/statvfs.h>
317],
318      [struct stat64 buf1;
319       struct dirent64 buf2;
320       struct statvfs64 buf3;
321
322       stat64( "", &buf1 );
323       lstat64( "", &buf1 );
324       open64( "", 0);
325       readdir64( NULL );
326       statvfs64( "", &buf3 );
327      ],
328      have_explicit_lfs=yes,
329      have_explicit_lfs=no)
330
331      if test "$have_explicit_lfs" = "yes"; then
332        AC_DEFINE(HAVE_EXPLICIT_LFS, 1, [Define to 1 if your system supports lfs with open64/...])
333        support_lfs=yes
334      fi
335    fi
336  fi
337  AC_MSG_RESULT($support_lfs)
338fi
339
340dnl Checks for library functions.
341AC_CHECK_FUNCS(strverscmp)
342AC_CHECK_FUNCS(strcasecmp)
343
344AC_CHECK_FUNCS(lockf)
345
346AC_FUNC_FNMATCH
347
348dnl AC_FUNC_GETMNTENT
349gl_MOUNTLIST
350
351AC_MSG_CHECKING([whether GNU fnmatch is available])
352AC_TRY_COMPILE([#include <fnmatch.h>],
353               [fnmatch("","",FNM_CASEFOLD);],
354               [ AC_DEFINE(HAVE_GNU_FNMATCH)
355                 AC_MSG_RESULT(yes) ],
356               [ AC_MSG_RESULT(no) ]);
357
358AC_FUNC_STRFTIME
359AC_CHECK_FUNCS(mkdir)
360dnl AC_CHECK_FUNCS(nanosleep,,[AC_CHECK_LIB(posix4,nanosleep)])
361AC_CHECK_FUNCS(nanosleep,,
362               [AC_CHECK_LIB(posix4, nanosleep,
363                             [LIBS="$LIBS -lposix4"
364                              AC_DEFINE(HAVE_NANOSLEEP)
365                             ],
366                             [AC_CHECK_LIB(rt, nanosleep,
367                                           [LIBS="$LIBS -lrt"
368                                            AC_DEFINE(HAVE_NANOSLEEP)],
369                                           [no_nanosleep="yes"])
370                             ])
371               ])
372AC_CHECK_FUNCS(usleep,,[no_usleep="yes"])
373
374if test "$no_nanosleep" -a "$no_usleep"; then
375	AC_MSG_ERROR([Neither nanosleep nor usleep was found!
376*********************************************************************
377* Worker need at least on of this. Please contact the author at     *
378*     http://www.boomerangsworld.de/cms/worker/support.html         *
379* and I will try to help!                                           *
380*********************************************************************])
381fi
382
383AC_CHECK_FUNCS(getcwd gettimeofday mkdir select strstr)
384
385dnl how to get file information
386have_statvfs=no
387AC_CHECK_HEADERS(sys/statvfs.h,[
388		 AC_CHECK_FUNCS(statvfs,[have_statvfs=yes])
389		])
390if test "$have_statvfs" = no; then
391  have_statfs_inc=no
392  AC_CHECK_HEADERS(sys/vfs.h,[have_statfs_inc=yes])
393  AC_CHECK_HEADERS(sys/param.h,[
394  		   AC_CHECK_HEADERS(sys/mount.h,[have_statfs_inc=yes],,[#include <sys/param.h>])
395                   ])
396  if test "$have_statfs_inc" = yes; then
397    AC_CHECK_FUNCS(statfs)
398  fi
399else
400  dnl the include on (some?) SUN systems use statvfs_t instead of struct statvfs
401  dnl so add another check for this
402  AC_MSG_CHECKING([whether statvfs_t is available])
403  AC_TRY_COMPILE([#include <sys/statvfs.h>],
404                 [statvfs_t b1;],
405                 [ AC_DEFINE(HAVE_STATVFS_T)
406                   AC_MSG_RESULT(yes) ],
407                 [ AC_MSG_RESULT(no) ]);
408fi
409
410dnl check for sysinfo
411dnl because it's linux specific use special
412dnl check to make sure it's really the function
413dnl I want
414AC_CHECK_HEADERS(sys/sysinfo.h,[
415		 AC_MSG_CHECKING([whether sysinfo call works as expected])
416		 AC_TRY_LINK([#include <sys/sysinfo.h>],
417    				[struct sysinfo info;sysinfo(&info);info.mem_unit=1;],
418				[ AC_DEFINE(HAVE_SYSINFO)
419                                  AC_MSG_RESULT(yes) ],
420				[ AC_MSG_RESULT(no) ]);
421                ])
422
423have_regex=no
424AC_CHECK_HEADER(regex.h,
425                [AC_CHECK_FUNC(regcomp,
426                               [AC_CHECK_FUNC(regexec,
427                                              [AC_CHECK_FUNC(regfree,[AC_DEFINE(HAVE_REGEX)
428                                                                      have_regex=yes ])
429                                              ]
430                                              )
431                               ])
432                ])
433
434dnl I changed from ANSI C signal to POSIX sigaction
435dnl but it is not needed; I made it optional
436AC_CHECK_HEADER(signal.h,
437                [AC_CHECK_FUNCS(sigaction)]
438               )
439AC_CHECK_FUNCS( snprintf )
440AC_CHECK_FUNCS( getopt_long )
441
442dnl check for pthread library
443AX_PTHREAD([AC_DEFINE(HAVE_LIBPTHREAD)
444            LIBS="$PTHREAD_LIBS $LIBS"
445            CPPFLAGS="$CPPFLAGS $PTHREAD_CFLAGS"
446           ],
447           [AC_MSG_ERROR([Couldn't find Pthreads library!
448*********************************************************************
449* Worker requires a working Pthreads library                        *
450*********************************************************************])
451           ])
452
453dnl libmagic
454have_libmagic=no
455AC_ARG_WITH(libmagic,
456	AS_HELP_STRING([--with-libmagic],[use libmagic library]),
457	[use_libmagic=$withval],
458        [use_libmagic=yes])
459
460if test "$use_libmagic" = "yes"; then
461    AC_CHECK_HEADER(magic.h,
462                    [AC_CHECK_LIB(magic,magic_open,[AC_DEFINE(HAVE_LIBMAGIC, 1, [Define to 1 if your system supports libmagic])
463                                                    LIBS="$LIBS -lmagic"
464                                                    have_libmagic=yes ])
465                    ])
466fi
467
468dnl check for XIM
469AC_ARG_ENABLE(xim,
470	AS_HELP_STRING([--disable-xim],[do not use X11 XIM]),
471	[use_xim=$enableval],
472        [use_xim=yes])
473
474if test "$use_xim" = "yes"; then
475dnl   AC_CHECK_LIB(X11,XOpenIM,
476dnl                [AC_DEFINE(USE_XIM)],
477dnl                [use_xim=no], $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS )
478  AC_DEFINE(USE_XIM)
479fi
480
481
482dnl UTF8 option
483AC_ARG_ENABLE(utf8,
484	AS_HELP_STRING([--disable-utf8],[disable utf8 support]),
485	[use_utf8=$enableval],
486        [use_utf8=yes])
487
488if test "$use_utf8" = "no"; then
489  AC_DEFINE(DISABLE_UTF8_SUPPORT)
490fi
491
492
493
494dnl AC_ARG_ENABLE(cygwin-workaround,
495dnl 	AS_HELP_STRING([--enable-cygwin-workaround],[Enable some cygwin workarounds]),
496dnl 	[cygwin_workarounds=$enableval],
497dnl 	[cygwin_workarounds=no])
498
499dnl if test "$cygwin_workarounds" = no; then
500AC_CHECK_FUNCS(shmget shmat shmdt,[AC_DEFINE(HAVE_SHM, 1, [Define to 1 if your system supports shm])])
501dnl fi
502
503
504AC_ARG_ENABLE(debug,
505	AS_HELP_STRING([--enable-debug],[compile some debug information]),
506	[use_debug=$enableval],
507	[use_debug=no])
508
509if test "$use_debug" = yes; then
510	AC_DEFINE(DEBUG)
511fi
512
513dnl check for XFT
514
515dnl direct call since PKG_CHECK_EXISTS is only called conditionally
516PKG_PROG_PKG_CONFIG
517
518XFT_LDFLAGS=""
519ac_cv_have_xft=no
520have_xft=no
521
522AC_ARG_ENABLE(xft,
523	AS_HELP_STRING([--disable-xft],[disable use of XFT font library]),
524	[use_xft=$enableval],
525        [use_xft=yes])
526
527if test "$use_xft" = "yes"; then
528    PKG_CHECK_EXISTS([xft],[
529                     PKG_CHECK_MODULES([XFT],[xft],
530                                       [have_xft=yes
531                                       ])
532                     ])
533
534    AC_MSG_CHECKING(for xft)
535    if test "$have_xft" = "yes"; then
536        CXXFLAGS="$CXXFLAGS $XFT_CFLAGS"
537        LIBS="$LIBS $XFT_LIBS"
538        AC_DEFINE(HAVE_XFT, 1, [Define to 1 if your system has XFT])
539        ac_cv_have_xft=yes
540    fi
541    AC_MSG_RESULT($have_xft)
542fi
543
544ac_cv_have_lua=no
545have_lua=no
546
547AC_ARG_ENABLE(lua,
548	AS_HELP_STRING([--disable-lua],[disable use of LUA scripting engine]),
549	[use_lua=$enableval],
550        [use_lua=yes])
551
552if test "$use_lua" = "yes"; then
553    PKG_CHECK_EXISTS([lua],[
554                     PKG_CHECK_MODULES([LUA],[lua],
555                                       [have_lua=yes
556                                       ])
557                     ])
558    if test "$have_lua" = "no"; then
559        PKG_CHECK_EXISTS([lua5.2],[
560                         PKG_CHECK_MODULES([LUA],[lua5.2],
561                                           [have_lua=yes
562                                           ])
563                         ])
564    fi
565
566    if test "$have_lua" = "no"; then
567        PKG_CHECK_EXISTS([lua5.1],[
568                         PKG_CHECK_MODULES([LUA],[lua5.1],
569                                           [have_lua=yes
570                                           ])
571                         ])
572    fi
573    if test "$have_lua" = "no"; then
574        PKG_CHECK_EXISTS([lua-5.1],[
575                         PKG_CHECK_MODULES([LUA],[lua-5.1],
576                                           [have_lua=yes
577                                           ])
578                         ])
579    fi
580    if test "$have_lua" = "no"; then
581        PKG_CHECK_EXISTS([lua-5.2],[
582                         PKG_CHECK_MODULES([LUA],[lua-5.2],
583                                           [have_lua=yes
584                                           ])
585                         ])
586    fi
587
588    AC_MSG_CHECKING(for lua)
589    if test "$have_lua" = "yes"; then
590        CXXFLAGS="$CXXFLAGS $LUA_CFLAGS"
591        LIBS="$LIBS $LUA_LIBS"
592        AC_DEFINE(HAVE_LUA, 1, [Define to 1 if your system has LUA])
593        ac_cv_have_lua=yes
594    fi
595    AC_MSG_RESULT($have_lua)
596fi
597
598dnl check for openssl
599PKG_CHECK_EXISTS([openssl],[
600                 PKG_CHECK_MODULES([OPENSSL],[openssl],
601                                   [have_openssl=yes
602                                   ])
603                 ])
604
605if test "$have_openssl" = "yes"; then
606    CXXFLAGS="$CXXFLAGS $OPENSSL_CFLAGS"
607    LIBS="$LIBS $OPENSSL_LIBS"
608    AC_DEFINE(HAVE_OPENSSL, 1, [Define to 1 if your system has openssl])
609    ac_cv_have_openssl=yes
610
611    AC_CHECK_HEADER(openssl/sha.h,
612                    [AC_CHECK_FUNC(SHA256_Init,[AC_DEFINE(HAVE_OPENSSL_SHA256, 1, [Define to 1 if your system support SHA256 from OpenSSL])
613                                                have_openssl_sha256=yes])
614                    ])
615fi
616
617dnl check for getfsent
618AC_CHECK_HEADERS(fstab.h,[
619		 AC_MSG_CHECKING([checking for getfsent])
620		 AC_TRY_COMPILE([#include <fstab.h>],
621    				[struct fstab *fstab_entry;fstab_entry = getfsent();],
622				[ AC_DEFINE([HAVE_GETFSENT],[1],[Define to 1 if getfsent is available])
623                                  AC_MSG_RESULT(yes) ],
624				[ AC_MSG_RESULT(no) ])
625                ])
626dnl check for getmntinfo from FreeBSD
627AC_CHECK_HEADERS([sys/param.h],[
628                 AC_CHECK_HEADERS([sys/ucred.h],[
629                                  AC_CHECK_HEADERS([sys/mount.h],[
630                                                   AC_MSG_CHECKING([checking for getmntinfo with statfs args])
631                                                   AC_TRY_COMPILE([#include <sys/param.h>
632                                                                   #include <sys/ucred.h>
633                                                                   #include <sys/mount.h>],
634                                                                  [struct statfs *mount_entries;int n;n = getmntinfo( &mount_entries, MNT_NOWAIT );],
635                                                                  [ AC_DEFINE([HAVE_GETMNTINFO_FBSD],[1],[Define to 1 if getmntinfo is available in statfs variant])
636                                                                    AC_MSG_RESULT(yes) ],
637                                                                  [ AC_MSG_RESULT(no) ])
638                                                   ])
639                                  ])
640                ])
641dnl check for getmntinfo from NetBSD
642AC_CHECK_HEADERS([sys/types.h],[
643                 AC_CHECK_HEADERS([sys/statvfs.h],[
644                                  AC_MSG_CHECKING([checking for getmntinfo with statvfs args])
645                                  AC_TRY_COMPILE([#include <sys/types.h>
646                                                  #include <sys/statvfs.h>],
647                                                 [struct statvfs *mount_entries;int n;n = getmntinfo( &mount_entries, ST_NOWAIT );],
648                                                 [ AC_DEFINE([HAVE_GETMNTINFO_NBSD],[1],[Define to 1 if getmntinfo is available in statvfs variant])
649                                                   AC_MSG_RESULT(yes) ],
650                                                 [ AC_MSG_RESULT(no) ])
651                                  ])
652                ])
653
654AC_ARG_ENABLE(developer,
655	[  --enable-developer	  compile developer version],
656	use_developer=$enableval,
657	use_developer=no)
658
659if test "$use_developer" = yes; then
660	AC_DEFINE(DEVELOPER)
661fi
662
663dnl LIBS=" -lX11 $LIBS"
664
665WORKER_LDADD="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $AVFS_LDFLAGS $XFT_LDFLAGS"
666
667dnl Checks for header files.
668AC_SUBST(X_CFLAGS)
669AC_SUBST(X_PRE_LIBS)
670AC_SUBST(X_EXTRA_LIBS)
671AC_SUBST(x_libraries)
672AC_SUBST(WORKER_LDADD)
673dnl CPPFLAGS="$CPPFLAGS -Wall"
674dnl CXXFLAGS="$CXXFLAGS -fcheck-new"
675
676dnl Check for compile error when adding X_CFLAGS to CPPFLAGS
677dnl as I know this is a problem on Solaris
678AC_CACHE_CHECK(for needed X include dir,
679		ac_cv_dneedxf,[AC_TRY_COMPILE([#include <X11/Xlib.h>],
680		[int x; x=0;], ac_cv_dneedxf=no, ac_cv_dneedxf=yes)])
681if test x$ac_cv_dneedxf = xyes; then
682	CPPFLAGS="$CPPFLAGS $X_CFLAGS"
683fi
684
685dnl Check if XRegisterIMInstantiateCallback can be used as expected
686if test "$use_xim" = "yes"; then
687  AC_MSG_CHECKING(for good XRegisterIMInstantiateCallback)
688
689  AC_TRY_COMPILE([#include <X11/Xlib.h>
690      void AGUIX_im_inst_callback( Display *calldsp, XPointer client_data, XPointer call_data )
691      {
692      }
693    ],
694    [XRegisterIMInstantiateCallback( NULL, NULL, NULL, NULL, AGUIX_im_inst_callback, (XPointer)0);],
695    xregisterokay=yes,
696    xregisterokay=no );
697
698  if test "$xregisterokay" = "yes" ; then
699    AC_DEFINE(XIM_XREGISTER_OKAY)
700  fi
701  AC_MSG_RESULT($xregisterokay)
702fi
703
704dnl Check for XSetIMValues prototype
705dnl it's not available on my machine
706if test "$use_xim" = "yes"; then
707  AC_MSG_CHECKING(for XSetIMValues prototype)
708
709  save_CPPFLAGS=$CPPFLAGS
710  CPPFLAGS="$CPPFLAGS -Werror"
711  AC_TRY_COMPILE([#include <X11/Xlib.h>],
712    [XSetIMValues( NULL, NULL );],
713    xsetimvaluespt=yes,
714    xsetimvaluespt=no );
715  CPPFLAGS=$save_CPPFLAGS
716
717  if test "$xsetimvaluespt" = "yes" ; then
718    AC_DEFINE(HAVE_XSETIMVALUES_PROTOTYPE)
719  fi
720  AC_MSG_RESULT($xsetimvaluespt)
721fi
722
723have_hal_dbus=no
724AC_ARG_WITH(hal,AC_HELP_STRING([--with-hal],[use hal (default is YES)]),
725            ac_cv_use_hal=$withval, ac_cv_use_hal=yes)
726have_dbus=no
727AC_ARG_WITH(dbus,AC_HELP_STRING([--with-dbus],[use dbus (default is YES)]),
728            ac_cv_use_dbus=$withval, ac_cv_use_dbus=yes)
729
730if test "$ac_cv_use_dbus" = "yes"; then
731    PKG_CHECK_EXISTS([dbus-1],[
732                     PKG_CHECK_MODULES([DBUS],[dbus-1],
733                                       [have_dbus=yes])
734                     ])
735
736    AC_MSG_CHECKING(for dbus-1 and hal-storage)
737    if test "$have_dbus" = "yes"; then
738        AC_MSG_RESULT("yes")
739
740        if test "$ac_cv_use_hal" = "yes"; then
741            PKG_CHECK_EXISTS([hal-storage],[
742                             PKG_CHECK_MODULES([HAL_STORAGE],[hal-storage],
743                                               [have_hal_dbus=yes])
744                             ])
745        fi
746
747        if test "$have_hal_dbus" = "yes"; then
748            AC_MSG_CHECKING(for hal-storage)
749            AC_DEFINE(HAVE_HAL_DBUS, 1, [Define to 1 if your system supports DBUS/HAL])
750            CXXFLAGS="$CXXFLAGS $DBUS_CFLAGS $HAL_STORAGE_CFLAGS"
751            LIBS="$LIBS $DBUS_LIBS $HAL_STORAGE_LIBS"
752            AC_MSG_RESULT("yes")
753            have_dbus=no
754        else
755            if test "$ac_cv_use_hal" = "yes"; then
756                AC_MSG_CHECKING(for hal-storage)
757                AC_MSG_RESULT("no (using dbus for udisks support)")
758            fi
759            AC_MSG_CHECKING(for dbus)
760            AC_DEFINE(HAVE_DBUS, 1, [Define to 1 if your system supports DBUS])
761            CXXFLAGS="$CXXFLAGS $DBUS_CFLAGS"
762            LIBS="$LIBS $DBUS_LIBS"
763            AC_MSG_RESULT("yes")
764        fi
765    else
766        AC_MSG_RESULT("no")
767    fi
768fi
769
770dnl check for XConnectionNumber
771AC_MSG_CHECKING(for XConnectionNumber)
772
773save_CPPFLAGS=$CPPFLAGS
774CPPFLAGS="$CPPFLAGS -Werror"
775AC_TRY_COMPILE([#include <X11/Xlib.h>],
776               [XConnectionNumber( NULL );],
777               xconnectionnumber=yes,
778               xconnectionnumber=no );
779CPPFLAGS=$save_CPPFLAGS
780
781if test "$xconnectionnumber" = "yes" ; then
782    AC_DEFINE(HAVE_XCONNECTIONNUMBER, 1, [Define to 1 if your system has the XConnectionNumber function])
783fi
784AC_MSG_RESULT($xconnectionnumber)
785
786CHECK_XINERAMA([AC_DEFINE(HAVE_XINERAMA, 1, [Define to 1 if your system has Xinerama support])
787                use_xinerama=yes],[use_xinerama=no])
788
789dnl ***********************
790dnl * check for -fcheck-new
791dnl * adapted from vice1.9 configure.in
792dnl ***********************
793
794dnl if test "$GXX" = "yes"; then
795dnl   old_CXXFLAGS="$CXXFLAGS"
796dnl   CXXFLAGS="$CXXFLAGS -fcheck-new"
797dnl   AC_MSG_CHECKING([whether the C++ works with "-fcheck-new"])
798dnl   AC_TRY_COMPILE([],
799dnl                  [ int test=0; test=5; ],
800dnl                  [ AC_MSG_RESULT(yes) ],
801dnl                  [ AC_MSG_RESULT(no)
802dnl                    CXXFLAGS="$old_CXXFLAGS"
803dnl                    ])
804dnl fi
805if test "$GXX" = "yes"; then
806  old_CXXFLAGS="$CXXFLAGS"
807  CXXFLAGS="$CXXFLAGS -Wall"
808  AC_MSG_CHECKING([whether the C++ works with "-Wall"])
809  AC_TRY_COMPILE([],
810                 [ int test=0; test=5; ],
811                 [ AC_MSG_RESULT(yes) ],
812                 [ AC_MSG_RESULT(no)
813                   CXXFLAGS="$old_CXXFLAGS"
814                   ])
815fi
816
817dnl inotify
818have_inotify=no
819AC_ARG_ENABLE(inotify,
820	AS_HELP_STRING([--disable-inotify],[disable use of inotify]),
821	[use_inotify=$enableval],
822        [use_inotify=yes])
823
824if test "$use_inotify" = "yes"; then
825    AC_CHECK_HEADER(sys/inotify.h,
826                    [AC_CHECK_FUNCS(inotify_init,[AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 if your system supports inotify])
827                                                  have_inotify=yes],
828                                                 [AC_SEARCH_LIBS([inotify_init],
829                                                                 [inotify],
830                                                                 [AC_DEFINE(HAVE_INOTIFY, 1, [Define to 1 if your system supports inotify])
831                                                                  have_inotify=yes])
832                                                 ])
833                    ])
834fi
835
836dnl inotify end
837
838if test "$prefix" = NONE; then
839  AC_DEFINE_UNQUOTED(PREFIX, "$ac_default_prefix")
840  instprefix=$ac_default_prefix
841else
842  AC_DEFINE_UNQUOTED(PREFIX, "$prefix")
843  instprefix=$prefix
844fi
845
846AH_TEMPLATE( [HAVE_NANOSLEEP], [Define to 1 if you have the `nanosleep' function.] )
847AH_TEMPLATE( [HAVE_SYSINFO], [Define to 1 if you have the linux `sysinfo' function.] )
848AH_TEMPLATE( [HAVE_REGEX], [Define to 1 when regular expressions are available.] )
849AH_TEMPLATE( [HAVE_LIBPTHREAD], [Define to 1 if you have the `pthread' library (-lpthread).] )
850AH_TEMPLATE( [USE_XIM], [Define to 1 for X11 XIM support.] )
851AH_TEMPLATE( [DEBUG], [Define to 1 for a debug version.] )
852AH_TEMPLATE( [DEVELOPER], [Define to 1 for a developer version.] )
853AH_TEMPLATE( [XIM_XREGISTER_OKAY], [Define to 1 when XRegisterIMInstantiateCallback is okay.] )
854AH_TEMPLATE( [HAVE_XSETIMVALUES_PROTOTYPE], [Define to 1 when the prototype for XSetIMValues is available.] )
855AH_TEMPLATE( [PREFIX], [Define to the install prefix.] )
856AH_TEMPLATE( [HAVE_STATVFS_T], [Define to 1 if you have statvfs_t.] )
857AH_TEMPLATE( [DISABLE_UTF8_SUPPORT], [Define to 1 for disabling utf8 support.] )
858AH_TEMPLATE( [HAVE_GNU_FNMATCH], [Define to 1 if you have GNU fnmatch.] )
859
860QUOTED_COMPANY_CLANG_ARGS=""
861for f in $CXXFLAGS; do
862    QUOTED_COMPANY_CLANG_ARGS="$QUOTED_COMPANY_CLANG_ARGS \"$f\""
863done
864for f in $CPPFLAGS; do
865    QUOTED_COMPANY_CLANG_ARGS="$QUOTED_COMPANY_CLANG_ARGS \"$f\""
866done
867AC_SUBST(QUOTED_COMPANY_CLANG_ARGS)
868
869AC_CONFIG_FILES([Makefile
870src/Makefile
871src/aguix/Makefile
872scripts/Makefile
873catalogs/Makefile
874Icons/Makefile
875examples/Makefile
876man/Makefile
877man/fr/Makefile
878man/it/Makefile
879m4/Makefile
880contrib/Makefile
881hints/Makefile
882config-updates/Makefile
883
884contrib/dir-locals.el
885])
886AC_OUTPUT
887
888echo ""
889echo "Configuration finished:"
890echo "  AVFS usage                  : $ac_cv_have_avfs"
891
892if test "$avfs_too_old" = "yes"; then
893echo "    AVFS version too old!"
894fi
895if test "$avfs_insecure_version" = "yes"; then
896echo "    AVFS version too old, containing security bugs, please consider update!"
897fi
898if test "$ac_cv_use_avfs" = "yes" -a ! "$ac_cv_have_avfs" = "yes"; then
899    echo "    *** Get at least version 0.9.5 from http://avf.sourceforge.net/ ***"
900    echo ""
901fi
902
903echo "  Large file support          : $support_lfs"
904echo "  Regular expressions support : $have_regex"
905echo "  X11 XIM usage               : $use_xim"
906
907echo "  X11 Xinerama support        : $use_xinerama"
908if test "$use_xinerama" != "yes"; then
909    echo "    *** To enable support, install libraries:"
910    echo "    ***  - libxinerama-dev or libXinerama-devel"
911    echo ""
912fi
913
914echo "  UTF8 support                : $use_utf8"
915
916echo "  Libmagic support            : $have_libmagic"
917if test "$use_libmagic" = "yes" -a ! "$have_libmagic" = "yes"; then
918    echo "    *** To enable support, install libraries:"
919    echo "    ***  - libmagic-dev or file-devel"
920    echo "    *** or get a recent version from ftp://ftp.astron.com/pub/file/ ***"
921    echo ""
922fi
923
924if test "$have_hal_dbus" = "yes"; then
925    echo "  DBUS device handling        : HAL"
926elif test "$have_dbus" = "yes"; then
927    echo "  DBUS device handling        : udisks"
928else
929    echo "  DBUS device handling        : no (fallback to fstab mounting)"
930    echo "    *** To enable support, install libraries:"
931    echo "    ***  - libdbus-1-dev or dbus-1-devel"
932    echo "    ***  - udisks or udisks2 (newer systems)"
933    echo "    ***  - hal-storage (older systems)"
934    echo ""
935fi
936
937echo "  Inotify support             : $have_inotify"
938echo "  LUA support                 : $have_lua"
939if test "$use_lua" = "yes" -a "$have_lua" != "yes"; then
940    echo "    *** To enable support, install libraries:"
941    echo "    ***  - liblua5.x-dev or lua53-devel"
942    echo ""
943fi
944
945if test "$ac_cv_have_xft" = "yes"; then
946    echo "  Font engine                 : Xft"
947else
948    echo "  Font engine                 : X11"
949    if test "$use_xft" = "yes"; then
950        echo "    *** To enable support for Xft, install libraries:"
951        echo "    ***  - libxft-dev or libXft-devel"
952        echo ""
953    fi
954fi
955
956if test "$have_openssl_sha256" = "yes"; then
957    echo "  OpenSSL SHA256              : yes"
958else
959    echo "  OpenSSL SHA256              : no"
960    echo "    *** install openssl-dev for checksumming support"
961fi
962
963if test "$use_debug" = "yes"; then
964  echo "  Debug code                  : $use_debug"
965fi
966if test "$use_developer" = "yes"; then
967  echo "  Developer version           : $use_developer"
968fi
969
970echo "  Maximum command line length : $max_cmd_len_to_use"
971
972echo ""
973echo "Installation prefix           : $instprefix"
974echo ""
975echo " To compile do"
976echo ""
977echo "   make"
978echo ""
979