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