3 # Set several defaults (optionally specified by the user in
4 # environemnt variables)
8 CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
10 XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config}
12 # We don't allow the EMACS or GZIP Makefile variables inherit values
13 # from the environment as we do with CC and CXX above. The reason is
14 # that these names as environment variables have existing uses other
15 # than the program name that we want. (EMACS is set to 't' when a
16 # shell is running within emacs and GZIP specifies arguments to pass
17 # on the gzip command line).
19 # Set the defaults for values the user can specify with command-line
30 Usage: ./configure [options]...
32 This script configures notmuch to build on your system.
34 It verifies that dependencies are available, determines flags needed
35 to compile and link against various required libraries, and identifies
36 whether various system functions can be used or if locally-provided
37 replacements will be built instead.
39 Finally, it allows you to control various aspects of the build and
42 First, some common variables can specified via environment variables:
44 CC The C compiler to use
45 CFLAGS Flags to pass to the C compiler
46 CXX The C++ compiler to use
47 CXXFLAGS Flags to pass to the C compiler
48 LDFLAGS Flags to pass when linking
50 Each of these values can further be controlled by specifying them
51 later on the "make" command line.
53 Other environment variables can be used to control configure itself,
54 (and for which there is no equivalent build-time control):
56 XAPIAN_CONFIG The program to use to determine flags for
57 compiling and linking against the Xapian
58 library. [$XAPIAN_CONFIG]
60 Additionally, various options can be specified on the configure
63 --prefix=PREFIX Install files in PREFIX [$PREFIX]
65 By default, "make install" will install the resulting program to
66 $PREFIX/bin, documentation to $PREFIX/man, etc. You can
67 specify an installation prefix other than $PREFIX using
68 --prefix, for instance:
70 ./configure --prefix=\$HOME
72 Fine tuning of some installation directories is available:
74 --libdir=DIR Install libraries to DIR [PREFIX/lib]
75 --includedir=DIR Install header files to DIR [PREFIX/include]
76 --mandir=DIR Install man pages to DIR [PREFIX/share/man]
77 --sysconfdir=DIR Read-only single-machine data [PREFIX/etc]
78 --emacslispdir=DIR Emacs code [PREFIX/share/emacs/site-lisp]
79 --bashcompletiondir=DIR Bash completions files [SYSCONFDIR/bash_completion.d]
80 --zshcompletiondir=DIR Zsh completions files [PREFIX/share/zsh/functions/Completion/Unix]
82 Some features can be disabled (--with-feature=no is equivalent to
85 --without-emacs Do not install lisp file
86 --without-bash-completion Do not install bash completions files
87 --without-zsh-completion Do not install zsh completions files
89 Additional options are accepted for compatibility with other
90 configure-script calling conventions, but don't do anything yet:
92 --build=<cpu>-<vendor>-<os> Currently ignored
93 --host=<cpu>-<vendor>-<os> Currently ignored
94 --infodir=DIR Currently ignored
95 --datadir=DIR Currently ignored
96 --localstatedir=DIR Currently ignored
97 --libexecdir=DIR Currently ignored
98 --disable-maintainer-mode Currently ignored
99 --disable-dependency-tracking Currently ignored
104 # Parse command-line options
106 if [ "${option}" = '--help' ] ; then
109 elif [ "${option%%=*}" = '--prefix' ] ; then
110 PREFIX="${option#*=}"
111 elif [ "${option%%=*}" = '--libdir' ] ; then
112 LIBDIR="${option#*=}"
113 elif [ "${option%%=*}" = '--includedir' ] ; then
114 INCLUDEDIR="${option#*=}"
115 elif [ "${option%%=*}" = '--mandir' ] ; then
116 MANDIR="${option#*=}"
117 elif [ "${option%%=*}" = '--sysconfdir' ] ; then
118 SYSCONFDIR="${option#*=}"
119 elif [ "${option%%=*}" = '--emacslispdir' ] ; then
120 EMACSLISPDIR="${option#*=}"
121 elif [ "${option%%=*}" = '--bashcompletiondir' ] ; then
122 BASHCOMPLETIONDIR="${option#*=}"
123 elif [ "${option%%=*}" = '--zshcompletiondir' ] ; then
124 ZSHCOMLETIONDIR="${option#*=}"
125 elif [ "${option%%=*}" = '--with-emacs' ]; then
126 if [ "${option#*=}" = 'no' ]; then
131 elif [ "${option}" = '--without-emacs' ] ; then
133 elif [ "${option%%=*}" = '--with-bash-completion' ]; then
134 if [ "${option#*=}" = 'no' ]; then
139 elif [ "${option}" = '--without-bash-completion' ] ; then
141 elif [ "${option%%=*}" = '--with-zsh-completion' ]; then
142 if [ "${option#*=}" = 'no' ]; then
147 elif [ "${option}" = '--without-zsh-completion' ] ; then
149 elif [ "${option%%=*}" = '--build' ] ; then
150 build_option="${option#*=}"
151 case ${build_option} in
154 echo "Unrecognized value for --build option: ${build_option}"
155 echo "Should be: <cpu>-<vendor>-<os>"
161 build_cpu=${build_option%%-*}
162 build_option=${build_option#*-}
163 build_vendor=${build_option%%-*}
164 build_os=${build_option#*-}
165 elif [ "${option%%=*}" = '--host' ] ; then
166 host_option="${option#*=}"
167 case ${host_option} in
170 echo "Unrecognized value for --host option: ${host_option}"
171 echo "Should be: <cpu>-<vendor>-<os>"
177 host_cpu=${host_option%%-*}
178 host_option=${host_option#*-}
179 host_vendor=${host_option%%-*}
180 host_os=${host_option#*-}
181 elif [ "${option%%=*}" = '--infodir' ] ; then
183 elif [ "${option%%=*}" = '--datadir' ] ; then
185 elif [ "${option%%=*}" = '--localstatedir' ] ; then
187 elif [ "${option%%=*}" = '--libexecdir' ] ; then
189 elif [ "${option}" = '--disable-maintainer-mode' ] ; then
191 elif [ "${option}" = '--disable-dependency-tracking' ] ; then
194 echo "Unrecognized option: ${option}"
202 # We set this value early, (rather than just while printing the
203 # Makefile.config file later like most values), because we need to
204 # actually investigate this value compared to the ldconfig_paths value
206 libdir_expanded=${LIBDIR:-${PREFIX}/lib}
209 Welcome to Notmuch, a system for indexing, searching and tagging your email.
211 We hope that the process of building and installing notmuch is quick
212 and smooth so that you can soon be reading and processing your email
213 more efficiently than ever.
215 If anything goes wrong in the configure process, you can override any
216 decisions it makes by manually editing the Makefile.config file that
217 it creates. Also please do as much as you can to figure out what could
218 be different on your machine compared to those of the notmuch
219 developers. Then, please email those details to the Notmuch list
220 (notmuch@notmuchmail.org) so that we can hopefully make future
221 versions of notmuch easier for you to use.
223 We'll now investigate your system to verify that all required
224 dependencies are available:
230 if pkg-config --version > /dev/null 2>&1; then
236 printf "Checking for Xapian development files... "
238 for xapian_config in ${XAPIAN_CONFIG}; do
239 if ${xapian_config} --version > /dev/null 2>&1; then
240 printf "Yes (%s).\n" $(${xapian_config} --version | sed -e 's/.* //')
242 xapian_cxxflags=$(${xapian_config} --cxxflags)
243 xapian_ldflags=$(${xapian_config} --libs)
247 if [ ${have_xapian} = "0" ]; then
249 errors=$((errors + 1))
252 printf "Checking for GMime development files... "
254 for gmimepc in gmime-2.6 gmime-2.4; do
255 if pkg-config --exists $gmimepc; then
256 printf "Yes ($gmimepc).\n"
258 gmime_cflags=$(pkg-config --cflags $gmimepc)
259 gmime_ldflags=$(pkg-config --libs $gmimepc)
262 if [ "$have_gmime" = "0" ]; then
264 errors=$((errors + 1))
267 # GMime already depends on Glib >= 2.12, but we use at least one Glib
268 # function that only exists as of 2.14, (g_hash_table_get_keys)
269 printf "Checking for Glib development files (>= 2.14)... "
271 if pkg-config --exists 'glib-2.0 >= 2.14'; then
274 glib_cflags=$(pkg-config --cflags glib-2.0)
275 glib_ldflags=$(pkg-config --libs glib-2.0)
278 errors=$((errors + 1))
281 printf "Checking for talloc development files... "
282 if pkg-config --exists talloc; then
285 talloc_cflags=$(pkg-config --cflags talloc)
286 talloc_ldflags=$(pkg-config --libs talloc)
291 errors=$((errors + 1))
294 printf "Checking for valgrind development files... "
295 if pkg-config --exists valgrind; then
298 valgrind_cflags=$(pkg-config --cflags valgrind)
300 printf "No (but that's fine).\n"
304 if [ -z "${EMACSLISPDIR}" ]; then
305 if pkg-config --exists emacs; then
306 EMACSLISPDIR=$(pkg-config emacs --variable sitepkglispdir)
308 EMACSLISPDIR='$(prefix)/share/emacs/site-lisp'
312 printf "Checking if emacs is available... "
313 if emacs --quick --batch > /dev/null 2>&1; then
317 printf "No (so will not byte-compile emacs code)\n"
323 printf "Checking which platform we are on... "
325 if [ $uname = "Darwin" ] ; then
328 linker_resolves_library_dependencies=0
329 elif [ $uname = "SunOS" ] ; then
332 linker_resolves_library_dependencies=0
333 elif [ $uname = "Linux" ] ; then
336 linker_resolves_library_dependencies=1
337 ldconfig_paths=$(/sbin/ldconfig -N -X -v 2>/dev/null | sed -n -e 's,^\(/.*\):\( (.*)\)\?$,\1,p')
338 # Separate ldconfig_paths only on newline (not on any potential
339 # embedded space characters in any filenames).
342 for path in $ldconfig_paths; do
343 if [ "$path" = "$libdir_expanded" ]; then
352 *** Warning: Unknown platform. Notmuch might or might not build correctly.
357 if [ $errors -gt 0 ]; then
360 *** Error: The dependencies of notmuch could not be satisfied. You will
361 need to install the following packages before being able to compile
365 if [ $have_xapian -eq 0 ]; then
366 echo " Xapian library (including development files such as headers)"
367 echo " http://xapian.org/"
369 if [ $have_gmime -eq 0 ]; then
370 echo " GMime 2.4 library (including development files such as headers)"
371 echo " http://spruce.sourceforge.net/gmime/"
373 if [ $have_glib -eq 0 ]; then
374 echo " Glib library >= 2.14 (including development files such as headers)"
375 echo " http://ftp.gnome.org/pub/gnome/sources/glib/"
377 if [ $have_talloc -eq 0 ]; then
378 echo " The talloc library (including development files such as headers)"
379 echo " http://talloc.samba.org/"
383 With any luck, you're using a modern, package-based operating system
384 that has all of these packages available in the distribution. In that
385 case a simple command will install everything you need. For example:
387 On Debian and similar systems:
389 sudo apt-get install libxapian-dev libgmime-2.4-dev libtalloc-dev
391 Or on Fedora and similar systems:
393 sudo yum install xapian-core-devel gmime-devel libtalloc-devel
395 On other systems, similar commands can be used, but the details of the
396 package names may be different.
399 if [ $have_pkg_config -eq 0 ]; then
401 Note: the pkg-config program is not available. This configure script
402 uses pkg-config to find the compilation flags required to link against
403 the various libraries needed by notmuch. It's possible you simply need
404 to install pkg-config with a command such as:
406 sudo apt-get install pkg-config
408 sudo yum install pkgconfig
410 But if pkg-config is not available for your system, then you will need
411 to modify the configure script to manually set the cflags and ldflags
412 variables to the correct values to link against each library in each
413 case that pkg-config could not be used to determine those values.
418 When you have installed the necessary dependencies, you can run
419 configure again to ensure the packages can be found, or simply run
420 "make" to compile notmuch.
426 printf "Checking for getline... "
427 if ${CC} -o compat/have_getline compat/have_getline.c > /dev/null 2>&1
432 printf "No (will use our own instead).\n"
435 rm -f compat/have_getline
437 printf "Checking for strcasestr... "
438 if ${CC} -o compat/have_strcasestr compat/have_strcasestr.c > /dev/null 2>&1
443 printf "No (will use our own instead).\n"
446 rm -f compat/have_strcasestr
448 printf "int main(void){return 0;}\n" > minimal.c
450 printf "Checking for rpath support... "
451 if ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1
454 rpath_ldflags="-Wl,--enable-new-dtags -Wl,-rpath,\$(libdir)"
456 printf "No (nothing to worry about).\n"
460 printf "Checking for -Wl,--as-needed... "
461 if ${CC} -Wl,--as-needed -o minimal minimal.c >/dev/null 2>&1
464 as_needed_ldflags="-Wl,--as-needed"
466 printf "No (nothing to worry about).\n"
471 printf "Checking for available C++ compiler warning flags... "
472 for flag in -Wall -Wextra -Wwrite-strings -Wswitch-enum; do
473 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
475 WARN_CXXFLAGS="${WARN_CXXFLAGS}${WARN_CXXFLAGS:+ }${flag}"
478 printf "\n\t${WARN_CXXFLAGS}\n"
480 WARN_CFLAGS="${WARN_CXXFLAGS}"
481 printf "Checking for available C compiler warning flags... "
482 for flag in -Wmissing-declarations; do
483 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
485 WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
488 printf "\n\t${WARN_CFLAGS}\n"
490 rm -f minimal minimal.c
494 All required packages were found. You may now run the following
495 commands to compile and install notmuch:
502 # construct the Makefile.config
503 cat > Makefile.config <<EOF
504 # This Makefile.config was automatically generated by the ./configure
505 # script of notmuch. If the configure script identified anything
506 # incorrectly, then you can edit this file to try to correct things,
507 # but be warned that if configure is run again it will destroy your
508 # changes, (and this could happen by simply calling "make" if the
509 # configure script is updated).
511 # The C compiler to use
514 # The C++ compiler to use
517 # Command to execute emacs from Makefiles
518 EMACS = emacs --quick
520 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
523 # Default FLAGS for C++ compiler (can be overridden by user such as "make CXXFLAGS=-g")
524 CXXFLAGS = ${CXXFLAGS}
526 # Default FLAGS for the linker (can be overridden by user such as "make LDFLAGS=-znow")
529 # Flags to enable warnings when using the C++ compiler
530 WARN_CXXFLAGS=${WARN_CXXFLAGS}
532 # Flags to enable warnings when using the C compiler
533 WARN_CFLAGS=${WARN_CFLAGS}
535 # The prefix to which notmuch should be installed
536 # Note: If you change this value here, be sure to ensure that the
537 # LIBDIR_IN_LDCONFIG value below is still set correctly.
540 # The directory to which libraries should be installed
541 # Note: If you change this value here, be sure to ensure that the
542 # LIBDIR_IN_LDCONFIG value below is still set correctly.
543 libdir = ${LIBDIR:=\$(prefix)/lib}
545 # Whether libdir is in a path configured into ldconfig
546 LIBDIR_IN_LDCONFIG = ${libdir_in_ldconfig}
548 # The directory to which header files should be installed
549 includedir = ${INCLUDEDIR:=\$(prefix)/include}
551 # The directory to which man pages should be installed
552 mandir = ${MANDIR:=\$(prefix)/share/man}
554 # The directory to which read-only (configuration) filesshould be installed
555 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
557 # The directory to which emacs lisp files should be installed
558 emacslispdir=${EMACSLISPDIR}
560 # Whether there's an emacs binary available for byte-compiling
561 HAVE_EMACS = ${have_emacs}
563 # The directory to which desktop files should be installed
564 desktop_dir = \$(prefix)/share/applications
566 # The directory to which bash completions files should be installed
567 bash_completion_dir = ${BASHCOMPLETIONDIR:=\$(sysconfdir)/bash_completion.d}
569 # The directory to which zsh completions files should be installed
570 zsh_completion_dir = ${ZSHCOMLETIONDIR:=\$(prefix)/share/zsh/functions/Completion/Unix}
572 # Whether the getline function is available (if not, then notmuch will
573 # build its own version)
574 HAVE_GETLINE = ${have_getline}
576 # Whether the strcasestr function is available (if not, then notmuch will
577 # build its own version)
578 HAVE_STRCASESTR = ${have_strcasestr}
580 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS
581 PLATFORM = ${platform}
583 # Whether the linker will automatically resolve the dependency of one
584 # library on another (if not, then linking a binary requires linking
585 # directly against both)
586 LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
588 # Flags needed to compile and link against Xapian
589 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
590 XAPIAN_LDFLAGS = ${xapian_ldflags}
592 # Flags needed to compile and link against GMime-2.4
593 GMIME_CFLAGS = ${gmime_cflags}
594 GMIME_LDFLAGS = ${gmime_ldflags}
596 # Flags needed to compile and link against talloc
597 TALLOC_CFLAGS = ${talloc_cflags}
598 TALLOC_LDFLAGS = ${talloc_ldflags}
600 # Flags needed to have linker set rpath attribute
601 RPATH_LDFLAGS = ${rpath_ldflags}
603 # Flags needed to have linker link only to necessary libraries
604 AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
606 # Whether valgrind header files are available
607 HAVE_VALGRIND = ${have_valgrind}
609 # And if so, flags needed at compile time for valgrind macros
610 VALGRIND_CFLAGS = ${valgrind_cflags}
613 WITH_EMACS = ${WITH_EMACS}
615 # Support for bash completion
616 WITH_BASH = ${WITH_BASH}
618 # Support for zsh completion
619 WITH_ZSH = ${WITH_ZSH}
621 # Combined flags for compiling and linking against all of the above
622 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
623 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
624 \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
625 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
626 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
627 \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
628 -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
629 CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)