5 # For a non-srcdir configure invocation (such as ../configure), create
6 # the directory structure and copy Makefiles.
7 if [ "$srcdir" != "." ]; then
9 for dir in . $(grep "^subdirs *=" "$srcdir"/Makefile | sed -e "s/subdirs *= *//"); do
11 cp "$srcdir"/"$dir"/Makefile.local "$dir"
12 cp "$srcdir"/"$dir"/Makefile "$dir"
15 # Easiest way to get the test suite to work is to just copy the
16 # whole thing into the build directory.
17 cp -a "$srcdir"/test/* test
19 # Emacs only likes to generate compiled files next to the .el files
20 # by default so copy these as well (which is not ideal0.
21 cp -a "$srcdir"/emacs/*.el emacs
24 # Set several defaults (optionally specified by the user in
25 # environment variables)
29 CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
31 XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config}
33 # We don't allow the EMACS or GZIP Makefile variables inherit values
34 # from the environment as we do with CC and CXX above. The reason is
35 # that these names as environment variables have existing uses other
36 # than the program name that we want. (EMACS is set to 't' when a
37 # shell is running within emacs and GZIP specifies arguments to pass
38 # on the gzip command line).
40 # Set the defaults for values the user can specify with command-line
51 Usage: ./configure [options]...
53 This script configures notmuch to build on your system.
55 It verifies that dependencies are available, determines flags needed
56 to compile and link against various required libraries, and identifies
57 whether various system functions can be used or if locally-provided
58 replacements will be built instead.
60 Finally, it allows you to control various aspects of the build and
63 First, some common variables can specified via environment variables:
65 CC The C compiler to use
66 CFLAGS Flags to pass to the C compiler
67 CXX The C++ compiler to use
68 CXXFLAGS Flags to pass to the C compiler
69 LDFLAGS Flags to pass when linking
71 Each of these values can further be controlled by specifying them
72 later on the "make" command line.
74 Other environment variables can be used to control configure itself,
75 (and for which there is no equivalent build-time control):
77 XAPIAN_CONFIG The program to use to determine flags for
78 compiling and linking against the Xapian
79 library. [$XAPIAN_CONFIG]
81 Additionally, various options can be specified on the configure
84 --prefix=PREFIX Install files in PREFIX [$PREFIX]
86 By default, "make install" will install the resulting program to
87 $PREFIX/bin, documentation to $PREFIX/man, etc. You can
88 specify an installation prefix other than $PREFIX using
89 --prefix, for instance:
91 ./configure --prefix=\$HOME
93 Fine tuning of some installation directories is available:
95 --libdir=DIR Install libraries to DIR [PREFIX/lib]
96 --includedir=DIR Install header files to DIR [PREFIX/include]
97 --mandir=DIR Install man pages to DIR [PREFIX/share/man]
98 --sysconfdir=DIR Read-only single-machine data [PREFIX/etc]
99 --emacslispdir=DIR Emacs code [PREFIX/share/emacs/site-lisp]
100 --emacsetcdir=DIR Emacs miscellaneous files [PREFIX/share/emacs/site-lisp]
101 --bashcompletiondir=DIR Bash completions files [SYSCONFDIR/bash_completion.d]
102 --zshcompletiondir=DIR Zsh completions files [PREFIX/share/zsh/functions/Completion/Unix]
104 Some features can be disabled (--with-feature=no is equivalent to
107 --without-emacs Do not install lisp file
108 --without-bash-completion Do not install bash completions files
109 --without-zsh-completion Do not install zsh completions files
111 Additional options are accepted for compatibility with other
112 configure-script calling conventions, but don't do anything yet:
114 --build=<cpu>-<vendor>-<os> Currently ignored
115 --host=<cpu>-<vendor>-<os> Currently ignored
116 --infodir=DIR Currently ignored
117 --datadir=DIR Currently ignored
118 --localstatedir=DIR Currently ignored
119 --libexecdir=DIR Currently ignored
120 --disable-maintainer-mode Currently ignored
121 --disable-dependency-tracking Currently ignored
126 # Parse command-line options
128 if [ "${option}" = '--help' ] ; then
131 elif [ "${option%%=*}" = '--prefix' ] ; then
132 PREFIX="${option#*=}"
133 elif [ "${option%%=*}" = '--libdir' ] ; then
134 LIBDIR="${option#*=}"
135 elif [ "${option%%=*}" = '--includedir' ] ; then
136 INCLUDEDIR="${option#*=}"
137 elif [ "${option%%=*}" = '--mandir' ] ; then
138 MANDIR="${option#*=}"
139 elif [ "${option%%=*}" = '--sysconfdir' ] ; then
140 SYSCONFDIR="${option#*=}"
141 elif [ "${option%%=*}" = '--emacslispdir' ] ; then
142 EMACSLISPDIR="${option#*=}"
143 elif [ "${option%%=*}" = '--emacsetcdir' ] ; then
144 EMACSETCDIR="${option#*=}"
145 elif [ "${option%%=*}" = '--bashcompletiondir' ] ; then
146 BASHCOMPLETIONDIR="${option#*=}"
147 elif [ "${option%%=*}" = '--zshcompletiondir' ] ; then
148 ZSHCOMLETIONDIR="${option#*=}"
149 elif [ "${option%%=*}" = '--with-emacs' ]; then
150 if [ "${option#*=}" = 'no' ]; then
155 elif [ "${option}" = '--without-emacs' ] ; then
157 elif [ "${option%%=*}" = '--with-bash-completion' ]; then
158 if [ "${option#*=}" = 'no' ]; then
163 elif [ "${option}" = '--without-bash-completion' ] ; then
165 elif [ "${option%%=*}" = '--with-zsh-completion' ]; then
166 if [ "${option#*=}" = 'no' ]; then
171 elif [ "${option}" = '--without-zsh-completion' ] ; then
173 elif [ "${option%%=*}" = '--build' ] ; then
174 build_option="${option#*=}"
175 case ${build_option} in
178 echo "Unrecognized value for --build option: ${build_option}"
179 echo "Should be: <cpu>-<vendor>-<os>"
185 build_cpu=${build_option%%-*}
186 build_option=${build_option#*-}
187 build_vendor=${build_option%%-*}
188 build_os=${build_option#*-}
189 elif [ "${option%%=*}" = '--host' ] ; then
190 host_option="${option#*=}"
191 case ${host_option} in
194 echo "Unrecognized value for --host option: ${host_option}"
195 echo "Should be: <cpu>-<vendor>-<os>"
201 host_cpu=${host_option%%-*}
202 host_option=${host_option#*-}
203 host_vendor=${host_option%%-*}
204 host_os=${host_option#*-}
205 elif [ "${option%%=*}" = '--infodir' ] ; then
207 elif [ "${option%%=*}" = '--datadir' ] ; then
209 elif [ "${option%%=*}" = '--localstatedir' ] ; then
211 elif [ "${option%%=*}" = '--libexecdir' ] ; then
213 elif [ "${option}" = '--disable-maintainer-mode' ] ; then
215 elif [ "${option}" = '--disable-dependency-tracking' ] ; then
218 echo "Unrecognized option: ${option}"
226 # We set this value early, (rather than just while printing the
227 # Makefile.config file later like most values), because we need to
228 # actually investigate this value compared to the ldconfig_paths value
230 libdir_expanded=${LIBDIR:-${PREFIX}/lib}
233 Welcome to Notmuch, a system for indexing, searching and tagging your email.
235 We hope that the process of building and installing notmuch is quick
236 and smooth so that you can soon be reading and processing your email
237 more efficiently than ever.
239 If anything goes wrong in the configure process, you can override any
240 decisions it makes by manually editing the Makefile.config file that
241 it creates. Also please do as much as you can to figure out what could
242 be different on your machine compared to those of the notmuch
243 developers. Then, please email those details to the Notmuch list
244 (notmuch@notmuchmail.org) so that we can hopefully make future
245 versions of notmuch easier for you to use.
247 We'll now investigate your system to verify that all required
248 dependencies are available:
254 if pkg-config --version > /dev/null 2>&1; then
260 printf "Checking for Xapian development files... "
262 for xapian_config in ${XAPIAN_CONFIG}; do
263 if ${xapian_config} --version > /dev/null 2>&1; then
264 printf "Yes (%s).\n" $(${xapian_config} --version | sed -e 's/.* //')
266 xapian_cxxflags=$(${xapian_config} --cxxflags)
267 xapian_ldflags=$(${xapian_config} --libs)
271 if [ ${have_xapian} = "0" ]; then
273 errors=$((errors + 1))
276 # If using GMime 2.6, we need to have a version >= 2.6.5 to avoid a
277 # crypto bug. We need 2.6.7 for permissive "From " header handling.
278 printf "Checking for GMime development files... "
280 for gmimepc in 'gmime-2.6 >= 2.6.7' gmime-2.4; do
281 if pkg-config --exists $gmimepc; then
282 printf "Yes ($gmimepc).\n"
284 gmime_cflags=$(pkg-config --cflags $gmimepc)
285 gmime_ldflags=$(pkg-config --libs $gmimepc)
289 if [ "$have_gmime" = "0" ]; then
291 errors=$((errors + 1))
294 # GMime already depends on Glib >= 2.12, but we use at least one Glib
295 # function that only exists as of 2.22, (g_array_unref)
296 printf "Checking for Glib development files (>= 2.22)... "
298 if pkg-config --exists 'glib-2.0 >= 2.22'; then
301 glib_cflags=$(pkg-config --cflags glib-2.0)
302 glib_ldflags=$(pkg-config --libs glib-2.0)
305 errors=$((errors + 1))
308 printf "Checking for talloc development files... "
309 if pkg-config --exists talloc; then
312 talloc_cflags=$(pkg-config --cflags talloc)
313 talloc_ldflags=$(pkg-config --libs talloc)
318 errors=$((errors + 1))
321 printf "Checking for valgrind development files... "
322 if pkg-config --exists valgrind; then
325 valgrind_cflags=$(pkg-config --cflags valgrind)
327 printf "No (but that's fine).\n"
331 if [ -z "${EMACSLISPDIR}" ]; then
332 if pkg-config --exists emacs; then
333 EMACSLISPDIR=$(pkg-config emacs --variable sitepkglispdir)
335 EMACSLISPDIR='$(prefix)/share/emacs/site-lisp'
339 if [ -z "${EMACSETCDIR}" ]; then
340 if pkg-config --exists emacs; then
341 EMACSETCDIR=$(pkg-config emacs --variable sitepkglispdir)
343 EMACSETCDIR='$(prefix)/share/emacs/site-lisp'
347 printf "Checking if emacs is available... "
348 if emacs --quick --batch > /dev/null 2>&1; then
352 printf "No (so will not byte-compile emacs code)\n"
358 printf "Checking which platform we are on... "
360 if [ $uname = "Darwin" ] ; then
363 linker_resolves_library_dependencies=0
364 elif [ $uname = "SunOS" ] ; then
367 linker_resolves_library_dependencies=0
368 elif [ $uname = "Linux" ] ; then
371 linker_resolves_library_dependencies=1
373 printf "Checking for $libdir_expanded in ldconfig... "
374 ldconfig_paths=$(/sbin/ldconfig -N -X -v 2>/dev/null | sed -n -e 's,^\(/.*\):\( (.*)\)\?$,\1,p')
375 # Separate ldconfig_paths only on newline (not on any potential
376 # embedded space characters in any filenames). Note, we use a
377 # literal newline in the source here rather than something like:
381 # because the shell's command substitution deletes any trailing newlines.
385 for path in $ldconfig_paths; do
386 if [ "$path" = "$libdir_expanded" ]; then
391 if [ "$libdir_in_ldconfig" = '0' ]; then
392 printf "No (will set RPATH)\n"
400 *** Warning: Unknown platform. Notmuch might or might not build correctly.
405 if [ $errors -gt 0 ]; then
408 *** Error: The dependencies of notmuch could not be satisfied. You will
409 need to install the following packages before being able to compile
413 if [ $have_xapian -eq 0 ]; then
414 echo " Xapian library (including development files such as headers)"
415 echo " http://xapian.org/"
417 if [ $have_gmime -eq 0 ]; then
418 echo " GMime 2.4 library (including development files such as headers)"
419 echo " http://spruce.sourceforge.net/gmime/"
421 if [ $have_glib -eq 0 ]; then
422 echo " Glib library >= 2.22 (including development files such as headers)"
423 echo " http://ftp.gnome.org/pub/gnome/sources/glib/"
425 if [ $have_talloc -eq 0 ]; then
426 echo " The talloc library (including development files such as headers)"
427 echo " http://talloc.samba.org/"
431 With any luck, you're using a modern, package-based operating system
432 that has all of these packages available in the distribution. In that
433 case a simple command will install everything you need. For example:
435 On Debian and similar systems:
437 sudo apt-get install libxapian-dev libgmime-2.4-dev libtalloc-dev
439 Or on Fedora and similar systems:
441 sudo yum install xapian-core-devel gmime-devel libtalloc-devel
443 On other systems, similar commands can be used, but the details of the
444 package names may be different.
447 if [ $have_pkg_config -eq 0 ]; then
449 Note: the pkg-config program is not available. This configure script
450 uses pkg-config to find the compilation flags required to link against
451 the various libraries needed by notmuch. It's possible you simply need
452 to install pkg-config with a command such as:
454 sudo apt-get install pkg-config
456 sudo yum install pkgconfig
458 But if pkg-config is not available for your system, then you will need
459 to modify the configure script to manually set the cflags and ldflags
460 variables to the correct values to link against each library in each
461 case that pkg-config could not be used to determine those values.
466 When you have installed the necessary dependencies, you can run
467 configure again to ensure the packages can be found, or simply run
468 "make" to compile notmuch.
474 printf "Checking for getline... "
475 if ${CC} -o compat/have_getline "$srcdir"/compat/have_getline.c > /dev/null 2>&1
480 printf "No (will use our own instead).\n"
483 rm -f compat/have_getline
485 printf "Checking for strcasestr... "
486 if ${CC} -o compat/have_strcasestr "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1
491 printf "No (will use our own instead).\n"
494 rm -f compat/have_strcasestr
496 printf "int main(void){return 0;}\n" > minimal.c
498 printf "Checking for rpath support... "
499 if ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1
502 rpath_ldflags="-Wl,--enable-new-dtags -Wl,-rpath,\$(libdir)"
504 printf "No (nothing to worry about).\n"
508 printf "Checking for -Wl,--as-needed... "
509 if ${CC} -Wl,--as-needed -o minimal minimal.c >/dev/null 2>&1
512 as_needed_ldflags="-Wl,--as-needed"
514 printf "No (nothing to worry about).\n"
519 printf "Checking for available C++ compiler warning flags... "
520 for flag in -Wall -Wextra -Wwrite-strings -Wswitch-enum; do
521 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
523 WARN_CXXFLAGS="${WARN_CXXFLAGS}${WARN_CXXFLAGS:+ }${flag}"
526 printf "\n\t${WARN_CXXFLAGS}\n"
528 WARN_CFLAGS="${WARN_CXXFLAGS}"
529 printf "Checking for available C compiler warning flags... "
530 for flag in -Wmissing-declarations; do
531 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
533 WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
536 printf "\n\t${WARN_CFLAGS}\n"
538 rm -f minimal minimal.c
542 All required packages were found. You may now run the following
543 commands to compile and install notmuch:
550 # construct the Makefile.config
551 cat > Makefile.config <<EOF
552 # This Makefile.config was automatically generated by the ./configure
553 # script of notmuch. If the configure script identified anything
554 # incorrectly, then you can edit this file to try to correct things,
555 # but be warned that if configure is run again it will destroy your
556 # changes, (and this could happen by simply calling "make" if the
557 # configure script is updated).
559 # The top-level directory for the source, (the directory containing
560 # the configure script). This may be different than the build
561 # directory (the current directory at the time configure was run).
564 configure_options = $@
566 # We use vpath directives (rather than the VPATH variable) since the
567 # VPATH variable matches targets as well as prerequisites, (which is
568 # not useful since then a target left-over from a srcdir build would
569 # cause a target to not be built in the non-srcdir build).
571 # Also, we don't use a single "vpath % \$(srcdir)" here because we
572 # don't want the vpath to trigger for our emacs lisp compilation,
573 # (unless we first find a way to convince emacs to build the .elc
574 # target in a directory other than the directory of the .el
575 # prerequisite). In the meantime, we're actually copying in the .el
576 # files, (which is quite ugly).
578 vpath %.cc \$(srcdir)
580 vpath Makefile.% \$(srcdir)
582 # The C compiler to use
585 # The C++ compiler to use
588 # Command to execute emacs from Makefiles
589 EMACS = emacs --quick
591 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
594 # Default FLAGS for C++ compiler (can be overridden by user such as "make CXXFLAGS=-g")
595 CXXFLAGS = ${CXXFLAGS}
597 # Default FLAGS for the linker (can be overridden by user such as "make LDFLAGS=-znow")
600 # Flags to enable warnings when using the C++ compiler
601 WARN_CXXFLAGS=${WARN_CXXFLAGS}
603 # Flags to enable warnings when using the C compiler
604 WARN_CFLAGS=${WARN_CFLAGS}
606 # The prefix to which notmuch should be installed
607 # Note: If you change this value here, be sure to ensure that the
608 # LIBDIR_IN_LDCONFIG value below is still set correctly.
611 # The directory to which libraries should be installed
612 # Note: If you change this value here, be sure to ensure that the
613 # LIBDIR_IN_LDCONFIG value below is still set correctly.
614 libdir = ${LIBDIR:=\$(prefix)/lib}
616 # Whether libdir is in a path configured into ldconfig
617 LIBDIR_IN_LDCONFIG = ${libdir_in_ldconfig}
619 # The directory to which header files should be installed
620 includedir = ${INCLUDEDIR:=\$(prefix)/include}
622 # The directory to which man pages should be installed
623 mandir = ${MANDIR:=\$(prefix)/share/man}
625 # The directory to which read-only (configuration) files should be installed
626 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
628 # The directory to which emacs lisp files should be installed
629 emacslispdir=${EMACSLISPDIR}
631 # The directory to which emacs miscellaneous (machine-independent) files should
633 emacsetcdir=${EMACSETCDIR}
635 # Whether there's an emacs binary available for byte-compiling
636 HAVE_EMACS = ${have_emacs}
638 # The directory to which desktop files should be installed
639 desktop_dir = \$(prefix)/share/applications
641 # The directory to which bash completions files should be installed
642 bash_completion_dir = ${BASHCOMPLETIONDIR:=\$(sysconfdir)/bash_completion.d}
644 # The directory to which zsh completions files should be installed
645 zsh_completion_dir = ${ZSHCOMLETIONDIR:=\$(prefix)/share/zsh/functions/Completion/Unix}
647 # Whether the getline function is available (if not, then notmuch will
648 # build its own version)
649 HAVE_GETLINE = ${have_getline}
651 # Whether the strcasestr function is available (if not, then notmuch will
652 # build its own version)
653 HAVE_STRCASESTR = ${have_strcasestr}
655 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS
656 PLATFORM = ${platform}
658 # Whether the linker will automatically resolve the dependency of one
659 # library on another (if not, then linking a binary requires linking
660 # directly against both)
661 LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
663 # Flags needed to compile and link against Xapian
664 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
665 XAPIAN_LDFLAGS = ${xapian_ldflags}
667 # Flags needed to compile and link against GMime-2.4
668 GMIME_CFLAGS = ${gmime_cflags}
669 GMIME_LDFLAGS = ${gmime_ldflags}
671 # Flags needed to compile and link against talloc
672 TALLOC_CFLAGS = ${talloc_cflags}
673 TALLOC_LDFLAGS = ${talloc_ldflags}
675 # Flags needed to have linker set rpath attribute
676 RPATH_LDFLAGS = ${rpath_ldflags}
678 # Flags needed to have linker link only to necessary libraries
679 AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
681 # Whether valgrind header files are available
682 HAVE_VALGRIND = ${have_valgrind}
684 # And if so, flags needed at compile time for valgrind macros
685 VALGRIND_CFLAGS = ${valgrind_cflags}
688 WITH_EMACS = ${WITH_EMACS}
690 # Support for bash completion
691 WITH_BASH = ${WITH_BASH}
693 # Support for zsh completion
694 WITH_ZSH = ${WITH_ZSH}
696 # Combined flags for compiling and linking against all of the above
697 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
698 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
699 \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
700 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
701 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
702 \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
703 -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
704 CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)