tizen 2.0
[framework/base/util-linux-ng.git] / configure.ac
1 AC_INIT(util-linux-ng, 2.16.2, kzak@redhat.com)
2
3 AC_PREREQ(2.60)
4
5 AC_CONFIG_AUX_DIR(config)
6 AC_CONFIG_MACRO_DIR([m4])
7
8 AM_INIT_AUTOMAKE([check-news -Wall foreign 1.9 dist-bzip2])
9
10 AC_CONFIG_SRCDIR(mount/mount.c)
11
12 AC_PREFIX_DEFAULT([/usr])
13
14 dnl version details from <major>.<minor>[-<suffix>]
15 PACKAGE_VERSION_MAJOR=$(echo $PACKAGE_VERSION | awk -F. '{print $1}')
16 PACKAGE_VERSION_MINOR=$(echo $PACKAGE_VERSION | awk -F. '{print $2}' \
17                                               | awk -F- '{print $1}')
18 PACKAGE_VERSION_RELEASE=0
19
20 dnl libblkid version
21 LIBBLKID_VERSION="$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_RELEASE"
22 LIBBLKID_DATE="10-Feb-2009"
23 LIBBLKID_LT_MAJOR=1
24 LIBBLKID_LT_MINOR=1
25 LIBBLKID_LT_MICRO=0
26 LIBBLKID_VERSION_INFO=`expr $LIBBLKID_LT_MAJOR + $LIBBLKID_LT_MINOR`:$LIBBLKID_LT_MICRO:$LIBBLKID_LT_MINOR
27
28 dnl libuuid version
29 LIBUUID_VERSION="$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_RELEASE"
30 LIBUUID_LT_MAJOR=1
31 LIBUUID_LT_MINOR=3
32 LIBUUID_LT_MICRO=0
33 LIBUUID_VERSION_INFO=`expr $LIBUUID_LT_MAJOR + $LIBUUID_LT_MINOR`:$LIBUUID_LT_MICRO:$LIBUUID_LT_MINOR
34
35 # Check whether exec_prefix=/usr:
36 case $exec_prefix:$prefix in
37 NONE:NONE | NONE:/usr | /usr:*)
38   AC_MSG_NOTICE([Default --exec-prefix detected.])
39   case $bindir in
40   '${exec_prefix}/bin') bindir=/bin
41     AC_MSG_NOTICE([  --bindir defaults to /bin]) ;;
42   esac
43   case $sbindir in
44   '${exec_prefix}/sbin') sbindir=/sbin
45     AC_MSG_NOTICE([  --sbindir defaults to /sbin]) ;;
46   esac
47   case $libdir in
48   '${exec_prefix}/lib') libdir=/lib
49     AC_MSG_NOTICE([  --libdir defaults to /lib]) ;;
50   esac ;;
51 esac
52
53 libdirname=`basename "$libdir"`
54 AC_SUBST([libdirname])
55
56 # The original default values of {bin,sbin,lib}dir
57 usrbin_execdir='${exec_prefix}/bin'
58 AC_SUBST([usrbin_execdir])
59
60 usrsbin_execdir='${exec_prefix}/sbin'
61 AC_SUBST([usrsbin_execdir])
62
63 usrlib_execdir='${exec_prefix}/'$libdirname
64 AC_SUBST([usrlib_execdir])
65
66
67 AC_PROG_CC_STDC
68 AC_GNU_SOURCE
69 AC_CANONICAL_HOST
70 AC_C_BIGENDIAN
71
72 dnl libtool-2
73 LT_INIT
74
75 PKG_PROG_PKG_CONFIG
76
77 linux_os=no
78 case ${host_os} in
79   *linux*)
80     linux_os=yes
81     ;;
82 esac
83 AM_CONDITIONAL([LINUX], test "x$linux_os" = xyes)
84
85 AC_PATH_PROG(PERL, perl)
86 AC_PATH_PROG(BLKID, blkid, [], [$PATH:/sbin])
87 AC_PATH_PROG(VOLID, vol_id, [], [$PATH:/lib/udev])
88
89 AC_SYS_LARGEFILE
90
91 AC_CHECK_HEADERS([linux/compiler.h linux/blkpg.h linux/major.h], [], [], [
92 #ifdef HAVE_LINUX_COMPILER_H
93 #include <linux/compiler.h>
94 #endif
95 ])
96 AC_CHECK_HEADERS(
97         [err.h \
98         errno.h \
99         getopt.h \
100         langinfo.h \
101         linux/fd.h \
102         linux/tiocl.h \
103         linux/version.h \
104         locale.h \
105         stdint.h \
106         inttypes.h \
107         pty.h \
108         mntent.h \
109         net/if.h \
110         net/if_dl.h \
111         netinet/in.h \
112         rpcsvc/nfs_prot.h \
113         scsi/scsi.h \
114         stdlib.h \
115         sys/disk.h \
116         sys/disklabel.h \
117         sys/ioctl.h \
118         sys/io.h \
119         sys/time.h \
120         sys/mkdev.h \
121         sys/prctl.h \
122         sys/queue.h \
123         sys/sockio.h \
124         sys/file.h \
125         sys/ioctl.h \
126         sys/stat.h \
127         sys/types.h \
128         sys/un.h \
129         sys/user.h \
130         sys/resource.h \
131         unistd.h ])
132 AC_CHECK_HEADERS([linux/raw.h],
133                  [AM_CONDITIONAL([HAVE_RAW], [true])],
134                  [AM_CONDITIONAL([HAVE_RAW], [false])])
135
136 AC_CHECK_DECLS([_NL_TIME_WEEK_1STDAY],[],[],[[#include <langinfo.h>]])
137
138 AC_CHECK_FUNCS(
139         [inet_aton \
140         fsync \
141         getdomainname \
142         get_current_dir_name \
143         nanosleep \
144         personality \
145         updwtmp \
146         jrand48 \
147         lchown \
148         llseek \
149         lseek64 \
150         strtoull \
151         sysconf \
152         getdtablesize \
153         getrlimit \
154         srandom \
155         setresgid \
156         setresuid \
157         inotify_init \
158         prctl \
159         __secure_getenv \
160         rpmatch])
161 AC_FUNC_FSEEKO
162
163 AC_CHECK_FUNCS([openat fstatat unlinkat], [have_openat=yes], [have_openat=no])
164
165 AC_CHECK_MEMBER(struct sockaddr.sa_len,
166                 AC_DEFINE_UNQUOTED(HAVE_SA_LEN,1,[Define if struct sockaddr contains sa_len]),,
167         [#include <sys/types.h>
168          #include <sys/socket.h>])
169
170 dnl Static compilation
171 m4_define([UTIL_STATIC_PROGRAMS], [losetup, mount, umount, fdisk, sfdisk, blkid])
172
173 AC_ARG_ENABLE([static-programs],
174   [AS_HELP_STRING([--enable-static-programs=LIST],
175       [link static the programs in LIST (comma-separated,
176       supported for ]m4_defn([UTIL_STATIC_PROGRAMS])[)])])
177
178 case $enable_static_programs in
179 yes) enable_static_programs=m4_quote(UTIL_STATIC_PROGRAMS) ;;
180 no) enable_static_programs= ;;
181 esac
182
183 dnl Set all the individual AM_CONDITIONALs
184 m4_foreach([UTIL_PRG], m4_defn([UTIL_STATIC_PROGRAMS]), [
185   case ,$enable_static_programs, in
186    *,UTIL_PRG,*) static_[]UTIL_PRG=yes ;;
187   esac
188   AM_CONDITIONAL([HAVE_STATIC_]m4_toupper(UTIL_PRG),
189     [test "x$static_[]UTIL_PRG" = xyes])
190 ])
191
192 dnl UTIL_PKG_STATIC(VARIABLE, MODULES)
193 dnl ----------------------------------
194 AC_DEFUN([UTIL_PKG_STATIC], [
195   if AC_RUN_LOG([pkg-config --exists --print-errors "$2"]); then
196     $1=`pkg-config --libs --static "$2"`
197   else
198     AC_MSG_ERROR([pkg-config description of $2, needed for static build, is not available])
199   fi
200 ])
201
202 dnl UTIL_CHECK_LIB(LIBRARY, FUNCTION, [VARSUFFIX = $1]))
203 dnl The VARSUFFIX is optional and overrides the default behaviour. For example:
204 dnl     UTIL_CHECK_LIB(yyy, func, xxx) generates have_xxx and HAVE_LIBXXX
205 dnl     UTIL_CHECK_LIB(yyy, func)      generates have_yyy and HAVE_LIBYYY
206 dnl ---------------------------------
207 AC_DEFUN([UTIL_CHECK_LIB], [
208   m4_define([suffix], m4_default([$3],$1))
209   [have_]suffix=yes
210   m4_ifdef([$3],
211     [AC_CHECK_LIB([$1], [$2], [AC_DEFINE(AS_TR_CPP([HAVE_LIB]suffix), 1)], [[have_]suffix=no])],
212     [AC_CHECK_LIB([$1], [$2], [], [[have_]suffix=no])])
213   AM_CONDITIONAL(AS_TR_CPP([HAVE_]suffix), [test [$have_]suffix = yes])
214 ])
215
216 dnl UTIL_SET_FLAGS(CFLAGS, CPPFLAGS, LDFLAGS)
217 AC_DEFUN([UTIL_SET_FLAGS], [
218   old_CFLAGS="$CFLAGS"
219   old_CPPFLAGS="$CPPFLAGS"
220   old_LDFLAGS="$LDFLAGS"
221   CFLAGS="$CFLAGS $1"
222   CPPFLAGS="$CPPFLAGS $2"
223   LDFLAGS="$LDFLAGS $3"
224 ])
225
226 dnl UTIL_RESTORE_FLAGS()
227 AC_DEFUN([UTIL_RESTORE_FLAGS], [
228   CFLAGS="$old_CFLAGS"
229   CPPFLAGS="$old_CPPFLAGS"
230   LDFLAGS="$old_LDFLAGS"
231 ])
232
233
234 AC_ARG_ENABLE([tls],
235   AS_HELP_STRING([--disable-tls], [disable use of thread local support]),
236   [], enable_tls=yes
237 )
238 if test "x$enable_tls" = xyes; then
239   AX_TLS
240 fi
241
242
243 AC_ARG_ENABLE([mount],
244   AS_HELP_STRING([--disable-mount], [do not build mount utilities]),
245   [], enable_mount=check
246 )
247 build_mount=yes
248 if test "x$enable_mount" = xcheck; then
249   if test "x$linux_os" = xno; then
250     AC_MSG_WARN([non-linux system; do not build mount utilities])
251     build_mount=no
252   fi
253 elif test "x$enable_mount" = xno; then
254     build_mount=no
255 fi
256 AM_CONDITIONAL(BUILD_MOUNT, test "x$build_mount" = xyes)
257
258
259 AC_ARG_ENABLE([fsck],
260   AS_HELP_STRING([--disable-fsck], [do not build fsck]),
261   [], enable_fsck=yes
262 )
263 AM_CONDITIONAL(BUILD_FSCK, test "x$enable_fsck" = xyes)
264
265
266 AC_ARG_ENABLE([libuuid],
267   AS_HELP_STRING([--disable-libuuid], [do not build libuuid and uuid utilities]),
268   [], enable_libuuid=yes
269 )
270 AC_SUBST([LIBUUID_VERSION])
271 AC_SUBST([LIBUUID_VERSION_INFO])
272 AM_CONDITIONAL(BUILD_LIBUUID, test "x$enable_libuuid" = xyes)
273 have_uuid=yes
274
275 if test "x$enable_libuuid" = xno; then
276   # Check for external (e2fsprogs) libuuid
277   PKG_CHECK_MODULES(UUID, uuid, [have_uuid=yes], [have_uuid=no])
278   if test "x$have_uuid" = xno; then
279     # system without pkg-config or so, try classic check
280     AC_CHECK_LIB(uuid, uuid_is_null, [have_uuid=yes], [have_uuid=no])
281   fi
282   if test "x$have_uuid" = xyes; then
283     UTIL_SET_FLAGS($UUID_CFLAGS, $UUID_CFLAGS, $UUID_LIBS)
284     AC_CHECK_HEADERS([uuid.h uuid/uuid.h], [break], [])
285     UTIL_RESTORE_FLAGS
286   fi
287 else
288   # internal library
289   AC_DEFINE(HAVE_UUID_H, 1, [Define to 1 if you have the <uuid.h> header file.])
290 fi
291
292 if test "x$have_uuid" = xyes; then
293   AC_DEFINE(HAVE_LIBUUID, 1, [Define to 1 if you have the -luuid.])
294 else
295   AC_MSG_WARN([uuid library is not found; mkswap(8) will not generate UUIDs])
296 fi
297 AM_CONDITIONAL(HAVE_UUID, test "x$have_uuid" = xyes)
298 # default
299 : ${UUID_LIBS='-luuid'}
300
301
302 AC_ARG_ENABLE([uuidd],
303   AS_HELP_STRING([--disable-uuidd], [do not build the uuid daemon]),
304   [], enable_uuidd=auto
305 )
306
307 case "$enable_uuidd:$have_uuid" in
308 yes:no)
309   AC_MSG_ERROR([cannot enable uuidd when libuuid is disabled]) ;;
310 auto:*)
311   enable_uuidd=$have_uuid ;;
312 esac
313 if test "x$enable_uuidd" = xyes; then
314   AC_DEFINE(HAVE_UUIDD, 1, [Define to 1 if you want to use uuid daemon.])
315 fi
316 AM_CONDITIONAL(BUILD_UUIDD, test "x$enable_uuidd" = xyes)
317
318
319 AC_ARG_ENABLE([libblkid],
320   AS_HELP_STRING([--disable-libblkid], [do not build libblkid and blkid utilities]),
321   [], enable_libblkid=yes
322 )
323 AC_SUBST([LIBBLKID_VERSION])
324 AC_SUBST([LIBBLKID_VERSION_INFO])
325 AM_CONDITIONAL(BUILD_LIBBLKID, test "x$enable_libblkid" = xyes)
326 AC_DEFINE_UNQUOTED(LIBBLKID_VERSION, "$LIBBLKID_VERSION", [libblkid version string])
327 AC_DEFINE_UNQUOTED(LIBBLKID_DATE, "$LIBBLKID_DATE", [libblkid date string])
328 have_blkid=yes
329
330 if test "x$enable_libblkid" = xno; then
331   if test "x$build_mount" = xyes || test "x$enable_fsck" = xyes; then
332     # Check for external (e2fsprogs) libblkid
333     PKG_CHECK_MODULES(BLKID, blkid, [have_blkid=yes], [have_blkid=no])
334     if test "x$have_blkid" = xno; then
335       # system without pkg-config or so, try classic check
336       AC_CHECK_LIB(blkid, blkid_get_cache, [have_blkid=yes], [have_blkid=no])
337     fi
338     if test "x$have_blkid" = xyes; then
339       UTIL_SET_FLAGS($BLKID_CFLAGS, $BLKID_CFLAGS, $BLKID_LIBS)
340       AC_CHECK_HEADERS([blkid.h blkid/blkid.h], [break], [])
341       UTIL_RESTORE_FLAGS
342     fi
343     if test -n "$enable_static_programs"; then
344       # TODO check only when mount of fsck are requested
345       UTIL_PKG_STATIC([BLKID_LIBS_STATIC], [blkid])
346     fi
347   fi
348 else
349   # internal library
350   AC_DEFINE(HAVE_BLKID_H, 1, [Define to 1 if you have the <blkid.h> header file.])
351   AC_DEFINE(HAVE_BLKID_EVALUATE_TAG, 1, [Define to 1 if you have the blkid_evaluate_tag().])
352 fi
353
354 if test "x$have_blkid" = xyes; then
355   AC_DEFINE(HAVE_LIBBLKID, 1, [Define to 1 if you have the -lblkid.])
356 else
357   if test "x$build_mount" = xyes; then
358     AC_MSG_ERROR([libblkid is needed to build util-linux-ng mount])
359   fi
360   if test "x$enable_fsck" = xyes; then
361     AC_MSG_ERROR([libblkid is needed to build util-linux-ng fsck])
362   fi
363 fi
364 AM_CONDITIONAL(HAVE_BLKID, test "x$have_blkid" = xyes)
365 # default
366 : ${BLKID_LIBS='-lblkid -luuid'}
367
368 AC_ARG_VAR([BLKID_LIBS_STATIC], [-l options for linking statically with blkid])
369
370
371 UTIL_CHECK_LIB(util, openpty)
372 UTIL_CHECK_LIB(termcap, tgetnum)
373
374 AM_GNU_GETTEXT_VERSION([0.14.1])
375 AM_GNU_GETTEXT([external])
376 if test -d "$srcdir/po"
377 then
378     ALL_LINGUAS=`cd $srcdir/po > /dev/null && echo *.po | sed 's/\.po//g'`
379 else
380     ALL_LINGUAS="af am ar as be bg bn_IN bn ca cs cy da de el en_GB es et eu_ES fa fi fr gl gu he hi hr hu hy id is it ja ka kn ko ku lo lt lv mk ml mr ms my nb nl nn no nso or pa pl pt_BR pt ro ru si sk sl sq sr@Latn sr sv ta te th tr uk ur vi zh_CN zh_TW zu"
381 fi
382
383 AC_ARG_WITH([ncurses],
384   AS_HELP_STRING([--with-ncurses], [build with non-wide ncurses, default is wide version
385                                     (--without-ncurses disables all ncurses(w) support)]),
386   [], with_ncurses=auto
387 )
388 AM_CONDITIONAL(HAVE_NCURSES, false)
389
390 if test "x$with_ncurses" != xno; then
391   have_ncurses=no
392   AC_CHECK_HEADERS([ncurses.h ncurses/ncurses.h], [
393     if test "x$with_ncurses" = xauto; then
394       UTIL_CHECK_LIB(ncursesw, initscr, ncurses)
395       if test "x$have_ncurses" = xyes; then
396         NCURSES_LIBS="-lncursesw"
397       fi
398     fi
399     if test "x$have_ncurses" = xno; then
400       UTIL_CHECK_LIB(ncurses, initscr)
401       if test "x$have_ncurses" = xyes; then
402         NCURSES_LIBS="-lncurses"
403       fi
404     fi
405   ])
406   if test "x$have_ncurses" = xno; then
407     AC_MSG_ERROR([ncurses or ncursesw selected, but library not found (--without-ncurses to disable)])
408   fi
409 fi
410 AC_SUBST([NCURSES_LIBS])
411
412
413 AC_ARG_WITH([slang],
414   AS_HELP_STRING([--with-slang], [compile cfdisk with slang]),
415   [], with_slang=no
416 )
417
418 have_tinfo=no
419 AC_CHECK_LIB(tinfo, tgetent, [have_tinfo=yes])
420 AM_CONDITIONAL(HAVE_TINFO, test "x$have_tinfo" = xyes)
421
422 use_slang=no
423 if test "x$with_slang" = xyes; then
424   AC_CHECK_HEADERS([slcurses.h slang/slcurses.h], [use_slang=yes])
425   if test "x$use_slang" = xno; then
426     AC_MSG_ERROR([slang selected but slcurses.h not found])
427   fi
428 fi
429 AM_CONDITIONAL(USE_SLANG, test "x$use_slang" = xyes)
430
431
432 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
433 #define _XOPEN_SOURCE
434 #include <unistd.h>
435 ]], [[
436 char *c = crypt("abc","pw");
437 ]])],[],[
438   LIBS="$LIBS -lcrypt"
439   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
440   #define _XOPEN_SOURCE
441   #include <unistd.h>
442   ]], [[
443   char *c = crypt("abc","pw");
444   ]])],[
445   AC_DEFINE(NEED_LIBCRYPT, 1, [Do we need -lcrypt?])
446   need_libcrypt=yes
447   ],[
448   AC_MSG_ERROR([crypt() is not available])
449   ])
450 ])
451
452 AM_CONDITIONAL(NEED_LIBCRYPT, test "x$need_libcrypt" = xyes)
453
454 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
455 #include <stdio.h>
456 ]], [[
457 printf(__progname);
458 ]])],
459 [AC_DEFINE(HAVE___PROGNAME, 1, Do we have __progname?)
460 ])
461
462
463 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
464 #include <wchar.h>
465 #include <wctype.h>
466 #include <stdio.h>
467 ]], [[
468   wchar_t wc;
469   wint_t w;
470   w = fgetwc(stdin);
471   if (w == WEOF) exit(1);
472   wc = w;
473   fputwc(wc,stdout);
474 ]])],
475 [AC_DEFINE(HAVE_WIDECHAR,1,Do we have wide character support?)
476 ])
477
478
479 dnl UTIL_CHECK_SYSCALL(SYSCALL, FALLBACK, ...)
480 dnl Only specify FALLBACK if the SYSCALL
481 dnl you're checking for is a "newish" one
482 dnl -------------------------------------
483 AC_DEFUN([UTIL_CHECK_SYSCALL], [
484   dnl This macro uses host_cpu.
485   AC_REQUIRE([AC_CANONICAL_HOST])
486   AC_CACHE_CHECK([for syscall $1],
487     [util_cv_syscall_$1],
488     [_UTIL_SYSCALL_CHECK_DECL([SYS_$1],
489       [syscall=SYS_$1],
490       [dnl Our libc failed use, so see if we can get the kernel
491       dnl headers to play ball ...
492       _UTIL_SYSCALL_CHECK_DECL([_NR_$1],
493         [syscall=_NR_$1],
494         [
495           syscall=no
496           if test "x$linux_os" = xyes; then
497             case $host_cpu in
498               _UTIL_CHECK_SYSCALL_FALLBACK(m4_shift($@))
499             esac
500           fi
501         ])
502       ])
503     util_cv_syscall_$1=$syscall
504     ])
505   AM_CONDITIONAL([HAVE_]m4_toupper($1), [test "x$util_cv_syscall_$1" != xno])
506   case $util_cv_syscall_$1 in #(
507   no) AC_MSG_WARN([Unable to detect syscall $1.]) ;;
508   SYS_*) ;;
509   *) AC_DEFINE_UNQUOTED([SYS_$1], [$util_cv_syscall_$1],
510         [Fallback syscall number for $1]) ;;
511   esac
512 ])
513
514 dnl _UTIL_SYSCALL_CHECK_DECL(SYMBOL, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
515 dnl Check if SYMBOL is declared, using the headers needed for syscall checks.
516 dnl -------------------------------------
517 m4_define([_UTIL_SYSCALL_CHECK_DECL],
518 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
519 #include <sys/syscall.h>
520 #include <unistd.h>
521 ]], [[int test = $1;]])],
522 [$2], [$3])
523 ])
524
525 dnl _UTIL_CHECK_SYSCALL_FALLBACK(PATTERN, VALUE, ...)
526 dnl Helper macro to create the body for the above `case'.
527 dnl -------------------------------------
528 m4_define([_UTIL_CHECK_SYSCALL_FALLBACK],
529 [m4_ifval([$1],
530   [#(
531   $1) syscall="$2" ;;dnl
532   _UTIL_CHECK_SYSCALL_FALLBACK(m4_shiftn(2, $@))])dnl
533 ])
534
535
536 UTIL_CHECK_SYSCALL([pivot_root])
537 UTIL_CHECK_SYSCALL([sched_getaffinity])
538 UTIL_CHECK_SYSCALL([ioprio_set],
539   [alpha],    [442],
540   [i*86],     [289],
541   [ia64*],    [1274],
542   [powerpc*], [273],
543   [s390*],    [282],
544   [sparc*],   [196],
545   [sh*],      [288],
546   [x86_64*],  [251])
547 UTIL_CHECK_SYSCALL([ioprio_get],
548   [alpha],    [443],
549   [i*86],     [290],
550   [ia64*],    [1275],
551   [powerpc*], [274],
552   [s390*],    [283],
553   [sparc*],   [218],
554   [sh*],      [289],
555   [x86_64*],  [252])
556
557
558 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
559 #include <time.h>
560 #include <unistd.h>
561 ]], [[
562     int a = 0;
563     struct tm *tm = localtime(0);
564     if (a == -1)  /* false */
565         sleep(tm->tm_gmtoff);
566 ]])],
567 [AC_DEFINE(HAVE_TM_GMTOFF,1,[Does struct tm have a field tm_gmtoff?])
568 ])
569
570 AC_CHECK_MEMBERS([struct termios.c_line],,,
571     [[#include <termios.h>]])
572
573 AC_CHECK_DECLS([
574  ADDR_NO_RANDOMIZE,
575  FDPIC_FUNCPTRS,
576  MMAP_PAGE_ZERO,
577  ADDR_COMPAT_LAYOUT,
578  READ_IMPLIES_EXEC,
579  ADDR_LIMIT_32BIT,
580  WHOLE_SECONDS,
581  STICKY_TIMEOUTS,
582  ADDR_LIMIT_3GB], [], [], [#include <linux/personality.h>])
583
584 AC_CHECK_HEADERS([sys/swap.h])
585
586 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
587 [[
588 #ifdef HAVE_SYS_SWAP_H
589 # include <sys/swap.h>
590 #endif
591 #include <unistd.h>
592 ]],
593 [[swapon("/dev/null", 0);]])],
594 [AC_DEFINE(SWAPON_HAS_TWO_ARGS, 1, [Is swapon() declared with two parameters?])
595 ],
596 [AC_MSG_NOTICE([Your libc thinks that swapon has 1 arg only.])
597 ])
598
599
600 dnl UTIL_SET_ARCH(ARCHNAME, PATTERN)
601 dnl ---------------------------------
602 AC_DEFUN([UTIL_SET_ARCH], [
603   cpu_$1=false
604   case "$host" in
605    $2) cpu_$1=true ;;
606   esac
607   AM_CONDITIONAL(AS_TR_CPP(ARCH_$1), [test "x$cpu_$1" = xtrue])
608 ])
609
610 UTIL_SET_ARCH(I86, i?86-*)
611 UTIL_SET_ARCH(86_64, x86_64*)
612 UTIL_SET_ARCH(IA64, ia64*)
613 UTIL_SET_ARCH(S390, s390*)
614 UTIL_SET_ARCH(SPARC, sparc*)
615 UTIL_SET_ARCH(PPC, ppc*|powerpc*)
616 UTIL_SET_ARCH(M68K, m68*)
617 UTIL_SET_ARCH(MIPS, mips*)
618 UTIL_SET_ARCH(HPPA, hppa*)
619
620 AC_ARG_ENABLE([arch],
621   AS_HELP_STRING([--enable-arch], [do build arch]),
622   [], enable_arch=no
623 )
624 AM_CONDITIONAL(BUILD_ARCH, test "x$enable_arch" = xyes)
625
626 AC_ARG_ENABLE([agetty],
627   AS_HELP_STRING([--disable-agetty], [do not build agetty]),
628   [], enable_agetty=yes
629 )
630 AM_CONDITIONAL(BUILD_AGETTY, test "x$enable_agetty" = xyes)
631
632 AC_ARG_ENABLE([cramfs],
633   AS_HELP_STRING([--disable-cramfs], [do not build fsck.cramfs, mkfs.cramfs]),
634   [], enable_cramfs=check
635 )
636
637 if test "x$enable_cramfs" = xno; then
638   build_cramfs=no
639 else
640   build_cramfs=yes
641   dnl Trick: leave the third parameter empty to get the default action.
642   AC_CHECK_LIB(z, crc32, [], build_cramfs=no)
643   case $enable_cramfs:$build_cramfs in
644   yes:no) AC_MSG_ERROR([cramfs selected but libz not found]);;
645   esac
646 fi
647 AM_CONDITIONAL(BUILD_CRAMFS, test "x$build_cramfs" = xyes)
648
649
650 AC_ARG_ENABLE([switch_root],
651   AS_HELP_STRING([--disable-switch_root], [do not build switch_root]),
652   [], enable_switch_root=check
653 )
654
655 if test "x$enable_switch_root" = xno; then
656   build_switch_root=no
657 else
658   build_switch_root=yes
659   case $enable_switch_root:$linux_os in
660   yes:no) AC_MSG_ERROR([switch_root selected for non-linux system]);;
661   check:no) AC_MSG_WARN([non-linux system; do not build switch_root])
662             build_switch_root=no;;
663   esac
664   if test "x$build_switch_root" = xyes; then
665     case $enable_switch_root:$have_openat in
666     yes:no) AC_MSG_ERROR([switch_root selected but openat() function not found]);;
667     check:no) AC_MSG_WARN([openat() function not found; do not build switch_root])
668               build_switch_root=no;;
669     esac
670   fi
671 fi
672 AM_CONDITIONAL(BUILD_SWITCH_ROOT, test "x$build_switch_root" = xyes)
673
674
675 AC_ARG_ENABLE([elvtune],
676   AS_HELP_STRING([--enable-elvtune], [build elvtune (only works with 2.2 and 2.4 kernels)]),
677   [], enable_elvtune=no
678 )
679 AM_CONDITIONAL(BUILD_ELVTUNE, test "x$enable_elvtune" = xyes)
680
681
682 AC_ARG_ENABLE([init],
683   AS_HELP_STRING([--enable-init], [build simpleinit, shutdown, initctl]),
684   [], enable_init=no
685 )
686 AM_CONDITIONAL(BUILD_INIT, test "x$enable_init" = xyes)
687
688
689 AC_ARG_ENABLE([kill],
690   AS_HELP_STRING([--enable-kill], [build kill]),
691   [], enable_kill=no
692 )
693 AM_CONDITIONAL(BUILD_KILL, test "x$enable_kill" = xyes)
694
695
696 AC_ARG_ENABLE([last],
697   AS_HELP_STRING([--enable-last], [build last]),
698   [], enable_last=no
699 )
700 AM_CONDITIONAL(BUILD_LAST, test "x$enable_last" = xyes)
701
702
703 AC_ARG_ENABLE([mesg],
704   AS_HELP_STRING([--enable-mesg], [build mesg]),
705   [], enable_mesg=no
706 )
707 AM_CONDITIONAL(BUILD_MESG, test "x$enable_mesg" = xyes)
708
709
710 AC_ARG_ENABLE([partx],
711   AS_HELP_STRING([--enable-partx], [build addpart, delpart, partx]),
712   [], enable_partx=no
713 )
714 AM_CONDITIONAL(BUILD_PARTX, test "x$enable_partx" = xyes)
715
716
717 AC_ARG_ENABLE([raw],
718   AS_HELP_STRING([--enable-raw], [build raw]),
719   [], enable_raw=no
720 )
721 AM_CONDITIONAL(BUILD_RAW, test "x$enable_raw" = xyes)
722
723
724 AC_ARG_ENABLE([rdev],
725   AS_HELP_STRING([--enable-rdev], [build rdev on i386]),
726   [], enable_rdev=no
727 )
728 AM_CONDITIONAL(BUILD_RDEV, test "x$enable_rdev" = xyes)
729
730
731 AC_ARG_ENABLE([rename],
732   AS_HELP_STRING([--disable-rename], [do not build rename]),
733   [], enable_rename=yes
734 )
735 AM_CONDITIONAL(BUILD_RENAME, test "x$enable_rename" = xyes)
736
737
738 AC_ARG_ENABLE([reset],
739   AS_HELP_STRING([--enable-reset], [build reset]),
740   [], enable_reset=no
741 )
742 AM_CONDITIONAL(BUILD_RESET, test "x$enable_reset" = xyes)
743
744
745 AC_ARG_ENABLE([login-utils],
746   AS_HELP_STRING([--enable-login-utils], [build chfn, chsh, login, newgrp, vipw]),
747   [], enable_login_utils=no
748 )
749 AM_CONDITIONAL(BUILD_LOGIN_UTILS, test "x$enable_login_utils" = xyes)
750
751 AC_ARG_WITH([pam],
752   [AS_HELP_STRING([--without-pam], [compile login-utils without PAM support])])
753
754 AM_CONDITIONAL(HAVE_PAM, false)
755 if test "x$enable_login_utils" = xyes && test "x$with_pam" != xno; then
756   AC_CHECK_HEADERS([security/pam_misc.h],
757     [AM_CONDITIONAL(HAVE_PAM, true)],
758     [if test "x$with_pam" = xyes; then
759         AC_MSG_ERROR([PAM selected but security/pam_misc.h not found])
760      fi
761     ])
762 fi
763
764 AC_ARG_WITH([selinux],
765   AS_HELP_STRING([--with-selinux], [compile with SELinux support]),
766   [], with_selinux=no
767 )
768
769 if test "x$with_selinux" = xno; then
770   AM_CONDITIONAL(HAVE_SELINUX, false)
771 else
772   UTIL_CHECK_LIB(selinux, getprevcon)
773   case "$with_selinux:$have_selinux" in
774   yes:no) AC_MSG_ERROR([SELinux selected but libselinux not found]);;
775   esac
776 fi
777
778 if test "x$have_selinux" = xyes; then
779   SELINUX_LIBS="-lselinux -lsepol"
780   SELINUX_LIBS_STATIC="-lselinux -lsepol"
781   old_LDFLAGS="$LDFLAGS"
782   LDFLAGS="$LDFLAGS $SELINUX_LIBS"
783   # This function is missing in old libselinux 1.xx versions
784   AC_CHECK_FUNCS([security_get_initial_context])
785   LDFLAGS="$old_LDFLAGS"
786 fi
787 AC_SUBST([SELINUX_LIBS])
788 AC_SUBST([SELINUX_LIBS_STATIC])
789
790 AC_ARG_WITH([audit],
791   AS_HELP_STRING([--with-audit], [compile with audit support]),
792   [], with_audit=no
793 )
794
795 if test "x$with_audit" = xno; then
796   AM_CONDITIONAL(HAVE_AUDIT, false)
797 else
798   UTIL_CHECK_LIB(audit, audit_log_user_message)
799   case "$with_audit:$have_audit" in
800   yes:no)
801    AC_MSG_ERROR([Audit selected but libaudit not found (or doesn't support audit_log_user_message())])
802    ;;
803   esac
804 fi
805
806 AC_ARG_ENABLE([schedutils],
807   AS_HELP_STRING([--disable-schedutils], [do not build chrt, ionice, teskset]),
808   [], enable_schedutils=yes
809 )
810 AM_CONDITIONAL(BUILD_SCHEDUTILS, test "x$enable_schedutils" = xyes)
811
812
813 AC_ARG_ENABLE([wall],
814   AS_HELP_STRING([--disable-wall], [do not build wall]),
815   [], enable_wall=yes
816 )
817 AM_CONDITIONAL(BUILD_WALL, test "x$enable_wall" = xyes)
818
819
820 AC_ARG_ENABLE([write],
821   AS_HELP_STRING([--enable-write], [build write]),
822   [], enable_write=no
823 )
824 AM_CONDITIONAL(BUILD_WRITE, test "x$enable_write" = xyes)
825
826
827 AC_ARG_ENABLE([chsh-only-listed],
828   AS_HELP_STRING([--disable-chsh-only-listed], [chsh: allow shells not in /etc/shells]),
829   [], enable_chsh_only_listed=yes
830 )
831
832 if test "x$enable_chsh_only_listed" = xyes; then
833   AC_DEFINE(ONLY_LISTED_SHELLS, 1, [Should chsh allow only shells in /etc/shells?])
834 fi
835
836
837 AC_ARG_ENABLE([login-chown-vcs],
838   AS_HELP_STRING([--enable-login-chown-vcs], [let login chown /dev/vcsN]),
839   [], enable_login_chown_vcs=no
840 )
841
842 if test "x$enable_login_chown_vcs" = xyes; then
843   AC_DEFINE(LOGIN_CHOWN_VCS, 1, [Should login chown /dev/vcsN?])
844 fi
845
846
847 AC_ARG_ENABLE([login-stat-mail],
848   AS_HELP_STRING([--enable-login-stat-mail], [let login stat() the mailbox]),
849   [], enable_login_stat_mail=no
850 )
851
852 if test "x$enable_login_stat_mail" = xyes; then
853   AC_DEFINE(LOGIN_STAT_MAIL, 1, [Should login stat() the mailbox?])
854 fi
855
856
857 AC_ARG_ENABLE([pg-bell],
858   AS_HELP_STRING([--disable-pg-bell], [let pg not ring the bell on invalid keys]),
859   [], enable_pg_bell=yes
860 )
861
862 if test "x$enable_pg_bell" = xyes; then
863   AC_DEFINE(PG_BELL, 1, [Should pg ring the bell on invalid keys?])
864 fi
865
866
867 AC_ARG_ENABLE([require-password],
868   AS_HELP_STRING([--disable-require-password], [do not require the user to enter the password in chfn and chsh]),
869   [], enable_require_password=yes
870 )
871
872 if test "x$enable_require_password" = xyes; then
873   AC_DEFINE(REQUIRE_PASSWORD, 1, [Should chfn and chsh require the user to enter the password?])
874 fi
875
876
877 AC_ARG_ENABLE([use-tty-group],
878   AS_HELP_STRING([--disable-use-tty-group], [do not install wall and write setgid tty]),
879   [], enable_use_tty_group=yes
880 )
881 AM_CONDITIONAL(USE_TTY_GROUP, test "x$enable_use_tty_group" = xyes)
882
883 if test "x$enable_use_tty_group" = xyes; then
884   AC_DEFINE(USE_TTY_GROUP, 1, [Should wall and write be installed setgid tty?])
885 fi
886
887 AC_ARG_ENABLE([makeinstall-chown],
888   AS_HELP_STRING([--disable-makeinstall-chown], [do not do chown-like operations during "make install"]),
889   [], enable_makeinstall_chown=yes
890 )
891 AM_CONDITIONAL(MAKEINSTALL_DO_CHOWN, test "x$enable_makeinstall_chown" = xyes)
892
893
894 AC_ARG_VAR([SUID_CFLAGS],
895            [CFLAGS used for binaries which are usually with the suid bit])
896 AC_ARG_VAR([SUID_LDFLAGS],
897            [LDFLAGS used for binaries which are usually with the suid bit])
898
899 LIBS=""
900
901
902 AC_CONFIG_HEADERS(config.h)
903
904 AC_CONFIG_FILES([
905 disk-utils/Makefile
906 fdisk/Makefile
907 fsck/Makefile
908 getopt/Makefile
909 hwclock/Makefile
910 include/Makefile
911 lib/Makefile
912 login-utils/Makefile
913 Makefile
914 misc-utils/chkdupexe:misc-utils/chkdupexe.pl
915 misc-utils/Makefile
916 mount/Makefile
917 partx/Makefile
918 po/Makefile.in
919 schedutils/Makefile
920 shlibs/blkid/blkid.pc
921 shlibs/blkid/Makefile
922 shlibs/blkid/src/Makefile
923 shlibs/blkid/src/probers/Makefile
924 shlibs/uuid/uuid.pc
925 shlibs/uuid/Makefile
926 shlibs/uuid/man/Makefile
927 shlibs/uuid/src/Makefile
928 shlibs/Makefile
929 sys-utils/Makefile
930 tests/commands.sh
931 tests/helpers/Makefile
932 tests/Makefile
933 text-utils/Makefile
934 ])
935
936
937 AC_OUTPUT