OSDN Git Service

Merge branch 'maint' into next
[android-x86/external-e2fsprogs.git] / configure.ac
1 AC_INIT(version.h)
2 AC_PREREQ(2.54)
3 AC_CONFIG_AUX_DIR(config)
4 AC_CONFIG_HEADERS([lib/config.h])
5 AH_BOTTOM([#include <dirpaths.h>])
6 MCONFIG=./MCONFIG
7 AC_SUBST_FILE(MCONFIG)
8 BINARY_TYPE=bin
9 dnl
10 dnl This is to figure out the version number and the date....
11 dnl
12 E2FSPROGS_VERSION=`grep E2FSPROGS_VERSION ${srcdir}/version.h  \
13         | awk '{print $3}' | tr \" " " | awk '{print $1}'`
14 DATE=`grep E2FSPROGS_DATE ${srcdir}/version.h | awk '{print $3}' \
15         | tr \" " "`
16 E2FSPROGS_DAY=$(echo $DATE | awk -F- '{print $1}' | sed -e '/^[[1-9]]$/s/^/0/')
17 MONTH=`echo $DATE | awk -F- '{print $2}'`
18 YEAR=`echo $DATE | awk -F- '{print $3}'`
19
20 if expr $YEAR ">" 1900 > /dev/null ; then
21         E2FSPROGS_YEAR=$YEAR
22 elif expr $YEAR ">" 90 >/dev/null ; then
23         E2FSPROGS_YEAR=19$YEAR
24 else
25         E2FSPROGS_YEAR=20$YEAR
26 fi
27
28 case $MONTH in
29 Jan)    MONTH_NUM=01; E2FSPROGS_MONTH="January" ;;
30 Feb)    MONTH_NUM=02; E2FSPROGS_MONTH="February" ;;
31 Mar)    MONTH_NUM=03; E2FSPROGS_MONTH="March" ;;
32 Apr)    MONTH_NUM=04; E2FSPROGS_MONTH="April" ;;
33 May)    MONTH_NUM=05; E2FSPROGS_MONTH="May" ;;
34 Jun)    MONTH_NUM=06; E2FSPROGS_MONTH="June" ;;
35 Jul)    MONTH_NUM=07; E2FSPROGS_MONTH="July" ;;
36 Aug)    MONTH_NUM=08; E2FSPROGS_MONTH="August" ;;
37 Sep)    MONTH_NUM=09; E2FSPROGS_MONTH="September" ;;
38 Oct)    MONTH_NUM=10; E2FSPROGS_MONTH="October" ;;
39 Nov)    MONTH_NUM=11; E2FSPROGS_MONTH="November" ;;
40 Dec)    MONTH_NUM=12; E2FSPROGS_MONTH="December" ;;
41 *)      AC_MSG_WARN([Unknown month $MONTH??]) ;;
42 esac
43
44 base_ver=`echo $E2FSPROGS_VERSION | \
45                sed -e 's/-WIP//' -e 's/pre-//' -e 's/-PLUS//'`
46
47 date_spec=${E2FSPROGS_YEAR}.${MONTH_NUM}.${E2FSPROGS_DAY}
48
49 case $E2FSPROGS_VERSION in
50 *-WIP|pre-*)
51         E2FSPROGS_PKGVER="$base_ver~WIP.$date_spec"
52         ;;
53 *)
54         E2FSPROGS_PKGVER="$base_ver"
55         ;;
56 esac
57
58 unset DATE MONTH YEAR base_ver pre_vers date_spec
59 AC_MSG_RESULT([Generating configuration file for e2fsprogs version $E2FSPROGS_VERSION])
60 AC_MSG_RESULT([Release date is ${E2FSPROGS_MONTH}, ${E2FSPROGS_YEAR}])
61 AC_SUBST(E2FSPROGS_YEAR)
62 AC_SUBST(E2FSPROGS_MONTH)
63 AC_SUBST(E2FSPROGS_DAY)
64 AC_SUBST(E2FSPROGS_VERSION)
65 AC_SUBST(E2FSPROGS_PKGVER)
66 dnl
67 dnl Use diet libc
68 dnl 
69 WITH_DIET_LIBC=
70 AC_ARG_WITH([diet-libc],
71 [  --with-diet-libc        use diet libc],
72 CC="diet cc -nostdinc"
73 WITH_DIET_LIBC=yes
74 if test -z "$LIBS"
75 then
76         LIBS="-lcompat"
77 else
78         LIBS="$LIBS -lcompat"
79 fi
80 AC_MSG_RESULT(CC=$CC))dnl
81 dnl
82 AC_CANONICAL_HOST
83 dnl
84 dnl Check to see if libdl exists for the sake of dlopen
85 dnl
86 DLOPEN_LIB=''
87 AC_CHECK_LIB(dl, dlopen,
88 [DLOPEN_LIB=-ldl
89 AC_DEFINE(HAVE_DLOPEN, 1, [Define to 1 if dlopen/libdl exists])])
90 AC_SUBST(DLOPEN_LIB)
91 dnl
92 AC_ARG_WITH([cc],
93 AC_HELP_STRING([--with-cc],[no longer supported, use CC= instead]),
94 AC_MSG_ERROR([--with-cc no longer supported; use CC= instead]))
95 dnl
96 AC_ARG_WITH([ccopts],
97 AC_HELP_STRING([--with-ccopts],[no longer supported, use CFLAGS= instead]),
98 AC_MSG_ERROR([--with-ccopts no longer supported; use CFLAGS= instead]))
99 dnl
100 AC_ARG_WITH([ldopts],
101 AC_HELP_STRING([--with-ldopts],[no longer supported, use LDFLAGS= instead]),
102 AC_MSG_ERROR([--with-ldopts no longer supported; use LDFLAGS= instead]))
103 dnl
104 AC_PROG_CC
105 if test "$GCC" = yes; then
106    RDYNAMIC="-rdynamic"
107    AC_SUBST(RDYNAMIC)
108 fi
109 AC_PROG_CPP
110 dnl
111 dnl Alpha computers use fast and imprecise floating point code that may
112 dnl miss exceptions by default. Force sane options if we're using GCC.
113 AC_MSG_CHECKING(for additional special compiler flags)
114 if test "$GCC" = yes
115 then
116     case "$host_cpu" in
117         alpha)          addcflags="-mieee" ;;
118     esac
119 fi
120 if test "x$addcflags" != x
121 then
122     AC_MSG_RESULT($addcflags)
123     CFLAGS="$addcflags $CFLAGS"
124 else
125     AC_MSG_RESULT([[(none)]])
126 fi
127 AC_USE_SYSTEM_EXTENSIONS
128 dnl
129 dnl Set default values for library extentions.  Will be dealt with after
130 dnl parsing configuration opions, which may modify these
131 dnl
132 LIB_EXT=.a
133 STATIC_LIB_EXT=.a
134 PROFILED_LIB_EXT=.a
135 dnl
136 dnl Allow separate `root_prefix' to be specified
137 dnl
138 AC_ARG_WITH([root-prefix],
139 [  --with-root-prefix=PREFIX override prefix variable for files to be placed in the root],
140 root_prefix=$withval,
141 root_prefix=NONE)dnl
142 dnl
143 dnl handle --enable-maintainer-mode
144 dnl
145 AC_ARG_ENABLE([maintainer-mode],
146 [  --enable-maintainer-mode enable makefile rules useful for maintainers],
147 if test "$enableval" = "no"
148 then
149         MAINTAINER_CMT=#
150         AC_MSG_RESULT([Disabling maintainer mode])
151 else
152         MAINTAINER_CMT=
153         AC_MSG_RESULT([Enabling maintainer mode])
154 fi
155 ,
156 MAINTAINER_CMT=#
157 AC_MSG_RESULT([Disabling maintainer mode by default])
158 )
159 AC_SUBST(MAINTAINER_CMT)
160 dnl
161 dnl handle --enable-symlink-install
162 dnl
163 AC_ARG_ENABLE([symlink-install],
164 [  --enable-symlink-install use symlinks when installing instead of hard links],
165 if test "$enableval" = "no"
166 then
167         LINK_INSTALL_FLAGS=-f
168         AC_MSG_RESULT([Disabling symlinks for install])
169 else
170         LINK_INSTALL_FLAGS=-sf
171         AC_MSG_RESULT([Enabling symlinks for install])
172 fi
173 ,
174 LINK_INSTALL_FLAGS=-f
175 AC_MSG_RESULT([Disabling symlinks for install by default])
176 )
177 AC_SUBST(LINK_INSTALL_FLAGS)
178 dnl
179 dnl handle --enable-relative-symlinks
180 dnl
181 relative_symlink_defined=
182 AC_ARG_ENABLE([relative-symlinks],
183 [  --enable-relative-symlinks use relative symlinks when installing],
184 if test "$enableval" = "no"
185 then
186         SYMLINK_RELATIVE=
187         relative_symlink_defined=yes
188         AC_MSG_RESULT([Disabling relative symlinks for install])
189 else
190         SYMLINK_RELATIVE=--relative
191         relative_symlink_defined=yes
192         AC_MSG_RESULT([Enabling relative symlinks for install])
193 fi)
194 AC_ARG_ENABLE([symlink-relative-symlinks],,
195 if test "$enableval" = "no"
196 then
197         SYMLINK_RELATIVE=yes
198         AC_MSG_RESULT([Disabling relative symlinks for install])
199 else
200         SYMLINK_RELATIVE=--relative
201         AC_MSG_RESULT([Enabling relative symlinks for install])
202 fi
203 ,
204 if test -z "$relative_symlink_defined"
205 then
206         SYMLINK_RELATIVE=
207 AC_MSG_RESULT([Disabling relative symlinks for install by default])
208 fi
209 )
210 AC_SUBST(SYMLINK_RELATIVE)
211 dnl
212 dnl handle --enable-symlink-build
213 dnl
214 AC_ARG_ENABLE([symlink-build],
215 [  --enable-symlink-build  use symlinks while building instead of hard links],
216 if test "$enableval" = "no"
217 then
218         LINK_BUILD_FLAGS=
219         AC_MSG_RESULT([Disabling symlinks for build])
220 else
221         LINK_BUILD_FLAGS=-s
222         AC_MSG_RESULT([Enabling symlinks for build])
223 fi
224 ,
225 LINK_BUILD_FLAGS=
226 AC_MSG_RESULT([Disabling symlinks for build by default])
227 )
228 AC_SUBST(LINK_BUILD_FLAGS)
229 dnl
230 dnl handle --enable-verbose-makecmds
231 dnl
232 AC_ARG_ENABLE([verbose-makecmds],
233 [  --enable-verbose-makecmds enable verbose make command output],
234 if test "$enableval" = "no"
235 then
236         AC_MSG_RESULT([Disabling verbose make commands])
237         E=@echo
238         ES=echo
239         Q=@
240 else
241         AC_MSG_RESULT([Enabling verbose make commands])
242         E=@\\#
243         ES=\\#
244         Q= 
245 fi
246 ,
247 AC_MSG_RESULT([Disabling verbose make commands])
248 E=@echo
249 ES=echo
250 Q=@
251 )
252 AC_SUBST(E)
253 AC_SUBST(ES)
254 AC_SUBST(Q)
255 dnl
256 dnl This needs to be before all of the --enable-*-shlibs options
257 dnl
258 E2_PKG_CONFIG_STATIC=--static
259 LDFLAG_DYNAMIC=
260 PRIVATE_LIBS_CMT=
261 dnl
262 dnl handle --enable-elf-shlibs
263 dnl
264 AC_ARG_ENABLE([elf-shlibs],
265 [  --enable-elf-shlibs    select ELF shared libraries],
266 if test "$enableval" = "no"
267 then
268         ELF_CMT=#
269         MAKEFILE_ELF=/dev/null
270         AC_MSG_RESULT([Disabling ELF shared libraries])
271 else
272         E2_PKG_CONFIG_STATIC=
273         ELF_CMT=
274         MAKEFILE_ELF=$srcdir/lib/Makefile.elf-lib
275         [case "$host_os" in
276         solaris2.*)
277                 MAKEFILE_ELF=$srcdir/lib/Makefile.solaris-lib
278         ;;
279         esac]
280         BINARY_TYPE=elfbin
281         LIB_EXT=.so
282         PRIVATE_LIBS_CMT=#
283         LDFLAG_DYNAMIC=['-Wl,-rpath-link,$(top_builddir)/lib']
284         AC_MSG_RESULT([Enabling ELF shared libraries])
285 fi
286 ,
287 MAKEFILE_ELF=/dev/null
288 ELF_CMT=#
289 AC_MSG_RESULT([Disabling ELF shared libraries by default])
290 )
291 AC_SUBST(ELF_CMT)
292 AC_SUBST_FILE(MAKEFILE_ELF)
293 dnl
294 dnl handle --enable-bsd-shlibs
295 dnl
296 AC_ARG_ENABLE([bsd-shlibs],
297 [  --enable-bsd-shlibs    select BSD shared libraries],
298 if test "$enableval" = "no"
299 then
300         BSDLIB_CMT=#
301         MAKEFILE_BSDLIB=/dev/null
302         AC_MSG_RESULT([Disabling BSD shared libraries])
303 else
304         E2_PKG_CONFIG_STATIC=
305         BSDLIB_CMT=
306         MAKEFILE_BSDLIB=$srcdir/lib/Makefile.bsd-lib
307         LIB_EXT=.so
308         [case "$host_os" in
309         darwin*)
310                 MAKEFILE_BSDLIB=$srcdir/lib/Makefile.darwin-lib
311                 LIB_EXT=.dylib
312         ;;
313         esac]
314         AC_MSG_RESULT([Enabling BSD shared libraries])
315 fi
316 ,
317 MAKEFILE_BSDLIB=/dev/null
318 BSDLIB_CMT=#
319 AC_MSG_RESULT([Disabling BSD shared libraries by default])
320 )
321 AC_SUBST(BSDLIB_CMT)
322 AC_SUBST_FILE(MAKEFILE_BSDLIB)
323 dnl
324 dnl handle --enable-profile
325 dnl
326 AC_ARG_ENABLE([profile],
327 [  --enable-profile       build profiling libraries],
328 if test "$enableval" = "no"
329 then
330         PROFILE_CMT=#
331         MAKEFILE_PROFILE=/dev/null
332         AC_MSG_RESULT([Disabling profiling libraries])
333 else
334         PROFILE_CMT=
335         MAKEFILE_PROFILE=$srcdir/lib/Makefile.profile
336         PROFILED_LIB_EXT=_p.a
337         AC_MSG_RESULT([Building profiling libraries])
338 fi
339 ,
340 PROFILE_CMT=#
341 MAKEFILE_PROFILE=/dev/null
342 AC_MSG_RESULT([Disabling profiling libraries by default])
343 )
344 AC_SUBST(PROFILE_CMT)
345 AC_SUBST_FILE(MAKEFILE_PROFILE)
346 dnl
347 dnl handle --enable-gcov
348 dnl
349 AC_ARG_ENABLE([gcov],
350 [  --enable-gcov                  build for coverage testing using gcov],
351 if test "$enableval" = "yes"
352 then
353         CFLAGS="-g -fprofile-arcs -ftest-coverage"
354         LDFLAGS="-fprofile-arcs -ftest-coverage"
355         AC_MSG_RESULT([Enabling gcov support])
356 fi
357 )
358
359 dnl
360 dnl Substitute library extensions
361 dnl
362 AC_SUBST(LIB_EXT)
363 AC_SUBST(STATIC_LIB_EXT)
364 AC_SUBST(PROFILED_LIB_EXT)
365 AC_SUBST(LDFLAG_DYNAMIC)
366 AC_SUBST(PRIVATE_LIBS_CMT)
367 dnl
368 dnl handle --enable-jbd-debug
369 dnl
370 AC_ARG_ENABLE([jbd-debug],
371 [  --enable-jbd-debug     enable journal debugging],
372 if test "$enableval" = "no"
373 then
374         AC_MSG_RESULT([Disabling journal debugging])
375 else
376         AC_DEFINE(CONFIG_JBD_DEBUG, 1,
377                 [Define to 1 if debugging ext3/4 journal code])
378         AC_MSG_RESULT([Enabling journal debugging])
379 fi
380 ,
381 AC_MSG_RESULT([Disabling journal debugging by default])
382 )
383 dnl
384 dnl handle --enable-blkid-debug
385 dnl
386 AC_ARG_ENABLE([blkid-debug],
387 [  --enable-blkid-debug    enable blkid debugging],
388 if test "$enableval" = "no"
389 then
390         AC_MSG_RESULT([Disabling blkid debugging])
391 else
392         AC_DEFINE(CONFIG_BLKID_DEBUG, 1,
393                 [Define to 1 if debugging the blkid library])
394         AC_MSG_RESULT([Enabling blkid debugging])
395 fi
396 ,
397 AC_MSG_RESULT([Disabling blkid debugging by default])
398 )
399 dnl
400 dnl handle --enable-testio-debug
401 dnl
402 AC_ARG_ENABLE([testio-debug],
403 [  --disable-testio-debug  disable the use of the test I/O manager for debugging],
404 AH_TEMPLATE([CONFIG_TESTIO_DEBUG],
405         [Define to 1 if the testio I/O manager should be enabled])
406 if test "$enableval" = "no"
407 then
408         AC_MSG_RESULT([Disabling testio debugging])
409         TEST_IO_CMT="#"
410 else
411         TEST_IO_CMT=
412         AC_DEFINE(CONFIG_TESTIO_DEBUG, 1)
413         AC_MSG_RESULT([Enabling testio debugging])
414 fi
415 ,
416 AC_MSG_RESULT([Enabling testio debugging by default])
417 AC_DEFINE(CONFIG_TESTIO_DEBUG, 1)
418 TEST_IO_CMT=
419 )
420 AC_SUBST(TEST_IO_CMT)
421 dnl
422 dnl handle --disable-libuuid
423 dnl
424 PKG_PROG_PKG_CONFIG
425 LIBUUID=
426 DEPLIBUUID=
427 STATIC_LIBUUID=
428 DEPSTATIC_LIBUUID=
429 PROFILED_LIBUUID=
430 DEPPROFILED_LIBUUID=
431 UUID_CMT=
432 AC_ARG_ENABLE([libuuid],
433 [  --enable-libuuid       build and use private uuid library],
434 if test "$enableval" = "no"
435 then
436         if test -z "$PKG_CONFIG"; then
437                 AC_MSG_ERROR([pkg-config not installed; please install it.])
438         fi
439
440         AC_CHECK_LIB(uuid, uuid_generate,
441                 [LIBUUID=`$PKG_CONFIG --libs uuid`;
442                  STATIC_LIBUUID=`$PKG_CONFIG --static --libs uuid`],
443                 [AC_MSG_ERROR([external uuid library not found])])
444         PROFILED_LIBUUID=$LIBUUID
445         UUID_CMT=#
446         AC_MSG_RESULT([Disabling private uuid library])
447 else
448         LIBUUID='$(LIB)/libuuid'$LIB_EXT
449         DEPLIBUUID=$LIBUUID
450         STATIC_LIBUUID='$(LIB)/libuuid'$STATIC_LIB_EXT
451         DEPSTATIC_LIBUUID=$STATIC_LIBUUID
452         PROFILED_LIBUUID='$(LIB)/libuuid'$PROFILED_LIB_EXT
453         DEPPROFILED_LIBUUID=$PROFILED_LIBUUID
454         AC_MSG_RESULT([Enabling private uuid library])
455 fi
456 ,
457 if test -n "$PKG_CONFIG"; then
458         AC_CHECK_LIB(uuid, uuid_generate,
459                 [LIBUUID=`$PKG_CONFIG --libs uuid`;
460                  STATIC_LIBUUID=`$PKG_CONFIG --static --libs uuid`])
461 fi
462 if test -n "$LIBUUID"; then
463         PROFILED_LIBUUID=$LIBUUID
464         UUID_CMT=#
465         AC_MSG_RESULT([Using system uuid by default])
466 else
467         LIBUUID='$(LIB)/libuuid'$LIB_EXT
468         DEPLIBUUID=$LIBUUID
469         STATIC_LIBUUID='$(LIB)/libuuid'$STATIC_LIB_EXT
470         DEPSTATIC_LIBUUID=$STATIC_LIBUUID
471         PROFILED_LIBUUID='$(LIB)/libuuid'$PROFILED_LIB_EXT
472         DEPPROFILED_LIBUUID=$PROFILED_LIBUUID
473         AC_MSG_RESULT([Enabling private uuid library by default])
474 fi
475 )
476 AC_SUBST(LIBUUID)
477 AC_SUBST(DEPLIBUUID)
478 AC_SUBST(STATIC_LIBUUID)
479 AC_SUBST(DEPSTATIC_LIBUUID)
480 AC_SUBST(PROFILED_LIBUUID)
481 AC_SUBST(DEPPROFILED_LIBUUID)
482 AC_SUBST(UUID_CMT)
483 dnl
484 dnl handle --disable-libblkid
485 dnl
486 PKG_PROG_PKG_CONFIG
487 LIBBLKID=
488 DEPLIBBLKID=
489 STATIC_LIBBLKID=
490 DEPSTATIC_LIBBLKID=
491 PROFILED_LIBBLKID=
492 DEPPROFILED_LIBBLKID=
493 BLKID_CMT=
494 AH_TEMPLATE([CONFIG_BUILD_FINDFS], [Define to 1 to compile findfs])
495 AC_ARG_ENABLE([libblkid],
496 [  --enable-libblkid      build and use private blkid library],
497 if test "$enableval" = "no"
498 then
499         if test -z "$PKG_CONFIG"; then
500                 AC_MSG_ERROR([pkg-config not installed; please install it.])
501         fi
502
503         AC_CHECK_LIB(blkid, blkid_get_cache,
504                 [LIBBLKID=`$PKG_CONFIG --libs blkid`;
505                  STATIC_LIBBLKID=`$PKG_CONFIG --static --libs blkid`],
506                 [AC_MSG_ERROR([external blkid library not found])], -luuid)
507         BLKID_CMT=#
508         PROFILED_LIBBLKID=$LIBBLKID
509         AC_MSG_RESULT([Disabling private blkid library])
510 else
511         LIBBLKID='$(LIB)/libblkid'$LIB_EXT
512         DEPLIBBLKID=$LIBBLKID
513         STATIC_LIBBLKID='$(LIB)/libblkid'$STATIC_LIB_EXT
514         DEPSTATIC_LIBBLKID=$STATIC_LIBBLKID
515         PROFILED_LIBBLKID='$(LIB)/libblkid'$PROFILED_LIB_EXT
516         DEPPROFILED_LIBBLKID=$PROFILED_LIBBLKID
517         AC_DEFINE(CONFIG_BUILD_FINDFS, 1)
518         AC_MSG_RESULT([Enabling private blkid library])
519 fi
520 ,
521 if test -n "$PKG_CONFIG"; then
522         AC_CHECK_LIB(blkid, blkid_get_cache,
523                 [LIBBLKID=`$PKG_CONFIG --libs blkid`;
524                  STATIC_LIBBLKID=`$PKG_CONFIG --static --libs blkid`])
525 fi
526 if test -n "$LIBBLKID"; then
527         BLKID_CMT=#
528         PROFILED_LIBBLKID=$LIBBLKID
529         AC_MSG_RESULT([Using system blkid library by default])
530 else
531         LIBBLKID='$(LIB)/libblkid'$LIB_EXT
532         DEPLIBBLKID=$LIBBLKID
533         STATIC_LIBBLKID='$(LIB)/libblkid'$STATIC_LIB_EXT
534         DEPSTATIC_LIBBLKID=$STATIC_LIBBLKID
535         PROFILED_LIBBLKID='$(LIB)/libblkid'$PROFILED_LIB_EXT
536         DEPPROFILED_LIBBLKID=$PROFILED_LIBBLKID
537         AC_DEFINE(CONFIG_BUILD_FINDFS, 1)
538         AC_MSG_RESULT([Enabling private blkid library by default])
539 fi
540 )
541 AC_SUBST(LIBBLKID)
542 AC_SUBST(DEPLIBBLKID)
543 AC_SUBST(STATIC_LIBBLKID)
544 AC_SUBST(DEPSTATIC_LIBBLKID)
545 AC_SUBST(PROFILED_LIBBLKID)
546 AC_SUBST(DEPPROFILED_LIBBLKID)
547 AC_SUBST(BLKID_CMT)
548 dnl
549 dnl handle --disable-backtrace
550 dnl
551 AH_TEMPLATE([DISABLE_BACKTRACE], [Define to 1 to disable use of backtrace])
552 AC_ARG_ENABLE([backtrace],
553 [  --disable-backtrace    disable use backtrace],
554 if test "$enableval" = "no"
555 then
556         AC_MSG_RESULT([Disabling use of backtrace])
557         AC_DEFINE(DISABLE_BACKTRACE, 1)
558 else
559         AC_MSG_RESULT([Enabling use of backtrace])
560 fi
561 ,
562 AC_MSG_RESULT([Enabling use of backtrace by default])
563 )
564 dnl
565 dnl handle --enable-debugfs
566 dnl
567 AC_ARG_ENABLE([debugfs],
568 [  --disable-debugfs      disable support of debugfs program],
569 if test "$enableval" = "no"
570 then
571         AC_MSG_RESULT([Disabling debugfs support])
572         DEBUGFS_CMT="#"
573 else
574         DEBUGFS_CMT=
575         AC_MSG_RESULT([Enabling debugfs support])
576 fi
577 ,
578 AC_MSG_RESULT([Enabling debugfs support by default])
579 DEBUGFS_CMT=
580 )
581 AC_SUBST(DEBUGFS_CMT)
582 dnl
583 dnl handle --enable-imager
584 dnl
585 AC_ARG_ENABLE([imager],
586 [  --disable-imager       disable support of e2image program],
587 if test "$enableval" = "no"
588 then
589         AC_MSG_RESULT([Disabling e2image support])
590         IMAGER_CMT="#"
591 else
592         IMAGER_CMT=
593         AC_MSG_RESULT([Enabling e2image support])
594 fi
595 ,
596 AC_MSG_RESULT([Enabling e2image support by default])
597 IMAGER_CMT=
598 )
599 AC_SUBST(IMAGER_CMT)
600 dnl
601 dnl handle --enable-resizer
602 dnl
603 AC_ARG_ENABLE([resizer],
604 [  --disable-resizer      disable support of e2resize program],
605 if test "$enableval" = "no"
606 then
607         AC_MSG_RESULT([Disabling e2resize support])
608         RESIZER_CMT="#"
609 else
610         RESIZER_CMT=
611         AC_MSG_RESULT([Enabling e2resize support])
612 fi
613 ,
614 AC_MSG_RESULT([Enabling e2resize support by default])
615 RESIZER_CMT=
616 )
617 AC_SUBST(RESIZER_CMT)
618 dnl
619 dnl handle --enable-defrag
620 dnl
621 AC_ARG_ENABLE([defrag],
622 [  --disable-defrag       disable support of e4defrag program],
623 if test "$enableval" = "no"
624 then
625         AC_MSG_RESULT([Disabling e4defrag support])
626         DEFRAG_CMT="#"
627 else
628         DEFRAG_CMT=
629         AC_MSG_RESULT([Enabling e4defrag support])
630 fi
631 ,
632 if test -z "$WITH_DIET_LIBC"
633 then
634         AC_MSG_RESULT([Enabling e4defrag support by default])
635         DEFRAG_CMT=
636 else
637         AC_MSG_RESULT([Disabling e4defrag support by default])
638         DEFRAG_CMT="#"
639 fi
640 )
641 AC_SUBST(DEFRAG_CMT)
642 dnl
643 dnl See whether to install the `fsck' wrapper program (that calls e2fsck)
644 dnl
645 AC_ARG_ENABLE([fsck],
646 [  --enable-fsck           build fsck wrapper program],
647 [if test "$enableval" = "no"
648 then
649         FSCK_PROG='' FSCK_MAN=''
650         AC_MSG_RESULT([Not building fsck wrapper])
651 else
652         FSCK_PROG=fsck FSCK_MAN=fsck.8
653         AC_MSG_RESULT([Building fsck wrapper])
654 fi]
655 ,
656 [case "$host_os" in
657   gnu*)
658     FSCK_PROG='' FSCK_MAN=''
659     AC_MSG_RESULT([Not building fsck wrapper by default])
660     ;;
661   *)
662     FSCK_PROG=fsck FSCK_MAN=fsck.8
663     AC_MSG_RESULT([Building fsck wrapper by default])
664 esac]
665 )
666 AC_SUBST(FSCK_PROG)
667 AC_SUBST(FSCK_MAN)
668 dnl
669 dnl See whether to install the `e2initrd-helper' program
670 dnl
671 AC_ARG_ENABLE([e2initrd-helper],
672 [  --enable-e2initrd-helper build e2initrd-helper program],
673 [if test "$enableval" = "no"
674 then
675         E2INITRD_PROG='' E2INITRD_MAN=''
676         AC_MSG_RESULT([Not building e2initrd helper])
677 else
678         E2INITRD_PROG=e2initrd_helper E2INITRD_MAN=e2initrd_helper.8
679         AC_MSG_RESULT([Building e2initrd helper])
680 fi]
681 ,
682 E2INITRD_PROG=e2initrd_helper E2INITRD_MAN=e2initrd_helper.8
683 AC_MSG_RESULT([Building e2initrd helper by default])
684 )
685 AC_SUBST(E2INITRD_PROG)
686 AC_SUBST(E2INITRD_MAN)
687 dnl
688 dnl
689 dnl
690 AC_ARG_ENABLE([tls],
691 [  --disable-tls           disable use of thread local support],
692 [if test "$enableval" = "no"
693 then
694         try_tls=""
695         AC_MSG_RESULT([Disabling thread local support])
696 else
697         try_tls="yes"
698         AC_MSG_RESULT([Enabling thread local support])
699 fi]
700 ,
701 if test -n "$WITH_DIET_LIBC"
702 then
703         try_tls=""
704         AC_MSG_RESULT([Diet libc does not support thread local support])
705 else
706         try_tls="yes"
707         AC_MSG_RESULT([Try using thread local support by default])
708 fi
709 )
710 if test "$try_tls" = "yes"
711 then
712 AX_TLS
713 fi
714 dnl
715 dnl
716 dnl
717 AH_TEMPLATE([USE_UUIDD], [Define to 1 to build uuidd])
718 AC_ARG_ENABLE([uuidd],
719 [  --disable-uuidd         disable building the uuid daemon],
720 [if test "$enableval" = "no"
721 then
722         AC_MSG_RESULT([Not building uuidd])
723         UUIDD_CMT="#"
724 else
725         AC_DEFINE(USE_UUIDD, 1)
726         UUIDD_CMT=""
727         AC_MSG_RESULT([Building uuidd])
728 fi]
729 ,
730 AC_DEFINE(USE_UUIDD, 1)
731 if test -z "$UUID_CMT"
732 then
733         UUIDD_CMT=""
734         AC_MSG_RESULT([Building uuidd by default])
735 else
736         UUIDD_CMT="#"
737         AC_MSG_RESULT([Disabling uuidd by default])
738 fi
739 )
740 AC_SUBST(UUIDD_CMT)
741 dnl
742 dnl handle --disable-mmp
743 dnl
744 AH_TEMPLATE([CONFIG_MMP], [Define to 1 to enable mmp support])
745 AC_ARG_ENABLE([mmp],
746 [  --disable-mmp           disable support mmp, Multi Mount Protection],
747 if test "$enableval" = "no"
748 then
749         AC_MSG_RESULT([Disabling mmp support])
750 else
751         AC_MSG_RESULT([Enabling mmp support])
752         AC_DEFINE(CONFIG_MMP, 1)
753 fi
754 ,
755 AC_MSG_RESULT([Enabling mmp support by default])
756 AC_DEFINE(CONFIG_MMP, 1)
757 )
758 dnl
759 dnl handle --disable-bmap-stats
760 dnl
761 AH_TEMPLATE([ENABLE_BMAP_STATS], [Define to 1 to enable bitmap stats.])
762 AC_ARG_ENABLE([bmap-stats],
763 [  --disable-bmap-stats    disable collection of bitmap stats.],
764 if test "$enableval" = "no"
765 then
766         AC_MSG_RESULT([Disabling bitmap statistics support])
767 else
768         AC_MSG_RESULT([Enabling bitmap statistics support])
769         AC_DEFINE(ENABLE_BMAP_STATS, 1)
770 fi
771 ,
772 AC_MSG_RESULT([Enabling bitmap statistics support by default])
773 AC_DEFINE(ENABLE_BMAP_STATS, 1)
774 )
775 dnl
776 dnl handle --enable-bmap-stats-ops
777 dnl
778 AH_TEMPLATE([ENABLE_BMAP_STATS_OPS], [Define to 1 to enable bitmap stats.])
779 AC_ARG_ENABLE([bmap-stats-ops],
780 [  --enable-bmap-stats-ops enable collection of additional bitmap stats],
781 if test "$enableval" = "no"
782 then
783         AC_MSG_RESULT([Disabling additional bitmap statistics])
784 else
785         dnl There has to be a better way!
786         AS_IF([test "x${enable_bmap_stats}" = "xno"],
787          AC_MSG_FAILURE([Error --enable-bmap-stats-ops requires bmap-stats]))
788
789         AC_MSG_RESULT([Enabling additional bitmap statistics])
790         AC_DEFINE(ENABLE_BMAP_STATS_OPS, 1)
791 fi
792 ,
793 AC_MSG_RESULT([Disabling additional bitmap statistics by default])
794 )
795 dnl
796 dnl
797 dnl
798 MAKEFILE_LIBRARY=$srcdir/lib/Makefile.library
799 AC_SUBST_FILE(MAKEFILE_LIBRARY)
800 dnl
801 dnl Add internationalization support, using gettext.
802 dnl
803 GETTEXT_PACKAGE=e2fsprogs
804 PACKAGE=e2fsprogs
805 VERSION="$E2FSPROGS_VERSION"
806 VERSION=0.14.1
807 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [package name for gettext])
808 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [version for gettext])
809 AC_SUBST(GETTEXT_PACKAGE)
810 AC_SUBST(PACKAGE)
811 AC_SUBST(VERSION)
812
813 AM_GNU_GETTEXT
814 dnl
815 dnl End of configuration options
816 dnl
817 AC_SUBST(BINARY_TYPE)
818 AC_PROG_MAKE_SET
819 CHECK_GNU_MAKE
820 AC_PATH_PROG(LN, ln, ln)
821 AC_PROG_LN_S
822 AC_PATH_PROG(MV, mv, mv)
823 AC_PATH_PROG(CP, cp, cp)
824 AC_PATH_PROG(RM, rm, rm)
825 AC_PATH_PROG(CHMOD, chmod, :)
826 AC_PROG_AWK
827 AC_PROG_EGREP
828 AC_PATH_PROG(SED, sed, sed)
829 AC_PATH_PROG(PERL, perl, perl)
830 AC_PATH_PROG(LDCONFIG, ldconfig, :)
831 AC_CHECK_TOOL(AR, ar, ar)
832 AC_CHECK_TOOL(RANLIB, ranlib, :)
833 AC_CHECK_TOOL(STRIP, strip, :)
834 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
835 if test "_$MAKEINFO" = "_"; then
836     MAKEINFO="@echo Makeinfo is missing. Info documentation will not be built.;true"
837 else
838     case "$MAKEINFO" in
839       */missing.*)
840         AC_MSG_WARN([
841 *** Makeinfo is missing. Info documentation will not be built.])
842         ;;
843       *)
844         ;;
845     esac
846 fi
847 AC_SUBST(MAKEINFO)
848 AC_PROG_INSTALL
849 # See if we need a separate native compiler.
850 if test $cross_compiling = no; then
851   BUILD_CC="$CC"
852   AC_SUBST(BUILD_CC)
853 else
854   AC_CHECK_PROGS(BUILD_CC, gcc cc)
855 fi
856 AC_CHECK_HEADERS(m4_flatten([
857         dirent.h
858         errno.h
859         execinfo.h
860         getopt.h
861         malloc.h
862         mntent.h
863         paths.h
864         semaphore.h
865         setjmp.h
866         signal.h
867         stdarg.h
868         stdint.h
869         stdlib.h
870         termios.h
871         termio.h
872         unistd.h
873         utime.h
874         attr/xattr.h
875         linux/falloc.h
876         linux/fd.h
877         linux/major.h
878         linux/loop.h
879         net/if_dl.h
880         netinet/in.h
881         sys/acl.h
882         sys/disklabel.h
883         sys/disk.h
884         sys/file.h
885         sys/ioctl.h
886         sys/key.h
887         sys/mkdev.h
888         sys/mman.h
889         sys/mount.h
890         sys/prctl.h
891         sys/resource.h
892         sys/select.h
893         sys/socket.h
894         sys/sockio.h
895         sys/stat.h
896         sys/syscall.h
897         sys/sysctl.h
898         sys/sysmacros.h
899         sys/time.h
900         sys/types.h
901         sys/un.h
902         sys/wait.h
903 ]))
904 AC_CHECK_HEADERS(net/if.h,,,
905 [[
906 #if HAVE_SYS_TYPES_H
907 #include <sys/types.h>
908 #endif
909 #if HAVE_SYS_SOCKET
910 #include <sys/socket.h>
911 #endif
912 ]])
913 AC_FUNC_VPRINTF
914 dnl Check to see if dirent has member d_reclen. On cygwin those d_reclen
915 dnl is not decleared.
916 AC_CHECK_MEMBER(struct dirent.d_reclen,[AC_DEFINE(HAVE_RECLEN_DIRENT, 1,
917                        [Define to 1 if dirent has d_reclen])],,
918                 [#include <dirent.h>])
919 AC_CHECK_MEMBERS([struct stat.st_atim])
920 dnl Check to see if ssize_t was declared
921 AC_CHECK_TYPE(ssize_t,[AC_DEFINE(HAVE_TYPE_SSIZE_T, 1,
922                 [Define to 1 if ssize_t declared])],,
923               [#include <sys/types.h>])
924 dnl
925 dnl Check to see if llseek() is declared in unistd.h.  On some libc's 
926 dnl it is, and on others it isn't..... Thank you glibc developers....
927 dnl
928 AC_CHECK_DECL(llseek,[AC_DEFINE(HAVE_LLSEEK_PROTOTYPE, 1,
929                         [Define to 1 if llseek declared in unistd.h])],,
930               [#include <unistd.h>])
931 dnl
932 dnl Check to see if lseek64() is declared in unistd.h.  Glibc's header files
933 dnl are so convoluted that I can't tell whether it will always be defined,
934 dnl and if it isn't defined while lseek64 is defined in the library, 
935 dnl disaster will strike.  
936 dnl
937 dnl Warning!  Use of --enable-gcc-wall may throw off this test.
938 dnl
939 dnl
940 AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1,
941                         [Define to 1 if lseek64 declared in unistd.h])],,
942                 [#define _LARGEFILE_SOURCE
943                  #define _LARGEFILE64_SOURCE
944                  #include <unistd.h>])
945 dnl
946 dnl Word sizes...
947 dnl
948 AC_CHECK_SIZEOF(short)
949 AC_CHECK_SIZEOF(int)
950 AC_CHECK_SIZEOF(long)
951 AC_CHECK_SIZEOF(long long)
952 AC_CHECK_SIZEOF(off_t)
953 SIZEOF_SHORT=$ac_cv_sizeof_short
954 SIZEOF_INT=$ac_cv_sizeof_int
955 SIZEOF_LONG=$ac_cv_sizeof_long
956 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
957 SIZEOF_OFF_T=$ac_cv_sizeof_off_t
958 AC_SUBST(SIZEOF_SHORT)
959 AC_SUBST(SIZEOF_INT)
960 AC_SUBST(SIZEOF_LONG)
961 AC_SUBST(SIZEOF_LONG_LONG)
962 AC_SUBST(SIZEOF_OFF_T)
963 AC_C_BIGENDIAN
964 if test $cross_compiling = no; then
965   BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
966 else
967   CROSS_COMPILE="1" BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
968 fi
969 ASM_TYPES_HEADER=./asm_types.h
970 AC_SUBST_FILE(ASM_TYPES_HEADER)
971 dnl
972 dnl Save the configuration #defines needed for the public ext2fs.h
973 dnl header file
974 dnl
975 echo "/* These defines are needed for the public ext2fs.h header file */" \
976      > public_config.h
977 if grep HAVE_SYS_TYPES_H confdefs.h > tmp_config.$$; then
978   uniq tmp_config.$$ >> public_config.h
979 else
980   echo "#undef HAVE_SYS_TYPES_H" >> public_config.h
981 fi
982 if grep WORDS_BIGENDIAN confdefs.h > tmp_config.$$; then
983   uniq tmp_config.$$ >> public_config.h
984 else
985   echo "#undef WORDS_BIGENDIAN" >> public_config.h
986 fi
987 rm -f tmp_config.$$
988 PUBLIC_CONFIG_HEADER=./public_config.h
989 AC_SUBST_FILE(PUBLIC_CONFIG_HEADER)
990 dnl
991 dnl See if we have inttypes.h and if intptr_t is defined
992 dnl
993 AC_CHECK_HEADERS([inttypes.h])
994 AC_CHECK_TYPES(intptr_t)
995 dnl
996 dnl See if struct stat has a st_flags field, in which case we can get file
997 dnl flags somewhat portably.  Also check for the analogous setter, chflags().
998 dnl
999 AC_MSG_CHECKING(whether struct stat has a st_flags field)
1000 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
1001         AC_TRY_COMPILE([#include <sys/stat.h>],
1002                 [struct stat stat; stat.st_flags = 0;],
1003                 [e2fsprogs_cv_struct_st_flags=yes],
1004                 [e2fsprogs_cv_struct_st_flags=no]))
1005 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
1006 if test "$e2fsprogs_cv_struct_st_flags" = yes; then
1007   AC_MSG_CHECKING(whether st_flags field is useful)
1008   AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags_immut,
1009         AC_TRY_COMPILE([#include <sys/stat.h>],
1010                 [struct stat stat; stat.st_flags |= UF_IMMUTABLE;],
1011                 [e2fsprogs_cv_struct_st_flags_immut=yes],
1012                 [e2fsprogs_cv_struct_st_flags_immut=no]))
1013   AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags_immut)
1014   if test "$e2fsprogs_cv_struct_st_flags_immut" = yes; then
1015           AC_DEFINE(HAVE_STAT_FLAGS, 1,
1016                 [Define to 1 if struct stat has st_flags])
1017   fi
1018 fi
1019 dnl
1020 dnl Check for the presence of SA_LEN
1021 dnl
1022 AC_CHECK_MEMBER(struct sockaddr.sa_len,
1023                 AC_DEFINE_UNQUOTED(HAVE_SA_LEN,1,
1024                         [Define to 1 if if struct sockaddr contains sa_len]),,
1025         [#include <sys/types.h>
1026          #include <sys/socket.h>])
1027 dnl
1028 dnl This will add -lblkid to the AC_CHECK_FUNCS search if we are using
1029 dnl the system-provided blkid library
1030 dnl
1031 if test -n "$BLKID_CMT"; then
1032   AC_SEARCH_LIBS([blkid_probe_all], [blkid])
1033 fi
1034 dnl
1035 AC_CHECK_FUNCS(m4_flatten([
1036         __secure_getenv
1037         add_key
1038         backtrace
1039         blkid_probe_get_topology
1040         blkid_probe_enable_partitions
1041         chflags
1042         fadvise64
1043         fallocate
1044         fallocate64
1045         fchown
1046         fdatasync
1047         fstat64
1048         ftruncate64
1049         futimes
1050         getcwd
1051         getdtablesize
1052         getmntinfo
1053         getpwuid_r
1054         getrlimit
1055         getrusage
1056         jrand48
1057         keyctl
1058         llistxattr
1059         llseek
1060         lseek64
1061         mallinfo
1062         mbstowcs
1063         memalign
1064         mempcpy
1065         mmap
1066         msync
1067         nanosleep
1068         open64
1069         pathconf
1070         posix_fadvise
1071         posix_fadvise64
1072         posix_memalign
1073         prctl
1074         pread
1075         pwrite
1076         pread64
1077         pwrite64
1078         secure_getenv
1079         setmntent
1080         setresgid
1081         setresuid
1082         snprintf
1083         srandom
1084         stpcpy
1085         strcasecmp
1086         strdup
1087         strnlen
1088         strptime
1089         strtoull
1090         sync_file_range
1091         sysconf
1092         usleep
1093         utime
1094         utimes
1095         valloc
1096 ]))
1097 dnl
1098 dnl Check to see if -lsocket is required (solaris) to make something
1099 dnl that uses socket() to compile; this is needed for the UUID library
1100 dnl
1101 SOCKET_LIB=''
1102 AC_CHECK_LIB(socket, socket, [SOCKET_LIB=-lsocket])
1103 AC_SUBST(SOCKET_LIB)
1104 dnl
1105 dnl See if libmagic exists
1106 dnl
1107 AC_CHECK_LIB(magic, magic_file, [MAGIC_LIB=-lmagic
1108 AC_CHECK_HEADERS([magic.h])])
1109 if test "$ac_cv_lib_dl_dlopen" = yes ; then
1110    MAGIC_LIB=$DLOPEN_LIB
1111 fi
1112 AC_SUBST(MAGIC_LIB)
1113 dnl
1114 dnl Check to see if the FUSE library is -lfuse or -losxfuse
1115 dnl
1116 FUSE_CMT=
1117 FUSE_LIB=
1118 dnl osxfuse.dylib supersedes fuselib.dylib
1119 AC_ARG_ENABLE([fuse2fs],
1120 [  --disable-fuse2fs      do not build fuse2fs],
1121 if test "$enableval" = "no"
1122 then
1123         FUSE_CMT="#"
1124         AC_MSG_RESULT([Disabling fuse2fs])
1125 else
1126         AC_CHECK_HEADERS([pthread.h fuse.h], [],
1127 [AC_MSG_FAILURE([Cannot find fuse2fs headers.])],
1128 [#define _FILE_OFFSET_BITS      64
1129 #define FUSE_USE_VERSION 29])
1130
1131         AC_PREPROC_IFELSE(
1132 [AC_LANG_PROGRAM([[#define FUSE_USE_VERSION 29
1133 #ifdef __linux__
1134 #include <linux/fs.h>
1135 #include <linux/falloc.h>
1136 #include <linux/xattr.h>
1137 #endif
1138 ]], [])], [], [AC_MSG_FAILURE([Cannot find fuse2fs Linux headers.])])
1139
1140         AC_CHECK_LIB(osxfuse, fuse_main, [FUSE_LIB=-losxfuse],
1141                 [AC_CHECK_LIB(fuse, fuse_main, [FUSE_LIB=-lfuse],
1142                               [AC_MSG_FAILURE([Cannot find fuse library.])])])
1143         AC_MSG_RESULT([Enabling fuse2fs])
1144 fi
1145 ,
1146 AC_CHECK_HEADERS([pthread.h fuse.h], [], [FUSE_CMT="#"],
1147 [#define _FILE_OFFSET_BITS      64
1148 #define FUSE_USE_VERSION 29
1149 #ifdef __linux__
1150 # include <linux/fs.h>
1151 # include <linux/falloc.h>
1152 # include <linux/xattr.h>
1153 #endif])
1154 if test -z "$FUSE_CMT"
1155 then
1156         AC_CHECK_LIB(osxfuse, fuse_main, [FUSE_LIB=-losxfuse],
1157 [AC_CHECK_LIB(fuse, fuse_main, [FUSE_LIB=-lfuse], [FUSE_CMT="#"])])
1158 fi
1159 if test -z "$FUSE_CMT"
1160 then
1161         AC_MSG_RESULT([Enabling fuse2fs by default.])
1162 fi
1163 )
1164 AC_SUBST(FUSE_LIB)
1165 AC_SUBST(FUSE_CMT)
1166 dnl
1167 dnl See if optreset exists
1168 dnl
1169 AC_MSG_CHECKING(for optreset)
1170 AC_CACHE_VAL(ac_cv_have_optreset,
1171 [AC_EGREP_HEADER(optreset, unistd.h,
1172   ac_cv_have_optreset=yes, ac_cv_have_optreset=no)])dnl
1173 AC_MSG_RESULT($ac_cv_have_optreset)
1174 if test $ac_cv_have_optreset = yes; then
1175   AC_DEFINE(HAVE_OPTRESET, 1, [Define to 1 if optreset for getopt is present])
1176 fi
1177 dnl
1178 dnl Test for sem_init, and which library it might require:
1179 dnl
1180 AH_TEMPLATE([HAVE_SEM_INIT], [Define to 1 if sem_init() exists])
1181 SEM_INIT_LIB=''
1182 AC_CHECK_FUNC(sem_init, ,
1183   AC_CHECK_LIB(pthread, sem_init,
1184         AC_DEFINE(HAVE_SEM_INIT, 1)
1185         SEM_INIT_LIB=-lpthread,
1186   AC_CHECK_LIB(rt, sem_init,
1187         AC_DEFINE(HAVE_SEM_INIT, 1)
1188         SEM_INIT_LIB=-lrt,
1189   AC_CHECK_LIB(posix4, sem_init,
1190         AC_DEFINE(HAVE_SEM_INIT, 1)
1191         SEM_INIT_LIB=-lposix4))))dnl
1192 AC_SUBST(SEM_INIT_LIB)
1193 dnl
1194 dnl Check for unified diff
1195 dnl
1196 AC_MSG_CHECKING(for unified diff option)
1197 if diff -u $0 $0 > /dev/null 2>&1 ; then
1198    UNI_DIFF_OPTS=-u
1199 else
1200    UNI_DIFF_OPTS=-c
1201 fi
1202 AC_MSG_RESULT($UNI_DIFF_OPTS)
1203 AC_SUBST(UNI_DIFF_OPTS)
1204 dnl
1205 dnl We use the EXT2 ioctls only under Linux
1206 dnl
1207 case "$host_os" in
1208 linux*)
1209         AC_DEFINE(HAVE_EXT2_IOCTLS, 1, [Define to 1 if Ext2 ioctls present])
1210         ;;
1211 esac
1212 dnl
1213 dnl OS-specific uncomment control
1214 dnl
1215 LINUX_CMT="#"
1216 CYGWIN_CMT="#"
1217 UNIX_CMT=
1218 case "$host_os" in
1219 linux*)
1220         LINUX_CMT=
1221         ;;
1222 cygwin)
1223         CYGWIN_CMT=
1224         UNIX_CMT="#"
1225         ;;
1226 esac
1227 AC_SUBST(LINUX_CMT)
1228 AC_SUBST(CYGWIN_CMT)
1229 AC_SUBST(UNIX_CMT)
1230 dnl
1231 dnl Linux and Hurd places root files in the / by default
1232 dnl
1233 case "$host_os" in
1234 linux* | gnu* | k*bsd*-gnu)
1235         if test "$prefix" = NONE -a "$root_prefix" = NONE ; then
1236                 root_prefix="";
1237                 AC_MSG_RESULT([On $host_os systems, root_prefix defaults to ''])
1238         fi
1239         ;;
1240 esac
1241 dnl
1242 dnl On Linux/hurd, force the prefix to be /usr
1243 dnl
1244 case "$host_os" in
1245 linux* | gnu* | k*bsd*-gnu)
1246         if test "$prefix" = NONE ; then
1247                 prefix="/usr";
1248                 AC_MSG_RESULT([On $host_os systems, prefix defaults to /usr])
1249                 if test "$mandir" = '${prefix}/man' ; then
1250                         AC_MSG_RESULT([...and mandir defaults to /usr/share/man])
1251                         mandir=/usr/share/man
1252                 fi
1253         fi
1254 ;;
1255 esac
1256 if test "$root_prefix" = NONE ; then
1257         if test "$prefix" = NONE ; then
1258                 root_prefix="$ac_default_prefix"
1259         else
1260                 root_prefix="$prefix"
1261         fi
1262         root_bindir=$bindir
1263         root_sbindir=$sbindir
1264         root_libdir=$libdir
1265         root_sysconfdir=$sysconfdir
1266 else
1267         root_bindir='${root_prefix}/bin'
1268         root_sbindir='${root_prefix}/sbin'
1269         root_libdir='${root_prefix}/lib'
1270         root_sysconfdir='${root_prefix}/etc'
1271 fi
1272 if test "$bindir" != '${exec_prefix}/bin'; then
1273     root_bindir=$bindir
1274     AC_MSG_RESULT([Setting root_bindir to $root_bindir])
1275 fi
1276 if test "$sbindir" != '${exec_prefix}/sbin'; then
1277     root_sbindir=$sbindir
1278     AC_MSG_RESULT([Setting root_sbindir to $root_sbindir])
1279 fi
1280 if test "$libdir" != '${exec_prefix}/lib'; then
1281     root_libdir=$libdir
1282     AC_MSG_RESULT([Setting root_libdir to $root_libdir])
1283 fi
1284 if test "$sysconfdir" != '${prefix}/etc'; then
1285     root_sysconfdir=$sysconfdir
1286     AC_MSG_RESULT([Setting root_sysconfdir to $root_sysconfdir])
1287 fi
1288 AC_SUBST(root_prefix)
1289 AC_SUBST(root_bindir)
1290 AC_SUBST(root_sbindir)
1291 AC_SUBST(root_libdir)
1292 AC_SUBST(root_sysconfdir)
1293 dnl
1294 dnl Allow specification of the multiarch arch
1295 dnl
1296 AC_ARG_WITH([multiarch],
1297 [  --with-multiarch=ARCH specify the multiarch triplet],
1298 if test "$withval" = "lib64"; then
1299     libdir=/usr/lib64
1300     root_libdir=/lib64
1301 else
1302     libdir=$libdir/$withval
1303     root_libdir=$root_libdir/$withval
1304 fi
1305 )dnl
1306 dnl
1307 dnl See if -static works.  This could fail if the linker does not
1308 dnl support -static, or if required external libraries are not available
1309 dnl in static form.
1310 dnl
1311 AC_MSG_CHECKING([whether we can link with -static])
1312 AC_CACHE_VAL(ac_cv_e2fsprogs_use_static,
1313 [SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -static"
1314 AC_TRY_LINK([#include <stdio.h>],[fflush(stdout);],
1315  ac_cv_e2fsprogs_use_static=yes, ac_cv_e2fsprogs_use_static=no)
1316 LDFLAGS=$SAVE_LDFLAGS])
1317 dnl
1318 dnl Regardless of how the test turns out, Solaris doesn't handle -static
1319 dnl This is caused by the socket library requiring the nsl library, which
1320 dnl requires the -dl library, which only works for dynamically linked 
1321 dnl programs.  It basically means you can't have statically linked programs
1322 dnl which use the network under Solaris.  
1323 dnl
1324 case "$host_os" in
1325 solaris2.*)
1326         ac_cv_e2fsprogs_use_static=no   
1327 ;;
1328 esac
1329 AC_MSG_RESULT($ac_cv_e2fsprogs_use_static)
1330 LDFLAG_STATIC=
1331 if test $ac_cv_e2fsprogs_use_static = yes; then
1332         LDFLAG_STATIC=-static
1333 fi
1334 AC_SUBST(LDFLAG_STATIC)
1335 dnl
1336 dnl Work around mysterious Darwin / GNU libintl problem
1337 dnl (__asm__ redirection doesn't work for some mysterious reason.  Looks like
1338 dnl Apple hacked gcc somehow?)
1339 dnl
1340 case "$host_os" in
1341 darwin*)
1342         AC_MSG_RESULT([Using Apple Darwin / GNU libintl workaround])
1343         AC_DEFINE(_INTL_REDIRECT_MACROS, 1,
1344                 [Define to 1 if Apple Darwin libintl workaround is needed])
1345         ;;
1346 esac
1347 dnl
1348 dnl Make the ss and et directories work correctly.
1349 dnl
1350 SS_DIR=`cd ${srcdir}/lib/ss; pwd`
1351 ET_DIR=`cd ${srcdir}/lib/et; pwd`
1352 AC_SUBST(SS_DIR)
1353 AC_SUBST(ET_DIR)
1354 dnl
1355 dnl Only try to run the test suite if we're not cross compiling.
1356 dnl
1357 if test "$cross_compiling" = yes ; then
1358   DO_TEST_SUITE=
1359 else
1360   DO_TEST_SUITE=check
1361 fi
1362 AC_SUBST(DO_TEST_SUITE)
1363 dnl
1364 dnl Only include the intl include files if we're building with them
1365 dnl
1366 INCLUDES='-I. -I$(top_builddir)/lib -I$(top_srcdir)/lib'
1367 if test -n "$CPPFLAGS" ; then
1368         INCLUDES="$INCLUDES $CPPFLAGS"
1369 fi
1370 if test "$USE_INCLUDED_LIBINTL" = "yes" ; then
1371         INCLUDES=$INCLUDES' -I$(top_builddir)/intl -I$(top_srcdir)/intl'
1372 fi
1373 if test -n "$WITH_DIET_LIBC" ; then
1374         INCLUDES="$INCLUDES -D_REENTRANT"
1375 fi
1376 AC_SUBST(INCLUDES)
1377 AM_MKINSTALLDIRS
1378 dnl
1379 dnl Build CFLAGS
1380 dnl
1381 if test $cross_compiling = no; then
1382    BUILD_CFLAGS="$CFLAGS $CPPFLAGS $INCLUDES -DHAVE_CONFIG_H"
1383    BUILD_LDFLAGS="$LDFLAGS"
1384 fi
1385 AC_SUBST(BUILD_CFLAGS)
1386 AC_SUBST(BUILD_LDFLAGS)
1387 dnl
1388 dnl Make our output files, being sure that we create the some miscellaneous 
1389 dnl directories
1390 dnl
1391 test -d lib || mkdir lib
1392 test -d include || mkdir include
1393 test -d include/linux || mkdir include/linux
1394 test -d include/asm || mkdir include/asm
1395 if test -z "$UUID_CMT" ; then
1396         uuid_out_list="lib/uuid/Makefile lib/uuid/uuid.pc \
1397                 lib/uuid/uuid_types.h"
1398 fi
1399 if test -z "$BLKID_CMT" ; then
1400         blkid_out_list="lib/blkid/Makefile lib/blkid/blkid.pc \
1401                 lib/blkid/blkid_types.h"
1402 fi
1403 for i in MCONFIG Makefile e2fsprogs.spec \
1404         util/Makefile util/subst.conf util/gen-tarball util/install-symlink \
1405         lib/et/Makefile lib/ss/Makefile lib/e2p/Makefile \
1406         lib/ext2fs/Makefile lib/ext2fs/ext2_types.h \
1407         $uuid_out_list $blkid_out_list lib/support/Makefile \
1408         lib/ss/ss.pc lib/et/com_err.pc lib/e2p/e2p.pc lib/ext2fs/ext2fs.pc \
1409         misc/Makefile ext2ed/Makefile e2fsck/Makefile \
1410         debugfs/Makefile tests/Makefile tests/progs/Makefile \
1411         resize/Makefile doc/Makefile intl/Makefile \
1412         intl/libgnuintl.h po/Makefile.in ; do
1413         if test -d `dirname ${srcdir}/$i` ; then
1414                 outlist="$outlist $i"
1415         fi
1416 done
1417 AC_OUTPUT($outlist)
1418 if test -f util/gen-tarball; then chmod +x util/gen-tarball; fi