3 # Removing space from IFS makes it much easier to support filenames
4 # with spaces. See http://www.dwheeler.com/essays/filenames-in-shell.html
8 # Since we don't have space in IFS we use tab to separate things in lists
11 # Set several defaults (optionally specified by the user in
12 # environemnt variables)
16 CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
18 XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config}
20 # We don't allow the EMACS or GZIP Makefile variables inherit values
21 # from the environment as we do with CC and CXX above. The reason is
22 # that these names as environment variables have existing uses other
23 # than the program name that we want. (EMACS is set to 't' when a
24 # shell is running within emacs and GZIP specifies arguments to pass
25 # on the gzip command line).
27 # Set the defaults for values the user can specify with command-line
38 Usage: ./configure [options]...
40 This script configures notmuch to build on your system.
42 It verifies that dependencies are available, determines flags needed
43 to compile and link against various required libraries, and identifies
44 whether various system functions can be used or if locally-provided
45 replacements will be built instead.
47 Finally, it allows you to control various aspects of the build and
50 First, some common variables can specified via environment variables:
52 CC The C compiler to use
53 CFLAGS Flags to pass to the C compiler
54 CXX The C++ compiler to use
55 CXXFLAGS Flags to pass to the C compiler
56 LDFLAGS Flags to pass when linking
58 Each of these values can further be controlled by specifying them
59 later on the "make" command line.
61 Other environment variables can be used to control configure itself,
62 (and for which there is no equivalent build-time control):
64 XAPIAN_CONFIG The program to use to determine flags for
65 compiling and linking against the Xapian
66 library. [$XAPIAN_CONFIG]
68 Additionally, various options can be specified on the configure
71 --prefix=PREFIX Install files in PREFIX [$PREFIX]
73 By default, "make install" will install the resulting program to
74 $PREFIX/bin, documentation to $PREFIX/man, etc. You can
75 specify an installation prefix other than $PREFIX using
76 --prefix, for instance:
78 ./configure --prefix=\$HOME
80 Fine tuning of some installation directories is available:
82 --libdir=DIR Install libraries to DIR [PREFIX/lib]
83 --includedir=DIR Install header files to DIR [PREFIX/include]
84 --mandir=DIR Install man pages to DIR [PREFIX/share/man]
85 --sysconfdir=DIR Read-only single-machine data [PREFIX/etc]
86 --emacslispdir=DIR Emacs code [PREFIX/share/emacs/site-lisp]
87 --bashcompletiondir=DIR Bash completions files [SYSCONFDIR/bash_completion.d]
88 --zshcompletiondir=DIR Zsh completions files [PREFIX/share/zsh/functions/Completion/Unix]
90 Some features can be disabled (--with-feature=no is equivalent to
93 --without-emacs Do not install lisp file
94 --without-bash-completion Do not install bash completions files
95 --without-zsh-completion Do not install zsh completions files
97 Additional options are accepted for compatibility with other
98 configure-script calling conventions, but don't do anything yet:
100 --build=<cpu>-<vendor>-<os> Currently ignored
101 --host=<cpu>-<vendor>-<os> Currently ignored
102 --infodir=DIR Currently ignored
103 --datadir=DIR Currently ignored
104 --localstatedir=DIR Currently ignored
105 --libexecdir=DIR Currently ignored
106 --disable-maintainer-mode Currently ignored
107 --disable-dependency-tracking Currently ignored
112 # Parse command-line options
114 if [ "${option}" = '--help' ] ; then
117 elif [ "${option%%=*}" = '--prefix' ] ; then
118 PREFIX="${option#*=}"
119 elif [ "${option%%=*}" = '--libdir' ] ; then
120 LIBDIR="${option#*=}"
121 elif [ "${option%%=*}" = '--includedir' ] ; then
122 INCLUDEDIR="${option#*=}"
123 elif [ "${option%%=*}" = '--mandir' ] ; then
124 MANDIR="${option#*=}"
125 elif [ "${option%%=*}" = '--sysconfdir' ] ; then
126 SYSCONFDIR="${option#*=}"
127 elif [ "${option%%=*}" = '--emacslispdir' ] ; then
128 EMACSLISPDIR="${option#*=}"
129 elif [ "${option%%=*}" = '--bashcompletiondir' ] ; then
130 BASHCOMPLETIONDIR="${option#*=}"
131 elif [ "${option%%=*}" = '--zshcompletiondir' ] ; then
132 ZSHCOMLETIONDIR="${option#*=}"
133 elif [ "${option%%=*}" = '--with-emacs' ]; then
134 if [ "${option#*=}" = 'no' ]; then
139 elif [ "${option}" = '--without-emacs' ] ; then
141 elif [ "${option%%=*}" = '--with-bash-completion' ]; then
142 if [ "${option#*=}" = 'no' ]; then
147 elif [ "${option}" = '--without-bash-completion' ] ; then
149 elif [ "${option%%=*}" = '--with-zsh-completion' ]; then
150 if [ "${option#*=}" = 'no' ]; then
155 elif [ "${option}" = '--without-zsh-completion' ] ; then
157 elif [ "${option%%=*}" = '--build' ] ; then
158 build_option="${option#*=}"
159 case ${build_option} in
162 echo "Unrecognized value for --build option: ${build_option}"
163 echo "Should be: <cpu>-<vendor>-<os>"
169 build_cpu=${build_option%%-*}
170 build_option=${build_option#*-}
171 build_vendor=${build_option%%-*}
172 build_os=${build_option#*-}
173 elif [ "${option%%=*}" = '--host' ] ; then
174 host_option="${option#*=}"
175 case ${host_option} in
178 echo "Unrecognized value for --host option: ${host_option}"
179 echo "Should be: <cpu>-<vendor>-<os>"
185 host_cpu=${host_option%%-*}
186 host_option=${host_option#*-}
187 host_vendor=${host_option%%-*}
188 host_os=${host_option#*-}
189 elif [ "${option%%=*}" = '--infodir' ] ; then
191 elif [ "${option%%=*}" = '--datadir' ] ; then
193 elif [ "${option%%=*}" = '--localstatedir' ] ; then
195 elif [ "${option%%=*}" = '--libexecdir' ] ; then
197 elif [ "${option}" = '--disable-maintainer-mode' ] ; then
199 elif [ "${option}" = '--disable-dependency-tracking' ] ; then
202 echo "Unrecognized option: ${option}"
210 # We set this value early, (rather than just while printing the
211 # Makefile.config file later like most values), because we need to
212 # actually investigate this value compared to the ldconfig_paths value
214 libdir_expanded=${LIBDIR:-${PREFIX}/lib}
217 Welcome to Notmuch, a system for indexing, searching and tagging your email.
219 We hope that the process of building and installing notmuch is quick
220 and smooth so that you can soon be reading and processing your email
221 more efficiently than ever.
223 If anything goes wrong in the configure process, you can override any
224 decisions it makes by manually editing the Makefile.config file that
225 it creates. Also please do as much as you can to figure out what could
226 be different on your machine compared to those of the notmuch
227 developers. Then, please email those details to the Notmuch list
228 (notmuch@notmuchmail.org) so that we can hopefully make future
229 versions of notmuch easier for you to use.
231 We'll now investigate your system to verify that all required
232 dependencies are available:
238 if pkg-config --version > /dev/null 2>&1; then
244 printf "Checking for Xapian development files... "
246 for xapian_config in ${XAPIAN_CONFIG}; do
247 if ${xapian_config} --version > /dev/null 2>&1; then
248 printf "Yes (%s).\n" $(${xapian_config} --version | sed -e 's/.* //')
250 xapian_cxxflags=$(${xapian_config} --cxxflags)
251 xapian_ldflags=$(${xapian_config} --libs)
255 if [ ${have_xapian} = "0" ]; then
257 errors=$((errors + 1))
260 printf "Checking for GMime development files... "
262 for gmimepc in gmime-2.6 gmime-2.4; do
263 if pkg-config --exists $gmimepc; then
264 printf "Yes ($gmimepc).\n"
266 gmime_cflags=$(pkg-config --cflags $gmimepc)
267 gmime_ldflags=$(pkg-config --libs $gmimepc)
270 if [ "$have_gmime" = "0" ]; then
272 errors=$((errors + 1))
275 # GMime already depends on Glib >= 2.12, but we use at least one Glib
276 # function that only exists as of 2.14, (g_hash_table_get_keys)
277 printf "Checking for Glib development files (>= 2.14)... "
279 if pkg-config --exists 'glib-2.0 >= 2.14'; then
282 glib_cflags=$(pkg-config --cflags glib-2.0)
283 glib_ldflags=$(pkg-config --libs glib-2.0)
286 errors=$((errors + 1))
289 printf "Checking for talloc development files... "
290 if pkg-config --exists talloc; then
293 talloc_cflags=$(pkg-config --cflags talloc)
294 talloc_ldflags=$(pkg-config --libs talloc)
299 errors=$((errors + 1))
302 printf "Checking for valgrind development files... "
303 if pkg-config --exists valgrind; then
306 valgrind_cflags=$(pkg-config --cflags valgrind)
308 printf "No (but that's fine).\n"
312 if [ -z "${EMACSLISPDIR}" ]; then
313 if pkg-config --exists emacs; then
314 EMACSLISPDIR=$(pkg-config emacs --variable sitepkglispdir)
316 EMACSLISPDIR='$(prefix)/share/emacs/site-lisp'
320 printf "Checking if emacs is available... "
321 if emacs --quick --batch > /dev/null 2>&1; then
325 printf "No (so will not byte-compile emacs code)\n"
331 printf "Checking which platform we are on... "
333 if [ $uname = "Darwin" ] ; then
336 linker_resolves_library_dependencies=0
337 elif [ $uname = "SunOS" ] ; then
340 linker_resolves_library_dependencies=0
341 elif [ $uname = "Linux" ] ; then
344 linker_resolves_library_dependencies=1
345 ldconfig_paths=$(/sbin/ldconfig -N -X -v 2>/dev/null | sed -n -e 's,^\(/.*\):\( (.*)\)\?$,\1,p')
346 for path in $ldconfig_paths; do
347 if [ "$path" = "$libdir_expanded" ]; then
355 *** Warning: Unknown platform. Notmuch might or might not build correctly.
360 if [ $errors -gt 0 ]; then
363 *** Error: The dependencies of notmuch could not be satisfied. You will
364 need to install the following packages before being able to compile
368 if [ $have_xapian -eq 0 ]; then
369 echo " Xapian library (including development files such as headers)"
370 echo " http://xapian.org/"
372 if [ $have_gmime -eq 0 ]; then
373 echo " GMime 2.4 library (including development files such as headers)"
374 echo " http://spruce.sourceforge.net/gmime/"
376 if [ $have_glib -eq 0 ]; then
377 echo " Glib library >= 2.14 (including development files such as headers)"
378 echo " http://ftp.gnome.org/pub/gnome/sources/glib/"
380 if [ $have_talloc -eq 0 ]; then
381 echo " The talloc library (including development files such as headers)"
382 echo " http://talloc.samba.org/"
386 With any luck, you're using a modern, package-based operating system
387 that has all of these packages available in the distribution. In that
388 case a simple command will install everything you need. For example:
390 On Debian and similar systems:
392 sudo apt-get install libxapian-dev libgmime-2.4-dev libtalloc-dev
394 Or on Fedora and similar systems:
396 sudo yum install xapian-core-devel gmime-devel libtalloc-devel
398 On other systems, similar commands can be used, but the details of the
399 package names may be different.
402 if [ $have_pkg_config -eq 0 ]; then
404 Note: the pkg-config program is not available. This configure script
405 uses pkg-config to find the compilation flags required to link against
406 the various libraries needed by notmuch. It's possible you simply need
407 to install pkg-config with a command such as:
409 sudo apt-get install pkg-config
411 sudo yum install pkgconfig
413 But if pkg-config is not available for your system, then you will need
414 to modify the configure script to manually set the cflags and ldflags
415 variables to the correct values to link against each library in each
416 case that pkg-config could not be used to determine those values.
421 When you have installed the necessary dependencies, you can run
422 configure again to ensure the packages can be found, or simply run
423 "make" to compile notmuch.
429 printf "Checking for getline... "
430 if ${CC} -o compat/have_getline compat/have_getline.c > /dev/null 2>&1
435 printf "No (will use our own instead).\n"
438 rm -f compat/have_getline
440 printf "Checking for strcasestr... "
441 if ${CC} -o compat/have_strcasestr compat/have_strcasestr.c > /dev/null 2>&1
446 printf "No (will use our own instead).\n"
449 rm -f compat/have_strcasestr
451 printf "int main(void){return 0;}\n" > minimal.c
453 printf "Checking for rpath support... "
454 if ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1
457 rpath_ldflags="-Wl,--enable-new-dtags -Wl,-rpath,\$(libdir)"
459 printf "No (nothing to worry about).\n"
463 printf "Checking for -Wl,--as-needed... "
464 if ${CC} -Wl,--as-needed -o minimal minimal.c >/dev/null 2>&1
467 as_needed_ldflags="-Wl,--as-needed"
469 printf "No (nothing to worry about).\n"
474 printf "Checking for available C++ compiler warning flags... "
475 for flag in -Wall -Wextra -Wwrite-strings -Wswitch-enum; do
476 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
478 WARN_CXXFLAGS="${WARN_CXXFLAGS}${WARN_CXXFLAGS:+ }${flag}"
481 printf "\n\t${WARN_CXXFLAGS}\n"
483 WARN_CFLAGS="${WARN_CXXFLAGS}"
484 printf "Checking for available C compiler warning flags... "
485 for flag in -Wmissing-declarations; do
486 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
488 WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
491 printf "\n\t${WARN_CFLAGS}\n"
493 rm -f minimal minimal.c
497 All required packages were found. You may now run the following
498 commands to compile and install notmuch:
505 # construct the Makefile.config
506 cat > Makefile.config <<EOF
507 # This Makefile.config was automatically generated by the ./configure
508 # script of notmuch. If the configure script identified anything
509 # incorrectly, then you can edit this file to try to correct things,
510 # but be warned that if configure is run again it will destroy your
511 # changes, (and this could happen by simply calling "make" if the
512 # configure script is updated).
514 # The C compiler to use
517 # The C++ compiler to use
520 # Command to execute emacs from Makefiles
521 EMACS = emacs --quick
523 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
526 # Default FLAGS for C++ compiler (can be overridden by user such as "make CXXFLAGS=-g")
527 CXXFLAGS = ${CXXFLAGS}
529 # Default FLAGS for the linker (can be overridden by user such as "make LDFLAGS=-znow")
532 # Flags to enable warnings when using the C++ compiler
533 WARN_CXXFLAGS=${WARN_CXXFLAGS}
535 # Flags to enable warnings when using the C compiler
536 WARN_CFLAGS=${WARN_CFLAGS}
538 # The prefix to which notmuch should be installed
539 # Note: If you change this value here, be sure to ensure that the
540 # LIBDIR_IN_LDCONFIG value below is still set correctly.
543 # The directory to which libraries should be installed
544 # Note: If you change this value here, be sure to ensure that the
545 # LIBDIR_IN_LDCONFIG value below is still set correctly.
546 libdir = ${LIBDIR:=\$(prefix)/lib}
548 # Whether libdir is in a path configured into ldconfig
549 LIBDIR_IN_LDCONFIG = ${libdir_in_ldconfig}
551 # The directory to which header files should be installed
552 includedir = ${INCLUDEDIR:=\$(prefix)/include}
554 # The directory to which man pages should be installed
555 mandir = ${MANDIR:=\$(prefix)/share/man}
557 # The directory to which read-only (configuration) filesshould be installed
558 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
560 # The directory to which emacs lisp files should be installed
561 emacslispdir=${EMACSLISPDIR}
563 # Whether there's an emacs binary available for byte-compiling
564 HAVE_EMACS = ${have_emacs}
566 # The directory to which desktop files should be installed
567 desktop_dir = \$(prefix)/share/applications
569 # The directory to which bash completions files should be installed
570 bash_completion_dir = ${BASHCOMPLETIONDIR:=\$(sysconfdir)/bash_completion.d}
572 # The directory to which zsh completions files should be installed
573 zsh_completion_dir = ${ZSHCOMLETIONDIR:=\$(prefix)/share/zsh/functions/Completion/Unix}
575 # Whether the getline function is available (if not, then notmuch will
576 # build its own version)
577 HAVE_GETLINE = ${have_getline}
579 # Whether the strcasestr function is available (if not, then notmuch will
580 # build its own version)
581 HAVE_STRCASESTR = ${have_strcasestr}
583 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS
584 PLATFORM = ${platform}
586 # Whether the linker will automatically resolve the dependency of one
587 # library on another (if not, then linking a binary requires linking
588 # directly against both)
589 LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
591 # Flags needed to compile and link against Xapian
592 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
593 XAPIAN_LDFLAGS = ${xapian_ldflags}
595 # Flags needed to compile and link against GMime-2.4
596 GMIME_CFLAGS = ${gmime_cflags}
597 GMIME_LDFLAGS = ${gmime_ldflags}
599 # Flags needed to compile and link against talloc
600 TALLOC_CFLAGS = ${talloc_cflags}
601 TALLOC_LDFLAGS = ${talloc_ldflags}
603 # Flags needed to have linker set rpath attribute
604 RPATH_LDFLAGS = ${rpath_ldflags}
606 # Flags needed to have linker link only to necessary libraries
607 AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
609 # Whether valgrind header files are available
610 HAVE_VALGRIND = ${have_valgrind}
612 # And if so, flags needed at compile time for valgrind macros
613 VALGRIND_CFLAGS = ${valgrind_cflags}
616 WITH_EMACS = ${WITH_EMACS}
618 # Support for bash completion
619 WITH_BASH = ${WITH_BASH}
621 # Support for zsh completion
622 WITH_ZSH = ${WITH_ZSH}
624 # Combined flags for compiling and linking against all of the above
625 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
626 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
627 \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
628 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
629 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
630 \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
631 -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
632 CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)