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