+# Set several defaults (optionally specified by the user in
+# environemnt variables)
+CC=${CC:-gcc}
+CXX=${CXX:-g++}
+CFLAGS=${CFLAGS:--O2}
+CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
+XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config-1.1 xapian-config}
+
+# We don't allow the EMACS or GZIP Makefile variables inherit values
+# from the environment as we do with CC and CXX above. The reason is
+# that these names as environment variables have existing uses other
+# than the program name that we want. (EMACS is set to 't' when a
+# shell is running within emacs and GZIP specifies arguments to pass
+# on the gzip command line).
+
+# Set the defaults for values the user can specify with command-line
+# options.
+PREFIX=/usr/local
+LIBDIR=
+
+usage ()
+{
+ cat <<EOF
+Usage: ./configure [options]...
+
+This script configures notmuch to build on your system.
+
+It verifies that dependencies are available, determines flags needed
+to compile and link against various required libraries, and identifies
+whether various system functions can be used or if locally-provided
+replacements will be built instead.
+
+Finally, it allows you to control various aspects of the build and
+installation process.
+
+First, some common variables can specified via environment variables:
+
+ CC The C compiler to use
+ CFLAGS Flags to pass to the C compiler
+ CXX The C++ compiler to use
+ CXXFLAGS Flags to pass to the C compiler
+ LDFLAGS Flags to pass when linking
+
+Each of these values can further be controlled by specifying them
+later on the "make" command line.
+
+Other environment variables can be used to control configure itself,
+(and for which there is no equivalent build-time control):
+
+ XAPIAN_CONFIG The program to use to determine flags for
+ compiling and linking against the Xapian
+ library. [$XAPIAN_CONFIG]
+
+Additionally, various options can be specified on the configure
+command line.
+
+ --prefix=PREFIX Install files in PREFIX [$PREFIX]
+
+By default, "make install" will install the resulting program to
+$PREFIX/bin, documentation to $PREFIX/man, etc. You can
+specify an installation prefix other than $PREFIX using
+--prefix, for instance:
+
+ ./configure --prefix=\$HOME
+
+Fine tuning of some installation directories is available:
+
+ --libdir=DIR Install libraries to DIR [PREFIX/lib]
+ --includedir=DIR Install header files to DIR [PREFIX/include]
+ --mandir=DIR Install man pages to DIR [PREFIX/share/man]
+ --sysconfdir=DIR Read-only single-machine data [PREFIX/etc]
+ --emacslispdir=DIR Emacs code [PREFIX/share/emacs/site-lisp]
+
+Additional options are accepted for compatibility with other
+configure-script calling conventions, but don't do anything yet:
+
+ --build=<cpu>-<vendor>-<os> Currently ignored
+ --host=<cpu>-<vendor>-<os> Currently ignored
+ --infodir=DIR Currently ignored
+ --datadir=DIR Currently ignored
+ --localstatedir=DIR Currently ignored
+ --libexecdir=DIR Currently ignored
+ --disable-maintainer-mode Currently ignored
+ --disable-dependency-tracking Currently ignored
+
+EOF
+}
+
+# Parse command-line options
+for option; do
+ if [ "${option}" = '--help' ] ; then
+ usage
+ exit 0
+ elif [ "${option%%=*}" = '--prefix' ] ; then
+ PREFIX="${option#*=}"
+ elif [ "${option%%=*}" = '--libdir' ] ; then
+ LIBDIR="${option#*=}"
+ elif [ "${option%%=*}" = '--includedir' ] ; then
+ INCLUDEDIR="${option#*=}"
+ elif [ "${option%%=*}" = '--mandir' ] ; then
+ MANDIR="${option#*=}"
+ elif [ "${option%%=*}" = '--sysconfdir' ] ; then
+ SYSCONFDIR="${option#*=}"
+ elif [ "${option%%=*}" = '--emacslispdir' ] ; then
+ EMACSLISPDIR="${option#*=}"
+ elif [ "${option%%=*}" = '--build' ] ; then
+ build_option="${option#*=}"
+ case ${build_option} in
+ *-*-*) ;;
+ *)
+ echo "Unrecognized value for --build option: ${build_option}"
+ echo "Should be: <cpu>-<vendor>-<os>"
+ echo "See:"
+ echo " $0 --help"
+ echo ""
+ exit 1
+ esac
+ build_cpu=${build_option%%-*}
+ build_option=${build_option#*-}
+ build_vendor=${build_option%%-*}
+ build_os=${build_option#*-}
+ elif [ "${option%%=*}" = '--host' ] ; then
+ host_option="${option#*=}"
+ case ${host_option} in
+ *-*-*) ;;
+ *)
+ echo "Unrecognized value for --host option: ${host_option}"
+ echo "Should be: <cpu>-<vendor>-<os>"
+ echo "See:"
+ echo " $0 --help"
+ echo ""
+ exit 1
+ esac
+ host_cpu=${host_option%%-*}
+ host_option=${host_option#*-}
+ host_vendor=${host_option%%-*}
+ host_os=${host_option#*-}
+ elif [ "${option%%=*}" = '--infodir' ] ; then
+ true
+ elif [ "${option%%=*}" = '--datadir' ] ; then
+ true
+ elif [ "${option%%=*}" = '--localstatedir' ] ; then
+ true
+ elif [ "${option%%=*}" = '--libexecdir' ] ; then
+ true
+ elif [ "${option}" = '--disable-maintainer-mode' ] ; then
+ true
+ elif [ "${option}" = '--disable-dependency-tracking' ] ; then
+ true
+ else
+ echo "Unrecognized option: ${option}"
+ echo "See:"
+ echo " $0 --help"
+ echo ""
+ exit 1
+ fi
+done
+