OSDN Git Service

Many files:
[android-x86/external-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 dnl
44 dnl set $(CC) from --with-cc=value
45 dnl
46 AC_ARG_WITH([cc],
47 [  --with-cc=COMPILER      select compiler to use],
48 AC_MSG_RESULT(CC=$withval)
49 CC=$withval,
50 if test -z "$CC" ; then CC=cc; fi
51 [AC_MSG_RESULT(CC defaults to $CC)])dnl
52 export CC
53 AC_SUBST([CC])
54 dnl
55 dnl set $(LD) from --with-linker=value
56 dnl
57 AC_ARG_WITH([linker],
58 [  --with-linker=LINKER    select linker to use],
59 AC_MSG_RESULT(LD=$withval)
60 LD=$withval,
61 if test -z "$LD" ; then LD=$CC; fi
62 [AC_MSG_RESULT(LD defaults to $LD)])dnl
63 export LD
64 AC_SUBST([LD])
65 dnl
66 dnl set $(CCOPTS) from --with-ccopts=value
67 dnl
68 AC_ARG_WITH([ccopts],
69 [  --with-ccopts=CCOPTS    select compiler command line options],
70 AC_MSG_RESULT(CCOPTS is $withval)
71 CCOPTS=$withval
72 CFLAGS="$CFLAGS $withval",
73 CCOPTS=)dnl
74 AC_SUBST(CCOPTS)
75 dnl
76 dnl Set default values for library extentions.  Will be dealt with after
77 dnl parsing configuration opions, which may modify these
78 dnl
79 LIB_EXT=.a
80 STATIC_LIB_EXT=.a
81 PROFILE_LIB_EXT=.a
82 dnl
83 dnl set $(LDFLAGS) from --with-ldopts=value
84 dnl
85 AC_ARG_WITH([ldopts],
86 [  --with-ldopts=LDOPTS    select linker command line options],
87 AC_MSG_RESULT(LDFLAGS is $withval)
88 LDFLAGS=$withval,
89 LDFLAGS=)dnl
90 AC_SUBST(LDFLAGS)
91 dnl
92 dnl handle --enable-dll-shlibs
93 dnl
94 AC_ARG_ENABLE([dll-shlibs],
95 [  --enable-dll-shlibs    select DLL libraries],
96 if test "$enableval" = "no"
97 then
98         DLL_CMT=#
99         MAKEFILE_DLL=/dev/null
100         echo "Disabling DLL shared libraries"
101 else
102         DLL_CMT=
103         MAKEFILE_DLL=$srcdir/lib/Makefile.dll-lib
104         BINARY_TYPE=dllbin
105         LIB_EXT=.sa
106         echo "Enabling DLL shared libraries"
107 fi
108 ,
109 MAKEFILE_DLL=/dev/null
110 DLL_CMT=#
111 echo "Disabling DLL shared libraries by default"
112 )
113 AC_SUBST(DLL_CMT)
114 AC_SUBST_FILE(MAKEFILE_DLL)
115 dnl
116 dnl handle --enable-elf-shlibs
117 dnl
118 AC_ARG_ENABLE([elf-shlibs],
119 [  --enable-elf-shlibs    select ELF shared libraries],
120 if test "$enableval" = "no"
121 then
122         ELF_CMT=#
123         MAKEFILE_ELF=/dev/null
124         echo "Disabling ELF shared libraries"
125 else
126         ELF_CMT=
127         MAKEFILE_ELF=$srcdir/lib/Makefile.elf-lib
128         BINARY_TYPE=elfbin
129         LIB_EXT=.so
130         echo "Enabling ELF shared libraries"
131 fi
132 ,
133 MAKEFILE_ELF=/dev/null
134 ELF_CMT=#
135 echo "Disabling ELF shared libraries by default"
136 )
137 AC_SUBST(ELF_CMT)
138 AC_SUBST_FILE(MAKEFILE_ELF)
139 dnl
140 dnl handle --enable-bsd-shlibs
141 dnl
142 AC_ARG_ENABLE([bsd-shlibs],
143 [  --enable-bsd-shlibs    select BSD shared libraries],
144 if test "$enableval" = "no"
145 then
146         BSDLIB_CMT=#
147         MAKEFILE_BSDLIB=/dev/null
148         echo "Disabling BSD shared libraries"
149 else
150         BSDLIB_CMT=
151         MAKEFILE_BSDLIB=$srcdir/lib/Makefile.bsd-lib
152         LIB_EXT=.so
153         echo "Enabling BSD shared libraries"
154 fi
155 ,
156 MAKEFILE_BSDLIB=/dev/null
157 BSDLIB_CMT=#
158 echo "Disabling BSD shared libraries by default"
159 )
160 AC_SUBST(BSDLIB_CMT)
161 AC_SUBST_FILE(MAKEFILE_BSDLIB)
162 dnl
163 dnl handle --enable-profile
164 dnl
165 AC_ARG_ENABLE([profile],
166 [  --enable-profile       build profiling libraries],
167 if test "$enableval" = "no"
168 then
169         PROFILE_CMT=#
170         MAKEFILE_PROFILE=/dev/null
171         echo "Disabling profiling libraries"
172 else
173         PROFILE_CMT=
174         MAKEFILE_PROFILE=$srcdir/lib/Makefile.profile
175         PROFILED_LIB_EXT=_p.a
176         echo "Building profiling libraries"
177 fi
178 ,
179 PROFILE_CMT=#
180 MAKEFILE_PROFILE=/dev/null
181 echo "Disabling profiling libraries by default"
182 )
183 AC_SUBST(PROFILE_CMT)
184 AC_SUBST_FILE(MAKEFILE_PROFILE)
185 dnl
186 dnl handle --enable-checker
187 dnl
188 AC_ARG_ENABLE([checker],
189 [  --enable-checker       build checker libraries],
190 if test "$enableval" = "no"
191 then
192         CHECKER_CMT=#
193         MAKEFILE_CHECKER=/dev/null
194         echo "Disabling checker libraries"
195 else
196         CHECKER_CMT=
197         MAKEFILE_CHECKER=$srcdir/lib/Makefile.checker
198         echo "Building checker libraries"
199 fi
200 ,
201 CHECKER_CMT=#
202 MAKEFILE_CHECKER=/dev/null
203 echo "Disabling checker libraries by default"
204 )
205 AC_SUBST(CHECKER_CMT)
206 AC_SUBST_FILE(MAKEFILE_CHECKER)
207 dnl
208 dnl Substitute library extensions
209 dnl
210 AC_SUBST(LIB_EXT)
211 AC_SUBST(STATIC_LIB_EXT)
212 AC_SUBST(PROFILED_LIB_EXT)
213 dnl
214 dnl handle --enable-gcc-wall
215 dnl
216 AC_ARG_ENABLE([gcc-wall],
217 [  --enable-gcc-wall      enable GCC anal warnings],
218 if test "$enableval" = "no"
219 then
220         W=#
221         echo "Disabling GCC warnings"
222 else
223         W=
224         echo "Enabling GCC warnings"
225 fi
226 ,
227 W=#
228 echo "Disabling GCC warnings by default"
229 )
230 AC_SUBST(W)
231 AC_ARG_ENABLE([dynamic-e2fsck],
232 [  --enable-dynamic-e2fsck build e2fsck dynamically],
233 if test "$enableval" = "no"
234 then
235         E2FSCK_TYPE=static
236         echo "Building e2fsck statically"
237 else
238         E2FSCK_TYPE=shared
239         echo "Building e2fsck dynamically"
240 fi
241 ,
242 E2FSCK_TYPE=static
243 echo "Building e2fsck statically by default"
244 )
245 AC_SUBST(E2FSCK_TYPE)
246 dnl
247 dnl
248 MAKEFILE_LIBRARY=$srcdir/lib/Makefile.library
249 AC_SUBST_FILE(MAKEFILE_LIBRARY)
250 dnl
251 dnl End of configuration options
252 dnl
253 AC_SUBST(BINARY_TYPE)
254 AC_PROG_MAKE_SET
255 AC_PATH_PROG(LN, ln, ln)
256 AC_PATH_PROG(MV, mv, mv)
257 AC_PATH_PROG(CP, cp, cp)
258 AC_PATH_PROG(RM, rm, rm)
259 AC_PATH_PROG(CHMOD, chmod, :)
260 AC_PATH_PROG(AWK, awk, awk)
261 AC_PATH_PROG(SED, sed, sed)
262 AC_CHECK_TOOL(AR, ar, ar)
263 AC_CHECK_TOOL(RANLIB, ranlib, :)
264 AC_CHECK_TOOL(STRIP, strip, :)
265 AC_PROG_CC
266 AC_PROG_INSTALL
267 AC_C_CROSS
268 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)
269 AC_FUNC_VPRINTF
270 dnl
271 dnl See if struct dirent has a d_namlen field (like bsd systems), implying
272 dnl that the actual length of the structure may be grater than the declared
273 dnl length. 
274 dnl
275 AC_MSG_CHECKING(whether struct dirent has a d_namlen field)
276 AC_CACHE_VAL(e2fsprogs_cv_struct_d_namlen,
277         AC_TRY_COMPILE(
278 [#include <sys/types.h>
279 #include <dirent.h>],
280                 [struct dirent de; de.d_namlen = 0;],
281                 [e2fsprogs_cv_struct_d_namlen=yes],
282                 [e2fsprogs_cv_struct_d_namlen=no]))
283 AC_MSG_RESULT($e2fsprogs_cv_struct_d_namlen)
284 if test "$e2fsprogs_cv_struct_d_namlen" = yes; then
285   AC_DEFINE(HAVE_DIRENT_NAMLEN)
286 fi
287 dnl
288 dnl Word sizes...
289 dnl
290 if test "$cross_compiling" = yes -a "$ac_cv_sizeof_long" = ""; then
291   # if cross-compiling, with no cached values, just assume something common. 
292   ac_cv_sizeof_short=2
293   ac_cv_sizeof_int=4
294   ac_cv_sizeof_long=4
295   AC_MSG_WARN([Cross-compiling, so cannot check type sizes; assuming short=2, int=4, long=4])
296 fi
297 AC_CHECK_SIZEOF(short)
298 AC_CHECK_SIZEOF(int)
299 AC_CHECK_SIZEOF(long)
300 SIZEOF_SHORT=$ac_cv_sizeof_short
301 SIZEOF_INT=$ac_cv_sizeof_int
302 SIZEOF_LONG=$ac_cv_sizeof_long
303 AC_SUBST(SIZEOF_SHORT)
304 AC_SUBST(SIZEOF_INT)
305 AC_SUBST(SIZEOF_LONG)
306 dnl
307 dnl See if struct stat has a st_flags field, in which case we can get file
308 dnl flags somewhat portably.  Also check for the analogous setter, chflags().
309 dnl
310 AC_MSG_CHECKING(whether struct stat has a st_flags field)
311 AC_CACHE_VAL(e2fsprogs_cv_struct_st_flags,
312         AC_TRY_COMPILE([#include <sys/stat.h>],
313                 [struct stat stat; stat.st_flags = 0;],
314                 [e2fsprogs_cv_struct_st_flags=yes],
315                 [e2fsprogs_cv_struct_st_flags=no]))
316 AC_MSG_RESULT($e2fsprogs_cv_struct_st_flags)
317 if test "$e2fsprogs_cv_struct_st_flags" = yes; then
318   AC_DEFINE(HAVE_STAT_FLAGS)
319 fi
320 AC_CHECK_FUNCS(chflags getrusage llseek strdup getmntinfo)
321 dnl
322 dnl On systems without linux header files, we add an extra include directory
323 dnl that holds enough to fake it (hopefully).  Note that the $(top_srcdir) here
324 dnl is quoted so that it gets expanded by make, not by configure.
325 dnl
326 AC_CHECK_HEADER(linux/fs.h, [linux_headers=yes], [linux_headers=no])
327 AC_SUBST(EXTRA_PROGS)
328 if test "$linux_headers" = yes; then
329   AC_DEFINE(HAVE_LINUX_FS_H)
330   # These are some programs that depend on having linux headers around, and
331   # won't work otherwise.  So we only compile them if we can.
332   EXTRA_PROGS="$EXTRA_PROGS flushb"
333 else
334   LINUX_INCLUDE='-I$(top_srcdir)/include -I$(top_builddir)/include'
335   # Use this include directory with test compiles in the configure script too.
336   CPPFLAGS="$CPPFLAGS -I$srcdir/include -I./include"
337 fi
338 AC_SUBST(LINUX_INCLUDE)
339 dnl
340 dnl See if optreset exists
341 dnl
342 AC_MSG_CHECKING(for optreset)
343 AC_CACHE_VAL(ac_cv_have_optreset,
344 [AC_EGREP_HEADER(optreset, unistd.h,
345   ac_cv_have_optreset=yes, ac_cv_have_optreset=no)])dnl
346 AC_MSG_RESULT($ac_cv_have_optreset)
347 if test $ac_cv_have_optreset = yes; then
348   AC_DEFINE(HAVE_OPTRESET)
349 fi
350 dnl
351 dnl See if our system has frags enabled (at least in the header file)
352 dnl
353 AC_MSG_CHECKING(whether struct ext2_inode has frags fields)
354 AC_CACHE_VAL(e2fsprogs_cv_struct_ext2_inode_frags,
355         AC_TRY_COMPILE([#include <linux/ext2_fs.h>],
356                 [struct ext2_inode i; i.i_frag = i.i_fsize = 0;],
357                 [e2fsprogs_cv_struct_ext2_inode_frags=yes],
358                 [e2fsprogs_cv_struct_ext2_inode_frags=no]))
359 AC_MSG_RESULT($e2fsprogs_cv_struct_ext2_inode_frags)
360 if test "$e2fsprogs_cv_struct_ext2_inode_frags" = yes; then
361   AC_DEFINE(HAVE_EXT2_FRAGS)
362 fi
363 dnl
364 dnl See if using the EXT2 ioctls causes a compile-time barf (as on the hurd).
365 dnl
366 AC_MSG_CHECKING(whether the ext2 ioctls compile)
367 AC_CACHE_VAL(e2fsprogs_cv_ioctl_ext2,
368         AC_TRY_COMPILE([#include <linux/ext2_fs.h>
369 #include <sys/ioctl.h>],
370                 [ioctl (0, EXT2_IOC_SETVERSION, 0);],
371                 [e2fsprogs_cv_ioctl_ext2=yes],
372                 [e2fsprogs_cv_ioctl_ext2=no]))
373 AC_MSG_RESULT($e2fsprogs_cv_ioctl_ext2)
374 if test "$e2fsprogs_cv_ioctl_ext2" = yes; then
375   AC_DEFINE(HAVE_EXT2_IOCTLS)
376 fi
377 dnl
378 dnl On linux, force the prefix to be '/'
379 dnl
380 AC_REQUIRE([AC_CANONICAL_HOST])
381 case "$host_os" in
382 linux*)
383         if test "$prefix" = NONE ; then
384                 prefix='/';
385                 echo "On Linux systems, prefix defaults to '/'"
386         fi
387 ;;
388 esac
389 dnl
390 dnl See if -static works.
391 dnl XXX for now, assume that only Linux systems support -static
392 dnl
393 AC_REQUIRE([AC_CANONICAL_HOST])
394 LDFLAG_STATIC=
395 case "$host_os" in
396 linux*)
397         LDFLAG_STATIC=-static
398         echo "On Linux systems, assume -static works"
399 ;;
400 esac
401 AC_SUBST(LDFLAG_STATIC)
402 dnl
403 dnl Check to see if prefix is '/'
404 dnl
405 if test "$prefix" = / ; then
406         usr_prefix=/usr
407 else
408         usr_prefix="\${prefix}"
409 fi
410 AC_SUBST(usr_prefix)
411 dnl
412 dnl Make the ss and et directories work correctly.
413 dnl
414 SS_DIR=`cd ${srcdir}/lib/ss; pwd`
415 ET_DIR=`cd ${srcdir}/lib/et; pwd`
416 AC_SUBST(SS_DIR)
417 AC_SUBST(ET_DIR)
418 dnl
419 dnl Only try to run the test suite if we're not cross compiling.
420 dnl
421 if test "$cross_compiling" = yes ; then
422   DO_TEST_SUITE=
423 else
424   DO_TEST_SUITE=check
425 fi
426 AC_SUBST(DO_TEST_SUITE)
427 dnl
428 dnl
429 dnl
430 DO_SUBSTITUTE_SCRIPT=$srcdir/lib/do_substitute
431 AC_SUBST_FILE(DO_SUBSTITUTE_SCRIPT)
432 dnl
433 dnl Make our output files, being sure that we create the some miscellaneous 
434 dnl directories
435 dnl
436 test -d lib || mkdir lib
437 test -d include || mkdir include
438 test -d include/linux || mkdir include/linux
439 AC_OUTPUT(MCONFIG lib/substitute_sh Makefile lib/et/Makefile 
440         lib/ss/Makefile lib/ext2fs/Makefile lib/e2p/Makefile misc/Makefile 
441         e2fsck/Makefile debugfs/Makefile tests/Makefile)