3 # Store original IFS value so it can be changed (and restored) in many places.
4 readonly DEFAULT_IFS=$IFS
8 # For a non-srcdir configure invocation (such as ../configure), create
9 # the directory structure and copy Makefiles.
10 if [ "$srcdir" != "." ]; then
12 for dir in . $(grep "^subdirs *=" "$srcdir"/Makefile | sed -e "s/subdirs *= *//"); do
14 cp "$srcdir"/"$dir"/Makefile.local "$dir"
15 cp "$srcdir"/"$dir"/Makefile "$dir"
18 # Easiest way to get the test suite to work is to just copy the
19 # whole thing into the build directory.
20 cp -a "$srcdir"/test/* test
22 # Emacs only likes to generate compiled files next to the .el files
23 # by default so copy these as well (which is not ideal0.
24 cp -a "$srcdir"/emacs/*.el emacs
27 # Set several defaults (optionally specified by the user in
28 # environment variables)
32 CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
34 XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config}
36 # We don't allow the EMACS or GZIP Makefile variables inherit values
37 # from the environment as we do with CC and CXX above. The reason is
38 # that these names as environment variables have existing uses other
39 # than the program name that we want. (EMACS is set to 't' when a
40 # shell is running within emacs and GZIP specifies arguments to pass
41 # on the gzip command line).
43 # Set the defaults for values the user can specify with command-line
51 # Compatible GMime versions (with constraints).
52 # If using GMime 2.6, we need to have a version >= 2.6.5 to avoid a
53 # crypto bug. We need 2.6.7 for permissive "From " header handling.
54 GMIME_24_VERSION_CTR=''
55 GMIME_24_VERSION="gmime-2.4 $GMIME_24_VERSION_CTR"
56 GMIME_26_VERSION_CTR='>= 2.6.7'
57 GMIME_26_VERSION="gmime-2.6 $GMIME_26_VERSION_CTR"
59 WITH_GMIME_VERSIONS="$GMIME_26_VERSION;$GMIME_24_VERSION"
64 Usage: ./configure [options]...
66 This script configures notmuch to build on your system.
68 It verifies that dependencies are available, determines flags needed
69 to compile and link against various required libraries, and identifies
70 whether various system functions can be used or if locally-provided
71 replacements will be built instead.
73 Finally, it allows you to control various aspects of the build and
76 First, some common variables can specified via environment variables:
78 CC The C compiler to use
79 CFLAGS Flags to pass to the C compiler
80 CXX The C++ compiler to use
81 CXXFLAGS Flags to pass to the C compiler
82 LDFLAGS Flags to pass when linking
84 Each of these values can further be controlled by specifying them
85 later on the "make" command line.
87 Other environment variables can be used to control configure itself,
88 (and for which there is no equivalent build-time control):
90 XAPIAN_CONFIG The program to use to determine flags for
91 compiling and linking against the Xapian
92 library. [$XAPIAN_CONFIG]
94 Additionally, various options can be specified on the configure
97 --prefix=PREFIX Install files in PREFIX [$PREFIX]
99 By default, "make install" will install the resulting program to
100 $PREFIX/bin, documentation to $PREFIX/man, etc. You can
101 specify an installation prefix other than $PREFIX using
102 --prefix, for instance:
104 ./configure --prefix=\$HOME
106 Fine tuning of some installation directories is available:
108 --libdir=DIR Install libraries to DIR [PREFIX/lib]
109 --includedir=DIR Install header files to DIR [PREFIX/include]
110 --mandir=DIR Install man pages to DIR [PREFIX/share/man]
111 --sysconfdir=DIR Read-only single-machine data [PREFIX/etc]
112 --emacslispdir=DIR Emacs code [PREFIX/share/emacs/site-lisp]
113 --emacsetcdir=DIR Emacs miscellaneous files [PREFIX/share/emacs/site-lisp]
114 --bashcompletiondir=DIR Bash completions files [SYSCONFDIR/bash_completion.d]
115 --zshcompletiondir=DIR Zsh completions files [PREFIX/share/zsh/functions/Completion/Unix]
117 Some features can be disabled (--with-feature=no is equivalent to
120 --without-emacs Do not install lisp file
121 --without-bash-completion Do not install bash completions files
122 --without-zsh-completion Do not install zsh completions files
124 Additional options are accepted for compatibility with other
125 configure-script calling conventions, but don't do anything yet:
127 --build=<cpu>-<vendor>-<os> Currently ignored
128 --host=<cpu>-<vendor>-<os> Currently ignored
129 --infodir=DIR Currently ignored
130 --datadir=DIR Currently ignored
131 --localstatedir=DIR Currently ignored
132 --libexecdir=DIR Currently ignored
133 --disable-maintainer-mode Currently ignored
134 --disable-dependency-tracking Currently ignored
139 # Parse command-line options
141 if [ "${option}" = '--help' ] ; then
144 elif [ "${option%%=*}" = '--prefix' ] ; then
145 PREFIX="${option#*=}"
146 elif [ "${option%%=*}" = '--libdir' ] ; then
147 LIBDIR="${option#*=}"
148 elif [ "${option%%=*}" = '--includedir' ] ; then
149 INCLUDEDIR="${option#*=}"
150 elif [ "${option%%=*}" = '--mandir' ] ; then
151 MANDIR="${option#*=}"
152 elif [ "${option%%=*}" = '--sysconfdir' ] ; then
153 SYSCONFDIR="${option#*=}"
154 elif [ "${option%%=*}" = '--emacslispdir' ] ; then
155 EMACSLISPDIR="${option#*=}"
156 elif [ "${option%%=*}" = '--emacsetcdir' ] ; then
157 EMACSETCDIR="${option#*=}"
158 elif [ "${option%%=*}" = '--bashcompletiondir' ] ; then
159 BASHCOMPLETIONDIR="${option#*=}"
160 elif [ "${option%%=*}" = '--zshcompletiondir' ] ; then
161 ZSHCOMLETIONDIR="${option#*=}"
162 elif [ "${option%%=*}" = '--with-emacs' ]; then
163 if [ "${option#*=}" = 'no' ]; then
168 elif [ "${option}" = '--without-emacs' ] ; then
170 elif [ "${option%%=*}" = '--with-bash-completion' ]; then
171 if [ "${option#*=}" = 'no' ]; then
176 elif [ "${option}" = '--without-bash-completion' ] ; then
178 elif [ "${option%%=*}" = '--with-zsh-completion' ]; then
179 if [ "${option#*=}" = 'no' ]; then
184 elif [ "${option}" = '--without-zsh-completion' ] ; then
186 elif [ "${option%%=*}" = '--with-gmime-version' ] ; then
187 if [ "${option#*=}" = '2.4' ]; then
188 WITH_GMIME_VERSIONS=$GMIME_24_VERSION
189 elif [ "${option#*=}" = '2.6' ]; then
190 WITH_GMIME_VERSIONS=$GMIME_26_VERSION
192 elif [ "${option%%=*}" = '--build' ] ; then
194 elif [ "${option%%=*}" = '--host' ] ; then
196 elif [ "${option%%=*}" = '--infodir' ] ; then
198 elif [ "${option%%=*}" = '--datadir' ] ; then
200 elif [ "${option%%=*}" = '--localstatedir' ] ; then
202 elif [ "${option%%=*}" = '--libexecdir' ] ; then
204 elif [ "${option}" = '--disable-maintainer-mode' ] ; then
206 elif [ "${option}" = '--disable-dependency-tracking' ] ; then
209 echo "Unrecognized option: ${option}"
217 # We set this value early, (rather than just while printing the
218 # Makefile.config file later like most values), because we need to
219 # actually investigate this value compared to the ldconfig_paths value
221 libdir_expanded=${LIBDIR:-${PREFIX}/lib}
224 Welcome to Notmuch, a system for indexing, searching and tagging your email.
226 We hope that the process of building and installing notmuch is quick
227 and smooth so that you can soon be reading and processing your email
228 more efficiently than ever.
230 If anything goes wrong in the configure process, you can override any
231 decisions it makes by manually editing the Makefile.config file that
232 it creates. Also please do as much as you can to figure out what could
233 be different on your machine compared to those of the notmuch
234 developers. Then, please email those details to the Notmuch list
235 (notmuch@notmuchmail.org) so that we can hopefully make future
236 versions of notmuch easier for you to use.
238 We'll now investigate your system to verify that all required
239 dependencies are available:
245 if pkg-config --version > /dev/null 2>&1; then
251 printf "Checking for Xapian development files... "
253 for xapian_config in ${XAPIAN_CONFIG}; do
254 if ${xapian_config} --version > /dev/null 2>&1; then
255 printf "Yes (%s).\n" $(${xapian_config} --version | sed -e 's/.* //')
257 xapian_cxxflags=$(${xapian_config} --cxxflags)
258 xapian_ldflags=$(${xapian_config} --libs)
262 if [ ${have_xapian} = "0" ]; then
264 errors=$((errors + 1))
267 printf "Checking for GMime development files... "
270 for gmimepc in $WITH_GMIME_VERSIONS; do
271 if pkg-config --exists $gmimepc; then
272 printf "Yes ($gmimepc).\n"
274 gmime_cflags=$(pkg-config --cflags $gmimepc)
275 gmime_ldflags=$(pkg-config --libs $gmimepc)
280 if [ "$have_gmime" = "0" ]; then
282 errors=$((errors + 1))
285 # GMime already depends on Glib >= 2.12, but we use at least one Glib
286 # function that only exists as of 2.22, (g_array_unref)
287 printf "Checking for Glib development files (>= 2.22)... "
289 if pkg-config --exists 'glib-2.0 >= 2.22'; then
292 glib_cflags=$(pkg-config --cflags glib-2.0)
293 glib_ldflags=$(pkg-config --libs glib-2.0)
296 errors=$((errors + 1))
299 printf "Checking for talloc development files... "
300 if pkg-config --exists talloc; then
303 talloc_cflags=$(pkg-config --cflags talloc)
304 talloc_ldflags=$(pkg-config --libs talloc)
309 errors=$((errors + 1))
312 printf "Checking for valgrind development files... "
313 if pkg-config --exists valgrind; then
316 valgrind_cflags=$(pkg-config --cflags valgrind)
318 printf "No (but that's fine).\n"
322 if [ -z "${EMACSLISPDIR}" ]; then
323 if pkg-config --exists emacs; then
324 EMACSLISPDIR=$(pkg-config emacs --variable sitepkglispdir)
326 EMACSLISPDIR='$(prefix)/share/emacs/site-lisp'
330 if [ -z "${EMACSETCDIR}" ]; then
331 if pkg-config --exists emacs; then
332 EMACSETCDIR=$(pkg-config emacs --variable sitepkglispdir)
334 EMACSETCDIR='$(prefix)/share/emacs/site-lisp'
338 printf "Checking if emacs is available... "
339 if emacs --quick --batch > /dev/null 2>&1; then
343 printf "No (so will not byte-compile emacs code)\n"
349 printf "Checking which platform we are on... "
351 if [ $uname = "Darwin" ] ; then
354 linker_resolves_library_dependencies=0
355 elif [ $uname = "SunOS" ] ; then
358 linker_resolves_library_dependencies=0
359 elif [ $uname = "Linux" ] || [ $uname = "GNU" ] ; then
362 linker_resolves_library_dependencies=1
364 printf "Checking for $libdir_expanded in ldconfig... "
365 ldconfig_paths=$(/sbin/ldconfig -N -X -v 2>/dev/null | sed -n -e 's,^\(/.*\):\( (.*)\)\?$,\1,p')
366 # Separate ldconfig_paths only on newline (not on any potential
367 # embedded space characters in any filenames). Note, we use a
368 # literal newline in the source here rather than something like:
372 # because the shell's command substitution deletes any trailing newlines.
375 for path in $ldconfig_paths; do
376 if [ "$path" = "$libdir_expanded" ]; then
381 if [ "$libdir_in_ldconfig" = '0' ]; then
382 printf "No (will set RPATH)\n"
390 *** Warning: Unknown platform. Notmuch might or might not build correctly.
395 if [ $errors -gt 0 ]; then
398 *** Error: The dependencies of notmuch could not be satisfied. You will
399 need to install the following packages before being able to compile
403 if [ $have_xapian -eq 0 ]; then
404 echo " Xapian library (including development files such as headers)"
405 echo " http://xapian.org/"
407 if [ $have_gmime -eq 0 ]; then
408 echo " Either GMime 2.4 library" $GMIME_24_VERSION_CTR "or GMime 2.6 library" $GMIME_26_VERSION_CTR
409 echo " (including development files such as headers)"
410 echo " http://spruce.sourceforge.net/gmime/"
413 if [ $have_glib -eq 0 ]; then
414 echo " Glib library >= 2.22 (including development files such as headers)"
415 echo " http://ftp.gnome.org/pub/gnome/sources/glib/"
418 if [ $have_talloc -eq 0 ]; then
419 echo " The talloc library (including development files such as headers)"
420 echo " http://talloc.samba.org/"
424 With any luck, you're using a modern, package-based operating system
425 that has all of these packages available in the distribution. In that
426 case a simple command will install everything you need. For example:
428 On Debian and similar systems:
430 sudo apt-get install libxapian-dev libgmime-2.6-dev libtalloc-dev
432 Or on Fedora and similar systems:
434 sudo yum install xapian-core-devel gmime-devel libtalloc-devel
436 On other systems, similar commands can be used, but the details of the
437 package names may be different.
440 if [ $have_pkg_config -eq 0 ]; then
442 Note: the pkg-config program is not available. This configure script
443 uses pkg-config to find the compilation flags required to link against
444 the various libraries needed by notmuch. It's possible you simply need
445 to install pkg-config with a command such as:
447 sudo apt-get install pkg-config
449 sudo yum install pkgconfig
451 But if pkg-config is not available for your system, then you will need
452 to modify the configure script to manually set the cflags and ldflags
453 variables to the correct values to link against each library in each
454 case that pkg-config could not be used to determine those values.
459 When you have installed the necessary dependencies, you can run
460 configure again to ensure the packages can be found, or simply run
461 "make" to compile notmuch.
467 printf "Checking for getline... "
468 if ${CC} -o compat/have_getline "$srcdir"/compat/have_getline.c > /dev/null 2>&1
473 printf "No (will use our own instead).\n"
476 rm -f compat/have_getline
478 printf "Checking for strcasestr... "
479 if ${CC} -o compat/have_strcasestr "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1
484 printf "No (will use our own instead).\n"
487 rm -f compat/have_strcasestr
489 printf "int main(void){return 0;}\n" > minimal.c
491 printf "Checking for rpath support... "
492 if ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1
495 rpath_ldflags="-Wl,--enable-new-dtags -Wl,-rpath,\$(libdir)"
497 printf "No (nothing to worry about).\n"
501 printf "Checking for -Wl,--as-needed... "
502 if ${CC} -Wl,--as-needed -o minimal minimal.c >/dev/null 2>&1
505 as_needed_ldflags="-Wl,--as-needed"
507 printf "No (nothing to worry about).\n"
512 printf "Checking for available C++ compiler warning flags... "
513 for flag in -Wall -Wextra -Wwrite-strings -Wswitch-enum; do
514 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
516 WARN_CXXFLAGS="${WARN_CXXFLAGS}${WARN_CXXFLAGS:+ }${flag}"
519 printf "\n\t${WARN_CXXFLAGS}\n"
521 WARN_CFLAGS="${WARN_CXXFLAGS}"
522 printf "Checking for available C compiler warning flags... "
523 for flag in -Wmissing-declarations; do
524 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
526 WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
529 printf "\n\t${WARN_CFLAGS}\n"
531 rm -f minimal minimal.c
535 All required packages were found. You may now run the following
536 commands to compile and install notmuch:
543 # construct the Makefile.config
544 cat > Makefile.config <<EOF
545 # This Makefile.config was automatically generated by the ./configure
546 # script of notmuch. If the configure script identified anything
547 # incorrectly, then you can edit this file to try to correct things,
548 # but be warned that if configure is run again it will destroy your
549 # changes, (and this could happen by simply calling "make" if the
550 # configure script is updated).
552 # The top-level directory for the source, (the directory containing
553 # the configure script). This may be different than the build
554 # directory (the current directory at the time configure was run).
557 configure_options = $@
559 # We use vpath directives (rather than the VPATH variable) since the
560 # VPATH variable matches targets as well as prerequisites, (which is
561 # not useful since then a target left-over from a srcdir build would
562 # cause a target to not be built in the non-srcdir build).
564 # Also, we don't use a single "vpath % \$(srcdir)" here because we
565 # don't want the vpath to trigger for our emacs lisp compilation,
566 # (unless we first find a way to convince emacs to build the .elc
567 # target in a directory other than the directory of the .el
568 # prerequisite). In the meantime, we're actually copying in the .el
569 # files, (which is quite ugly).
571 vpath %.cc \$(srcdir)
573 vpath Makefile.% \$(srcdir)
575 # The C compiler to use
578 # The C++ compiler to use
581 # Command to execute emacs from Makefiles
582 EMACS = emacs --quick
584 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
587 # Default FLAGS for C++ compiler (can be overridden by user such as "make CXXFLAGS=-g")
588 CXXFLAGS = ${CXXFLAGS}
590 # Default FLAGS for the linker (can be overridden by user such as "make LDFLAGS=-znow")
593 # Flags to enable warnings when using the C++ compiler
594 WARN_CXXFLAGS=${WARN_CXXFLAGS}
596 # Flags to enable warnings when using the C compiler
597 WARN_CFLAGS=${WARN_CFLAGS}
599 # The prefix to which notmuch should be installed
600 # Note: If you change this value here, be sure to ensure that the
601 # LIBDIR_IN_LDCONFIG value below is still set correctly.
604 # The directory to which libraries should be installed
605 # Note: If you change this value here, be sure to ensure that the
606 # LIBDIR_IN_LDCONFIG value below is still set correctly.
607 libdir = ${LIBDIR:=\$(prefix)/lib}
609 # Whether libdir is in a path configured into ldconfig
610 LIBDIR_IN_LDCONFIG = ${libdir_in_ldconfig}
612 # The directory to which header files should be installed
613 includedir = ${INCLUDEDIR:=\$(prefix)/include}
615 # The directory to which man pages should be installed
616 mandir = ${MANDIR:=\$(prefix)/share/man}
618 # The directory to which read-only (configuration) files should be installed
619 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
621 # The directory to which emacs lisp files should be installed
622 emacslispdir=${EMACSLISPDIR}
624 # The directory to which emacs miscellaneous (machine-independent) files should
626 emacsetcdir=${EMACSETCDIR}
628 # Whether there's an emacs binary available for byte-compiling
629 HAVE_EMACS = ${have_emacs}
631 # The directory to which desktop files should be installed
632 desktop_dir = \$(prefix)/share/applications
634 # The directory to which bash completions files should be installed
635 bash_completion_dir = ${BASHCOMPLETIONDIR:=\$(sysconfdir)/bash_completion.d}
637 # The directory to which zsh completions files should be installed
638 zsh_completion_dir = ${ZSHCOMLETIONDIR:=\$(prefix)/share/zsh/functions/Completion/Unix}
640 # Whether the getline function is available (if not, then notmuch will
641 # build its own version)
642 HAVE_GETLINE = ${have_getline}
644 # Whether the strcasestr function is available (if not, then notmuch will
645 # build its own version)
646 HAVE_STRCASESTR = ${have_strcasestr}
648 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS
649 PLATFORM = ${platform}
651 # Whether the linker will automatically resolve the dependency of one
652 # library on another (if not, then linking a binary requires linking
653 # directly against both)
654 LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
656 # Flags needed to compile and link against Xapian
657 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
658 XAPIAN_LDFLAGS = ${xapian_ldflags}
660 # Flags needed to compile and link against GMime-2.4
661 GMIME_CFLAGS = ${gmime_cflags}
662 GMIME_LDFLAGS = ${gmime_ldflags}
664 # Flags needed to compile and link against talloc
665 TALLOC_CFLAGS = ${talloc_cflags}
666 TALLOC_LDFLAGS = ${talloc_ldflags}
668 # Flags needed to have linker set rpath attribute
669 RPATH_LDFLAGS = ${rpath_ldflags}
671 # Flags needed to have linker link only to necessary libraries
672 AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
674 # Whether valgrind header files are available
675 HAVE_VALGRIND = ${have_valgrind}
677 # And if so, flags needed at compile time for valgrind macros
678 VALGRIND_CFLAGS = ${valgrind_cflags}
681 WITH_EMACS = ${WITH_EMACS}
683 # Support for bash completion
684 WITH_BASH = ${WITH_BASH}
686 # Support for zsh completion
687 WITH_ZSH = ${WITH_ZSH}
689 # Combined flags for compiling and linking against all of the above
690 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
691 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
692 \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
693 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
694 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
695 \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
696 -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
697 CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)