Whamcloud - gitweb
b28fc53d2432f055b330087347ce0a6d93da38e2
[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 handle --enable-elf-shlibs
211 dnl
212 AC_ARG_ENABLE([elf-shlibs],
213 [  --enable-elf-shlibs    select ELF shared libraries],
214 if test "$enableval" = "no"
215 then
216         ELF_CMT=#
217         MAKEFILE_ELF=/dev/null
218         echo "Disabling ELF shared libraries"
219 else
220         ELF_CMT=
221         MAKEFILE_ELF=$srcdir/lib/Makefile.elf-lib
222         [case "$host_os" in
223         solaris2.*)
224                 MAKEFILE_ELF=$srcdir/lib/Makefile.solaris-lib
225         ;;
226         esac]
227         BINARY_TYPE=elfbin
228         LIB_EXT=.so
229         echo "Enabling ELF shared libraries"
230 fi
231 ,
232 MAKEFILE_ELF=/dev/null
233 ELF_CMT=#
234 echo "Disabling ELF shared libraries by default"
235 )
236 AC_SUBST(ELF_CMT)
237 AC_SUBST_FILE(MAKEFILE_ELF)
238 dnl
239 dnl handle --enable-bsd-shlibs
240 dnl
241 AC_ARG_ENABLE([bsd-shlibs],
242 [  --enable-bsd-shlibs    select BSD shared libraries],
243 if test "$enableval" = "no"
244 then
245         BSDLIB_CMT=#
246         MAKEFILE_BSDLIB=/dev/null
247         echo "Disabling BSD shared libraries"
248 else
249         BSDLIB_CMT=
250         MAKEFILE_BSDLIB=$srcdir/lib/Makefile.bsd-lib
251         LIB_EXT=.so
252         [case "$host_os" in
253         darwin*)
254                 MAKEFILE_BSDLIB=$srcdir/lib/Makefile.darwin-lib
255                 LIB_EXT=.dylib
256         ;;
257         esac]
258         echo "Enabling BSD shared libraries"
259 fi
260 ,
261 MAKEFILE_BSDLIB=/dev/null
262 BSDLIB_CMT=#
263 echo "Disabling BSD shared libraries by default"
264 )
265 AC_SUBST(BSDLIB_CMT)
266 AC_SUBST_FILE(MAKEFILE_BSDLIB)
267 dnl
268 dnl handle --enable-profile
269 dnl
270 AC_ARG_ENABLE([profile],
271 [  --enable-profile       build profiling libraries],
272 if test "$enableval" = "no"
273 then
274         PROFILE_CMT=#
275         MAKEFILE_PROFILE=/dev/null
276         echo "Disabling profiling libraries"
277 else
278         PROFILE_CMT=
279         MAKEFILE_PROFILE=$srcdir/lib/Makefile.profile
280         PROFILED_LIB_EXT=_p.a
281         echo "Building profiling libraries"
282 fi
283 ,
284 PROFILE_CMT=#
285 MAKEFILE_PROFILE=/dev/null
286 echo "Disabling profiling libraries by default"
287 )
288 AC_SUBST(PROFILE_CMT)
289 AC_SUBST_FILE(MAKEFILE_PROFILE)
290 dnl
291 dnl handle --enable-checker
292 dnl
293 AC_ARG_ENABLE([checker],
294 [  --enable-checker       build checker libraries],
295 if test "$enableval" = "no"
296 then
297         CHECKER_CMT=#
298         MAKEFILE_CHECKER=/dev/null
299         echo "Disabling checker libraries"
300 else
301         CHECKER_CMT=
302         MAKEFILE_CHECKER=$srcdir/lib/Makefile.checker
303         echo "Building checker libraries"
304 fi
305 ,
306 CHECKER_CMT=#
307 MAKEFILE_CHECKER=/dev/null
308 echo "Disabling checker libraries by default"
309 )
310 AC_SUBST(CHECKER_CMT)
311 AC_SUBST_FILE(MAKEFILE_CHECKER)
312 dnl
313 dnl Substitute library extensions
314 dnl
315 AC_SUBST(LIB_EXT)
316 AC_SUBST(STATIC_LIB_EXT)
317 AC_SUBST(PROFILED_LIB_EXT)
318 dnl
319 dnl handle --enable-jbd-debug
320 dnl
321 AC_ARG_ENABLE([jbd-debug],
322 [  --enable-jbd-debug     enable journal debugging],
323 if test "$enableval" = "no"
324 then
325         echo "Disabling journal debugging"
326 else
327         AC_DEFINE(CONFIG_JBD_DEBUG)
328         echo "Enabling journal debugging"
329 fi
330 ,
331 echo "Disabling journal debugging by default"
332 )
333 dnl
334 dnl handle --enable-blkid-debug
335 dnl
336 AC_ARG_ENABLE([blkid-debug],
337 [  --enable-blkid-debug    enable blkid debugging],
338 if test "$enableval" = "no"
339 then
340         echo "Disabling blkid debugging"
341 else
342         AC_DEFINE(CONFIG_BLKID_DEBUG)
343         echo "Enabling blkid debugging"
344 fi
345 ,
346 echo "Disabling blkid debugging by default"
347 )
348 dnl
349 dnl handle --enable-testio-debug
350 dnl
351 AC_ARG_ENABLE([testio-debug],
352 [  --enable-testio-debug   enable the use of the test I/O manager for debugging],
353 if test "$enableval" = "no"
354 then
355         echo "Disabling testio debugging"
356 else
357         AC_DEFINE(CONFIG_TESTIO_DEBUG)
358         echo "Enabling testio debugging"
359 fi
360 ,
361 echo "Disabling testio debugging by default"
362 )
363 dnl
364 dnl handle --enable-debugfs
365 dnl
366 AC_ARG_ENABLE([debugfs],
367 [  --disable-debugfs      disable support of debugfs program],
368 if test "$enableval" = "no"
369 then
370         echo "Disabling debugfs support"
371         DEBUGFS_CMT="#"
372 else
373         DEBUGFS_CMT=
374         echo "Enabling debugfs support"
375 fi
376 ,
377 echo "Enabling debugfs support by default"
378 DEBUGFS_CMT=
379 )
380 AC_SUBST(DEBUGFS_CMT)
381 dnl
382 dnl handle --enable-imager
383 dnl
384 AC_ARG_ENABLE([imager],
385 [  --disable-imager       disable support of e2image program],
386 if test "$enableval" = "no"
387 then
388         echo "Disabling e2image support"
389         IMAGER_CMT="#"
390 else
391         IMAGER_CMT=
392         echo "Enabling e2image support"
393 fi
394 ,
395 echo "Enabling e2image support by default"
396 IMAGER_CMT=
397 )
398 AC_SUBST(IMAGER_CMT)
399 dnl
400 dnl handle --enable-resizer
401 dnl
402 AC_ARG_ENABLE([resizer],
403 [  --disable-resizer      disable support of e2resize program],
404 if test "$enableval" = "no"
405 then
406         echo "Disabling e2resize support"
407         RESIZER_CMT="#"
408 else
409         RESIZER_CMT=
410         echo "Enabling e2resize support"
411 fi
412 ,
413 echo "Enabling e2resize support by default"
414 RESIZER_CMT=
415 )
416 AC_SUBST(RESIZER_CMT)
417 dnl
418 dnl handle --enable-dynamic-e2fsck
419 dnl
420 AC_ARG_ENABLE([dynamic-e2fsck],
421 [  --enable-dynamic-e2fsck build e2fsck dynamically],
422 if test "$enableval" = "no"
423 then
424         E2FSCK_TYPE=static
425         echo "Building e2fsck statically"
426 else
427         E2FSCK_TYPE=shared
428         echo "Building e2fsck dynamically"
429 fi
430 ,
431 E2FSCK_TYPE=static
432 echo "Building e2fsck statically by default"
433 )
434 AC_SUBST(E2FSCK_TYPE)
435 dnl
436 dnl See whether to install the `fsck' wrapper program (that calls e2fsck)
437 dnl
438 AC_ARG_ENABLE([fsck],
439 [  --enable-fsck           build fsck wrapper program],
440 [if test "$enableval" = "no"
441 then
442         FSCK_PROG='' FSCK_MAN=''
443         echo "Not building fsck wrapper"
444 else
445         FSCK_PROG=fsck FSCK_MAN=fsck.8
446         echo "Building fsck wrapper"
447 fi]
448 ,
449 [case "$host_os" in
450   gnu*)
451     FSCK_PROG='' FSCK_MAN=''
452     echo "Not building fsck wrapper by default"
453     ;;
454   *)
455     FSCK_PROG=fsck FSCK_MAN=fsck.8
456     echo "Building fsck wrapper by default"
457 esac]
458 )
459 AC_SUBST(FSCK_PROG)
460 AC_SUBST(FSCK_MAN)
461 dnl
462 dnl See whether to install the `e2initrd-helper' program
463 dnl
464 AC_ARG_ENABLE([e2initrd-helper],
465 [  --enable-e2initrd-helper build e2initrd-helper program],
466 [if test "$enableval" = "no"
467 then
468         E2INITRD_PROG='' E2INITRD_MAN=''
469         echo "Not building e2initrd helper"
470 else
471         E2INITRD_PROG=e2initrd_helper E2INITRD_MAN=e2initrd_helper.8
472         echo "Building e2initrd helper"
473 fi]
474 ,
475 E2INITRD_PROG=e2initrd_helper E2INITRD_MAN=e2initrd_helper.8
476 echo "Building e2initrd helper by default"
477 )
478 AC_SUBST(E2INITRD_PROG)
479 AC_SUBST(E2INITRD_MAN)
480 dnl handle --enable-blkid-devmapper
481 dnl
482 AC_ARG_ENABLE([blkid-devmapper],
483 [  --enable-blkid-devmapper  build with device-mapper support],
484 [if test "$enableval" = "no"
485 then
486         echo "Disabling device-mapper support"
487         DEVMAPPER_REQ=''
488         DEVMAPPER_LIBS=''
489         STATIC_DEVMAPPER_LIBS=''
490 else
491         AC_DEFINE(HAVE_DEVMAPPER)
492         echo "Enabling device-mapper support"
493
494         DEVMAPPER_REQ='libselinux libsepol'
495         DEVMAPPER_PC_LIBS='-ldevmapper'
496         DEVMAPPER_LIBS='-ldevmapper -lselinux -lsepol -lpthread'
497         STATIC_DEVMAPPER_LIBS='/usr/lib/libdevmapper.a /usr/lib/libselinux.a /usr/lib/libsepol.a -lpthread'
498
499 fi]
500 ,
501 echo "Disabling device-mapper support by default"
502 )
503 AC_SUBST(DEVMAPPER_REQ)
504 AC_SUBST(DEVMAPPER_PC_LIBS)
505 AC_SUBST(DEVMAPPER_LIBS)
506 AC_SUBST(STATIC_DEVMAPPER_LIBS)
507 dnl
508 dnl
509 dnl
510 MAKEFILE_LIBRARY=$srcdir/lib/Makefile.library
511 AC_SUBST_FILE(MAKEFILE_LIBRARY)
512 dnl
513 dnl Add internationalization support, using gettext.
514 dnl
515 GETTEXT_PACKAGE=e2fsprogs
516 PACKAGE=e2fsprogs
517 VERSION="$E2FSPROGS_VERSION"
518 VERSION=0.14.1
519 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
520 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
521 AC_SUBST(GETTEXT_PACKAGE)
522 AC_SUBST(PACKAGE)
523 AC_SUBST(VERSION)
524
525 AM_GNU_GETTEXT
526 dnl
527 dnl End of configuration options
528 dnl
529 AC_SUBST(BINARY_TYPE)
530 AC_PROG_MAKE_SET
531 AC_PATH_PROG(LN, ln, ln)
532 AC_PROG_LN_S
533 AC_PATH_PROG(MV, mv, mv)
534 AC_PATH_PROG(CP, cp, cp)
535 AC_PATH_PROG(RM, rm, rm)
536 AC_PATH_PROG(CHMOD, chmod, :)
537 AC_PROG_AWK
538 AC_PROG_EGREP
539 AC_PATH_PROG(SED, sed, sed)
540 AC_PATH_PROG(PERL, perl, perl)
541 AC_PATH_PROG(LDCONFIG, ldconfig, :)
542 AC_CHECK_TOOL(AR, ar, ar)
543 AC_CHECK_TOOL(RANLIB, ranlib, :)
544 AC_CHECK_TOOL(STRIP, strip, :)
545 AC_PROG_INSTALL
546 # See if we need a separate native compiler.
547 if test $cross_compiling = no; then
548   BUILD_CC="$CC"
549   AC_SUBST(BUILD_CC)
550 else
551   AC_CHECK_PROGS(BUILD_CC, gcc cc)
552 fi
553 AX_TLS
554 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)
555 AC_CHECK_HEADERS(sys/disk.h sys/mount.h,,,
556 [[
557 #if HAVE_SYS_QUEUE_H
558 #include <sys/queue.h>
559 #endif
560 ]])
561 AC_CHECK_HEADERS(net/if.h,,,
562 [[
563 #if HAVE_SYS_TYPES_H
564 #include <sys/types.h>
565 #endif
566 #if HAVE_SYS_SOCKET
567 #include <sys/socket.h>
568 #endif
569 ]])
570 AC_FUNC_VPRINTF
571 dnl Check to see if dirent has member d_reclen. On cygwin those d_reclen
572 dnl is not decleared.
573 AC_CHECK_MEMBER(struct dirent.d_reclen,[AC_DEFINE(HAVE_RECLEN_DIRENT)],,
574                 [#include <dirent.h>])
575 dnl Check to see if ssize_t was decleared
576 AC_CHECK_TYPE(ssize_t,[AC_DEFINE(HAVE_TYPE_SSIZE_T)],,
577               [#include <sys/types.h>])
578 dnl
579 dnl Check to see if llseek() is declared in unistd.h.  On some libc's 
580 dnl it is, and on others it isn't..... Thank you glibc developers....
581 dnl
582 AC_CHECK_DECL(llseek,[AC_DEFINE(HAVE_LLSEEK_PROTOTYPE)],,
583               [#include <unistd.h>])
584 dnl
585 dnl Check to see if lseek64() is declared in unistd.h.  Glibc's header files
586 dnl are so convoluted that I can't tell whether it will always be defined,
587 dnl and if it isn't defined while lseek64 is defined in the library, 
588 dnl disaster will strike.  
589 dnl
590 dnl Warning!  Use of --enable-gcc-wall may throw off this test.
591 dnl
592 dnl
593 AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE)],,
594                 [#define _LARGEFILE_SOURCE
595                  #define _LARGEFILE64_SOURCE
596                  #include <unistd.h>])
597 dnl
598 dnl Word sizes...
599 dnl
600 if test "$cross_compiling" = yes -a "$ac_cv_sizeof_long" = ""; then
601   # if cross-compiling, with no cached values, just assume something common. 
602   ac_cv_sizeof_short=2
603   ac_cv_sizeof_int=4
604   ac_cv_sizeof_long=4
605   ac_cv_sizeof_long_long=8
606   AC_MSG_WARN([Cross-compiling, so cannot check type sizes; assuming short=2, int=4, long=4, long long=8])
607 fi
608 AC_CHECK_SIZEOF(short)
609 AC_CHECK_SIZEOF(int)
610 AC_CHECK_SIZEOF(long)
611 AC_CHECK_SIZEOF(long long)
612 SIZEOF_SHORT=$ac_cv_sizeof_short
613 SIZEOF_INT=$ac_cv_sizeof_int
614 SIZEOF_LONG=$ac_cv_sizeof_long
615 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
616 AC_SUBST(SIZEOF_SHORT)
617 AC_SUBST(SIZEOF_INT)
618 AC_SUBST(SIZEOF_LONG)
619 AC_SUBST(SIZEOF_LONG_LONG)
620 AC_C_BIGENDIAN
621 BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
622 ASM_TYPES_HEADER=./asm_types.h
623 AC_SUBST_FILE(ASM_TYPES_HEADER)
624 dnl
625 dnl See if we have inttypes.h and if intptr_t is defined
626 dnl
627 AC_CHECK_HEADERS([inttypes.h])
628 AC_CHECK_TYPES(intptr_t)
629 dnl
630 dnl See if struct stat has a st_flags field, in which case we can get file
631 dnl flags somewhat portably.  Also check for the analogous setter, chflags().
632 dnl
633 AC_MSG_CHECKING(whether struct stat has a st_flags field)
634 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
635         AC_TRY_COMPILE([#include <sys/stat.h>],
636                 [struct stat stat; stat.st_flags = 0;],
637                 [e2fsprogs_cv_struct_st_flags=yes],
638                 [e2fsprogs_cv_struct_st_flags=no]))
639 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
640 if test "$e2fsprogs_cv_struct_st_flags" = yes; then
641   AC_MSG_CHECKING(whether st_flags field is useful)
642   AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags_immut,
643         AC_TRY_COMPILE([#include <sys/stat.h>],
644                 [struct stat stat; stat.st_flags |= UF_IMMUTABLE;],
645                 [e2fsprogs_cv_struct_st_flags_immut=yes],
646                 [e2fsprogs_cv_struct_st_flags_immut=no]))
647   AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags_immut)
648   if test "$e2fsprogs_cv_struct_st_flags_immut" = yes; then
649           AC_DEFINE(HAVE_STAT_FLAGS)
650   fi
651 fi
652 dnl
653 dnl Check for the presence of SA_LEN
654 dnl
655 AC_CHECK_MEMBER(struct sockaddr.sa_len,
656                 AC_DEFINE_UNQUOTED(HAVE_SA_LEN,1,[Define if struct sockaddr contains sa_len]),,
657         [#include <sys/types.h>
658          #include <sys/socket.h>])
659 dnl
660 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)
661 dnl
662 dnl Check to see if -lsocket is required (solaris) to make something
663 dnl that uses socket() to compile; this is needed for the UUID library
664 dnl
665 SOCKET_LIB=''
666 AC_CHECK_LIB(socket, socket, [SOCKET_LIB=-lsocket])
667 AC_SUBST(SOCKET_LIB)
668 dnl
669 dnl Check to see if libdl exists for the sake of dlopen
670 dnl
671 DLOPEN_LIB=''
672 AC_CHECK_LIB(dl, dlopen, 
673 [DLOPEN_LIB=-ldl
674 AC_DEFINE(HAVE_DLOPEN)])
675 AC_SUBST(DLOPEN_LIB)
676 dnl
677 dnl See if optreset exists
678 dnl
679 AC_MSG_CHECKING(for optreset)
680 AC_CACHE_VAL(ac_cv_have_optreset,
681 [AC_EGREP_HEADER(optreset, unistd.h,
682   ac_cv_have_optreset=yes, ac_cv_have_optreset=no)])dnl
683 AC_MSG_RESULT($ac_cv_have_optreset)
684 if test $ac_cv_have_optreset = yes; then
685   AC_DEFINE(HAVE_OPTRESET)
686 fi
687 dnl
688 dnl Check for unified diff
689 dnl
690 AC_MSG_CHECKING(for unified diff option)
691 if diff -u $0 $0 >& /dev/null ; then
692    UNI_DIFF_OPTS=-u
693 else
694    UNI_DIFF_OPTS=-c
695 fi
696 AC_MSG_RESULT($UNI_DIFF_OPTS)
697 AC_SUBST(UNI_DIFF_OPTS)
698 dnl
699 dnl We use the EXT2 ioctls only under Linux
700 dnl
701 case "$host_os" in
702 linux*)
703         AC_DEFINE(HAVE_EXT2_IOCTLS)
704         ;;
705 esac
706 dnl
707 dnl OS-specific uncomment control
708 dnl
709 LINUX_CMT="#"
710 CYGWIN_CMT="#"
711 UNIX_CMT=
712 case "$host_os" in
713 linux*)
714         LINUX_CMT=
715         ;;
716 cygwin)
717         CYGWIN_CMT=
718         UNIX_CMT="#"
719         ;;
720 esac
721 AC_SUBST(LINUX_CMT)
722 AC_SUBST(CYGWIN_CMT)
723 AC_SUBST(UNIX_CMT)
724 dnl
725 dnl Linux and Hurd places root files in the / by default
726 dnl
727 case "$host_os" in
728 linux* | gnu* | k*bsd*-gnu)
729         if test "$prefix" = NONE -a "$root_prefix" = NONE ; then
730                 root_prefix="";
731                 echo "On $host_os systems, root_prefix defaults to ''"
732         fi
733         ;;
734 esac
735 dnl
736 dnl On Linux/hurd, force the prefix to be /usr
737 dnl
738 case "$host_os" in
739 linux* | gnu* | k*bsd*-gnu)
740         if test "$prefix" = NONE ; then
741                 prefix="/usr";
742                 echo "On $host_os systems, prefix defaults to /usr"
743                 if test "$mandir" = '${prefix}/man' ; then
744                         echo "...and mandir defaults to /usr/share/man"
745                         mandir=/usr/share/man
746                 fi
747         fi
748 ;;
749 esac
750 if test "$root_prefix" = NONE ; then
751         if test "$prefix" = NONE ; then
752                 root_prefix="$ac_default_prefix"
753         else
754                 root_prefix="$prefix"
755         fi
756         root_bindir=$bindir
757         root_sbindir=$sbindir
758         root_libdir=$libdir
759         root_sysconfdir=$sysconfdir
760 else
761         root_bindir='${root_prefix}/bin'
762         root_sbindir='${root_prefix}/sbin'
763         root_libdir='${root_prefix}/lib'
764         root_sysconfdir='${root_prefix}/etc'
765 fi
766 AC_SUBST(root_prefix)
767 AC_SUBST(root_bindir)
768 AC_SUBST(root_sbindir)
769 AC_SUBST(root_libdir)
770 AC_SUBST(root_sysconfdir)
771 dnl
772 dnl See if -static works.
773 dnl
774 AC_MSG_CHECKING([whether linker accepts -static])
775 AC_CACHE_VAL(ac_cv_e2fsprogs_use_static,
776 [SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -static"
777 AC_TRY_LINK([#include <stdio.h>],[fflush(stdout);],
778  ac_cv_e2fsprogs_use_static=yes, ac_cv_e2fsprogs_use_static=no)
779 LDFLAGS=$SAVE_LDFLAGS])
780 dnl
781 dnl Regardless of how the test turns out, Solaris doesn't handle -static
782 dnl This is caused by the socket library requiring the nsl library, which
783 dnl requires the -dl library, which only works for dynamically linked 
784 dnl programs.  It basically means you can't have statically linked programs
785 dnl which use the network under Solaris.  
786 dnl
787 case "$host_os" in
788 solaris2.*)
789         ac_cv_e2fsprogs_use_static=no   
790 ;;
791 esac
792 AC_MSG_RESULT($ac_cv_e2fsprogs_use_static)
793 LDFLAG_STATIC=
794 if test $ac_cv_e2fsprogs_use_static = yes; then
795         LDFLAG_STATIC=-static
796 fi
797 AC_SUBST(LDFLAG_STATIC)
798 dnl
799 dnl Work around mysterious Darwin / GNU libintl problem
800 dnl (__asm__ redirection doesn't work for some mysterious reason.  Looks like
801 dnl Apple hacked gcc somehow?)
802 dnl
803 case "$host_os" in
804 darwin*)
805         echo "Using Apple Darwin / GNU libintl workaround"
806         AC_DEFINE(_INTL_REDIRECT_MACROS)
807         ;;
808 esac
809 dnl
810 dnl Make the ss and et directories work correctly.
811 dnl
812 SS_DIR=`cd ${srcdir}/lib/ss; pwd`
813 ET_DIR=`cd ${srcdir}/lib/et; pwd`
814 AC_SUBST(SS_DIR)
815 AC_SUBST(ET_DIR)
816 dnl
817 dnl Only try to run the test suite if we're not cross compiling.
818 dnl
819 if test "$cross_compiling" = yes ; then
820   DO_TEST_SUITE=
821 else
822   DO_TEST_SUITE=check
823 fi
824 AC_SUBST(DO_TEST_SUITE)
825 dnl
826 dnl Only include the intl include files if we're building with them
827 dnl 
828 INTL_FLAGS=
829 if test "$USE_INCLUDED_LIBINTL" = "yes" ; then
830         INTL_FLAGS='-I$(top_builddir)/intl -I$(top_srcdir)/intl'
831 fi
832 AC_SUBST(INTL_FLAGS)
833 dnl
834 dnl Build CFLAGS
835 dnl
836 if test $cross_compiling = no; then
837    BUILD_CFLAGS="$CFLAGS"
838    BUILD_LDFLAGS="$LDFLAGS"
839 else
840    BUILD_CFLAGS=
841    BUILD_LDFLAGS=
842 fi
843 AC_SUBST(BUILD_CFLAGS)
844 AC_SUBST(BUILD_LDFLAGS)
845 dnl
846 dnl Make our output files, being sure that we create the some miscellaneous 
847 dnl directories
848 dnl
849 test -d lib || mkdir lib
850 test -d include || mkdir include
851 test -d include/linux || mkdir include/linux
852 test -d include/asm || mkdir include/asm
853 for i in MCONFIG Makefile e2fsprogs.spec \
854         util/Makefile util/subst.conf util/gen-tarball \
855         lib/et/Makefile lib/ss/Makefile lib/e2p/Makefile \
856         lib/ext2fs/Makefile lib/ext2fs/ext2_types.h \
857         lib/uuid/Makefile lib/uuid/uuid_types.h \
858         lib/blkid/Makefile lib/blkid/blkid_types.h \
859         lib/ss/ss.pc lib/uuid/uuid.pc lib/et/com_err.pc \
860         lib/e2p/e2p.pc lib/blkid/blkid.pc lib/ext2fs/ext2fs.pc \
861         misc/Makefile ext2ed/Makefile e2fsck/Makefile \
862         debugfs/Makefile tests/Makefile tests/progs/Makefile \
863         resize/Makefile doc/Makefile intl/Makefile po/Makefile.in ; do
864         if test -d `dirname ${srcdir}/$i` ; then
865                 outlist="$outlist $i"
866         fi
867 done
868 AC_OUTPUT($outlist)
869 if test -f util/gen-tarball; then chmod +x util/gen-tarball; fi
870