Whamcloud - gitweb
8b86b5dad5b6807e0985802bd39c9d3dbde54f65
[tools/e2fsprogs.git] / configure.in
1 AC_INIT(version.h)
2 MCONFIG=./MCONFIG
3 AC_SUBST_FILE(MCONFIG)
4 BINARY_TYPE=bin
5 dnl
6 dnl This is to figure out the version number and the date....
7 dnl
8 E2FSPROGS_VERSION=`grep E2FSPROGS_VERSION ${srcdir}/version.h  \
9         | awk '{print $3}' | tr \" " " | awk '{print $1}'`
10 DATE=`grep E2FSPROGS_DATE ${srcdir}/version.h | awk '{print $3}' \
11         | tr \" " "`
12 MONTH=`echo $DATE | awk -F- '{print $2}'`
13 YEAR=`echo $DATE | awk -F- '{print $3}'`
14
15 if expr $YEAR ">" 90 >/dev/null ; then
16         E2FSPROGS_YEAR=19$YEAR
17 else
18         E2FSPROGS_YEAR=20$YEAR
19 fi
20
21 case $MONTH in
22 Jan)    E2FSPROGS_MONTH="January" ;;
23 Feb)    E2FSPROGS_MONTH="February" ;;
24 Mar)    E2FSPROGS_MONTH="March" ;;
25 Apr)    E2FSPROGS_MONTH="April" ;;
26 May)    E2FSPROGS_MONTH="May" ;;
27 Jun)    E2FSPROGS_MONTH="June" ;;
28 Jul)    E2FSPROGS_MONTH="July" ;;
29 Aug)    E2FSPROGS_MONTH="August" ;;
30 Sep)    E2FSPROGS_MONTH="September" ;;
31 Oct)    E2FSPROGS_MONTH="October" ;;
32 Nov)    E2FSPROGS_MONTH="November" ;;
33 Dec)    E2FSPROGS_MONTH="December" ;;
34 *)      echo "Unknown month $MONTH??" ;;
35 esac
36
37 unset DATE MONTH YEAR
38 echo "Generating configuration file for e2fsprogs version $E2FSPROGS_VERSION"
39 echo "Release date is ${E2FSPROGS_MONTH}, ${E2FSPROGS_YEAR}"
40 AC_SUBST(E2FSPROGS_YEAR)
41 AC_SUBST(E2FSPROGS_MONTH)
42 AC_SUBST(E2FSPROGS_VERSION)
43 AC_REQUIRE([AC_CANONICAL_HOST])
44 dnl
45 dnl set $(CC) from --with-cc=value
46 dnl
47 AC_ARG_WITH([cc],
48 [  --with-cc=COMPILER      select compiler to use],
49 AC_MSG_RESULT(CC=$withval)
50 CC=$withval,
51 if test -z "$CC" ; then CC=cc; fi
52 [AC_MSG_RESULT(CC defaults to $CC)])dnl
53 export CC
54 AC_SUBST([CC])
55 dnl
56 dnl set $(LD) from --with-linker=value
57 dnl
58 AC_ARG_WITH([linker],
59 [  --with-linker=LINKER    select linker to use],
60 AC_MSG_RESULT(LD=$withval)
61 LD=$withval,
62 if test -z "$LD" ; then LD=$CC; fi
63 [AC_MSG_RESULT(LD defaults to $LD)])dnl
64 export LD
65 AC_SUBST([LD])
66 dnl
67 dnl set $(CCOPTS) from --with-ccopts=value
68 dnl
69 AC_ARG_WITH([ccopts],
70 [  --with-ccopts=CCOPTS    select compiler command line options],
71 AC_MSG_RESULT(CCOPTS is $withval)
72 CCOPTS=$withval
73 CFLAGS="$CFLAGS $withval",
74 CCOPTS=)dnl
75 AC_SUBST(CCOPTS)
76 dnl
77 dnl Set default values for library extentions.  Will be dealt with after
78 dnl parsing configuration opions, which may modify these
79 dnl
80 LIB_EXT=.a
81 STATIC_LIB_EXT=.a
82 PROFILE_LIB_EXT=.a
83 dnl
84 dnl set $(LDFLAGS) from --with-ldopts=value
85 dnl
86 AC_ARG_WITH([ldopts],
87 [  --with-ldopts=LDOPTS    select linker command line options],
88 AC_MSG_RESULT(LDFLAGS is $withval)
89 LDFLAGS=$withval,
90 LDFLAGS=)dnl
91 AC_SUBST(LDFLAGS)
92 dnl
93 dnl Allow separate `usr_prefix' to be specified
94 dnl
95 AC_ARG_WITH([usr-prefix],
96 [  --with-usr-prefx=PREFIX specify a prefix corresponding to /usr (default ${prefix})],
97 usr_prefix=$withval,
98 usr_prefix=NONE)dnl
99 dnl
100 dnl handle --enable-dll-shlibs
101 dnl
102 AC_ARG_ENABLE([dll-shlibs],
103 [  --enable-dll-shlibs    select DLL libraries],
104 if test "$enableval" = "no"
105 then
106         DLL_CMT=#
107         MAKEFILE_DLL=/dev/null
108         echo "Disabling DLL shared libraries"
109 else
110         DLL_CMT=
111         MAKEFILE_DLL=$srcdir/lib/Makefile.dll-lib
112         BINARY_TYPE=dllbin
113         LIB_EXT=.sa
114         echo "Enabling DLL shared libraries"
115 fi
116 ,
117 MAKEFILE_DLL=/dev/null
118 DLL_CMT=#
119 echo "Disabling DLL shared libraries by default"
120 )
121 AC_SUBST(DLL_CMT)
122 AC_SUBST_FILE(MAKEFILE_DLL)
123 dnl
124 dnl handle --enable-elf-shlibs
125 dnl
126 AC_ARG_ENABLE([elf-shlibs],
127 [  --enable-elf-shlibs    select ELF shared libraries],
128 if test "$enableval" = "no"
129 then
130         ELF_CMT=#
131         MAKEFILE_ELF=/dev/null
132         echo "Disabling ELF shared libraries"
133 else
134         ELF_CMT=
135         MAKEFILE_ELF=$srcdir/lib/Makefile.elf-lib
136         BINARY_TYPE=elfbin
137         LIB_EXT=.so
138         echo "Enabling ELF shared libraries"
139 fi
140 ,
141 MAKEFILE_ELF=/dev/null
142 ELF_CMT=#
143 echo "Disabling ELF shared libraries by default"
144 )
145 AC_SUBST(ELF_CMT)
146 AC_SUBST_FILE(MAKEFILE_ELF)
147 dnl
148 dnl handle --enable-bsd-shlibs
149 dnl
150 AC_ARG_ENABLE([bsd-shlibs],
151 [  --enable-bsd-shlibs    select BSD shared libraries],
152 if test "$enableval" = "no"
153 then
154         BSDLIB_CMT=#
155         MAKEFILE_BSDLIB=/dev/null
156         echo "Disabling BSD shared libraries"
157 else
158         BSDLIB_CMT=
159         MAKEFILE_BSDLIB=$srcdir/lib/Makefile.bsd-lib
160         LIB_EXT=.so
161         echo "Enabling BSD shared libraries"
162 fi
163 ,
164 MAKEFILE_BSDLIB=/dev/null
165 BSDLIB_CMT=#
166 echo "Disabling BSD shared libraries by default"
167 )
168 AC_SUBST(BSDLIB_CMT)
169 AC_SUBST_FILE(MAKEFILE_BSDLIB)
170 dnl
171 dnl handle --enable-profile
172 dnl
173 AC_ARG_ENABLE([profile],
174 [  --enable-profile       build profiling libraries],
175 if test "$enableval" = "no"
176 then
177         PROFILE_CMT=#
178         MAKEFILE_PROFILE=/dev/null
179         echo "Disabling profiling libraries"
180 else
181         PROFILE_CMT=
182         MAKEFILE_PROFILE=$srcdir/lib/Makefile.profile
183         PROFILED_LIB_EXT=_p.a
184         echo "Building profiling libraries"
185 fi
186 ,
187 PROFILE_CMT=#
188 MAKEFILE_PROFILE=/dev/null
189 echo "Disabling profiling libraries by default"
190 )
191 AC_SUBST(PROFILE_CMT)
192 AC_SUBST_FILE(MAKEFILE_PROFILE)
193 dnl
194 dnl handle --enable-checker
195 dnl
196 AC_ARG_ENABLE([checker],
197 [  --enable-checker       build checker libraries],
198 if test "$enableval" = "no"
199 then
200         CHECKER_CMT=#
201         MAKEFILE_CHECKER=/dev/null
202         echo "Disabling checker libraries"
203 else
204         CHECKER_CMT=
205         MAKEFILE_CHECKER=$srcdir/lib/Makefile.checker
206         echo "Building checker libraries"
207 fi
208 ,
209 CHECKER_CMT=#
210 MAKEFILE_CHECKER=/dev/null
211 echo "Disabling checker libraries by default"
212 )
213 AC_SUBST(CHECKER_CMT)
214 AC_SUBST_FILE(MAKEFILE_CHECKER)
215 dnl
216 dnl Substitute library extensions
217 dnl
218 AC_SUBST(LIB_EXT)
219 AC_SUBST(STATIC_LIB_EXT)
220 AC_SUBST(PROFILED_LIB_EXT)
221 dnl
222 dnl handle --enable-gcc-wall
223 dnl
224 AC_ARG_ENABLE([gcc-wall],
225 [  --enable-gcc-wall      enable GCC anal warnings (DON'T USE IN PRODUCTION)],
226 if test "$enableval" = "no"
227 then
228         W=#
229         echo "Disabling GCC warnings"
230 else
231         W=
232         echo "Enabling GCC warnings"
233 fi
234 ,
235 W=#
236 echo "Disabling GCC warnings by default"
237 )
238 AC_SUBST(W)
239 AC_ARG_ENABLE([dynamic-e2fsck],
240 [  --enable-dynamic-e2fsck build e2fsck dynamically],
241 if test "$enableval" = "no"
242 then
243         E2FSCK_TYPE=static
244         echo "Building e2fsck statically"
245 else
246         E2FSCK_TYPE=shared
247         echo "Building e2fsck dynamically"
248 fi
249 ,
250 E2FSCK_TYPE=static
251 echo "Building e2fsck statically by default"
252 )
253 AC_SUBST(E2FSCK_TYPE)
254 dnl
255 dnl See whether to install the `fsck' wrapper program (that calls e2fsck)
256 dnl
257 AC_ARG_ENABLE([fsck],
258 [  --enable-fsck           build fsck wrapper program],
259 [if test "$enableval" = "no"
260 then
261         FSCK_PROG='' FSCK_MAN=''
262         echo "Not building fsck wrapper"
263 else
264         FSCK_PROG=fsck FSCK_MAN=fsck.8
265         echo "Building fsck wrapper"
266 fi]
267 ,
268 [case "$host_os" in
269   gnu*)
270     FSCK_PROG='' FSCK_MAN=''
271     echo "Not building fsck wrapper by default"
272     ;;
273   *)
274     FSCK_PROG=fsck FSCK_MAN=fsck.8
275     echo "Building fsck wrapper by default"
276 esac]
277 )
278 AC_SUBST(FSCK_PROG)
279 AC_SUBST(FSCK_MAN)
280 dnl
281 dnl
282 MAKEFILE_LIBRARY=$srcdir/lib/Makefile.library
283 AC_SUBST_FILE(MAKEFILE_LIBRARY)
284 dnl
285 dnl
286 AC_ARG_ENABLE([old-bitops],
287 [  --enable-old-bitops    Use old (non-standard but native) bitmask operations],
288 if test "$enableval" = "no"
289 then
290         echo "Using new (standard) bitmask operations"
291 else
292         AC_DEFINE(EXT2_OLD_BITOPS)
293         echo "Using old (native) bitmask operations"
294
295 fi
296 ,
297 echo "Using standard bitmask operations by default"
298 )
299 dnl
300 dnl End of configuration options
301 dnl
302 AC_SUBST(BINARY_TYPE)
303 AC_PROG_MAKE_SET
304 AC_PATH_PROG(LN, ln, ln)
305 AC_PROG_LN_S
306 AC_PATH_PROG(MV, mv, mv)
307 AC_PATH_PROG(CP, cp, cp)
308 AC_PATH_PROG(RM, rm, rm)
309 AC_PATH_PROG(CHMOD, chmod, :)
310 AC_PATH_PROG(AWK, awk, awk)
311 AC_PATH_PROG(SED, sed, sed)
312 AC_CHECK_TOOL(AR, ar, ar)
313 AC_CHECK_TOOL(RANLIB, ranlib, :)
314 AC_CHECK_TOOL(STRIP, strip, :)
315 AC_PROG_CC
316 AC_PROG_INSTALL
317 AC_C_CROSS
318 AC_CHECK_HEADERS(stdlib.h unistd.h stdarg.h errno.h mntent.h dirent.h getopt.h linux/fd.h linux/major.h sys/disklabel.h sys/sockio.h sys/time.h sys/stat.h sys/types.h net/if.h netinet/in.h)
319 AC_FUNC_VPRINTF
320 dnl
321 dnl See if struct dirent has a d_namlen field (like bsd systems), implying
322 dnl that the actual length of the structure may be grater than the declared
323 dnl length. 
324 dnl
325 AC_MSG_CHECKING(whether struct dirent has a d_namlen field)
326 AC_CACHE_VAL(e2fsprogs_cv_struct_d_namlen,
327         AC_TRY_COMPILE(
328 [#include <sys/types.h>
329 #include <dirent.h>],
330                 [struct dirent de; de.d_namlen = 0;],
331                 [e2fsprogs_cv_struct_d_namlen=yes],
332                 [e2fsprogs_cv_struct_d_namlen=no]))
333 AC_MSG_RESULT($e2fsprogs_cv_struct_d_namlen)
334 if test "$e2fsprogs_cv_struct_d_namlen" = yes; then
335   AC_DEFINE(HAVE_DIRENT_NAMLEN)
336 fi
337 dnl
338 dnl Check to see if llseek() is declared in unistd.h.  On some libc's 
339 dnl it is, and on others it isn't..... Thank you glibc developers....
340 dnl
341 dnl Warning!  Use of --enable-gcc-wall may throw off this test.
342 dnl
343 dnl
344 AC_MSG_CHECKING(whether llseek declared in unistd.h)
345 AC_CACHE_VAL(e2fsprogs_cv_have_llseek_prototype,
346         AC_TRY_COMPILE(
347 [#include <unistd.h>], [extern int llseek(int);],
348         [e2fsprogs_cv_have_llseek_prototype=no],
349         [e2fsprogs_cv_have_llseek_prototype=yes]))
350 AC_MSG_RESULT($e2fsprogs_cv_have_llseek_prototype)
351 if test "$e2fsprogs_cv_have_llseek_prototype" = yes; then
352    AC_DEFINE(HAVE_LLSEEK_PROTOTYPE)
353 fi
354 dnl
355 dnl Word sizes...
356 dnl
357 if test "$cross_compiling" = yes -a "$ac_cv_sizeof_long" = ""; then
358   # if cross-compiling, with no cached values, just assume something common. 
359   ac_cv_sizeof_short=2
360   ac_cv_sizeof_int=4
361   ac_cv_sizeof_long=4
362   ac_cv_sizeof_long_long=0
363   AC_MSG_WARN([Cross-compiling, so cannot check type sizes; assuming short=2, int=4, long=4])
364 fi
365 AC_CHECK_SIZEOF(short)
366 AC_CHECK_SIZEOF(int)
367 AC_CHECK_SIZEOF(long)
368 AC_CHECK_SIZEOF(long long)
369 SIZEOF_SHORT=$ac_cv_sizeof_short
370 SIZEOF_INT=$ac_cv_sizeof_int
371 SIZEOF_LONG=$ac_cv_sizeof_long
372 SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
373 AC_SUBST(SIZEOF_SHORT)
374 AC_SUBST(SIZEOF_INT)
375 AC_SUBST(SIZEOF_LONG)
376 AC_SUBST(SIZEOF_LONG_LONG)
377 dnl
378 dnl See if struct stat has a st_flags field, in which case we can get file
379 dnl flags somewhat portably.  Also check for the analogous setter, chflags().
380 dnl
381 AC_MSG_CHECKING(whether struct stat has a st_flags field)
382 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
383         AC_TRY_COMPILE([#include <sys/stat.h>],
384                 [struct stat stat; stat.st_flags = 0;],
385                 [e2fsprogs_cv_struct_st_flags=yes],
386                 [e2fsprogs_cv_struct_st_flags=no]))
387 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
388 if test "$e2fsprogs_cv_struct_st_flags" = yes; then
389   AC_DEFINE(HAVE_STAT_FLAGS)
390 fi
391 AC_CHECK_FUNCS(chflags getrusage llseek strdup getmntinfo strcasecmp srandom fchown)
392 dnl
393 dnl Check to see if ino_t is defined
394 dnl
395 AC_MSG_CHECKING(ino_t defined by sys/types.h)
396 AC_CACHE_VAL(e2fsprogs_cv_ino_t,
397         AC_TRY_COMPILE([#include <sys/types.h>],
398         [ino_t ino; ino = 0;],
399         [e2fsprogs_cv_ino_t=yes],
400         [e2fsprogs_cv_ino_t=no]))
401 AC_MSG_RESULT($e2fsprogs_cv_ino_t)
402 if test "$e2fsprogs_cv_ino_t" = yes; then
403    AC_DEFINE(HAVE_INO_T)
404 fi
405 dnl
406 dnl On systems without linux header files, we add an extra include directory
407 dnl that holds enough to fake it (hopefully).  Note that the $(top_srcdir) here
408 dnl is quoted so that it gets expanded by make, not by configure.
409 dnl
410 AC_CHECK_HEADER(linux/fs.h, [linux_headers=yes], [linux_headers=no])
411 AC_SUBST(EXTRA_PROGS)
412 if test "$linux_headers" = yes; then
413   AC_DEFINE(HAVE_LINUX_FS_H)
414   # These are some programs that depend on having linux headers around, and
415   # won't work otherwise.  So we only compile them if we can.
416   EXTRA_PROGS="$EXTRA_PROGS flushb"
417 else
418   LINUX_INCLUDE='-I$(top_srcdir)/include -I$(top_builddir)/include'
419   # Use this include directory with test compiles in the configure script too.
420   CPPFLAGS="$CPPFLAGS -I$srcdir/include -I./include"
421 fi
422 AC_SUBST(LINUX_INCLUDE)
423 dnl
424 dnl Check to see if -lsocket is required (solaris) to make something
425 dnl that uses socket() to compile; this is needed for the UUID library
426 dnl
427 SOCKET_LIB=''
428 AC_CHECK_LIB(socket, socket, [SOCKET_LIB=-lsocket])
429 AC_SUBST(SOCKET_LIB)
430 dnl
431 dnl See if optreset exists
432 dnl
433 AC_MSG_CHECKING(for optreset)
434 AC_CACHE_VAL(ac_cv_have_optreset,
435 [AC_EGREP_HEADER(optreset, unistd.h,
436   ac_cv_have_optreset=yes, ac_cv_have_optreset=no)])dnl
437 AC_MSG_RESULT($ac_cv_have_optreset)
438 if test $ac_cv_have_optreset = yes; then
439   AC_DEFINE(HAVE_OPTRESET)
440 fi
441 dnl
442 dnl See if using the EXT2 ioctls causes a compile-time barf (as on the hurd).
443 dnl
444 AC_MSG_CHECKING(whether the ext2 ioctls compile)
445 AC_CACHE_VAL(e2fsprogs_cv_ioctl_ext2,
446         AC_TRY_COMPILE([#include <linux/ext2_fs.h>
447 #include <sys/ioctl.h>],
448                 [ioctl (0, EXT2_IOC_SETVERSION, 0);],
449                 [e2fsprogs_cv_ioctl_ext2=yes],
450                 [e2fsprogs_cv_ioctl_ext2=no]))
451 AC_MSG_RESULT($e2fsprogs_cv_ioctl_ext2)
452 if test "$e2fsprogs_cv_ioctl_ext2" = yes; then
453   AC_DEFINE(HAVE_EXT2_IOCTLS)
454 fi
455 dnl
456 dnl Linux uses a separate usr_prefix by default
457 dnl
458 case "$host_os" in
459 linux*)
460         if test "$prefix" = NONE ; then
461                 usr_prefix="\${prefix}/usr";
462                 echo "On $host_os systems, usr_prefix defaults to $usr_prefix"
463         fi
464         ;;
465 esac
466 if test "$usr_prefix" = NONE ; then
467         usr_prefix="\${prefix}"
468 fi
469 AC_SUBST(usr_prefix)
470 dnl
471 dnl On Linux/hurd, force the prefix to be ''
472 dnl
473 case "$host_os" in
474 linux* | gnu*)
475         if test "$prefix" = NONE ; then
476                 prefix='';
477                 echo "On $host_os systems, prefix defaults to ''"
478         fi
479 ;;
480 esac
481 dnl
482 dnl See if -static works.
483 dnl
484 AC_MSG_CHECKING([whether linker accepts -static])
485 AC_CACHE_VAL(ac_cv_e2fsprogs_use_static,
486 [SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -static"
487 AC_TRY_LINK([#include <stdio.h>],[fflush(stdout);],
488  ac_cv_e2fsprogs_use_static=yes, ac_cv_e2fsprogs_use_static=no)
489 LDFLAGS=$SAVE_LDFLAGS])
490 AC_MSG_RESULT($ac_cv_e2fsprogs_use_static)
491 LDFLAG_STATIC=
492 if test $ac_cv_e2fsprogs_use_static = yes; then
493         LDFLAG_STATIC=-static
494 fi
495 AC_SUBST(LDFLAG_STATIC)
496 dnl
497 dnl Make the ss and et directories work correctly.
498 dnl
499 SS_DIR=`cd ${srcdir}/lib/ss; pwd`
500 ET_DIR=`cd ${srcdir}/lib/et; pwd`
501 AC_SUBST(SS_DIR)
502 AC_SUBST(ET_DIR)
503 dnl
504 dnl Only try to run the test suite if we're not cross compiling.
505 dnl
506 if test "$cross_compiling" = yes ; then
507   DO_TEST_SUITE=
508 else
509   DO_TEST_SUITE=check
510 fi
511 AC_SUBST(DO_TEST_SUITE)
512 dnl
513 dnl
514 dnl
515 DO_SUBSTITUTE_SCRIPT=$srcdir/lib/do_substitute
516 AC_SUBST_FILE(DO_SUBSTITUTE_SCRIPT)
517 dnl
518 dnl Make our output files, being sure that we create the some miscellaneous 
519 dnl directories
520 dnl
521 test -d lib || mkdir lib
522 test -d include || mkdir include
523 test -d include/linux || mkdir include/linux
524 rmakefile=
525 if test -d ${srcdir}/resize ; then
526    rmakefile=resize/Makefile
527 fi
528 AC_OUTPUT(MCONFIG Makefile util/Makefile util/subst.conf lib/et/Makefile 
529         lib/ss/Makefile lib/ext2fs/Makefile lib/e2p/Makefile lib/uuid/Makefile
530         misc/Makefile e2fsck/Makefile debugfs/Makefile tests/Makefile 
531         tests/progs/Makefile $rmakefile doc/Makefile)