Whamcloud - gitweb
libextr2fs: handle short reads/writes while creating the qcow file
[tools/e2fsprogs.git] / configure.ac
1 AC_INIT
2 AC_CONFIG_SRCDIR([version.h])
3 AC_PREREQ([2.71])
4 AC_CONFIG_AUX_DIR(config)
5 AC_CONFIG_HEADERS([lib/config.h])
6 AH_BOTTOM([#include <dirpaths.h>])
7 AC_USE_SYSTEM_EXTENSIONS
8 MCONFIG=./MCONFIG
9 AC_SUBST_FILE(MCONFIG)
10 BINARY_TYPE=bin
11 dnl
12 dnl This is to figure out the version number and the date....
13 dnl
14 E2FSPROGS_VERSION=`awk -F\" '/E2FSPROGS_VERS/ { print $2 }' ${srcdir}/version.h`
15 E2FSPROGS_DATE=`awk -F\" '/E2FSPROGS_DATE/ { print $2 }' ${srcdir}/version.h`
16 E2FSPROGS_DAY=$(echo $E2FSPROGS_DATE | awk -F- '{ printf "%02d", $1 }')
17 MONTH=`echo $E2FSPROGS_DATE | awk -F- '{print $2}'`
18 YEAR=`echo $E2FSPROGS_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 | sed -e 's/pre-//' -e 's/-.*//'`
45 base_rel=`echo $E2FSPROGS_VERSION | awk -F- '{ print $2 }'`
46
47 date_spec=${E2FSPROGS_YEAR}.${MONTH_NUM}.${E2FSPROGS_DAY}
48
49 case $E2FSPROGS_VERSION in
50 *-WIP|pre-*)
51         E2FSPROGS_PKGVER="$base_ver"
52         E2FSPROGS_PKGREL="WIP.$date_spec"
53         ;;
54 *)
55         E2FSPROGS_PKGVER="$base_ver"
56         E2FSPROGS_PKGREL="$base_rel"
57         ;;
58 esac
59
60 unset DATE MONTH YEAR base_ver pre_vers date_spec
61 AC_MSG_RESULT([Generating configuration file for e2fsprogs version $E2FSPROGS_VERSION])
62 AC_MSG_RESULT([Package version ${E2FSPROGS_PKGVER} release ${E2FSPROGS_PKGREL}])
63 AC_MSG_RESULT([Release date is ${E2FSPROGS_MONTH}, ${E2FSPROGS_YEAR}])
64 AC_SUBST(E2FSPROGS_YEAR)
65 AC_SUBST(E2FSPROGS_MONTH)
66 AC_SUBST(E2FSPROGS_DAY)
67 AC_SUBST(E2FSPROGS_VERSION)
68 AC_SUBST(E2FSPROGS_PKGREL)
69 AC_SUBST(E2FSPROGS_PKGVER)
70 AC_SUBST(E2FSPROGS_DATE)
71 dnl
72 dnl Use diet libc
73 dnl 
74 WITH_DIET_LIBC=
75 AC_ARG_WITH([diet-libc],
76 AS_HELP_STRING([--with-diet-libc],[use diet libc]),
77 CC="diet cc -nostdinc"
78 WITH_DIET_LIBC=yes
79 if test -z "$LIBS"
80 then
81         LIBS="-lcompat"
82 else
83         LIBS="$LIBS -lcompat"
84 fi
85 AC_MSG_RESULT(CC=$CC))dnl
86 dnl
87 AC_CANONICAL_HOST
88 dnl
89 dnl Check to see if libdl exists for the sake of dlopen
90 dnl
91 DLOPEN_LIB=''
92 AC_CHECK_LIB(dl, dlopen,DLOPEN_LIB=-ldl)
93 AC_SUBST(DLOPEN_LIB)
94 dnl
95 AC_ARG_WITH([cc],
96 AS_HELP_STRING([--with-cc],[no longer supported, use CC= instead]),
97 AC_MSG_ERROR([--with-cc no longer supported; use CC= instead]))
98 dnl
99 AC_ARG_WITH([ccopts],
100 AS_HELP_STRING([--with-ccopts],[no longer supported, use CFLAGS= instead]),
101 AC_MSG_ERROR([--with-ccopts no longer supported; use CFLAGS= instead]))
102 dnl
103 AC_ARG_WITH([ldopts],
104 AS_HELP_STRING([--with-ldopts],[no longer supported, use LDFLAGS= instead]),
105 AC_MSG_ERROR([--with-ldopts no longer supported; use LDFLAGS= instead]))
106 dnl
107 AC_PROG_CC
108 if test "$GCC" = yes; then
109    RDYNAMIC="-rdynamic"
110    AC_SUBST(RDYNAMIC)
111 fi
112 AC_PROG_CPP
113 dnl
114 dnl Alpha computers use fast and imprecise floating point code that may
115 dnl miss exceptions by default. Force sane options if we're using GCC.
116 AC_MSG_CHECKING(for additional special compiler flags)
117 if test "$GCC" = yes
118 then
119     case "$host_cpu" in
120         alpha)          addcflags="-mieee" ;;
121     esac
122 fi
123 if test "x$addcflags" != x
124 then
125     AC_MSG_RESULT($addcflags)
126     CFLAGS="$addcflags $CFLAGS"
127 else
128     AC_MSG_RESULT([[(none)]])
129 fi
130 dnl
131 dnl Set default values for library extensions.  Will be dealt with after
132 dnl parsing configuration options, which may modify these
133 dnl
134 LIB_EXT=.a
135 STATIC_LIB_EXT=.a
136 PROFILED_LIB_EXT=.a
137 dnl
138 dnl Allow separate `root_prefix' to be specified
139 dnl
140 AC_ARG_WITH([root-prefix],
141 AS_HELP_STRING([--with-root-prefix=PREFIX],[override prefix variable for files to be placed in the root]),
142 root_prefix=$withval,
143 root_prefix=NONE)dnl
144 dnl
145 dnl handle --enable-maintainer-mode
146 dnl
147 AC_ARG_ENABLE([maintainer-mode],
148 AS_HELP_STRING([--enable-maintainer-mode],[enable makefile rules useful for maintainers]),
149 if test "$enableval" = "no"
150 then
151         MAINTAINER_CMT=#
152         AC_MSG_RESULT([Disabling maintainer mode])
153 else
154         MAINTAINER_CMT=
155         AC_MSG_RESULT([Enabling maintainer mode])
156 fi
157 ,
158 MAINTAINER_CMT=#
159 AC_MSG_RESULT([Disabling maintainer mode by default])
160 )
161 AC_SUBST(MAINTAINER_CMT)
162 dnl
163 dnl handle --enable-symlink-install
164 dnl
165 AC_ARG_ENABLE([symlink-install],
166 AS_HELP_STRING([--enable-symlink-install],[use symlinks when installing instead of hard links]),
167 if test "$enableval" = "no"
168 then
169         LINK_INSTALL_FLAGS=-f
170         AC_MSG_RESULT([Disabling symlinks for install])
171 else
172         LINK_INSTALL_FLAGS=-sf
173         AC_MSG_RESULT([Enabling symlinks for install])
174 fi
175 ,
176 LINK_INSTALL_FLAGS=-f
177 AC_MSG_RESULT([Disabling symlinks for install by default])
178 )
179 AC_SUBST(LINK_INSTALL_FLAGS)
180 dnl
181 dnl handle --enable-relative-symlinks
182 dnl
183 relative_symlink_defined=
184 AC_ARG_ENABLE([relative-symlinks],
185 AS_HELP_STRING([--enable-relative-symlinks],[use relative symlinks when installing]),
186 if test "$enableval" = "no"
187 then
188         SYMLINK_RELATIVE=
189         relative_symlink_defined=yes
190         AC_MSG_RESULT([Disabling relative symlinks for install])
191 else
192         SYMLINK_RELATIVE=--relative
193         relative_symlink_defined=yes
194         AC_MSG_RESULT([Enabling relative symlinks for install])
195 fi)
196 AC_ARG_ENABLE([symlink-relative-symlinks],,
197 if test "$enableval" = "no"
198 then
199         SYMLINK_RELATIVE=yes
200         AC_MSG_RESULT([Disabling relative symlinks for install])
201 else
202         SYMLINK_RELATIVE=--relative
203         AC_MSG_RESULT([Enabling relative symlinks for install])
204 fi
205 ,
206 if test -z "$relative_symlink_defined"
207 then
208         SYMLINK_RELATIVE=
209 AC_MSG_RESULT([Disabling relative symlinks for install by default])
210 fi
211 )
212 AC_SUBST(SYMLINK_RELATIVE)
213 dnl
214 dnl handle --enable-symlink-build
215 dnl
216 AC_ARG_ENABLE([symlink-build],
217 AS_HELP_STRING([--enable-symlink-build],[use symlinks while building instead of hard links]),
218 if test "$enableval" = "no"
219 then
220         LINK_BUILD_FLAGS=
221         AC_MSG_RESULT([Disabling symlinks for build])
222 else
223         LINK_BUILD_FLAGS=-s
224         AC_MSG_RESULT([Enabling symlinks for build])
225 fi
226 ,
227 LINK_BUILD_FLAGS=
228 AC_MSG_RESULT([Disabling symlinks for build by default])
229 )
230 AC_SUBST(LINK_BUILD_FLAGS)
231 dnl
232 dnl handle --enable-verbose-makecmds
233 dnl
234 AC_ARG_ENABLE([verbose-makecmds],
235 AS_HELP_STRING([--enable-verbose-makecmds],[enable verbose make command output]),
236 if test "$enableval" = "no"
237 then
238         AC_MSG_RESULT([Disabling verbose make commands])
239         E=@echo
240         ES=echo
241         Q=@
242 else
243         AC_MSG_RESULT([Enabling verbose make commands])
244         E=@\\#
245         ES=\\#
246         Q= 
247 fi
248 ,
249 AC_MSG_RESULT([Disabling verbose make commands])
250 E=@echo
251 ES=echo
252 Q=@
253 )
254 AC_SUBST(E)
255 AC_SUBST(ES)
256 AC_SUBST(Q)
257 dnl
258 dnl This needs to be before all of the --enable-*-shlibs options
259 dnl
260 E2_PKG_CONFIG_STATIC=--static
261 LDFLAG_DYNAMIC=
262 PRIVATE_LIBS_CMT=
263 dnl
264 dnl handle --enable-elf-shlibs
265 dnl
266 AC_ARG_ENABLE([elf-shlibs],
267 AS_HELP_STRING([--enable-elf-shlibs],[select ELF shared libraries]),
268 if test "$enableval" = "no"
269 then
270         ELF_CMT=#
271         MAKEFILE_ELF=/dev/null
272         AC_MSG_RESULT([Disabling ELF shared libraries])
273 else
274         E2_PKG_CONFIG_STATIC=
275         ELF_CMT=
276         MAKEFILE_ELF=$srcdir/lib/Makefile.elf-lib
277         [case "$host_os" in
278         solaris2.*)
279                 MAKEFILE_ELF=$srcdir/lib/Makefile.solaris-lib
280         ;;
281         esac]
282         BINARY_TYPE=elfbin
283         LIB_EXT=.so
284         PRIVATE_LIBS_CMT=#
285         LDFLAG_DYNAMIC=['-Wl,-rpath-link,$(top_builddir)/lib']
286         AC_MSG_RESULT([Enabling ELF shared libraries])
287 fi
288 ,
289 MAKEFILE_ELF=/dev/null
290 ELF_CMT=#
291 AC_MSG_RESULT([Disabling ELF shared libraries by default])
292 )
293 AC_SUBST(ELF_CMT)
294 AC_SUBST_FILE(MAKEFILE_ELF)
295 dnl
296 dnl handle --enable-bsd-shlibs
297 dnl
298 AC_ARG_ENABLE([bsd-shlibs],
299 AS_HELP_STRING([--enable-bsd-shlibs],[select BSD shared libraries]),
300 if test "$enableval" = "no"
301 then
302         BSDLIB_CMT=#
303         MAKEFILE_BSDLIB=/dev/null
304         AC_MSG_RESULT([Disabling BSD shared libraries])
305 else
306         E2_PKG_CONFIG_STATIC=
307         BSDLIB_CMT=
308         MAKEFILE_BSDLIB=$srcdir/lib/Makefile.bsd-lib
309         LIB_EXT=.so
310         [case "$host_os" in
311         darwin*)
312                 MAKEFILE_BSDLIB=$srcdir/lib/Makefile.darwin-lib
313                 LIB_EXT=.dylib
314         ;;
315         esac]
316         AC_MSG_RESULT([Enabling BSD shared libraries])
317 fi
318 ,
319 MAKEFILE_BSDLIB=/dev/null
320 BSDLIB_CMT=#
321 AC_MSG_RESULT([Disabling BSD shared libraries by default])
322 )
323 AC_SUBST(BSDLIB_CMT)
324 AC_SUBST_FILE(MAKEFILE_BSDLIB)
325 dnl
326 dnl handle --enable-profile
327 dnl
328 AC_ARG_ENABLE([profile],
329 AS_HELP_STRING([--enable-profile],[build profiling libraries]),
330 if test "$enableval" = "no"
331 then
332         PROFILE_CMT=#
333         MAKEFILE_PROFILE=/dev/null
334         AC_MSG_RESULT([Disabling profiling libraries])
335 else
336         PROFILE_CMT=
337         MAKEFILE_PROFILE=$srcdir/lib/Makefile.profile
338         PROFILED_LIB_EXT=_p.a
339         AC_MSG_RESULT([Building profiling libraries])
340 fi
341 ,
342 PROFILE_CMT=#
343 MAKEFILE_PROFILE=/dev/null
344 AC_MSG_RESULT([Disabling profiling libraries by default])
345 )
346 AC_SUBST(PROFILE_CMT)
347 AC_SUBST_FILE(MAKEFILE_PROFILE)
348 dnl
349 dnl handle --enable-gcov
350 dnl
351 AC_ARG_ENABLE([gcov],
352 AS_HELP_STRING([--enable-gcov],[build for coverage testing using gcov]),
353 if test "$enableval" = "yes"
354 then
355         CFLAGS="-g -fprofile-arcs -ftest-coverage"
356         LDFLAGS="-fprofile-arcs -ftest-coverage"
357         AC_MSG_RESULT([Enabling gcov support])
358 fi
359 )
360 dnl
361 dnl handle --enable-hardening
362 dnl
363 CFLAGS_SHLIB="${CFLAGS_SHLIB:-$CFLAGS}"
364 CFLAGS_STLIB="${CFLAGS_STLIB:-$CFLAGS}"
365 LDFLAGS_SHLIB=${LDFLAGS_SHLIB:-$LDFLAGS}
366 LDFLAGS_STATIC=${LDFLAGS_STATIC:-$LDFLAGS}
367 AC_ARG_ENABLE([hardening],
368 AS_HELP_STRING([--enable-hardening],[build with hardening flags such as fortify]),
369 if test "$enableval" = "yes"
370 then
371         HARDEN_CFLAGS="-D_FORTIFY_SOURCE=3 -fstack-protector-strong"
372         HARDEN_LDFLAGS=["-Wl,-z,relro -Wl,-z,now"]
373         CFLAGS="$CFLAGS $HARDEN_CFLAGS -fPIE"
374         CFLAGS_SHLIB="$CFLAGS_SHLIB $HARDEN_CFLAGS"
375         CFLAGS_STLIB="$CFLAGS_STLIB $HARDEN_CFLAGS -fPIE"
376         LDFLAGS="$LDFLAGS $HARDEN_LDFLAGS -fPIE -pie"
377         LDFLAGS_STATIC="$LDFLAGS_STATIC $HARDEN_LDFLAGS"
378         LDFLAGS_SHLIB="$LDFLAGS_SHLIB $HARDEN_LDFLAGS"
379         AC_MSG_RESULT([Enabling hardening support])
380 fi
381 )
382 dnl
383 dnl Substitute library extensions
384 dnl
385 AC_SUBST(LIB_EXT)
386 AC_SUBST(STATIC_LIB_EXT)
387 AC_SUBST(PROFILED_LIB_EXT)
388 AC_SUBST(LDFLAG_DYNAMIC)
389 AC_SUBST(PRIVATE_LIBS_CMT)
390 dnl
391 dnl handle --enable-jbd-debug
392 dnl
393 AC_ARG_ENABLE([jbd-debug],
394 AS_HELP_STRING([--enable-jbd-debug],[enable journal debugging]),
395 if test "$enableval" = "no"
396 then
397         AC_MSG_RESULT([Disabling journal debugging])
398 else
399         AC_DEFINE(CONFIG_JBD_DEBUG, 1,
400                 [Define to 1 if debugging ext3/4 journal code])
401         AC_MSG_RESULT([Enabling journal debugging])
402 fi
403 ,
404 AC_MSG_RESULT([Disabling journal debugging by default])
405 )
406 dnl
407 dnl handle --enable-blkid-debug
408 dnl
409 AC_ARG_ENABLE([blkid-debug],
410 AS_HELP_STRING([--enable-blkid-debug],[enable blkid debugging]),
411 if test "$enableval" = "no"
412 then
413         AC_MSG_RESULT([Disabling blkid debugging])
414 else
415         AC_DEFINE(CONFIG_BLKID_DEBUG, 1,
416                 [Define to 1 if debugging the blkid library])
417         AC_MSG_RESULT([Enabling blkid debugging])
418 fi
419 ,
420 AC_MSG_RESULT([Disabling blkid debugging by default])
421 )
422 dnl
423 dnl handle --enable-testio-debug
424 dnl
425 AC_ARG_ENABLE([testio-debug],
426 AS_HELP_STRING([--disable-testio-debug],[disable the use of the test I/O manager for debugging]),
427 AH_TEMPLATE([CONFIG_TESTIO_DEBUG],
428         [Define to 1 if the testio I/O manager should be enabled])
429 if test "$enableval" = "no"
430 then
431         AC_MSG_RESULT([Disabling testio debugging])
432         TEST_IO_CMT="#"
433 else
434         TEST_IO_CMT=
435         AC_DEFINE(CONFIG_TESTIO_DEBUG, 1)
436         AC_MSG_RESULT([Enabling testio debugging])
437 fi
438 ,
439 AC_MSG_RESULT([Enabling testio debugging by default])
440 AC_DEFINE(CONFIG_TESTIO_DEBUG, 1)
441 TEST_IO_CMT=
442 )
443 AC_SUBST(TEST_IO_CMT)
444 dnl
445 dnl handle --enable-developer-features
446 dnl
447 AC_ARG_ENABLE([developer-features],
448 AS_HELP_STRING([--enable-developer-features],[enable features for use by ext4 developers]),
449 AH_TEMPLATE([CONFIG_DEVELOPER_FEATURES],
450         [Define to 1 for features for use by ext4 developers])
451 if test "$enableval" = "yes"
452 then
453         DEV_FEATURES_CMT=
454         AC_DEFINE(CONFIG_DEVELOPER_FEATURES, 1)
455         AC_MSG_RESULT([Enabling ext4 developer features])
456 else
457         AC_MSG_RESULT([Disabling ext4 developer features])
458         DEV_FEATURES_CMT="#"
459 fi
460 ,
461 AC_MSG_RESULT([Disabling ext4 developer features by default])
462 DEV_FEATURES_CMT=
463 )
464 AC_SUBST(DEV_FEATURES_CMT)
465 dnl
466 dnl handle --disable-libuuid
467 dnl
468 PKG_PROG_PKG_CONFIG
469 LIBUUID=
470 DEPLIBUUID=
471 STATIC_LIBUUID=
472 DEPSTATIC_LIBUUID=
473 PROFILED_LIBUUID=
474 DEPPROFILED_LIBUUID=
475 UUID_CMT=
476 AC_ARG_ENABLE([libuuid],
477 AS_HELP_STRING([--enable-libuuid],[build and use private uuid library]),
478 if test "$enableval" = "no"
479 then
480         if test -z "$PKG_CONFIG"; then
481                 AC_MSG_ERROR([pkg-config not installed; please install it.])
482         fi
483
484         AC_CHECK_LIB(uuid, uuid_generate,
485                 [LIBUUID=`$PKG_CONFIG --libs uuid`;
486                  STATIC_LIBUUID=`$PKG_CONFIG --static --libs uuid`],
487                 [AC_MSG_ERROR([external uuid library not found])])
488         PROFILED_LIBUUID=$LIBUUID
489         UUID_CMT=#
490         AC_MSG_RESULT([Disabling private uuid library])
491 else
492         LIBUUID='$(LIB)/libuuid'$LIB_EXT
493         DEPLIBUUID=$LIBUUID
494         STATIC_LIBUUID='$(LIB)/libuuid'$STATIC_LIB_EXT
495         DEPSTATIC_LIBUUID=$STATIC_LIBUUID
496         PROFILED_LIBUUID='$(LIB)/libuuid'$PROFILED_LIB_EXT
497         DEPPROFILED_LIBUUID=$PROFILED_LIBUUID
498         AC_MSG_RESULT([Enabling private uuid library])
499 fi
500 ,
501 if test -n "$PKG_CONFIG"; then
502         AC_CHECK_LIB(uuid, uuid_generate,
503                 [LIBUUID=`$PKG_CONFIG --libs uuid`;
504                  STATIC_LIBUUID=`$PKG_CONFIG --static --libs uuid`])
505 fi
506 if test -n "$LIBUUID"; then
507         PROFILED_LIBUUID=$LIBUUID
508         UUID_CMT=#
509         AC_MSG_RESULT([Using system uuid by default])
510 else
511         LIBUUID='$(LIB)/libuuid'$LIB_EXT
512         DEPLIBUUID=$LIBUUID
513         STATIC_LIBUUID='$(LIB)/libuuid'$STATIC_LIB_EXT
514         DEPSTATIC_LIBUUID=$STATIC_LIBUUID
515         PROFILED_LIBUUID='$(LIB)/libuuid'$PROFILED_LIB_EXT
516         DEPPROFILED_LIBUUID=$PROFILED_LIBUUID
517         AC_MSG_RESULT([Enabling private uuid library by default])
518 fi
519 )
520 AC_SUBST(LIBUUID)
521 AC_SUBST(DEPLIBUUID)
522 AC_SUBST(STATIC_LIBUUID)
523 AC_SUBST(DEPSTATIC_LIBUUID)
524 AC_SUBST(PROFILED_LIBUUID)
525 AC_SUBST(DEPPROFILED_LIBUUID)
526 AC_SUBST(UUID_CMT)
527 dnl
528 dnl handle --disable-libblkid
529 dnl
530 PKG_PROG_PKG_CONFIG
531 LIBBLKID=
532 DEPLIBBLKID=
533 STATIC_LIBBLKID=
534 DEPSTATIC_LIBBLKID=
535 PROFILED_LIBBLKID=
536 DEPPROFILED_LIBBLKID=
537 BLKID_CMT=
538 AH_TEMPLATE([CONFIG_BUILD_FINDFS], [Define to 1 to compile findfs])
539 AC_ARG_ENABLE([libblkid],
540 AS_HELP_STRING([--enable-libblkid],[build and use private blkid library]),
541 if test "$enableval" = "no"
542 then
543         if test -z "$PKG_CONFIG"; then
544                 AC_MSG_ERROR([pkg-config not installed; please install it.])
545         fi
546
547         AC_CHECK_LIB(blkid, blkid_get_cache,
548                 [LIBBLKID=`$PKG_CONFIG --libs blkid`;
549                  STATIC_LIBBLKID=`$PKG_CONFIG --static --libs blkid`],
550                 [AC_MSG_ERROR([external blkid library not found])], -luuid)
551         BLKID_CMT=#
552         PROFILED_LIBBLKID=$LIBBLKID
553         AC_MSG_RESULT([Disabling private blkid library])
554 else
555         LIBBLKID='$(LIB)/libblkid'$LIB_EXT
556         DEPLIBBLKID=$LIBBLKID
557         STATIC_LIBBLKID='$(LIB)/libblkid'$STATIC_LIB_EXT
558         DEPSTATIC_LIBBLKID=$STATIC_LIBBLKID
559         PROFILED_LIBBLKID='$(LIB)/libblkid'$PROFILED_LIB_EXT
560         DEPPROFILED_LIBBLKID=$PROFILED_LIBBLKID
561         AC_DEFINE(CONFIG_BUILD_FINDFS, 1)
562         AC_MSG_RESULT([Enabling private blkid library])
563 fi
564 ,
565 if test -n "$PKG_CONFIG"; then
566         AC_CHECK_LIB(blkid, blkid_get_cache,
567                 [LIBBLKID=`$PKG_CONFIG --libs blkid`;
568                  STATIC_LIBBLKID=`$PKG_CONFIG --static --libs blkid`])
569 fi
570 if test -n "$LIBBLKID"; then
571         BLKID_CMT=#
572         PROFILED_LIBBLKID=$LIBBLKID
573         AC_MSG_RESULT([Using system blkid library by default])
574 else
575         LIBBLKID='$(LIB)/libblkid'$LIB_EXT
576         DEPLIBBLKID=$LIBBLKID
577         STATIC_LIBBLKID='$(LIB)/libblkid'$STATIC_LIB_EXT
578         DEPSTATIC_LIBBLKID=$STATIC_LIBBLKID
579         PROFILED_LIBBLKID='$(LIB)/libblkid'$PROFILED_LIB_EXT
580         DEPPROFILED_LIBBLKID=$PROFILED_LIBBLKID
581         AC_DEFINE(CONFIG_BUILD_FINDFS, 1)
582         AC_MSG_RESULT([Enabling private blkid library by default])
583 fi
584 )
585 AC_SUBST(LIBBLKID)
586 AC_SUBST(DEPLIBBLKID)
587 AC_SUBST(STATIC_LIBBLKID)
588 AC_SUBST(DEPSTATIC_LIBBLKID)
589 AC_SUBST(PROFILED_LIBBLKID)
590 AC_SUBST(DEPPROFILED_LIBBLKID)
591 AC_SUBST(BLKID_CMT)
592 dnl
593 dnl handle --enable-subset
594 dnl
595 ALL_CMT=
596 SUBSET_CMT=
597 AC_ARG_ENABLE([subset],
598 AS_HELP_STRING([--enable-subset],[enable subset-only build]),
599 if test "$enableval" = "no"
600 then
601         SUBSET_CMT=#
602         AC_MSG_RESULT([Disabling subset-only build])
603 else
604         ALL_CMT=#
605         AC_MSG_RESULT([Enabling subset-only-build])
606 fi
607 ,)
608 AC_SUBST(ALL_CMT)
609 AC_SUBST(SUBSET_CMT)
610 dnl
611 dnl handle --disable-backtrace
612 dnl
613 AH_TEMPLATE([DISABLE_BACKTRACE], [Define to 1 to disable use of backtrace])
614 AC_ARG_ENABLE([backtrace],
615 AS_HELP_STRING([--disable-backtrace],[disable use backtrace]),
616 if test "$enableval" = "no"
617 then
618         AC_MSG_RESULT([Disabling use of backtrace])
619         AC_DEFINE(DISABLE_BACKTRACE, 1)
620 else
621         AC_MSG_RESULT([Enabling use of backtrace])
622 fi
623 ,
624 AC_MSG_RESULT([Enabling use of backtrace by default])
625 )
626 dnl
627 dnl handle --enable-debugfs
628 dnl
629 AC_ARG_ENABLE([debugfs],
630 AS_HELP_STRING([--disable-debugfs],[disable support of debugfs program]),
631 if test "$enableval" = "no"
632 then
633         AC_MSG_RESULT([Disabling debugfs support])
634         DEBUGFS_CMT="#"
635 else
636         DEBUGFS_CMT=
637         AC_MSG_RESULT([Enabling debugfs support])
638 fi
639 ,
640 AC_MSG_RESULT([Enabling debugfs support by default])
641 DEBUGFS_CMT=
642 )
643 AC_SUBST(DEBUGFS_CMT)
644 dnl
645 dnl handle --enable-imager
646 dnl
647 AC_ARG_ENABLE([imager],
648 AS_HELP_STRING([--disable-imager],[disable support of e2image program]),
649 if test "$enableval" = "no"
650 then
651         AC_MSG_RESULT([Disabling e2image support])
652         IMAGER_CMT="#"
653 else
654         IMAGER_CMT=
655         AC_MSG_RESULT([Enabling e2image support])
656 fi
657 ,
658 AC_MSG_RESULT([Enabling e2image support by default])
659 IMAGER_CMT=
660 )
661 AC_SUBST(IMAGER_CMT)
662 dnl
663 dnl handle --enable-resizer
664 dnl
665 AC_ARG_ENABLE([resizer],
666 AS_HELP_STRING([--disable-resizer],[disable support of e2resize program]),
667 if test "$enableval" = "no"
668 then
669         AC_MSG_RESULT([Disabling e2resize support])
670         RESIZER_CMT="#"
671 else
672         RESIZER_CMT=
673         AC_MSG_RESULT([Enabling e2resize support])
674 fi
675 ,
676 AC_MSG_RESULT([Enabling e2resize support by default])
677 RESIZER_CMT=
678 )
679 AC_SUBST(RESIZER_CMT)
680 dnl
681 dnl handle --enable-defrag
682 dnl
683 AC_ARG_ENABLE([defrag],
684 AS_HELP_STRING([--disable-defrag],[disable support of e4defrag program]),
685 if test "$enableval" = "no"
686 then
687         AC_MSG_RESULT([Disabling e4defrag support])
688         DEFRAG_CMT="#"
689 else
690         DEFRAG_CMT=
691         AC_MSG_RESULT([Enabling e4defrag support])
692 fi
693 ,
694 if test -z "$WITH_DIET_LIBC"
695 then
696         AC_MSG_RESULT([Enabling e4defrag support by default])
697         DEFRAG_CMT=
698 else
699         AC_MSG_RESULT([Disabling e4defrag support by default])
700         DEFRAG_CMT="#"
701 fi
702 )
703 AC_SUBST(DEFRAG_CMT)
704 dnl
705 dnl See whether to install the `fsck' wrapper program (that calls e2fsck)
706 dnl
707 AC_ARG_ENABLE([fsck],
708 AS_HELP_STRING([--enable-fsck],[build fsck wrapper program]),
709 [if test "$enableval" = "no"
710 then
711         FSCK_PROG='' FSCK_MAN=''
712         AC_MSG_RESULT([Not building fsck wrapper])
713 else
714         FSCK_PROG=fsck FSCK_MAN=fsck.8
715         AC_MSG_RESULT([Building fsck wrapper])
716 fi]
717 ,
718 [case "$host_os" in
719   gnu*)
720     FSCK_PROG='' FSCK_MAN=''
721     AC_MSG_RESULT([Not building fsck wrapper by default])
722     ;;
723   *)
724     FSCK_PROG=fsck FSCK_MAN=fsck.8
725     AC_MSG_RESULT([Building fsck wrapper by default])
726 esac]
727 )
728 AC_SUBST(FSCK_PROG)
729 AC_SUBST(FSCK_MAN)
730 dnl
731 dnl See whether to install the `e2initrd-helper' program
732 dnl
733 AC_ARG_ENABLE([e2initrd-helper],
734 AS_HELP_STRING([--enable-e2initrd-helper],[build e2initrd-helper program]),
735 [if test "$enableval" = "no"
736 then
737         E2INITRD_PROG='' E2INITRD_MAN=''
738         AC_MSG_RESULT([Not building e2initrd helper])
739 else
740         E2INITRD_PROG=e2initrd_helper E2INITRD_MAN=e2initrd_helper.8
741         AC_MSG_RESULT([Building e2initrd helper])
742 fi]
743 ,
744 E2INITRD_PROG=e2initrd_helper E2INITRD_MAN=e2initrd_helper.8
745 AC_MSG_RESULT([Building e2initrd helper by default])
746 )
747 AC_SUBST(E2INITRD_PROG)
748 AC_SUBST(E2INITRD_MAN)
749 dnl
750 dnl
751 dnl
752 AC_ARG_ENABLE([tls],
753 AS_HELP_STRING([--disable-tls],[disable use of thread local support]),
754 [if test "$enableval" = "no"
755 then
756         try_tls=""
757         AC_MSG_RESULT([Disabling thread local support])
758 else
759         try_tls="yes"
760         AC_MSG_RESULT([Enabling thread local support])
761 fi]
762 ,
763 if test -n "$WITH_DIET_LIBC"
764 then
765         try_tls=""
766         AC_MSG_RESULT([Diet libc does not support thread local support])
767 else
768         try_tls="yes"
769         AC_MSG_RESULT([Try using thread local support by default])
770 fi
771 )
772 if test "$try_tls" = "yes"
773 then
774 AX_TLS
775 fi
776 dnl
777 dnl
778 dnl
779 AC_ARG_WITH([pthread],
780 AS_HELP_STRING([--without-pthread],[disable use of pthread support]),
781 [if test "$withval" = "no"
782 then
783         try_pthread=""
784         AC_MSG_RESULT([Disabling pthread support])
785 else
786         try_pthread="yes"
787         AC_MSG_RESULT([Testing for pthread support])
788 fi]
789 ,
790 try_pthread="yes"
791 AC_MSG_RESULT([Try testing for pthread support by default])
792 )
793 if test "$try_pthread" = "yes"
794 then
795 AX_PTHREAD
796 else
797 test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
798 AC_SUBST([PTHREAD_CC])
799 fi
800 dnl
801 dnl
802 dnl
803 AH_TEMPLATE([USE_UUIDD], [Define to 1 to build uuidd])
804 AC_ARG_ENABLE([uuidd],
805 AS_HELP_STRING([--disable-uuidd],[disable building the uuid daemon]),
806 [if test "$enableval" = "no"
807 then
808         AC_MSG_RESULT([Not building uuidd])
809         UUIDD_CMT="#"
810 else
811         AC_DEFINE(USE_UUIDD, 1)
812         UUIDD_CMT=""
813         AC_MSG_RESULT([Building uuidd])
814 fi]
815 ,
816 AC_DEFINE(USE_UUIDD, 1)
817 if test -z "$UUID_CMT"
818 then
819         UUIDD_CMT=""
820         AC_MSG_RESULT([Building uuidd by default])
821 else
822         UUIDD_CMT="#"
823         AC_MSG_RESULT([Disabling uuidd by default])
824 fi
825 )
826 AC_SUBST(UUIDD_CMT)
827 dnl
828 dnl handle --disable-mmp
829 dnl
830 AH_TEMPLATE([CONFIG_MMP], [Define to 1 to enable mmp support])
831 AC_ARG_ENABLE([mmp],
832 AS_HELP_STRING([--disable-mmp],[disable support mmp, Multi Mount Protection]),
833 if test "$enableval" = "no"
834 then
835         AC_MSG_RESULT([Disabling mmp support])
836 else
837         AC_MSG_RESULT([Enabling mmp support])
838         AC_DEFINE(CONFIG_MMP, 1)
839 fi
840 ,
841 AC_MSG_RESULT([Enabling mmp support by default])
842 AC_DEFINE(CONFIG_MMP, 1)
843 )
844 dnl
845 dnl handle --disable-tdb
846 dnl
847 AH_TEMPLATE([CONFIG_TDB], [Define to 1 to enable tdb support])
848 AC_ARG_ENABLE([tdb],
849 AS_HELP_STRING([--disable-tdb],[disable tdb support]),
850 [
851 if test "$enableval" = "no"
852 then
853         AC_MSG_RESULT([Disabling tdb support])
854         CONFIG_TDB=0
855 else
856         AC_MSG_RESULT([Enabling tdb support])
857         CONFIG_TDB=1
858 fi
859 ]
860 ,
861 [
862 case "$host_os" in
863 mingw*)
864         AC_MSG_RESULT([Disabling tdb support by default])
865         CONFIG_TDB=0
866         ;;
867 *)
868         AC_MSG_RESULT([Enabling tdb support by default])
869         CONFIG_TDB=1
870         ;;
871 esac
872 ]
873 )
874 if test "$CONFIG_TDB" = "1"
875 then
876         AC_DEFINE(CONFIG_TDB, 1)
877         TDB_CMT=""
878         TDB_MAN_COMMENT=""
879 else
880         TDB_CMT="#"
881         TDB_MAN_COMMENT='.\"'
882 fi
883 AC_SUBST(TDB_CMT)
884 AC_SUBST(TDB_MAN_COMMENT)
885 dnl
886 dnl handle --disable-bmap-stats
887 dnl
888 AH_TEMPLATE([ENABLE_BMAP_STATS], [Define to 1 to enable bitmap stats.])
889 AC_ARG_ENABLE([bmap-stats],
890 AS_HELP_STRING([--disable-bmap-stats],[disable collection of bitmap stats]),
891 if test "$enableval" = "no"
892 then
893         AC_MSG_RESULT([Disabling bitmap statistics support])
894 else
895         AC_MSG_RESULT([Enabling bitmap statistics support])
896         AC_DEFINE(ENABLE_BMAP_STATS, 1)
897 fi
898 ,
899 AC_MSG_RESULT([Enabling bitmap statistics support by default])
900 AC_DEFINE(ENABLE_BMAP_STATS, 1)
901 )
902 dnl
903 dnl handle --enable-bmap-stats-ops
904 dnl
905 AH_TEMPLATE([ENABLE_BMAP_STATS_OPS], [Define to 1 to enable bitmap stats.])
906 AC_ARG_ENABLE([bmap-stats-ops],
907 AS_HELP_STRING([--enable-bmap-stats-ops],[enable collection of additional bitmap stats]),
908 if test "$enableval" = "no"
909 then
910         AC_MSG_RESULT([Disabling additional bitmap statistics])
911 else
912         dnl There has to be a better way!
913         AS_IF([test "x${enable_bmap_stats}" = "xno"],
914          AC_MSG_FAILURE([Error --enable-bmap-stats-ops requires bmap-stats]))
915
916         AC_MSG_RESULT([Enabling additional bitmap statistics])
917         AC_DEFINE(ENABLE_BMAP_STATS_OPS, 1)
918 fi
919 ,
920 AC_MSG_RESULT([Disabling additional bitmap statistics by default])
921 )
922 dnl
923 dnl
924 dnl
925 MAKEFILE_LIBRARY=$srcdir/lib/Makefile.library
926 AC_SUBST_FILE(MAKEFILE_LIBRARY)
927 dnl
928 dnl Add internationalization support, using gettext.
929 dnl
930 GETTEXT_PACKAGE=e2fsprogs
931 PACKAGE=e2fsprogs
932 VERSION="$E2FSPROGS_VERSION"
933 VERSION=0.14.1
934 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [package name for gettext])
935 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [version for gettext])
936 AC_SUBST(GETTEXT_PACKAGE)
937 AC_SUBST(PACKAGE)
938 AC_SUBST(VERSION)
939
940 AM_GNU_GETTEXT([external])
941 dnl
942 dnl End of configuration options
943 dnl
944 AC_SUBST(BINARY_TYPE)
945 AC_PROG_MAKE_SET
946 CHECK_GNU_MAKE
947 AC_PATH_PROG(LN, ln, ln)
948 AC_PROG_MKDIR_P
949 dnl
950 dnl @mkdir_p@ is used by po's Makefile.in
951 dnl
952 mkdir_p=$MKDIR_P
953 AC_SUBST(mkdir_p)
954 AC_PROG_LN_S
955 AC_PATH_PROG(MV, mv, mv)
956 AC_PATH_PROG(CP, cp, cp)
957 AC_PATH_PROG(RM, rm, rm)
958 AC_PATH_PROG(CHMOD, chmod, :)
959 AC_PROG_AWK
960 AC_PROG_EGREP
961 AC_PATH_PROG(SED, sed, sed)
962 AC_PATH_PROG(PERL, perl, perl)
963 AC_PATH_PROG(LDCONFIG, ldconfig, :)
964 AC_CHECK_TOOL(AR, ar, ar)
965 AC_CHECK_TOOL(RANLIB, ranlib, :)
966 AC_CHECK_TOOL(STRIP, strip, :)
967 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
968 if test "_$MAKEINFO" = "_"; then
969     MAKEINFO="echo Makeinfo is missing. Info documentation will not be built."
970 else
971     case "$MAKEINFO" in
972       */missing.*)
973         AC_MSG_WARN([
974 *** Makeinfo is missing. Info documentation will not be built.])
975         ;;
976       *)
977         ;;
978     esac
979 fi
980 AC_SUBST(MAKEINFO)
981 AC_PROG_INSTALL
982 # See if we need a separate native compiler.
983 if test $cross_compiling = no; then
984   BUILD_CC="$CC"
985   AC_SUBST(BUILD_CC)
986 else
987   AC_CHECK_PROGS(BUILD_CC, gcc cc)
988 fi
989 AC_CHECK_HEADERS(m4_flatten([
990         dirent.h
991         errno.h
992         execinfo.h
993         getopt.h
994         malloc.h
995         mntent.h
996         paths.h
997         pthread.h
998         semaphore.h
999         setjmp.h
1000         signal.h
1001         stdarg.h
1002         stdint.h
1003         stdlib.h
1004         termios.h
1005         termio.h
1006         unistd.h
1007         utime.h
1008         attr/xattr.h
1009         linux/falloc.h
1010         linux/fd.h
1011         linux/fsmap.h
1012         linux/major.h
1013         linux/loop.h
1014         linux/types.h
1015         net/if_dl.h
1016         netinet/in.h
1017         sys/acl.h
1018         sys/disklabel.h
1019         sys/disk.h
1020         sys/file.h
1021         sys/ioctl.h
1022         sys/key.h
1023         sys/mkdev.h
1024         sys/mman.h
1025         sys/mount.h
1026         sys/prctl.h
1027         sys/random.h
1028         sys/resource.h
1029         sys/select.h
1030         sys/socket.h
1031         sys/sockio.h
1032         sys/stat.h
1033         sys/syscall.h
1034         sys/sysmacros.h
1035         sys/time.h
1036         sys/types.h
1037         sys/un.h
1038         sys/wait.h
1039         sys/xattr.h
1040 ]))
1041 case "$host_os" in
1042 mingw*)
1043         # The above checks only detect system headers, not the headers in
1044         # ./include/mingw/, so explicitly define them to be available.
1045         AC_DEFINE(HAVE_LINUX_TYPES_H, 1)
1046         AC_DEFINE(HAVE_SYS_STAT_H, 1)
1047         AC_DEFINE(HAVE_SYS_SYSMACROS_H, 1)
1048         AC_DEFINE(HAVE_SYS_TYPES_H, 1)
1049         AC_DEFINE(HAVE_UNISTD_H, 1)
1050         ;;
1051 esac
1052 dnl Check where to find a dd(1) that supports iflag=fullblock
1053 dnl and oflag=append
1054 AC_MSG_CHECKING([for a dd(1) program that supports iflag=fullblock])
1055 DD=
1056 for i in dd gdd ; do
1057         if "$i" if=/dev/null of=/dev/null count=1 bs=10k 2>/dev/null iflag=fullblock oflag=append ; then
1058                 DD=$i
1059                 break
1060         fi
1061 done
1062 if test -n "$DD" ; then
1063         AC_MSG_RESULT([$DD])
1064 else
1065         AC_MSG_RESULT([not found, using dd])
1066         DD=dd
1067         AC_MSG_WARN([No GNU-compatible dd(1) program found, expect some self-test failures.])
1068 fi
1069 AC_SUBST([DD])
1070
1071 AC_CHECK_HEADERS(net/if.h,,,
1072 [[
1073 #if HAVE_SYS_TYPES_H
1074 #include <sys/types.h>
1075 #endif
1076 #if HAVE_SYS_SOCKET
1077 #include <sys/socket.h>
1078 #endif
1079 ]])
1080 AC_FUNC_VPRINTF
1081 dnl Check to see if dirent has member d_reclen. On cygwin those d_reclen
1082 dnl is not declared.
1083 AC_CHECK_MEMBER(struct dirent.d_reclen,[AC_DEFINE(HAVE_RECLEN_DIRENT, 1,
1084                        [Define to 1 if dirent has d_reclen])],,
1085                 [#include <dirent.h>])
1086 AC_CHECK_MEMBERS([struct stat.st_atim])
1087 dnl Check to see if ssize_t was declared
1088 AC_CHECK_TYPE(ssize_t,[AC_DEFINE(HAVE_TYPE_SSIZE_T, 1,
1089                 [Define to 1 if ssize_t declared])],,
1090               [#include <sys/types.h>])
1091 dnl
1092 dnl Check to see if llseek() is declared in unistd.h.  On some libc's 
1093 dnl it is, and on others it isn't..... Thank you glibc developers....
1094 dnl
1095 AC_CHECK_DECL(llseek,[AC_DEFINE(HAVE_LLSEEK_PROTOTYPE, 1,
1096                         [Define to 1 if llseek declared in unistd.h])],,
1097               [#include <unistd.h>])
1098 dnl
1099 dnl Check to see if lseek64() is declared in unistd.h.  Glibc's header files
1100 dnl are so convoluted that I can't tell whether it will always be defined,
1101 dnl and if it isn't defined while lseek64 is defined in the library, 
1102 dnl disaster will strike.  
1103 dnl
1104 dnl Warning!  Use of --enable-gcc-wall may throw off this test.
1105 dnl
1106 dnl
1107 AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1,
1108                         [Define to 1 if lseek64 declared in unistd.h])],,
1109                 [#define _LARGEFILE_SOURCE
1110                  #define _LARGEFILE64_SOURCE
1111                  #include <unistd.h>])
1112
1113 dnl The Android NDK has <linux/fsmap.h>, but it is missing the inline functions
1114 dnl fsmap_sizeof() and fsmap_advance().  Check whether this is the case.
1115 AC_CHECK_DECL(fsmap_sizeof,[AC_DEFINE(HAVE_FSMAP_SIZEOF, 1,
1116                             [Define to 1 if fsmap_sizeof() is declared in linux/fsmap.h])],,
1117                 [#include <linux/fsmap.h>])
1118 dnl
1119 dnl Word sizes...
1120 dnl
1121 AC_SYS_LARGEFILE
1122 AC_CHECK_SIZEOF(short)
1123 AC_CHECK_SIZEOF(int)
1124 AC_CHECK_SIZEOF(long)
1125 AC_CHECK_SIZEOF(long long)
1126 AC_CHECK_SIZEOF(off_t)
1127 AC_CHECK_SIZEOF(time_t)
1128 SIZEOF_SHORT=$ac_cv_sizeof_short
1129 SIZEOF_INT=$ac_cv_sizeof_int
1130 SIZEOF_LONG=$ac_cv_sizeof_long
1131 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
1132 SIZEOF_OFF_T=$ac_cv_sizeof_off_t
1133 SIZEOF_TIME_T=$ac_cv_sizeof_time_t
1134 AC_SUBST(SIZEOF_SHORT)
1135 AC_SUBST(SIZEOF_INT)
1136 AC_SUBST(SIZEOF_LONG)
1137 AC_SUBST(SIZEOF_LONG_LONG)
1138 AC_SUBST(SIZEOF_OFF_T)
1139 AC_SUBST(SIZEOF_TIME_T)
1140 AC_C_BIGENDIAN
1141 if test $cross_compiling = no; then
1142   BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
1143 else
1144   CROSS_COMPILE="1" BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh
1145 fi
1146 ASM_TYPES_HEADER=./asm_types.h
1147 AC_SUBST_FILE(ASM_TYPES_HEADER)
1148 dnl
1149 dnl Save the configuration #defines needed for the public ext2fs.h
1150 dnl header file
1151 dnl
1152 echo "/* These defines are needed for the public ext2fs.h header file */" \
1153      > public_config.h
1154 if grep HAVE_SYS_TYPES_H confdefs.h > tmp_config.$$; then
1155   uniq tmp_config.$$ >> public_config.h
1156 else
1157   echo "#undef HAVE_SYS_TYPES_H" >> public_config.h
1158 fi
1159 if grep WORDS_BIGENDIAN confdefs.h > tmp_config.$$; then
1160   uniq tmp_config.$$ >> public_config.h
1161 else
1162   echo "#undef WORDS_BIGENDIAN" >> public_config.h
1163 fi
1164 rm -f tmp_config.$$
1165 PUBLIC_CONFIG_HEADER=./public_config.h
1166 AC_SUBST_FILE(PUBLIC_CONFIG_HEADER)
1167 dnl
1168 dnl See if we have inttypes.h and if intptr_t is defined
1169 dnl
1170 AC_CHECK_HEADERS([inttypes.h])
1171 AC_CHECK_TYPES(intptr_t)
1172 dnl
1173 dnl See if struct stat has a st_flags field, in which case we can get file
1174 dnl flags somewhat portably.  Also check for the analogous setter, chflags().
1175 dnl
1176 AC_MSG_CHECKING(whether struct stat has a st_flags field)
1177 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
1178         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[struct stat stat; stat.st_flags = 0;]])],[e2fsprogs_cv_struct_st_flags=yes],[e2fsprogs_cv_struct_st_flags=no]))
1179 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
1180 if test "$e2fsprogs_cv_struct_st_flags" = yes; then
1181   AC_MSG_CHECKING(whether st_flags field is useful)
1182   AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags_immut,
1183         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[struct stat stat; stat.st_flags |= UF_IMMUTABLE;]])],[e2fsprogs_cv_struct_st_flags_immut=yes],[e2fsprogs_cv_struct_st_flags_immut=no]))
1184   AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags_immut)
1185   if test "$e2fsprogs_cv_struct_st_flags_immut" = yes; then
1186           AC_DEFINE(HAVE_STAT_FLAGS, 1,
1187                 [Define to 1 if struct stat has st_flags])
1188   fi
1189 fi
1190 dnl
1191 dnl Check for the presence of SA_LEN
1192 dnl
1193 AC_CHECK_MEMBER(struct sockaddr.sa_len,
1194                 AC_DEFINE_UNQUOTED(HAVE_SA_LEN,1,
1195                         [Define to 1 if if struct sockaddr contains sa_len]),,
1196         [#include <sys/types.h>
1197          #include <sys/socket.h>])
1198 dnl
1199 dnl If we are using the system-provided blkid library, check for
1200 dnl the functions added after migrating that library to util-linux
1201 dnl
1202 if test -n "$BLKID_CMT"; then
1203   AC_CHECK_LIB(blkid, blkid_probe_get_topology,
1204                       AC_DEFINE(HAVE_BLKID_PROBE_GET_TOPOLOGY, 1,
1205                                 [Define to 1 if blkid has blkid_probe_get_topology]))
1206   AC_CHECK_LIB(blkid, blkid_topology_get_dax,
1207                       AC_DEFINE(HAVE_BLKID_TOPOLOGY_GET_DAX, 1,
1208                                 [Define to 1 if blkid has blkid_topology_get_dax]))
1209   AC_CHECK_LIB(blkid, blkid_probe_enable_partitions,
1210                       AC_DEFINE(HAVE_BLKID_PROBE_ENABLE_PARTITIONS, 1,
1211                                 [Define to 1 if blkid has blkid_probe_enable_partitions]))
1212 fi
1213 dnl
1214 if test -n "$DLOPEN_LIB" ; then
1215    ac_cv_func_dlopen=yes
1216 fi
1217 AC_CHECK_FUNCS(m4_flatten([
1218         __secure_getenv
1219         add_key
1220         backtrace
1221         chflags
1222         dlopen
1223         fadvise64
1224         fallocate
1225         fallocate64
1226         fchown
1227         fcntl
1228         fdatasync
1229         fstat64
1230         fsync
1231         ftruncate64
1232         futimes
1233         getcwd
1234         getdtablesize
1235         getentropy
1236         gethostname
1237         getmntinfo
1238         getpwuid_r
1239         getrandom
1240         getrlimit
1241         getrusage
1242         jrand48
1243         keyctl
1244         llistxattr
1245         llseek
1246         lseek64
1247         mallinfo
1248         mallinfo2
1249         mbstowcs
1250         memalign
1251         mempcpy
1252         mmap
1253         msync
1254         nanosleep
1255         open64
1256         pathconf
1257         posix_fadvise
1258         posix_fadvise64
1259         posix_memalign
1260         prctl
1261         pread
1262         pwrite
1263         pread64
1264         pwrite64
1265         qsort_r
1266         secure_getenv
1267         setmntent
1268         setresgid
1269         setresuid
1270         snprintf
1271         srandom
1272         stpcpy
1273         strcasecmp
1274         strdup
1275         strnlen
1276         strptime
1277         strtoull
1278         sync_file_range
1279         sysconf
1280         usleep
1281         utime
1282         utimes
1283         valloc
1284 ]))
1285 dnl
1286 dnl Check to see if -lsocket is required (solaris) to make something
1287 dnl that uses socket() to compile; this is needed for the UUID library
1288 dnl
1289 SOCKET_LIB=''
1290 AC_CHECK_LIB(socket, socket, [SOCKET_LIB=-lsocket])
1291 AC_SUBST(SOCKET_LIB)
1292 dnl
1293 dnl See if libmagic exists
1294 dnl
1295 AC_CHECK_LIB(magic, magic_file, [MAGIC_LIB=-lmagic
1296 AC_CHECK_HEADERS([magic.h])])
1297 if test "$ac_cv_func_dlopen" = yes ; then
1298    MAGIC_LIB=$DLOPEN_LIB
1299 fi
1300 AC_SUBST(MAGIC_LIB)
1301 dnl
1302 dnl libarchive
1303 dnl
1304 AC_CHECK_LIB(archive, archive_read_new, [ARCHIVE_LIB=-larchive
1305 AC_CHECK_HEADERS([archive.h])])
1306 if test "$ac_cv_func_dlopen" = yes ; then
1307    ARCHIVE_LIB=$DLOPEN_LIB
1308 fi
1309 AC_SUBST(ARCHIVE_LIB)
1310 dnl
1311 dnl Check to see if librt is required for clock_gettime() (glibc < 2.17)
1312 dnl
1313 AC_CHECK_LIB(rt, clock_gettime, [CLOCK_GETTIME_LIB=-lrt])
1314 AC_SUBST(CLOCK_GETTIME_LIB)
1315 dnl
1316 dnl Check to see if the FUSE library is -lfuse3, -losxfuse, or -lfuse
1317 dnl
1318 FUSE_CMT=
1319 FUSE_LIB=
1320 dnl osxfuse.dylib supersedes fuselib.dylib
1321 AC_ARG_ENABLE([fuse2fs],
1322 AS_HELP_STRING([--disable-fuse2fs],[do not build fuse2fs]),
1323 if test "$enableval" = "no"
1324 then
1325         FUSE_CMT="#"
1326         AC_MSG_RESULT([Disabling fuse2fs])
1327 else
1328         AC_PREPROC_IFELSE(
1329 [AC_LANG_PROGRAM([[#ifdef __linux__
1330 #include <linux/fs.h>
1331 #include <linux/falloc.h>
1332 #include <linux/xattr.h>
1333 #endif
1334 ]], [])], [], [AC_MSG_FAILURE([Cannot find fuse2fs Linux headers.])])
1335
1336         PKG_CHECK_MODULES([fuse3], [fuse3],
1337           [
1338                 FUSE_LIB=-lfuse3
1339           ], [
1340                 AC_CHECK_HEADERS([pthread.h fuse.h], [],
1341                         [AC_MSG_FAILURE([Cannot find fuse2fs headers.])],
1342 [#define _FILE_OFFSET_BITS      64
1343 #define FUSE_USE_VERSION 29])
1344
1345                 AC_CHECK_LIB(osxfuse, fuse_main, [FUSE_LIB=-losxfuse],
1346                         [AC_CHECK_LIB(fuse, fuse_main, [FUSE_LIB=-lfuse],
1347                                 [AC_MSG_FAILURE([Cannot find fuse library.])])])
1348           ])
1349         AC_MSG_RESULT([Enabling fuse2fs])
1350 fi
1351 ,
1352 PKG_CHECK_MODULES([fuse3], [fuse3],
1353   [
1354         FUSE_LIB=-lfuse3
1355   ], [
1356         AC_CHECK_HEADERS([pthread.h fuse.h], [], [FUSE_CMT="#"], 
1357 [#define _FILE_OFFSET_BITS      64
1358 #define FUSE_USE_VERSION 29
1359 #ifdef __linux__
1360 # include <linux/fs.h>
1361 # include <linux/falloc.h>
1362 # include <linux/xattr.h>
1363 #endif])
1364         if test -z "$FUSE_CMT"
1365         then
1366                 AC_CHECK_LIB(osxfuse, fuse_main, [FUSE_LIB=-losxfuse],
1367                         [AC_CHECK_LIB(fuse, fuse_main, [FUSE_LIB=-lfuse],
1368                                 [FUSE_CMT="#"])])
1369         fi
1370   ])
1371 if test -z "$FUSE_CMT"
1372 then
1373         AC_MSG_RESULT([Enabling fuse2fs by default.])
1374 fi
1375 )
1376 AC_SUBST(FUSE_LIB)
1377 AC_SUBST(FUSE_CMT)
1378 if test "$FUSE_LIB" = "-lfuse3"
1379 then
1380         FUSE_USE_VERSION=35
1381         CFLAGS="$CFLAGS $fuse3_CFLAGS"
1382         LDFLAGS="$LDFLAGS $fuse3_LDFLAGS"
1383         AC_CHECK_HEADERS([pthread.h fuse.h], [],
1384                 [AC_MSG_FAILURE([Cannot find fuse3 fuse2fs headers.])],
1385 [#define _FILE_OFFSET_BITS      64
1386 #define FUSE_USE_VERSION 35
1387 #ifdef __linux__
1388 #include <linux/fs.h>
1389 #include <linux/falloc.h>
1390 #include <linux/xattr.h>
1391 #endif])
1392 elif test -n "$FUSE_LIB"
1393 then
1394         FUSE_USE_VERSION=29
1395 fi
1396 if test -n "$FUSE_USE_VERSION"
1397 then
1398         AC_DEFINE_UNQUOTED(FUSE_USE_VERSION, $FUSE_USE_VERSION,
1399                 [Define to the version of FUSE to use])
1400 fi
1401 dnl
1402 dnl See if optreset exists
1403 dnl
1404 AC_MSG_CHECKING(for optreset)
1405 AC_CACHE_VAL(ac_cv_have_optreset,
1406 [AC_EGREP_HEADER(optreset, unistd.h,
1407   ac_cv_have_optreset=yes, ac_cv_have_optreset=no)])dnl
1408 AC_MSG_RESULT($ac_cv_have_optreset)
1409 if test $ac_cv_have_optreset = yes; then
1410   AC_DEFINE(HAVE_OPTRESET, 1, [Define to 1 if optreset for getopt is present])
1411 fi
1412 dnl
1413 dnl Test for sem_init, and which library it might require:
1414 dnl
1415 AH_TEMPLATE([HAVE_SEM_INIT], [Define to 1 if sem_init() exists])
1416 SEM_INIT_LIB=''
1417 echo GL_THREADS_API: ${gl_threads_api}
1418 if test "${gl_threads_api}" != none
1419 then
1420   AC_CHECK_FUNC(sem_init, ,
1421     AC_CHECK_LIB(pthread, sem_init,
1422         AC_DEFINE(HAVE_SEM_INIT, 1)
1423         SEM_INIT_LIB=-lpthread,
1424     AC_CHECK_LIB(rt, sem_init,
1425         AC_DEFINE(HAVE_SEM_INIT, 1)
1426         SEM_INIT_LIB=-lrt,
1427     AC_CHECK_LIB(posix4, sem_init,
1428         AC_DEFINE(HAVE_SEM_INIT, 1)
1429         SEM_INIT_LIB=-lposix4))))dnl
1430 fi
1431 AC_SUBST(SEM_INIT_LIB)
1432 dnl
1433 dnl qsort_r detection
1434 dnl
1435 AS_IF([test "$ac_cv_func_qsort_r" != no], [
1436   AC_CACHE_CHECK(whether qsort_r is GNU version, e2_cv_gnu_qsort_r,
1437     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1438 @%:@include <stdlib.h>
1439 void (qsort_r)(void *base, size_t nmemb, size_t size,
1440             int (*compar)(const void *, const void *, void *),
1441             void *arg);
1442 ]], [[ ]])],[e2_cv_gnu_qsort_r=yes],[e2_cv_gnu_qsort_r=no])
1443   ])
1444   AC_CACHE_CHECK(whether qsort_r is BSD version, e2_cv_bsd_qsort_r,
1445     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1446 @%:@include <stdlib.h>
1447 void (qsort_r)(void *base, size_t nmemb, size_t size,
1448              void *arg, int (*compar)(void *, const void *, const void *));
1449 ]], [[ ]])],[e2_cv_bsd_qsort_r=yes],[e2_cv_bsd_qsort_r=no])
1450   ])
1451   AS_CASE("$e2_cv_gnu_qsort_r:$e2_cv_bsd_qsort_r",
1452   [yes:no], [
1453     AC_DEFINE(HAVE_GNU_QSORT_R, 1, [ Define to 1 if you have the GNU-style 'qsort_r' function.])
1454   ],
1455   [no:yes], [
1456     AC_DEFINE(HAVE_BSD_QSORT_R, 1, [ Define to 1 if you have the BSD-style 'qsort_r' function.])
1457   ])
1458 ])
1459 dnl
1460 dnl Check for unified diff
1461 dnl
1462 AC_MSG_CHECKING(for unified diff option)
1463 if diff -u $0 $0 > /dev/null 2>&1 ; then
1464    UNI_DIFF_OPTS=-u
1465 else
1466    UNI_DIFF_OPTS=-c
1467 fi
1468 AC_MSG_RESULT($UNI_DIFF_OPTS)
1469 AC_SUBST(UNI_DIFF_OPTS)
1470 dnl
1471 dnl We use the EXT2 ioctls only under Linux
1472 dnl
1473 case "$host_os" in
1474 linux*)
1475         AC_DEFINE(HAVE_EXT2_IOCTLS, 1, [Define to 1 if Ext2 ioctls present])
1476         ;;
1477 esac
1478 dnl
1479 dnl Check the available mount options
1480 dnl
1481 AX_CHECK_MOUNT_OPT(nosuid)
1482 AX_CHECK_MOUNT_OPT(nodev)
1483 dnl Enable LTO for all packages
1484 dnl
1485 AC_ARG_ENABLE([lto],
1486 AS_HELP_STRING([--enable-lto],[enable link time optimization]),,
1487 enable_lto=no)
1488 if test "$enable_lto" = "yes" || test "$enable_lto" = "probe"; then
1489         AC_MSG_CHECKING([if C compiler supports LTO])
1490         OLD_CFLAGS="$CFLAGS"
1491         OLD_LDFLAGS="$LDFLAGS"
1492         LTO_FLAGS="-g -flto -ffat-lto-objects"
1493         CFLAGS="$CFLAGS $LTO_FLAGS"
1494         LDFLAGS="$LDFLAGS $LTO_FLAGS"
1495         AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1496                 [AC_MSG_RESULT([yes])]
1497                 [lto_cflags=$LTO_FLAGS]
1498                 [lto_ldflags=$LTO_FLAGS]
1499                 [AC_PATH_PROG(gcc_ar, gcc-ar,,)]
1500                 [AC_PATH_PROG(gcc_ranlib, gcc-ranlib,,)],
1501                 [AC_MSG_RESULT([no])])
1502         if test -x "$gcc_ar" && test -x "$gcc_ranlib"; then
1503                 have_lto=yes
1504                 AR="${gcc_ar}"
1505                 RANLIB="${gcc_ranlib}"
1506         fi
1507         CFLAGS="${OLD_CFLAGS}"
1508         LDFLAGS="${OLD_LDFLAGS}"
1509         AC_SUBST(have_lto)
1510         AC_SUBST(lto_cflags)
1511         AC_SUBST(lto_ldflags)
1512 fi
1513 if test "$enable_lto" = "yes" && test "$have_lto" != "yes"; then
1514         AC_MSG_ERROR([LTO not supported by compiler.])
1515 fi
1516 dnl
1517 dnl Enable UBSAN for all packages
1518 dnl
1519 AC_ARG_ENABLE([ubsan],
1520 AS_HELP_STRING([--enable-ubsan],[enable undefined behavior sanitizer]),,
1521 enable_ubsan=no)
1522 if test "$enable_ubsan" = "yes" || test "$enable_ubsan" = "probe"; then
1523         AC_MSG_CHECKING([if C compiler supports UBSAN])
1524         OLD_CFLAGS="$CFLAGS"
1525         OLD_LDFLAGS="$LDFLAGS"
1526         UBSAN_FLAGS="-fsanitize=undefined"
1527         CFLAGS="$CFLAGS $UBSAN_FLAGS"
1528         LDFLAGS="$LDFLAGS $UBSAN_FLAGS"
1529         AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1530                 [AC_MSG_RESULT([yes])]
1531                 [ubsan_cflags=$UBSAN_FLAGS]
1532                 [ubsan_ldflags=$UBSAN_FLAGS]
1533                 [have_ubsan=yes],
1534                 [AC_MSG_RESULT([no])])
1535         CFLAGS="${OLD_CFLAGS}"
1536         LDFLAGS="${OLD_LDFLAGS}"
1537         AC_SUBST(have_ubsan)
1538         AC_SUBST(ubsan_cflags)
1539         AC_SUBST(ubsan_ldflags)
1540 fi
1541 if test "$enable_ubsan" = "yes" && test "$have_ubsan" != "yes"; then
1542         AC_MSG_ERROR([UBSAN not supported by compiler.])
1543 fi
1544 dnl
1545 dnl Enable ADDRSAN for all packages
1546 dnl
1547 AC_ARG_ENABLE([addrsan],
1548 AS_HELP_STRING([--enable-addrsan],[enable address sanitizer]),,
1549 enable_addrsan=no)
1550 if test "$enable_addrsan" = "yes" || test "$enable_addrsan" = "probe"; then
1551         AC_MSG_CHECKING([if C compiler supports ADDRSAN])
1552         OLD_CFLAGS="$CFLAGS"
1553         OLD_LDFLAGS="$LDFLAGS"
1554         ADDRSAN_FLAGS="-fsanitize=address"
1555         CFLAGS="$CFLAGS $ADDRSAN_FLAGS"
1556         LDFLAGS="$LDFLAGS $ADDRSAN_FLAGS"
1557         AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1558                 [AC_MSG_RESULT([yes])]
1559                 [addrsan_cflags=$ADDRSAN_FLAGS]
1560                 [addrsan_ldflags=$ADDRSAN_FLAGS]
1561                 [have_addrsan=yes],
1562                 [AC_MSG_RESULT([no])])
1563         CFLAGS="${OLD_CFLAGS}"
1564         LDFLAGS="${OLD_LDFLAGS}"
1565         AC_SUBST(have_addrsan)
1566         AC_SUBST(addrsan_cflags)
1567         AC_SUBST(addrsan_ldflags)
1568 fi
1569 if test "$enable_addrsan" = "yes" && test "$have_addrsan" != "yes"; then
1570         AC_MSG_ERROR([ADDRSAN not supported by compiler.])
1571 fi
1572 dnl
1573 dnl Enable THREADSAN for all packages
1574 dnl
1575 AC_ARG_ENABLE([threadsan],
1576 AS_HELP_STRING([--enable-threadsan],[enable thread sanitizer]),,
1577 enable_threadsan=no)
1578 if test "$enable_threadsan" = "yes" || test "$enable_threadsan" = "probe"; then
1579         AC_MSG_CHECKING([if C compiler supports THREADSAN])
1580         OLD_CFLAGS="$CFLAGS"
1581         OLD_LDFLAGS="$LDFLAGS"
1582         THREADSAN_FLAGS="-fsanitize=thread"
1583         CFLAGS="$CFLAGS $THREADSAN_FLAGS"
1584         LDFLAGS="$LDFLAGS $THREADSAN_FLAGS"
1585         AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
1586                 [AC_MSG_RESULT([yes])]
1587                 [threadsan_cflags=$THREADSAN_FLAGS]
1588                 [threadsan_ldflags=$THREADSAN_FLAGS]
1589                 [have_threadsan=yes],
1590                 [AC_MSG_RESULT([no])])
1591         CFLAGS="${OLD_CFLAGS}"
1592         LDFLAGS="${OLD_LDFLAGS}"
1593         AC_SUBST(have_threadsan)
1594         AC_SUBST(threadsan_cflags)
1595         AC_SUBST(threadsan_ldflags)
1596 fi
1597 if test "$enable_threadsan" = "yes" && test "$have_threadsan" != "yes"; then
1598         AC_MSG_ERROR([THREADSAN not supported by compiler.])
1599 fi
1600 if test "$have_threadsan" = "yes" && test "$have_addrsan" = "yes"; then
1601         AC_MSG_WARN([ADDRSAN and THREADSAN are not known to work together.])
1602 fi
1603 dnl
1604 dnl Enable the fuzzer sanitizer for all packages
1605 dnl
1606 FUZZING_CMT="#"
1607 AC_ARG_ENABLE([fuzzing],
1608 AS_HELP_STRING([--enable-fuzzing],[enable fuzzing sanitizer]),,
1609 enable_fuzzing=no)
1610 if test "$enable_fuzzing" = "yes" || test "$enable_fuzzing" = "probe"; then
1611         AC_PROG_CXX
1612         AC_MSG_CHECKING([if C compiler supports fuzzing sanitizer])
1613         AC_LANG_PUSH([C++])
1614         OLD_CXXFLAGS="$CXXFLAGS"
1615         OLD_LDFLAGS="$LDFLAGS"
1616         FUZZER_FLAGS="-fsanitize=fuzzer"
1617         CXXFLAGS="$CXXFLAGS $FUZZER_FLAGS"
1618         LDFLAGS="$LDFLAGS $FUZZER_FLAGS"
1619         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1620                 #include <stddef.h>
1621                 #include <stdint.h>
1622                 ]],
1623                 [ return 0; ])],
1624                 [AC_MSG_RESULT([yes])]
1625                 [fuzzer_cflags=$FUZZER_FLAGS]
1626                 [fuzzer_ldflags=$FUZZER_FLAGS]
1627                 [FUZZING_CMT=]
1628                 [have_fuzzer=yes],
1629                 [AC_MSG_RESULT([no])]
1630                 [AC_MSG_ERROR([fuzzing requested but not available])])
1631         CXXFLAGS="${OLD_CXXFLAGS}"
1632         LDFLAGS="${OLD_LDFLAGS}"
1633         AC_LANG_POP([C++])
1634         AC_SUBST(have_fuzzer)
1635         AC_SUBST(fuzzer_cflags)
1636         AC_SUBST(fuzzer_ldflags)
1637 fi
1638 if test "$enable_fuzzer" = "yes" && test "$have_fuzzer" != "yes"; then
1639         AC_MSG_ERROR([Fuzzing not supported by compiler.])
1640 fi
1641 AC_SUBST(FUZZING_CMT)
1642 dnl
1643 dnl OS-specific uncomment control
1644 dnl
1645 LINUX_CMT="#"
1646 CYGWIN_CMT="#"
1647 UNIX_CMT=
1648 case "$host_os" in
1649 linux*)
1650         LINUX_CMT=
1651         ;;
1652 cygwin)
1653         CYGWIN_CMT=
1654         UNIX_CMT="#"
1655         ;;
1656 esac
1657 AC_SUBST(LINUX_CMT)
1658 AC_SUBST(CYGWIN_CMT)
1659 AC_SUBST(UNIX_CMT)
1660 dnl
1661 dnl e2scrub only builds on linux
1662 dnl
1663 E2SCRUB_CMT="$LINUX_CMT"
1664 AC_SUBST(E2SCRUB_CMT)
1665 dnl
1666 dnl Linux and Hurd places root files in the / by default
1667 dnl
1668 case "$host_os" in
1669 linux* | gnu* | k*bsd*-gnu)
1670         if test "$prefix" = NONE -a "$root_prefix" = NONE ; then
1671                 root_prefix="";
1672                 AC_MSG_RESULT([On $host_os systems, root_prefix defaults to ''])
1673         fi
1674         ;;
1675 esac
1676 dnl
1677 dnl On Linux/hurd, force the prefix to be /usr
1678 dnl
1679 case "$host_os" in
1680 linux* | gnu* | k*bsd*-gnu)
1681         if test "$prefix" = NONE ; then
1682                 prefix="/usr";
1683                 AC_MSG_RESULT([On $host_os systems, prefix defaults to /usr])
1684                 if test "$mandir" = '${prefix}/man' ; then
1685                         AC_MSG_RESULT([...and mandir defaults to /usr/share/man])
1686                         mandir=/usr/share/man
1687                 fi
1688         fi
1689 ;;
1690 esac
1691 if test "$root_prefix" = NONE ; then
1692         if test "$prefix" = NONE ; then
1693                 root_prefix="$ac_default_prefix"
1694         else
1695                 root_prefix="$prefix"
1696         fi
1697         root_bindir=$bindir
1698         root_sbindir=$sbindir
1699         root_libdir=$libdir
1700         root_sysconfdir=$sysconfdir
1701 else
1702         root_bindir='${root_prefix}/bin'
1703         root_sbindir='${root_prefix}/sbin'
1704         root_libdir='${root_prefix}/lib'
1705         root_sysconfdir='${root_prefix}/etc'
1706 fi
1707 if test "$bindir" != '${exec_prefix}/bin'; then
1708     root_bindir=$bindir
1709     AC_MSG_RESULT([Setting root_bindir to $root_bindir])
1710 fi
1711 if test "$sbindir" != '${exec_prefix}/sbin'; then
1712     root_sbindir=$sbindir
1713     AC_MSG_RESULT([Setting root_sbindir to $root_sbindir])
1714 fi
1715 if test "$libdir" != '${exec_prefix}/lib'; then
1716     root_libdir=$libdir
1717     AC_MSG_RESULT([Setting root_libdir to $root_libdir])
1718 fi
1719 if test "$sysconfdir" != '${prefix}/etc'; then
1720     root_sysconfdir=$sysconfdir
1721     AC_MSG_RESULT([Setting root_sysconfdir to $root_sysconfdir])
1722 fi
1723 AC_SUBST(root_prefix)
1724 AC_SUBST(root_bindir)
1725 AC_SUBST(root_sbindir)
1726 AC_SUBST(root_libdir)
1727 AC_SUBST(root_sysconfdir)
1728 dnl
1729 dnl Allow specification of the multiarch arch
1730 dnl
1731 AC_ARG_WITH([multiarch],
1732 AS_HELP_STRING([--with-multiarch=ARCH],[specify the multiarch triplet]),
1733 if test "$withval" = "lib64"; then
1734     libdir=/usr/lib64
1735     root_libdir=/lib64
1736 else
1737     libdir=$libdir/$withval
1738     root_libdir=$root_libdir/$withval
1739 fi
1740 )
1741 dnl
1742 dnl
1743 dnl See if -static works.  This could fail if the linker does not
1744 dnl support -static, or if required external libraries are not available
1745 dnl in static form.
1746 dnl
1747 AC_MSG_CHECKING([whether we can link with -static])
1748 AC_CACHE_VAL(ac_cv_e2fsprogs_use_static,
1749 [SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS_STATIC -static"
1750 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[fflush(stdout);]])],[ac_cv_e2fsprogs_use_static=yes],[ac_cv_e2fsprogs_use_static=no])
1751 LDFLAGS=$SAVE_LDFLAGS])
1752 dnl
1753 dnl Regardless of how the test turns out, Solaris doesn't handle -static
1754 dnl This is caused by the socket library requiring the nsl library, which
1755 dnl requires the -dl library, which only works for dynamically linked 
1756 dnl programs.  It basically means you can't have statically linked programs
1757 dnl which use the network under Solaris.  
1758 dnl
1759 case "$host_os" in
1760 solaris2.*)
1761         ac_cv_e2fsprogs_use_static=no   
1762 ;;
1763 esac
1764 AC_MSG_RESULT($ac_cv_e2fsprogs_use_static)
1765 if test $ac_cv_e2fsprogs_use_static = yes; then
1766         LDFLAGS_STATIC="$LDFLAGS_STATIC -static"
1767 fi
1768 AC_SUBST(LDFLAGS_STATIC)
1769 dnl
1770 dnl Work around mysterious Darwin / GNU libintl problem
1771 dnl (__asm__ redirection doesn't work for some mysterious reason.  Looks like
1772 dnl Apple hacked gcc somehow?)
1773 dnl
1774 case "$host_os" in
1775 darwin*)
1776         AC_MSG_RESULT([Using Apple Darwin / GNU libintl workaround])
1777         AC_DEFINE(_INTL_REDIRECT_MACROS, 1,
1778                 [Define to 1 if Apple Darwin libintl workaround is needed])
1779         ;;
1780 esac
1781 dnl
1782 dnl Only try to run the test suite if we're not cross compiling.
1783 dnl
1784 if test "$cross_compiling" = yes ; then
1785   DO_TEST_SUITE=
1786 else
1787   DO_TEST_SUITE=check
1788 fi
1789 AC_SUBST(DO_TEST_SUITE)
1790 dnl
1791 dnl Only include the intl include files if we're building with them
1792 dnl
1793 INCLUDES='-I. -I$(top_builddir)/lib -I$(top_srcdir)/lib'
1794 if test -n "$CPPFLAGS" ; then
1795         INCLUDES="$INCLUDES $CPPFLAGS"
1796 fi
1797 if test "$USE_INCLUDED_LIBINTL" = "yes" ; then
1798         INCLUDES=$INCLUDES' -I$(top_builddir)/intl -I$(top_srcdir)/intl'
1799 fi
1800 if test -n "$WITH_DIET_LIBC" ; then
1801         INCLUDES="$INCLUDES -D_REENTRANT"
1802 fi
1803 case "$host_os" in
1804 mingw*)
1805         INCLUDES=$INCLUDES' -I$(top_srcdir)/include/mingw'
1806         ;;
1807 esac
1808 AC_SUBST(INCLUDES)
1809 dnl
1810 dnl Build CFLAGS
1811 dnl
1812 if test $cross_compiling = no; then
1813    BUILD_CFLAGS="$CFLAGS $CPPFLAGS $INCLUDES -DHAVE_CONFIG_H"
1814    BUILD_LDFLAGS="$LDFLAGS"
1815 fi
1816 AC_SUBST(BUILD_CFLAGS)
1817 AC_SUBST(BUILD_LDFLAGS)
1818 dnl
1819 dnl Define CFLAGS and LDFLAGS for shared libraries
1820 dnl
1821 CFLAGS_SHLIB=${CFLAGS_SHLIB:-$CFLAGS}
1822 CFLAGS_STLIB=${CFLAGS_STLIB:-$CFLAGS}
1823 LDFLAGS_SHLIB=${LDFLAGS_SHLIB:-$LDFLAGS}
1824 AC_SUBST(CFLAGS_SHLIB)
1825 AC_SUBST(CFLAGS_STLIB)
1826 AC_SUBST(LDFLAGS_SHLIB)
1827
1828 dnl
1829 dnl Where do udev rules go?
1830 dnl
1831 AC_ARG_WITH([udev_rules_dir],
1832   [AS_HELP_STRING([--with-udev-rules-dir@<:@=DIR@:>@],
1833         [Install udev rules into DIR.])],
1834   [],
1835   [with_udev_rules_dir=yes])
1836 AS_IF([test "x${with_udev_rules_dir}" != "xno"],
1837   [
1838         AS_IF([test "x${with_udev_rules_dir}" = "xyes"],
1839           [
1840                 PKG_CHECK_MODULES([udev], [udev],
1841                   [
1842                         with_udev_rules_dir="$($PKG_CONFIG --variable=udevdir udev)/rules.d"
1843                   ], [
1844                         with_udev_rules_dir=""
1845                   ])
1846           ])
1847         AC_MSG_CHECKING([for udev rules dir])
1848         pkg_udev_rules_dir="${with_udev_rules_dir}"
1849         AS_IF([test -n "${pkg_udev_rules_dir}"],
1850           [
1851                 AC_MSG_RESULT(${pkg_udev_rules_dir})
1852                 have_udev="yes"
1853           ],
1854           [
1855                 AC_MSG_RESULT(no)
1856                 have_udev="no"
1857           ])
1858   ],
1859   [
1860         have_udev="disabled"
1861   ])
1862 AC_SUBST(have_udev)
1863 AC_SUBST(pkg_udev_rules_dir)
1864
1865 dnl
1866 dnl Where do cron jobs go?
1867 dnl
1868 AC_ARG_WITH([crond_dir],
1869   [AS_HELP_STRING([--with-crond-dir@<:@=DIR@:>@],
1870         [Install system crontabs into DIR.])],
1871   [],
1872   [with_crond_dir=yes])
1873 AS_IF([test "x${with_crond_dir}" != "xno"],
1874   [
1875         AS_IF([test "x${with_crond_dir}" = "xyes"],
1876           [
1877                 AS_IF([test -d "/etc/cron.d"],
1878                   [with_crond_dir="/etc/cron.d"],
1879                   [have_crond="no"; with_crond_dir=""])
1880           ])
1881         AC_MSG_CHECKING([for system crontab dir])
1882         crond_dir="${with_crond_dir}"
1883         AS_IF([test -n "${crond_dir}"],
1884           [
1885                 AC_MSG_RESULT(${crond_dir})
1886                 have_crond="yes"
1887           ],
1888           [
1889                 AC_MSG_RESULT(no)
1890                 have_crond="no"
1891           ])
1892   ],
1893   [
1894         have_crond="disabled"
1895   ])
1896 AC_SUBST(have_crond)
1897 AC_SUBST(crond_dir)
1898
1899 dnl
1900 dnl Where do systemd services go?
1901 dnl
1902 AC_ARG_WITH([systemd_unit_dir],
1903   [AS_HELP_STRING([--with-systemd-unit-dir@<:@=DIR@:>@],
1904         [Install systemd system units into DIR.])],
1905   [],
1906   [with_systemd_unit_dir=yes])
1907 AS_IF([test "x${with_systemd_unit_dir}" != "xno"],
1908   [
1909         AS_IF([test "x${with_systemd_unit_dir}" = "xyes"],
1910           [
1911                 PKG_CHECK_MODULES([systemd], [systemd],
1912                   [
1913                         with_systemd_unit_dir="$($PKG_CONFIG --variable=systemdsystemunitdir systemd)"
1914                   ], [
1915                         with_systemd_unit_dir=""
1916                   ])
1917                 m4_pattern_allow([^PKG_(MAJOR|MINOR|BUILD|REVISION)$])
1918           ])
1919         AC_MSG_CHECKING([for systemd system unit dir])
1920         systemd_system_unit_dir="${with_systemd_unit_dir}"
1921         AS_IF([test -n "${systemd_system_unit_dir}"],
1922           [
1923                 AC_MSG_RESULT(${systemd_system_unit_dir})
1924                 have_systemd="yes"
1925           ],
1926           [
1927                 AC_MSG_RESULT(no)
1928                 have_systemd="no"
1929           ])
1930   ],
1931   [
1932         have_systemd="disabled"
1933   ])
1934 AC_SUBST(have_systemd)
1935 AC_SUBST(systemd_system_unit_dir)
1936 dnl Adjust the compiled files if we are on windows vs everywhere else
1937 dnl
1938 OS_IO_FILE=""
1939 [case "$host_os" in
1940   mingw*)
1941     OS_IO_FILE=windows_io
1942   ;;
1943   *)
1944     OS_IO_FILE=unix_io
1945   ;;
1946 esac]
1947 AC_SUBST(OS_IO_FILE)
1948
1949 dnl
1950 dnl Make our output files, being sure that we create the some miscellaneous 
1951 dnl directories
1952 dnl
1953 test -d lib || mkdir lib
1954 test -d include || mkdir include
1955 test -d include/linux || mkdir include/linux
1956 test -d include/asm || mkdir include/asm
1957 if test -z "$UUID_CMT" ; then
1958         uuid_out_list="lib/uuid/Makefile lib/uuid/uuid.pc \
1959                 lib/uuid/uuid_types.h"
1960 fi
1961 if test -z "$BLKID_CMT" ; then
1962         blkid_out_list="lib/blkid/Makefile lib/blkid/blkid.pc \
1963                 lib/blkid/blkid_types.h"
1964 fi
1965 for i in MCONFIG Makefile \
1966         util/Makefile util/subst.conf util/gen-tarball util/install-symlink \
1967         lib/et/Makefile lib/ss/Makefile lib/e2p/Makefile \
1968         lib/ext2fs/Makefile lib/ext2fs/ext2_types.h \
1969         $uuid_out_list $blkid_out_list lib/support/Makefile \
1970         lib/ss/ss.pc lib/et/com_err.pc lib/e2p/e2p.pc lib/ext2fs/ext2fs.pc \
1971         misc/Makefile ext2ed/Makefile e2fsck/Makefile \
1972         debugfs/Makefile tests/Makefile tests/progs/Makefile \
1973         tests/fuzz/Makefile resize/Makefile doc/Makefile \
1974         po/Makefile.in scrub/Makefile; do
1975         if test -d `dirname ${srcdir}/$i` ; then
1976                 outlist="$outlist $i"
1977         fi
1978 done
1979 AC_CONFIG_FILES([$outlist])
1980 AC_OUTPUT
1981 if test -f util/gen-tarball; then chmod +x util/gen-tarball; fi