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