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