regedit: Fix documentation for CurrentControlSet (thanks Yuval Kashtan).
[hivex.git] / configure.ac
1 # hivex
2 # Copyright (C) 2009-2010 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 # major/minor/release must be numbers
19 m4_define([hivex_major],   [1])
20 m4_define([hivex_minor],   [2])
21 m4_define([hivex_release], [2])
22 # extra can be any string
23 m4_define([hivex_extra],   [])
24
25 AC_INIT([hivex],hivex_major.hivex_minor.hivex_release[]hivex_extra)
26 AC_CONFIG_AUX_DIR([build-aux])
27 AM_INIT_AUTOMAKE([foreign])
28
29 m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
30 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
31
32 AC_CONFIG_MACRO_DIR([m4])
33
34 dnl Split up the version string.
35 AC_DEFINE([PACKAGE_VERSION_MAJOR],[hivex_major],[Major version number])
36 AC_DEFINE([PACKAGE_VERSION_MINOR],[hivex_minor],[Minor version number])
37 AC_DEFINE([PACKAGE_VERSION_RELEASE],[hivex_release],[Release number])
38 AC_DEFINE([PACKAGE_VERSION_EXTRA],["hivex_extra"],[Extra version string])
39
40 gl_EARLY
41 gl_INIT
42
43 AC_PROG_LIBTOOL
44
45 dnl Check for basic C environment.
46 AC_PROG_CC_STDC
47 AC_PROG_INSTALL
48 AC_PROG_CPP
49
50 AC_ARG_ENABLE([gcc-warnings],
51   [AS_HELP_STRING([--enable-gcc-warnings],
52                   [turn on lots of GCC warnings (for developers)])],
53   [case $enableval in
54      yes|no) ;;
55      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
56    esac
57    gl_gcc_warnings=$enableval],
58   [gl_gcc_warnings=no]
59 )
60
61 if test "$gl_gcc_warnings" = yes; then
62   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
63   AC_SUBST([WERROR_CFLAGS])
64
65   nw=
66   # This, $nw, is the list of warnings we disable.
67   nw="$nw -Wdeclaration-after-statement" # too useful to forbid
68   nw="$nw -Waggregate-return"       # anachronistic
69   nw="$nw -Wc++-compat"             # We don't care about C++ compilers
70   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
71   nw="$nw -Wtraditional"            # Warns on #elif which we use often
72   nw="$nw -Wcast-qual"              # Too many warnings for now
73   nw="$nw -Wconversion"             # Too many warnings for now
74   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
75   nw="$nw -Wsign-conversion"        # Too many warnings for now
76   nw="$nw -Wtraditional-conversion" # Too many warnings for now
77   nw="$nw -Wunreachable-code"       # Too many warnings for now
78   nw="$nw -Wpadded"                 # Our structs are not padded
79   nw="$nw -Wredundant-decls"        # openat.h declares e.g., mkdirat
80   nw="$nw -Wlogical-op"             # any use of fwrite provokes this
81   nw="$nw -Wvla"                    # two warnings in mount.c
82   # things I might fix soon:
83   nw="$nw -Wmissing-format-attribute" # daemon.h's asprintf_nowarn
84   nw="$nw -Winline"                 # daemon.h's asprintf_nowarn
85   nw="$nw -Wshadow"                 # numerous, plus we're not unanimous
86   # ?? -Wstrict-overflow
87   nw="$nw -Wunsafe-loop-optimizations" # just a warning that an optimization
88                                     # was not possible, safe to ignore
89   nw="$nw -Wpacked"                 # Allow attribute((packed)) on structs
90
91   gl_MANYWARN_ALL_GCC([ws])
92   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
93   for w in $ws; do
94     gl_WARN_ADD([$w])
95   done
96   gl_WARN_ADD([-Wno-unused-parameter]) # stubs.c
97   gl_WARN_ADD([-Wno-jump-misses-init]) # stubs.c
98   gl_WARN_ADD([-Wno-unused-variable]) # FIXME: only temporary, for guestfs_protocol.c, etc
99
100   # In spite of excluding -Wlogical-op above, it is enabled, as of
101   # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
102   gl_WARN_ADD([-Wno-logical-op])
103
104   gl_WARN_ADD([-fdiagnostics-show-option])
105
106   AC_SUBST([WARN_CFLAGS])
107
108   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
109   AC_DEFINE([_FORTIFY_SOURCE], [2],
110     [enable compile-time and run-time bounds-checking, and some warnings])
111   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
112 fi
113
114 AC_C_PROTOTYPES
115 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
116
117 AM_PROG_CC_C_O
118
119 dnl Work out how to specify the linker script to the linker.
120 VERSION_SCRIPT_FLAGS=-Wl,--version-script=
121 `/usr/bin/ld --help 2>&1 | grep -- --version-script >/dev/null` || \
122     VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,"
123 AC_SUBST(VERSION_SCRIPT_FLAGS)
124
125 dnl Check support for 64 bit file offsets.
126 AC_SYS_LARGEFILE
127
128 dnl Check sizeof long.
129 AC_CHECK_SIZEOF([long])
130
131 dnl Headers.
132 AC_CHECK_HEADERS([endian.h byteswap.h])
133
134 dnl Check for pod2man and pod2text.
135 AC_CHECK_PROG([POD2MAN],[pod2man],[pod2man],[no])
136 test "x$POD2MAN" = "xno" &&
137      AC_MSG_ERROR([pod2man must be installed])
138 AC_CHECK_PROG([POD2TEXT],[pod2text],[pod2text],[no])
139 test "x$POD2TEXT" = "xno" &&
140      AC_MSG_ERROR([pod2text must be installed])
141
142 dnl Readline.
143 AC_ARG_WITH([readline],
144     [AS_HELP_STRING([--with-readline],
145         [support fancy command line editing @<:@default=check@:>@])],
146     [],
147     [with_readline=check])
148
149 LIBREADLINE=
150 AS_IF([test "x$with_readline" != xno],
151     [AC_CHECK_LIB([readline], [main],
152         [AC_SUBST([LIBREADLINE], ["-lreadline"])
153          AC_DEFINE([HAVE_LIBREADLINE], [1],
154                    [Define if you have libreadline])
155         ],
156         [if test "x$with_readline" != xcheck; then
157          AC_MSG_FAILURE(
158              [--with-readline was given, but test for readline failed])
159          fi
160         ])])
161
162 dnl For i18n.
163 AM_GNU_GETTEXT([external])
164 AM_GNU_GETTEXT_VERSION([0.17])
165
166 dnl libxml2.
167 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
168 AC_SUBST([LIBXML2_CFLAGS])
169 AC_SUBST([LIBXML2_LIBS])
170
171 dnl Check for OCaml (optional, for OCaml bindings).
172 AC_PROG_OCAML
173 AC_PROG_FINDLIB
174 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLC" != "xno" -a "x$OCAMLFIND" != "xno"])
175
176 if test "x$OCAMLC" != "xno"; then
177     dnl Check if we have caml/unixsupport.h header (OCaml bindings only).
178     old_CFLAGS="$CFLAGS"
179     CFLAGS="$CFLAGS -I$OCAMLLIB"
180     AC_CHECK_HEADERS([caml/unixsupport.h],[],[],
181     [
182     #include <caml/config.h>
183     #include <caml/mlvalues.h>
184     ])
185     CFLAGS="$old_CFLAGS"
186
187     dnl Do we have function caml_raise_with_args?
188     f=caml_raise_with_args
189     AC_MSG_CHECKING([for function $f])
190     echo "char $f (); char foo() { return $f (); }" > conftest.c
191     rm -f conftest_ml.ml
192     touch conftest_ml.ml
193     if $OCAMLOPT -c conftest.c 2>/dev/null && \
194        $OCAMLOPT -c conftest_ml.ml 2>/dev/null && \
195        $OCAMLOPT conftest.o conftest_ml.cmx -o conftest 2>/dev/null ; then
196         AC_DEFINE([HAVE_CAML_RAISE_WITH_ARGS],[1],
197                   [Defined if function caml_raise_with_args exists.])
198         AC_MSG_RESULT([found])
199     else
200         AC_MSG_RESULT([not found])
201     fi
202     rm -f conftest conftest.* conftest_ml.*
203 fi
204
205 dnl Check for Perl (optional, for Perl bindings).
206 dnl XXX This isn't quite right, we should check for Perl devel library.
207 AC_CHECK_PROG([PERL],[perl],[perl],[no])
208
209 dnl Check for Perl modules that must be present to compile and
210 dnl test the Perl bindings.
211 missing_perl_modules=no
212 for pm in Test::More ExtUtils::MakeMaker IO::Stringy; do
213     AC_MSG_CHECKING([for $pm])
214     if ! perl -M$pm -e1 >/dev/null 2>&1; then
215         AC_MSG_RESULT([no])
216         missing_perl_modules=yes
217     else
218         AC_MSG_RESULT([yes])
219     fi
220 done
221 if test "x$missing_perl_modules" = "xyes"; then
222     AC_MSG_WARN([some Perl modules required to compile or test the Perl bindings are missing])
223 fi
224
225 AM_CONDITIONAL([HAVE_PERL],
226     [test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
227
228 dnl dnl Check for Python (optional, for Python bindings).
229 dnl AC_CHECK_PROG([PYTHON],[python],[python],[no])
230
231 dnl PYTHON_PREFIX=
232 dnl PYTHON_VERSION=
233 dnl PYTHON_INCLUDEDIR=
234 dnl PYTHON_SITE_PACKAGES=
235
236 dnl if test "x$PYTHON" != "xno"; then
237 dnl     PYTHON_PREFIX=`$PYTHON -c "import sys; print sys.prefix"`
238 dnl     PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
239 dnl     for d in \
240 dnl         $PYTHON_PREFIX/include/python$PYTHON_VERSION \
241 dnl         /usr/include/python$PYTHON_VERSION \
242 dnl         /usr/local/include/python$PYTHON_VERSION
243 dnl     do
244 dnl         AC_MSG_CHECKING([Python.h in $d])
245 dnl         if test -r "$d/Python.h"; then
246 dnl             AC_MSG_RESULT([found])
247 dnl             PYTHON_INCLUDEDIR=$d
248 dnl             break
249 dnl         fi
250 dnl         AC_MSG_RESULT([not found])
251 dnl     done
252 dnl     for d in \
253 dnl         $PYTHON_PREFIX/lib64/python$PYTHON_VERSION/site-packages \
254 dnl         $PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages \
255 dnl         /usr/lib64/python$PYTHON_VERSION/site-packages \
256 dnl         /usr/lib/python$PYTHON_VERSION/site-packages \
257 dnl         /usr/local/lib/python$PYTHON_VERSION/site-packages
258 dnl     do
259 dnl         AC_MSG_CHECKING([for $d])
260 dnl         if test -d "$d"; then
261 dnl             AC_MSG_RESULT([found])
262 dnl             PYTHON_SITE_PACKAGES=$d
263 dnl             break
264 dnl         fi
265 dnl         AC_MSG_RESULT([not found])
266 dnl     done
267 dnl fi
268
269 dnl AC_SUBST(PYTHON_PREFIX)
270 dnl AC_SUBST(PYTHON_VERSION)
271 dnl AC_SUBST(PYTHON_INCLUDEDIR)
272 dnl AC_SUBST(PYTHON_SITE_PACKAGES)
273
274 dnl AM_CONDITIONAL([HAVE_PYTHON],
275 dnl     [test "x$PYTHON_INCLUDEDIR" != "x" -a "x$PYTHON_SITE_PACKAGES" != "x"])
276
277 dnl dnl Check for Ruby and rake (optional, for Ruby bindings).
278 dnl AC_CHECK_LIB([ruby],[ruby_init],[HAVE_LIBRUBY=1],[HAVE_LIBRUBY=0])
279 dnl AC_CHECK_PROG([RAKE],[rake],[rake],[no])
280
281 dnl AM_CONDITIONAL([HAVE_RUBY],
282 dnl     [test "x$RAKE" != "xno" -a -n "$HAVE_LIBRUBY"])
283
284 dnl dnl Check for Java.
285 dnl AC_ARG_WITH(java_home,
286 dnl     [AS_HELP_STRING([--with-java-home],
287 dnl         [specify path to JDK directory @<:@default=check@:>@])],
288 dnl     [],
289 dnl     [with_java_home=check])
290
291 dnl if test "x$with_java_home" != "xno"; then
292 dnl     if test "x$with_java_home" != "xyes" -a "x$with_java_home" != "xcheck"
293 dnl     then
294 dnl         # Reject unsafe characters in $JAVA_HOME
295 dnl         jh_lf='
296 dnl '
297 dnl         case $JAVA_HOME in
298 dnl           *[\\\"\#\$\&\'\`$jh_lf\ \ ]*)
299 dnl             AC_MSG_FAILURE([unsafe \$JAVA_HOME directory (use --with-java-home=no to disable Java support)]);;
300 dnl         esac
301 dnl         if test -d "$with_java_home"; then
302 dnl             JAVA_HOME="$with_java_home"
303 dnl         else
304 dnl             AC_MSG_FAILURE([$with_java_home is not a directory (use --with-java-home=no to disable Java support)])
305 dnl         fi
306 dnl     fi
307
308 dnl     if test "x$JAVA_HOME" = "x"; then
309 dnl         # Look for Java in some likely locations.
310 dnl         for d in \
311 dnl             /usr/lib/jvm/java \
312 dnl             /usr/lib/jvm/java-6-openjdk
313 dnl         do
314 dnl             if test -d $d -a -f $d/bin/java; then
315 dnl                 JAVA_HOME=$d
316 dnl                 break
317 dnl             fi
318 dnl         done
319 dnl     fi
320
321 dnl     if test "x$JAVA_HOME" != "x"; then
322 dnl         AC_MSG_CHECKING(for JDK in $JAVA_HOME)
323 dnl         if test ! -x "$JAVA_HOME/bin/java"; then
324 dnl             AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary (use --with-java-home=no to disable Java support)])
325 dnl         else
326 dnl             JAVA="$JAVA_HOME/bin/java"
327 dnl         fi
328 dnl         if test ! -x "$JAVA_HOME/bin/javac"; then
329 dnl             AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary])
330 dnl         else
331 dnl             JAVAC="$JAVA_HOME/bin/javac"
332 dnl         fi
333 dnl         if test ! -x "$JAVA_HOME/bin/javah"; then
334 dnl             AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary])
335 dnl         else
336 dnl             JAVAH="$JAVA_HOME/bin/javah"
337 dnl         fi
338 dnl         if test ! -x "$JAVA_HOME/bin/javadoc"; then
339 dnl             AC_MSG_ERROR([missing $JAVA_HOME/bin/javadoc binary])
340 dnl         else
341 dnl             JAVADOC="$JAVA_HOME/bin/javadoc"
342 dnl         fi
343 dnl         if test ! -x "$JAVA_HOME/bin/jar"; then
344 dnl             AC_MSG_ERROR([missing $JAVA_HOME/bin/jar binary])
345 dnl         else
346 dnl             JAR="$JAVA_HOME/bin/jar"
347 dnl         fi
348 dnl         java_version=`$JAVA -version 2>&1 | grep "java version"`
349 dnl         AC_MSG_RESULT(found $java_version in $JAVA_HOME)
350
351 dnl         dnl Find jni.h.
352 dnl         AC_MSG_CHECKING([for jni.h])
353 dnl         if test -f "$JAVA_HOME/include/jni.h"; then
354 dnl             JNI_CFLAGS="-I$JAVA_HOME/include"
355 dnl         else
356 dnl             if test "`find $JAVA_HOME -name jni.h`" != ""; then
357 dnl                 head=`find $JAVA_HOME -name jni.h | tail -1`
358 dnl                 dir=`dirname "$head"`
359 dnl                 JNI_CFLAGS="-I$dir"
360 dnl             else
361 dnl                 AC_MSG_FAILURE([missing jni.h header file])
362 dnl             fi
363 dnl         fi
364 dnl         AC_MSG_RESULT([$JNI_CFLAGS])
365
366 dnl         dnl Find jni_md.h.
367 dnl         AC_MSG_CHECKING([for jni_md.h])
368 dnl         case "$build_os" in
369 dnl         *linux*) system="linux" ;;
370 dnl         *SunOS*) system="solaris" ;;
371 dnl         *cygwin*) system="win32" ;;
372 dnl         *) system="$build_os" ;;
373 dnl         esac
374 dnl         if test -f "$JAVA_HOME/include/$system/jni_md.h"; then
375 dnl             JNI_CFLAGS="$JNI_CFLAGS -I$JAVA_HOME/include/$system"
376 dnl         else
377 dnl             if test "`find $JAVA_HOME -name jni_md.h`" != ""; then
378 dnl                 head=`find $JAVA_HOME -name jni_md.h | tail -1`
379 dnl                 dir=`dirname "$head"`
380 dnl                 JNI_CFLAGS="$JNI_CFLAGS -I$dir"
381 dnl             else
382 dnl                 AC_MSG_FAILURE([missing jni_md.h header file])
383 dnl             fi
384 dnl         fi
385 dnl         AC_MSG_RESULT([$JNI_CFLAGS])
386
387 dnl         dnl Need extra version flag?
388 dnl         AC_MSG_CHECKING([extra javac flags])
389 dnl         JAVAC_FLAGS=
390 dnl         javac_version=`$JAVAC -version 2>&1`
391 dnl         case "$javac_version" in
392 dnl         *Eclipse*)
393 dnl             JAVAC_FLAGS="-source 1.5" ;;
394 dnl         esac
395 dnl         AC_MSG_RESULT([$JAVAC_FLAGS])
396
397 dnl         dnl Where to install jarfiles.
398 dnl         dnl XXX How to make it configurable?
399 dnl         JAR_INSTALL_DIR=\${prefix}/share/java
400 dnl         JNI_INSTALL_DIR=\${libdir}
401
402 dnl         dnl JNI version.
403 dnl         jni_major_version=`echo "$VERSION" | awk -F. '{print $1}'`
404 dnl         jni_minor_version=`echo "$VERSION" | awk -F. '{print $2}'`
405 dnl         jni_micro_version=`echo "$VERSION" | awk -F. '{print $3}'`
406 dnl         JNI_VERSION_INFO=`expr "$jni_major_version" + "$jni_minor_version"`":$jni_micro_version:$jni_minor_version"
407 dnl     fi
408 dnl fi
409
410 dnl AC_SUBST(JAVA_HOME)
411 dnl AC_SUBST(JAVA)
412 dnl AC_SUBST(JAVAC)
413 dnl AC_SUBST(JAVAH)
414 dnl AC_SUBST(JAVADOC)
415 dnl AC_SUBST(JAR)
416 dnl AC_SUBST(JNI_CFLAGS)
417 dnl AC_SUBST(JAVAC_FLAGS)
418 dnl AC_SUBST(JAR_INSTALL_DIR)
419 dnl AC_SUBST(JNI_INSTALL_DIR)
420 dnl AC_SUBST(JNI_VERSION_INFO)
421
422 dnl AM_CONDITIONAL([HAVE_JAVA],[test -n "$JAVAC"])
423
424 dnl dnl Check for Haskell (GHC).
425 dnl AC_CHECK_PROG([GHC],[ghc],[ghc],[no])
426
427 dnl AM_CONDITIONAL([HAVE_HASKELL],
428 dnl     [test "x$GHC" != "xno"])
429
430 dnl Produce output files.
431 AC_CONFIG_HEADERS([config.h])
432 AC_CONFIG_FILES([Makefile
433                  gnulib/lib/Makefile
434                  gnulib/tests/Makefile
435                  hivex.pc
436                  images/Makefile
437                  lib/Makefile
438                  lib/tools/Makefile
439                  ocaml/Makefile ocaml/META
440                  perl/Makefile perl/Makefile.PL
441                  po/Makefile.in
442                  regedit/Makefile
443                  sh/Makefile
444                  xml/Makefile])
445 AC_OUTPUT
446
447 dnl Produce summary.
448 echo
449 echo
450 echo "------------------------------------------------------------"
451 echo "Thank you for downloading $PACKAGE_STRING"
452 echo
453 echo "This is how we have configured the optional components for you today:"
454 echo
455 echo -n "OCaml bindings ...................... "
456 if test "x$HAVE_OCAML_TRUE" = "x"; then echo "yes"; else echo "no"; fi
457 echo -n "Perl bindings ....................... "
458 if test "x$HAVE_PERL_TRUE" = "x"; then echo "yes"; else echo "no"; fi
459 dnl echo -n "Python bindings ..................... "
460 dnl if test "x$HAVE_PYTHON_TRUE" = "x"; then echo "yes"; else echo "no"; fi
461 dnl echo -n "Ruby bindings ....................... "
462 dnl if test "x$HAVE_RUBY_TRUE" = "x"; then echo "yes"; else echo "no"; fi
463 dnl echo -n "Java bindings ....................... "
464 dnl if test "x$HAVE_JAVA_TRUE" = "x"; then echo "yes"; else echo "no"; fi
465 dnl echo -n "Haskell bindings .................... "
466 dnl if test "x$HAVE_HASKELL" = "x"; then echo "yes"; else echo "no"; fi
467 echo
468 echo "If any optional component is configured 'no' when you expected 'yes'"
469 echo "then you should check the preceeding messages."
470 echo
471 echo "Please report bugs back to the mailing list:"
472 echo "http://www.redhat.com/mailman/listinfo/libguestfs"
473 echo
474 echo "Next you should type 'make' to build the package,"
475 echo "then 'make check' to run the tests."
476 echo "------------------------------------------------------------"