Whamcloud - gitweb
Improve I/O error messages in e2fsck
[tools/e2fsprogs.git] / configure.in
1 AC_INIT(version.h)
2 AC_PREREQ(2.50)
3 AC_CONFIG_AUX_DIR(config)
4 MCONFIG=./MCONFIG
5 AC_SUBST_FILE(MCONFIG)
6 BINARY_TYPE=bin
7 dnl
8 dnl This is to figure out the version number and the date....
9 dnl
10 E2FSPROGS_VERSION=`grep E2FSPROGS_VERSION ${srcdir}/version.h  \
11         | awk '{print $3}' | tr \" " " | awk '{print $1}'`
12 DATE=`grep E2FSPROGS_DATE ${srcdir}/version.h | awk '{print $3}' \
13         | tr \" " "`
14 E2FSPROGS_DAY=`echo $DATE | awk -F- '{print $1}'`
15 MONTH=`echo $DATE | awk -F- '{print $2}'`
16 YEAR=`echo $DATE | awk -F- '{print $3}'`
17
18 if expr $YEAR ">" 1900 > /dev/null ; then
19         E2FSPROGS_YEAR=$YEAR
20 elif expr $YEAR ">" 90 >/dev/null ; then
21         E2FSPROGS_YEAR=19$YEAR
22 else
23         E2FSPROGS_YEAR=20$YEAR
24 fi
25
26 case $MONTH in
27 Jan)    MONTH_NUM=01; E2FSPROGS_MONTH="January" ;;
28 Feb)    MONTH_NUM=02; E2FSPROGS_MONTH="February" ;;
29 Mar)    MONTH_NUM=03; E2FSPROGS_MONTH="March" ;;
30 Apr)    MONTH_NUM=04; E2FSPROGS_MONTH="April" ;;
31 May)    MONTH_NUM=05; E2FSPROGS_MONTH="May" ;;
32 Jun)    MONTH_NUM=06; E2FSPROGS_MONTH="June" ;;
33 Jul)    MONTH_NUM=07; E2FSPROGS_MONTH="July" ;;
34 Aug)    MONTH_NUM=08; E2FSPROGS_MONTH="August" ;;
35 Sep)    MONTH_NUM=09; E2FSPROGS_MONTH="September" ;;
36 Oct)    MONTH_NUM=10; E2FSPROGS_MONTH="October" ;;
37 Nov)    MONTH_NUM=11; E2FSPROGS_MONTH="November" ;;
38 Dec)    MONTH_NUM=12; E2FSPROGS_MONTH="December" ;;
39 *)      echo "Unknown month $MONTH??" ;;
40 esac
41
42 base_ver=`echo $E2FSPROGS_VERSION | \
43                sed -e 's/-WIP//' -e 's/pre-//' -e 's/-PLUS//'`
44 pre_vers=`echo $base_ver 0.01 - p | dc`
45
46 date_spec=${E2FSPROGS_YEAR}.${MONTH_NUM}.${E2FSPROGS_DAY}
47
48 case $E2FSPROGS_VERSION in
49 *-WIP|pre-*)
50         E2FSPROGS_PKGVER="$pre_vers+${base_ver}_WIP_$date_spec"
51         ;;
52 *)
53         E2FSPROGS_PKGVER="$base_ver"
54         ;;
55 esac
56
57 unset DATE MONTH YEAR base_ver pre_vers date_spec
58 echo "Generating configuration file for e2fsprogs version $E2FSPROGS_VERSION"
59 echo "Release date is ${E2FSPROGS_MONTH}, ${E2FSPROGS_YEAR}"
60 AC_SUBST(E2FSPROGS_YEAR)
61 AC_SUBST(E2FSPROGS_MONTH)
62 AC_SUBST(E2FSPROGS_DAY)
63 AC_SUBST(E2FSPROGS_VERSION)
64 AC_SUBST(E2FSPROGS_PKGVER)
65 AC_CANONICAL_HOST
66 dnl
67 dnl Use diet libc
68 dnl 
69 AC_ARG_WITH([diet-libc],
70 [  --with-diet-libc      Use diet libc],
71 CC="diet cc -nostdinc"
72 AC_MSG_RESULT(CC=$CC))dnl
73 dnl
74 dnl set $(CC) from --with-cc=value
75 dnl
76 AC_ARG_WITH([cc],
77 [  --with-cc=COMPILER      select compiler to use],
78 AC_MSG_RESULT(CC=$withval)
79 CC=$withval,
80 if test -z "$CC" ; then CC=cc; fi
81 [AC_MSG_RESULT(CC defaults to $CC)])dnl
82 export CC
83 AC_SUBST([CC])
84 AC_PROG_CC
85 dnl
86 dnl set $(LD) from --with-linker=value
87 dnl
88 AC_ARG_WITH([linker],
89 [  --with-linker=LINKER    select linker to use],
90 AC_MSG_RESULT(LD=$withval)
91 LD=$withval,
92 if test -z "$LD" ; then LD=$CC; fi
93 [AC_MSG_RESULT(LD defaults to $LD)])dnl
94 export LD
95 AC_SUBST([LD])
96 dnl
97 dnl set $(CCOPTS) from --with-ccopts=value
98 dnl
99 AC_ARG_WITH([ccopts],
100 [  --with-ccopts=CCOPTS    select compiler command line options],
101 AC_MSG_RESULT(CCOPTS is $withval)
102 CFLAGS=$withval,
103 )dnl
104 dnl
105 dnl On systems without linux header files, we add an extra include directory
106 dnl that holds enough to fake it (hopefully).  Note that the $(top_srcdir) here
107 dnl is quoted so that it gets expanded by make, not by configure.
108 dnl
109 AC_CHECK_HEADER(linux/fs.h, [linux_headers=yes], [linux_headers=no])
110 if test "$linux_headers" != yes; then
111   LINUX_INCLUDE='-I$(top_builddir)/include'
112 fi
113 AC_SUBST(LINUX_INCLUDE)
114 dnl
115 dnl Alpha computers use fast and imprecise floating point code that may
116 dnl miss exceptions by default. Force sane options if we're using GCC.
117 AC_MSG_CHECKING(for additional special compiler flags)
118 if test "$GCC" = yes
119 then
120     case "$host_cpu" in
121         alpha)          addcflags="-mieee" ;;
122     esac
123 fi
124 if test "x$addcflags" != x
125 then
126     AC_MSG_RESULT($addcflags)
127     CFLAGS="$addcflags $CFLAGS"
128 else
129     AC_MSG_RESULT([[(none)]])
130 fi
131 dnl
132 dnl Set default values for library extentions.  Will be dealt with after
133 dnl parsing configuration opions, which may modify these
134 dnl
135 LIB_EXT=.a
136 STATIC_LIB_EXT=.a
137 PROFILE_LIB_EXT=.a
138 dnl
139 dnl set $(LDFLAGS) from --with-ldopts=value
140 dnl
141 AC_ARG_WITH([ldopts],
142 [  --with-ldopts=LDOPTS    select linker command line options],
143 AC_MSG_RESULT(LDFLAGS is $withval)
144 LDFLAGS=$withval,
145 LDFLAGS=)dnl
146 AC_SUBST(LDFLAGS)
147 dnl
148 dnl Allow separate `root_prefix' to be specified
149 dnl
150 AC_ARG_WITH([root-prefix],
151 [  --with-root-prefix=PREFIX override prefix variable for files to be placed in the root],
152 root_prefix=$withval,
153 root_prefix=NONE)dnl
154 dnl
155 dnl handle --enable-maintainer-mode
156 dnl
157 AC_ARG_ENABLE([maintainer-mode],
158 [  --enable-maintainer-mode enable makefile rules useful for maintainers],
159 if test "$enableval" = "no"
160 then
161         MAINTAINER_CMT=#
162         echo "Disabling maintainer mode"
163 else
164         MAINTAINER_CMT=
165         echo "Enabling maintainer mode"
166 fi
167 ,
168 MAINTAINER_CMT=#
169 echo "Disabling maintainer mode by default"
170 )
171 AC_SUBST(MAINTAINER_CMT)
172 dnl
173 dnl handle --enable-compression
174 dnl
175 AC_ARG_ENABLE([compression],
176 [  --enable-compression   enable EXPERIMENTAL compression support],
177 if test "$enableval" = "no"
178 then
179         echo "Disabling compression support"
180 else
181         AC_DEFINE(ENABLE_COMPRESSION)
182         echo "Enabling compression support"
183         echo "WARNING: Compression support is experimental"
184 fi
185 ,
186 echo "Disabling compression support by default"
187 )
188 dnl
189 dnl handle --enable-htree
190 dnl
191 AC_ARG_ENABLE([htree],
192 [  --enable-htree         enable EXPERIMENTAL htree directory support],
193 if test "$enableval" = "no"
194 then
195         HTREE_CMT=#
196         echo "Disabling htree directory support"
197 else
198         HTREE_CMT=
199         AC_DEFINE(ENABLE_HTREE)
200         echo "Enabling htree directory support"
201 fi
202 ,
203 HTREE_CMT=
204 AC_DEFINE(ENABLE_HTREE)
205 echo "Enabling htree directory support by default"
206 )
207 AC_SUBST(HTREE_CMT)
208 dnl
209 dnl handle --enable-elf-shlibs
210 dnl
211 AC_ARG_ENABLE([elf-shlibs],
212 [  --enable-elf-shlibs    select ELF shared libraries],
213 if test "$enableval" = "no"
214 then
215         ELF_CMT=#
216         MAKEFILE_ELF=/dev/null
217         echo "Disabling ELF shared libraries"
218 else
219         ELF_CMT=
220         MAKEFILE_ELF=$srcdir/lib/Makefile.elf-lib
221         [case "$host_os" in
222         solaris2.*)
223                 MAKEFILE_ELF=$srcdir/lib/Makefile.solaris-lib
224         ;;
225         esac]
226         BINARY_TYPE=elfbin
227         LIB_EXT=.so
228         echo "Enabling ELF shared libraries"
229 fi
230 ,
231 MAKEFILE_ELF=/dev/null
232 ELF_CMT=#
233 echo "Disabling ELF shared libraries by default"
234 )
235 AC_SUBST(ELF_CMT)
236 AC_SUBST_FILE(MAKEFILE_ELF)
237 dnl
238 dnl handle --enable-bsd-shlibs
239 dnl
240 AC_ARG_ENABLE([bsd-shlibs],
241 [  --enable-bsd-shlibs    select BSD shared libraries],
242 if test "$enableval" = "no"
243 then
244         BSDLIB_CMT=#
245         MAKEFILE_BSDLIB=/dev/null
246         echo "Disabling BSD shared libraries"
247 else
248         BSDLIB_CMT=
249         MAKEFILE_BSDLIB=$srcdir/lib/Makefile.bsd-lib
250         LIB_EXT=.so
251         [case "$host_os" in
252         darwin*)
253                 MAKEFILE_BSDLIB=$srcdir/lib/Makefile.darwin-lib
254                 LIB_EXT=.dylib
255         ;;
256         esac]
257         echo "Enabling BSD shared libraries"
258 fi
259 ,
260 MAKEFILE_BSDLIB=/dev/null
261 BSDLIB_CMT=#
262 echo "Disabling BSD shared libraries by default"
263 )
264 AC_SUBST(BSDLIB_CMT)
265 AC_SUBST_FILE(MAKEFILE_BSDLIB)
266 dnl
267 dnl handle --enable-profile
268 dnl
269 AC_ARG_ENABLE([profile],
270 [  --enable-profile       build profiling libraries],
271 if test "$enableval" = "no"
272 then
273         PROFILE_CMT=#
274         MAKEFILE_PROFILE=/dev/null
275         echo "Disabling profiling libraries"
276 else
277         PROFILE_CMT=
278         MAKEFILE_PROFILE=$srcdir/lib/Makefile.profile
279         PROFILED_LIB_EXT=_p.a
280         echo "Building profiling libraries"
281 fi
282 ,
283 PROFILE_CMT=#
284 MAKEFILE_PROFILE=/dev/null
285 echo "Disabling profiling libraries by default"
286 )
287 AC_SUBST(PROFILE_CMT)
288 AC_SUBST_FILE(MAKEFILE_PROFILE)
289 dnl
290 dnl handle --enable-checker
291 dnl
292 AC_ARG_ENABLE([checker],
293 [  --enable-checker       build checker libraries],
294 if test "$enableval" = "no"
295 then
296         CHECKER_CMT=#
297         MAKEFILE_CHECKER=/dev/null
298         echo "Disabling checker libraries"
299 else
300         CHECKER_CMT=
301         MAKEFILE_CHECKER=$srcdir/lib/Makefile.checker
302         echo "Building checker libraries"
303 fi
304 ,
305 CHECKER_CMT=#
306 MAKEFILE_CHECKER=/dev/null
307 echo "Disabling checker libraries by default"
308 )
309 AC_SUBST(CHECKER_CMT)
310 AC_SUBST_FILE(MAKEFILE_CHECKER)
311 dnl
312 dnl Substitute library extensions
313 dnl
314 AC_SUBST(LIB_EXT)
315 AC_SUBST(STATIC_LIB_EXT)
316 AC_SUBST(PROFILED_LIB_EXT)
317 dnl
318 dnl handle --enable-jbd-debug
319 dnl
320 AC_ARG_ENABLE([jbd-debug],
321 [  --enable-jbd-debug     enable journal debugging],
322 if test "$enableval" = "no"
323 then
324         echo "Disabling journal debugging"
325 else
326         AC_DEFINE(CONFIG_JBD_DEBUG)
327         echo "Enabling journal debugging"
328 fi
329 ,
330 echo "Disabling journal debugging by default"
331 )
332 dnl
333 dnl handle --enable-blkid-debug
334 dnl
335 AC_ARG_ENABLE([blkid-debug],
336 [  --enable-blkid-debug    enable blkid debugging],
337 if test "$enableval" = "no"
338 then
339         echo "Disabling blkid debugging"
340 else
341         AC_DEFINE(CONFIG_BLKID_DEBUG)
342         echo "Enabling blkid debugging"
343 fi
344 ,
345 echo "Disabling blkid debugging by default"
346 )
347 dnl
348 dnl handle --enable-testio-debug
349 dnl
350 AC_ARG_ENABLE([testio-debug],
351 [  --enable-testio-debug   enable the use of the test I/O manager for debugging],
352 if test "$enableval" = "no"
353 then
354         echo "Disabling testio debugging"
355 else
356         AC_DEFINE(CONFIG_TESTIO_DEBUG)
357         echo "Enabling testio debugging"
358 fi
359 ,
360 echo "Disabling testio debugging by default"
361 )
362 dnl
363 dnl handle --enable-swapfs
364 dnl
365 AC_ARG_ENABLE([swapfs],
366 [  --disable-swapfs       disable support of legacy byte-swapped filesystems],
367 if test "$enableval" = "no"
368 then
369         SWAPFS_CMT=#
370         echo "Disabling swapfs support"
371 else
372         SWAPFS_CMT=
373         AC_DEFINE(ENABLE_SWAPFS)
374         echo "Enabling swapfs support"
375 fi
376 ,
377 SWAPFS_CMT=
378 echo "Enabling swapfs support by default"
379 AC_DEFINE(ENABLE_SWAPFS)
380 )
381 AC_SUBST(SWAPFS_CMT)
382 dnl
383 dnl handle --enable-debugfs
384 dnl
385 AC_ARG_ENABLE([debugfs],
386 [  --disable-debugfs      disable support of debugfs program],
387 if test "$enableval" = "no"
388 then
389         echo "Disabling debugfs support"
390         DEBUGFS_CMT="#"
391 else
392         DEBUGFS_CMT=
393         echo "Enabling debugfs support"
394 fi
395 ,
396 echo "Enabling debugfs support by default"
397 DEBUGFS_CMT=
398 )
399 AC_SUBST(DEBUGFS_CMT)
400 dnl
401 dnl handle --enable-imager
402 dnl
403 AC_ARG_ENABLE([imager],
404 [  --disable-imager       disable support of e2image program],
405 if test "$enableval" = "no"
406 then
407         echo "Disabling e2image support"
408         IMAGER_CMT="#"
409 else
410         IMAGER_CMT=
411         echo "Enabling e2image support"
412 fi
413 ,
414 echo "Enabling e2image support by default"
415 IMAGER_CMT=
416 )
417 AC_SUBST(IMAGER_CMT)
418 dnl
419 dnl handle --enable-resizer
420 dnl
421 AC_ARG_ENABLE([resizer],
422 [  --disable-resizer      disable support of e2resize program],
423 if test "$enableval" = "no"
424 then
425         echo "Disabling e2resize support"
426         RESIZER_CMT="#"
427 else
428         RESIZER_CMT=
429         echo "Enabling e2resize support"
430 fi
431 ,
432 echo "Enabling e2resize support by default"
433 RESIZER_CMT=
434 )
435 AC_SUBST(RESIZER_CMT)
436 dnl
437 dnl handle --enable-dynamic-e2fsck
438 dnl
439 AC_ARG_ENABLE([dynamic-e2fsck],
440 [  --enable-dynamic-e2fsck build e2fsck dynamically],
441 if test "$enableval" = "no"
442 then
443         E2FSCK_TYPE=static
444         echo "Building e2fsck statically"
445 else
446         E2FSCK_TYPE=shared
447         echo "Building e2fsck dynamically"
448 fi
449 ,
450 E2FSCK_TYPE=static
451 echo "Building e2fsck statically by default"
452 )
453 AC_SUBST(E2FSCK_TYPE)
454 dnl
455 dnl See whether to install the `fsck' wrapper program (that calls e2fsck)
456 dnl
457 AC_ARG_ENABLE([fsck],
458 [  --enable-fsck           build fsck wrapper program],
459 [if test "$enableval" = "no"
460 then
461         FSCK_PROG='' FSCK_MAN=''
462         echo "Not building fsck wrapper"
463 else
464         FSCK_PROG=fsck FSCK_MAN=fsck.8
465         echo "Building fsck wrapper"
466 fi]
467 ,
468 [case "$host_os" in
469   gnu*)
470     FSCK_PROG='' FSCK_MAN=''
471     echo "Not building fsck wrapper by default"
472     ;;
473   *)
474     FSCK_PROG=fsck FSCK_MAN=fsck.8
475     echo "Building fsck wrapper by default"
476 esac]
477 )
478 AC_SUBST(FSCK_PROG)
479 AC_SUBST(FSCK_MAN)
480 dnl
481 dnl See whether to install the `e2initrd-helper' program
482 dnl
483 AC_ARG_ENABLE([e2initrd-helper],
484 [  --enable-e2initrd-helper build e2initrd-helper program],
485 [if test "$enableval" = "no"
486 then
487         E2INITRD_PROG='' E2INITRD_MAN=''
488         echo "Not building e2initrd helper"
489 else
490         E2INITRD_PROG=e2initrd_helper E2INITRD_MAN=e2initrd_helper.8
491         echo "Building e2initrd helper"
492 fi]
493 ,
494 E2INITRD_PROG=e2initrd_helper E2INITRD_MAN=e2initrd_helper.8
495 echo "Building e2initrd helper by default"
496 )
497 AC_SUBST(E2INITRD_PROG)
498 AC_SUBST(E2INITRD_MAN)
499 dnl handle --enable-blkid-devmapper
500 dnl
501 AC_ARG_ENABLE([blkid-devmapper],
502 [  --enable-blkid-devmapper  build with device-mapper support],
503 [if test "$enableval" = "no"
504 then
505         echo "Disabling device-mapper support"
506         DEVMAPPER_REQ=''
507         DEVMAPPER_LIBS=''
508         STATIC_DEVMAPPER_LIBS=''
509 else
510         AC_DEFINE(HAVE_DEVMAPPER)
511         echo "Enabling device-mapper support"
512
513         DEVMAPPER_REQ='libselinux libsepol'
514         DEVMAPPER_PC_LIBS='-ldevmapper'
515         DEVMAPPER_LIBS='-ldevmapper -lselinux -lsepol -lpthread'
516         STATIC_DEVMAPPER_LIBS='/usr/lib/libdevmapper.a /usr/lib/libselinux.a /usr/lib/libsepol.a -lpthread'
517
518 fi]
519 ,
520 echo "Disabling device-mapper support by default"
521 )
522 AC_SUBST(DEVMAPPER_REQ)
523 AC_SUBST(DEVMAPPER_PC_LIBS)
524 AC_SUBST(DEVMAPPER_LIBS)
525 AC_SUBST(STATIC_DEVMAPPER_LIBS)
526 dnl
527 dnl
528 dnl
529 MAKEFILE_LIBRARY=$srcdir/lib/Makefile.library
530 AC_SUBST_FILE(MAKEFILE_LIBRARY)
531 dnl
532 dnl Add internationalization support, using gettext.
533 dnl
534 GETTEXT_PACKAGE=e2fsprogs
535 PACKAGE=e2fsprogs
536 VERSION="$E2FSPROGS_VERSION"
537 VERSION=0.14.1
538 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
539 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
540 AC_SUBST(GETTEXT_PACKAGE)
541 AC_SUBST(PACKAGE)
542 AC_SUBST(VERSION)
543
544 AM_GNU_GETTEXT
545 dnl
546 dnl End of configuration options
547 dnl
548 AC_SUBST(BINARY_TYPE)
549 AC_PROG_MAKE_SET
550 AC_PATH_PROG(LN, ln, ln)
551 AC_PROG_LN_S
552 AC_PATH_PROG(MV, mv, mv)
553 AC_PATH_PROG(CP, cp, cp)
554 AC_PATH_PROG(RM, rm, rm)
555 AC_PATH_PROG(CHMOD, chmod, :)
556 AC_PROG_AWK
557 AC_PROG_EGREP
558 AC_PATH_PROG(SED, sed, sed)
559 AC_PATH_PROG(PERL, perl, perl)
560 AC_PATH_PROG(LDCONFIG, ldconfig, :)
561 AC_CHECK_TOOL(AR, ar, ar)
562 AC_CHECK_TOOL(RANLIB, ranlib, :)
563 AC_CHECK_TOOL(STRIP, strip, :)
564 AC_PROG_INSTALL
565 # See if we need a separate native compiler.
566 if test $cross_compiling = no; then
567   BUILD_CC="$CC"
568   AC_SUBST(BUILD_CC)
569 else
570   AC_CHECK_PROGS(BUILD_CC, gcc cc)
571 fi
572 AC_CHECK_HEADERS(stdlib.h unistd.h stdarg.h stdint.h errno.h malloc.h mntent.h paths.h dirent.h getopt.h setjmp.h signal.h termios.h linux/fd.h linux/major.h sys/disklabel.h sys/ioctl.h sys/mman.h sys/mkdev.h sys/prctl.h sys/queue.h sys/sockio.h sys/socket.h sys/sysmacros.h sys/time.h sys/stat.h sys/types.h sys/wait.h sys/resource.h net/if_dl.h netinet/in.h utime.h)
573 AC_CHECK_HEADERS(sys/disk.h sys/mount.h,,,
574 [[
575 #if HAVE_SYS_QUEUE_H
576 #include <sys/queue.h>
577 #endif
578 ]])
579 AC_CHECK_HEADERS(net/if.h,,,
580 [[
581 #if HAVE_SYS_TYPES_H
582 #include <sys/types.h>
583 #endif
584 #if HAVE_SYS_SOCKET
585 #include <sys/socket.h>
586 #endif
587 ]])
588 AC_FUNC_VPRINTF
589 dnl Check to see if dirent has member d_reclen. On cygwin those d_reclen
590 dnl is not decleared.
591 AC_CHECK_MEMBER(struct dirent.d_reclen,[AC_DEFINE(HAVE_RECLEN_DIRENT)],,
592                 [#include <dirent.h>])
593 dnl Check to see if ssize_t was decleared
594 AC_CHECK_TYPE(ssize_t,[AC_DEFINE(HAVE_TYPE_SSIZE_T)],,
595               [#include <sys/types.h>])
596 dnl
597 dnl Check to see if llseek() is declared in unistd.h.  On some libc's 
598 dnl it is, and on others it isn't..... Thank you glibc developers....
599 dnl
600 AC_CHECK_DECL(llseek,[AC_DEFINE(HAVE_LLSEEK_PROTOTYPE)],,
601               [#include <unistd.h>])
602 dnl
603 dnl Check to see if lseek64() is declared in unistd.h.  Glibc's header files
604 dnl are so convoluted that I can't tell whether it will always be defined,
605 dnl and if it isn't defined while lseek64 is defined in the library, 
606 dnl disaster will strike.  
607 dnl
608 dnl Warning!  Use of --enable-gcc-wall may throw off this test.
609 dnl
610 dnl
611 AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE)],,
612                 [#define _LARGEFILE_SOURCE
613                  #define _LARGEFILE64_SOURCE
614                  #include <unistd.h>])
615 dnl
616 dnl Word sizes...
617 dnl
618 if test "$cross_compiling" = yes -a "$ac_cv_sizeof_long" = ""; then
619   # if cross-compiling, with no cached values, just assume something common. 
620   ac_cv_sizeof_short=2
621   ac_cv_sizeof_int=4
622   ac_cv_sizeof_long=4
623   ac_cv_sizeof_long_long=8
624   AC_MSG_WARN([Cross-compiling, so cannot check type sizes; assuming short=2, int=4, long=4, long long=8])
625 fi
626 AC_CHECK_SIZEOF(short)
627 AC_CHECK_SIZEOF(int)
628 AC_CHECK_SIZEOF(long)
629 AC_CHECK_SIZEOF(long long)
630 SIZEOF_SHORT=$ac_cv_sizeof_short
631 SIZEOF_INT=$ac_cv_sizeof_int
632 SIZEOF_LONG=$ac_cv_sizeof_long
633 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
634 AC_SUBST(SIZEOF_SHORT)
635 AC_SUBST(SIZEOF_INT)
636 AC_SUBST(SIZEOF_LONG)
637 AC_SUBST(SIZEOF_LONG_LONG)
638 AC_C_BIGENDIAN
639 /bin/sh $ac_aux_dir/parse-types.sh
640 ASM_TYPES_HEADER=./asm_types.h
641 AC_SUBST_FILE(ASM_TYPES_HEADER)
642 dnl
643 dnl See if we have inttypes.h and if intptr_t is defined
644 dnl
645 AC_CHECK_HEADERS([inttypes.h])
646 AC_CHECK_TYPES(intptr_t)
647 dnl
648 dnl See if struct stat has a st_flags field, in which case we can get file
649 dnl flags somewhat portably.  Also check for the analogous setter, chflags().
650 dnl
651 AC_MSG_CHECKING(whether struct stat has a st_flags field)
652 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
653         AC_TRY_COMPILE([#include <sys/stat.h>],
654                 [struct stat stat; stat.st_flags = 0;],
655                 [e2fsprogs_cv_struct_st_flags=yes],
656                 [e2fsprogs_cv_struct_st_flags=no]))
657 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
658 if test "$e2fsprogs_cv_struct_st_flags" = yes; then
659   AC_MSG_CHECKING(whether st_flags field is useful)
660   AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags_immut,
661         AC_TRY_COMPILE([#include <sys/stat.h>],
662                 [struct stat stat; stat.st_flags |= UF_IMMUTABLE;],
663                 [e2fsprogs_cv_struct_st_flags_immut=yes],
664                 [e2fsprogs_cv_struct_st_flags_immut=no]))
665   AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags_immut)
666   if test "$e2fsprogs_cv_struct_st_flags_immut" = yes; then
667           AC_DEFINE(HAVE_STAT_FLAGS)
668   fi
669 fi
670 dnl
671 dnl Check for the presence of SA_LEN
672 dnl
673 AC_CHECK_MEMBER(struct sockaddr.sa_len,
674                 AC_DEFINE_UNQUOTED(HAVE_SA_LEN,1,[Define if struct sockaddr contains sa_len]),,
675         [#include <sys/types.h>
676          #include <sys/socket.h>])
677 dnl
678 AC_CHECK_FUNCS(chflags getrusage llseek lseek64 open64 fstat64 getmntinfo strtoull strcasecmp srandom jrand48 fchown mallinfo fdatasync strnlen strptime strdup sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl mmap utime)
679 dnl
680 dnl Check to see if -lsocket is required (solaris) to make something
681 dnl that uses socket() to compile; this is needed for the UUID library
682 dnl
683 SOCKET_LIB=''
684 AC_CHECK_LIB(socket, socket, [SOCKET_LIB=-lsocket])
685 AC_SUBST(SOCKET_LIB)
686 dnl
687 dnl Check to see if libdl exists for the sake of dlopen
688 dnl
689 DLOPEN_LIB=''
690 AC_CHECK_LIB(dl, dlopen, 
691 [DLOPEN_LIB=-ldl
692 AC_DEFINE(HAVE_DLOPEN)])
693 AC_SUBST(DLOPEN_LIB)
694 dnl
695 dnl See if optreset exists
696 dnl
697 AC_MSG_CHECKING(for optreset)
698 AC_CACHE_VAL(ac_cv_have_optreset,
699 [AC_EGREP_HEADER(optreset, unistd.h,
700   ac_cv_have_optreset=yes, ac_cv_have_optreset=no)])dnl
701 AC_MSG_RESULT($ac_cv_have_optreset)
702 if test $ac_cv_have_optreset = yes; then
703   AC_DEFINE(HAVE_OPTRESET)
704 fi
705 dnl
706 dnl Check for unified diff
707 dnl
708 AC_MSG_CHECKING(for unified diff option)
709 if diff -u $0 $0 >& /dev/null ; then
710    UNI_DIFF_OPTS=-u
711 else
712    UNI_DIFF_OPTS=-c
713 fi
714 AC_MSG_RESULT($UNI_DIFF_OPTS)
715 AC_SUBST(UNI_DIFF_OPTS)
716 dnl
717 dnl We use the EXT2 ioctls only under Linux
718 dnl
719 case "$host_os" in
720 linux*)
721         AC_DEFINE(HAVE_EXT2_IOCTLS)
722         ;;
723 esac
724 dnl
725 dnl OS-specific uncomment control
726 dnl
727 LINUX_CMT="#"
728 CYGWIN_CMT="#"
729 UNIX_CMT=
730 case "$host_os" in
731 linux*)
732         LINUX_CMT=
733         ;;
734 cygwin)
735         CYGWIN_CMT=
736         UNIX_CMT="#"
737         ;;
738 esac
739 AC_SUBST(LINUX_CMT)
740 AC_SUBST(CYGWIN_CMT)
741 AC_SUBST(UNIX_CMT)
742 dnl
743 dnl Linux and Hurd places root files in the / by default
744 dnl
745 case "$host_os" in
746 linux* | gnu* | k*bsd*-gnu)
747         if test "$prefix" = NONE -a "$root_prefix" = NONE ; then
748                 root_prefix="";
749                 echo "On $host_os systems, root_prefix defaults to ''"
750         fi
751         ;;
752 esac
753 dnl
754 dnl On Linux/hurd, force the prefix to be /usr
755 dnl
756 case "$host_os" in
757 linux* | gnu* | k*bsd*-gnu)
758         if test "$prefix" = NONE ; then
759                 prefix="/usr";
760                 echo "On $host_os systems, prefix defaults to /usr"
761                 if test "$mandir" = '${prefix}/man' ; then
762                         echo "...and mandir defaults to /usr/share/man"
763                         mandir=/usr/share/man
764                 fi
765         fi
766 ;;
767 esac
768 if test "$root_prefix" = NONE ; then
769         if test "$prefix" = NONE ; then
770                 root_prefix="$ac_default_prefix"
771         else
772                 root_prefix="$prefix"
773         fi
774         root_bindir=$bindir
775         root_sbindir=$sbindir
776         root_libdir=$libdir
777         root_sysconfdir=$sysconfdir
778 else
779         root_bindir='${root_prefix}/bin'
780         root_sbindir='${root_prefix}/sbin'
781         root_libdir='${root_prefix}/lib'
782         root_sysconfdir='${root_prefix}/etc'
783 fi
784 AC_SUBST(root_prefix)
785 AC_SUBST(root_bindir)
786 AC_SUBST(root_sbindir)
787 AC_SUBST(root_libdir)
788 AC_SUBST(root_sysconfdir)
789 dnl
790 dnl See if -static works.
791 dnl
792 AC_MSG_CHECKING([whether linker accepts -static])
793 AC_CACHE_VAL(ac_cv_e2fsprogs_use_static,
794 [SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -static"
795 AC_TRY_LINK([#include <stdio.h>],[fflush(stdout);],
796  ac_cv_e2fsprogs_use_static=yes, ac_cv_e2fsprogs_use_static=no)
797 LDFLAGS=$SAVE_LDFLAGS])
798 dnl
799 dnl Regardless of how the test turns out, Solaris doesn't handle -static
800 dnl This is caused by the socket library requiring the nsl library, which
801 dnl requires the -dl library, which only works for dynamically linked 
802 dnl programs.  It basically means you can't have statically linked programs
803 dnl which use the network under Solaris.  
804 dnl
805 case "$host_os" in
806 solaris2.*)
807         ac_cv_e2fsprogs_use_static=no   
808 ;;
809 esac
810 AC_MSG_RESULT($ac_cv_e2fsprogs_use_static)
811 LDFLAG_STATIC=
812 if test $ac_cv_e2fsprogs_use_static = yes; then
813         LDFLAG_STATIC=-static
814 fi
815 AC_SUBST(LDFLAG_STATIC)
816 dnl
817 dnl Work around mysterious Darwin / GNU libintl problem
818 dnl (__asm__ redirection doesn't work for some mysterious reason.  Looks like
819 dnl Apple hacked gcc somehow?)
820 dnl
821 case "$host_os" in
822 darwin*)
823         echo "Using Apple Darwin / GNU libintl workaround"
824         AC_DEFINE(_INTL_REDIRECT_MACROS)
825         ;;
826 esac
827 dnl
828 dnl Make the ss and et directories work correctly.
829 dnl
830 SS_DIR=`cd ${srcdir}/lib/ss; pwd`
831 ET_DIR=`cd ${srcdir}/lib/et; pwd`
832 AC_SUBST(SS_DIR)
833 AC_SUBST(ET_DIR)
834 dnl
835 dnl Only try to run the test suite if we're not cross compiling.
836 dnl
837 if test "$cross_compiling" = yes ; then
838   DO_TEST_SUITE=
839 else
840   DO_TEST_SUITE=check
841 fi
842 AC_SUBST(DO_TEST_SUITE)
843 dnl
844 dnl Only include the intl include files if we're building with them
845 dnl 
846 INTL_FLAGS=
847 if test "$USE_INCLUDED_LIBINTL" = "yes" ; then
848         INTL_FLAGS='-I$(top_builddir)/intl -I$(top_srcdir)/intl'
849 fi
850 AC_SUBST(INTL_FLAGS)
851 dnl
852 dnl Build CFLAGS
853 dnl
854 if test $cross_compiling = no; then
855    BUILD_CFLAGS="$CFLAGS"
856    BUILD_LDFLAGS="$LDFLAGS"
857 else
858    BUILD_CFLAGS=
859    BUILD_LDFLAGS=
860 fi
861 AC_SUBST(BUILD_CFLAGS)
862 AC_SUBST(BUILD_LDFLAGS)
863 dnl
864 dnl Make our output files, being sure that we create the some miscellaneous 
865 dnl directories
866 dnl
867 test -d lib || mkdir lib
868 test -d include || mkdir include
869 test -d include/linux || mkdir include/linux
870 test -d include/asm || mkdir include/asm
871 for i in MCONFIG Makefile e2fsprogs.spec \
872         util/Makefile util/subst.conf util/gen-tarball \
873         lib/et/Makefile lib/ss/Makefile lib/e2p/Makefile \
874         lib/ext2fs/Makefile lib/ext2fs/ext2_types.h \
875         lib/uuid/Makefile lib/uuid/uuid_types.h \
876         lib/blkid/Makefile lib/blkid/blkid_types.h \
877         lib/ss/ss.pc lib/uuid/uuid.pc lib/et/com_err.pc \
878         lib/e2p/e2p.pc lib/blkid/blkid.pc lib/ext2fs/ext2fs.pc \
879         misc/Makefile ext2ed/Makefile e2fsck/Makefile \
880         debugfs/Makefile tests/Makefile tests/progs/Makefile \
881         resize/Makefile doc/Makefile intl/Makefile po/Makefile.in ; do
882         if test -d `dirname ${srcdir}/$i` ; then
883                 outlist="$outlist $i"
884         fi
885 done
886 AC_OUTPUT($outlist)
887 if test -f util/gen-tarball; then chmod +x util/gen-tarball; fi
888