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
35 Usage: ./configure [options]...
37 This script configures notmuch to build on your system.
39 It verifies that dependencies are available, determines flags needed
40 to compile and link against various required libraries, and identifies
41 whether various system functions can be used or if locally-provided
42 replacements will be built instead.
44 Finally, it allows you to control various aspects of the build and
47 First, some common variables can specified via environment variables:
49 CC The C compiler to use
50 CFLAGS Flags to pass to the C compiler
51 CXX The C++ compiler to use
52 CXXFLAGS Flags to pass to the C compiler
53 LDFLAGS Flags to pass when linking
55 Each of these values can further be controlled by specifying them
56 later on the "make" command line.
58 Other environment variables can be used to control configure itself,
59 (and for which there is no equivalent build-time control):
61 XAPIAN_CONFIG The program to use to determine flags for
62 compiling and linking against the Xapian
63 library. [$XAPIAN_CONFIG]
65 Additionally, various options can be specified on the configure
68 --prefix=PREFIX Install files in PREFIX [$PREFIX]
70 By default, "make install" will install the resulting program to
71 $PREFIX/bin, documentation to $PREFIX/man, etc. You can
72 specify an installation prefix other than $PREFIX using
73 --prefix, for instance:
75 ./configure --prefix=\$HOME
77 Fine tuning of some installation directories is available:
79 --libdir=DIR Install libraries to DIR [PREFIX/lib]
80 --includedir=DIR Install header files to DIR [PREFIX/include]
81 --mandir=DIR Install man pages to DIR [PREFIX/share/man]
82 --sysconfdir=DIR Read-only single-machine data [PREFIX/etc]
83 --emacslispdir=DIR Emacs code [PREFIX/share/emacs/site-lisp]
85 Additional options are accepted for compatibility with other
86 configure-script calling conventions, but don't do anything yet:
88 --build=<cpu>-<vendor>-<os> Currently ignored
89 --host=<cpu>-<vendor>-<os> Currently ignored
90 --infodir=DIR Currently ignored
91 --datadir=DIR Currently ignored
92 --localstatedir=DIR Currently ignored
93 --libexecdir=DIR Currently ignored
94 --disable-maintainer-mode Currently ignored
95 --disable-dependency-tracking Currently ignored
100 # Parse command-line options
102 if [ "${option}" = '--help' ] ; then
105 elif [ "${option%%=*}" = '--prefix' ] ; then
106 PREFIX="${option#*=}"
107 elif [ "${option%%=*}" = '--libdir' ] ; then
108 LIBDIR="${option#*=}"
109 elif [ "${option%%=*}" = '--includedir' ] ; then
110 INCLUDEDIR="${option#*=}"
111 elif [ "${option%%=*}" = '--mandir' ] ; then
112 MANDIR="${option#*=}"
113 elif [ "${option%%=*}" = '--sysconfdir' ] ; then
114 SYSCONFDIR="${option#*=}"
115 elif [ "${option%%=*}" = '--emacslispdir' ] ; then
116 EMACSLISPDIR="${option#*=}"
117 elif [ "${option%%=*}" = '--build' ] ; then
118 build_option="${option#*=}"
119 case ${build_option} in
122 echo "Unrecognized value for --build option: ${build_option}"
123 echo "Should be: <cpu>-<vendor>-<os>"
129 build_cpu=${build_option%%-*}
130 build_option=${build_option#*-}
131 build_vendor=${build_option%%-*}
132 build_os=${build_option#*-}
133 elif [ "${option%%=*}" = '--host' ] ; then
134 host_option="${option#*=}"
135 case ${host_option} in
138 echo "Unrecognized value for --host option: ${host_option}"
139 echo "Should be: <cpu>-<vendor>-<os>"
145 host_cpu=${host_option%%-*}
146 host_option=${host_option#*-}
147 host_vendor=${host_option%%-*}
148 host_os=${host_option#*-}
149 elif [ "${option%%=*}" = '--infodir' ] ; then
151 elif [ "${option%%=*}" = '--datadir' ] ; then
153 elif [ "${option%%=*}" = '--localstatedir' ] ; then
155 elif [ "${option%%=*}" = '--libexecdir' ] ; then
157 elif [ "${option}" = '--disable-maintainer-mode' ] ; then
159 elif [ "${option}" = '--disable-dependency-tracking' ] ; then
162 echo "Unrecognized option: ${option}"
170 # We set this value early, (rather than just while printing the
171 # Makefile.config file later like most values), because we need to
172 # actually investigate this value compared to the ldconfig_paths value
174 libdir_expanded=${LIBDIR:-${PREFIX}/lib}
177 Welcome to Notmuch, a system for indexing, searching and tagging your email.
179 We hope that the process of building and installing notmuch is quick
180 and smooth so that you can soon be reading and processing your email
181 more efficiently than ever.
183 If anything goes wrong in the configure process, you can override any
184 decisions it makes by manually editing the Makefile.config file that
185 it creates. Also please do as much as you can to figure out what could
186 be different on your machine compared to those of the notmuch
187 developers. Then, please email those details to the Notmuch list
188 (notmuch@notmuchmail.org) so that we can hopefully make future
189 versions of notmuch easier for you to use.
191 We'll now investigate your system to verify that all required
192 dependencies are available:
198 if pkg-config --version > /dev/null 2>&1; then
204 printf "Checking for Xapian development files... "
206 for xapian_config in ${XAPIAN_CONFIG}; do
207 if ${xapian_config} --version > /dev/null 2>&1; then
208 printf "Yes (%s).\n" $(${xapian_config} --version | sed -e 's/.* //')
210 xapian_cxxflags=$(${xapian_config} --cxxflags)
211 xapian_ldflags=$(${xapian_config} --libs)
215 if [ ${have_xapian} = "0" ]; then
217 errors=$((errors + 1))
220 printf "Checking for GMime development files... "
222 for gmimepc in gmime-2.6 gmime-2.4; do
223 if pkg-config --exists $gmimepc; then
224 printf "Yes ($gmimepc).\n"
226 gmime_cflags=$(pkg-config --cflags $gmimepc)
227 gmime_ldflags=$(pkg-config --libs $gmimepc)
230 if [ "$have_gmime" = "0" ]; then
232 errors=$((errors + 1))
235 # GMime already depends on Glib >= 2.12, but we use at least one Glib
236 # function that only exists as of 2.14, (g_hash_table_get_keys)
237 printf "Checking for Glib development files (>= 2.14)... "
239 if pkg-config --exists 'glib-2.0 >= 2.14'; then
242 glib_cflags=$(pkg-config --cflags glib-2.0)
243 glib_ldflags=$(pkg-config --libs glib-2.0)
246 errors=$((errors + 1))
249 printf "Checking for talloc development files... "
250 if pkg-config --exists talloc; then
253 talloc_cflags=$(pkg-config --cflags talloc)
254 talloc_ldflags=$(pkg-config --libs talloc)
259 errors=$((errors + 1))
262 printf "Checking for valgrind development files... "
263 if pkg-config --exists valgrind; then
266 valgrind_cflags=$(pkg-config --cflags valgrind)
268 printf "No (but that's fine).\n"
272 if [ -z "${EMACSLISPDIR}" ]; then
273 if pkg-config --exists emacs; then
274 EMACSLISPDIR=$(pkg-config emacs --variable sitepkglispdir)
276 EMACSLISPDIR='$(prefix)/share/emacs/site-lisp'
280 printf "Checking if emacs is available... "
281 if emacs --quick --batch > /dev/null 2>&1; then
285 printf "No (so will not byte-compile emacs code)\n"
291 printf "Checking which platform we are on... "
293 if [ $uname = "Darwin" ] ; then
296 linker_resolves_library_dependencies=0
297 elif [ $uname = "SunOS" ] ; then
300 linker_resolves_library_dependencies=0
301 elif [ $uname = "Linux" ] ; then
304 linker_resolves_library_dependencies=1
305 ldconfig_paths=$(/sbin/ldconfig -N -X -v 2>/dev/null | sed -n -e 's,^\(/.*\):\( (.*)\)\?$,\1,p')
306 for path in $ldconfig_paths; do
307 if [ "$path" = "$libdir_expanded" ]; then
315 *** Warning: Unknown platform. Notmuch might or might not build correctly.
320 if [ $errors -gt 0 ]; then
323 *** Error: The dependencies of notmuch could not be satisfied. You will
324 need to install the following packages before being able to compile
328 if [ $have_xapian -eq 0 ]; then
329 echo " Xapian library (including development files such as headers)"
330 echo " http://xapian.org/"
332 if [ $have_gmime -eq 0 ]; then
333 echo " GMime 2.4 library (including development files such as headers)"
334 echo " http://spruce.sourceforge.net/gmime/"
336 if [ $have_glib -eq 0 ]; then
337 echo " Glib library >= 2.14 (including development files such as headers)"
338 echo " http://ftp.gnome.org/pub/gnome/sources/glib/"
340 if [ $have_talloc -eq 0 ]; then
341 echo " The talloc library (including development files such as headers)"
342 echo " http://talloc.samba.org/"
346 With any luck, you're using a modern, package-based operating system
347 that has all of these packages available in the distribution. In that
348 case a simple command will install everything you need. For example:
350 On Debian and similar systems:
352 sudo apt-get install libxapian-dev libgmime-2.4-dev libtalloc-dev
354 Or on Fedora and similar systems:
356 sudo yum install xapian-core-devel gmime-devel libtalloc-devel
358 On other systems, similar commands can be used, but the details of the
359 package names may be different.
362 if [ $have_pkg_config -eq 0 ]; then
364 Note: the pkg-config program is not available. This configure script
365 uses pkg-config to find the compilation flags required to link against
366 the various libraries needed by notmuch. It's possible you simply need
367 to install pkg-config with a command such as:
369 sudo apt-get install pkg-config
371 sudo yum install pkgconfig
373 But if pkg-config is not available for your system, then you will need
374 to modify the configure script to manually set the cflags and ldflags
375 variables to the correct values to link against each library in each
376 case that pkg-config could not be used to determine those values.
381 When you have installed the necessary dependencies, you can run
382 configure again to ensure the packages can be found, or simply run
383 "make" to compile notmuch.
389 printf "Checking for getline... "
390 if ${CC} -o compat/have_getline compat/have_getline.c > /dev/null 2>&1
395 printf "No (will use our own instead).\n"
398 rm -f compat/have_getline
400 printf "Checking for strcasestr... "
401 if ${CC} -o compat/have_strcasestr compat/have_strcasestr.c > /dev/null 2>&1
406 printf "No (will use our own instead).\n"
409 rm -f compat/have_strcasestr
411 printf "int main(void){return 0;}\n" > minimal.c
413 printf "Checking for rpath support... "
414 if ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1
417 rpath_ldflags="-Wl,--enable-new-dtags -Wl,-rpath,\$(libdir)"
419 printf "No (nothing to worry about).\n"
423 printf "Checking for -Wl,--as-needed... "
424 if ${CC} -Wl,--as-needed -o minimal minimal.c >/dev/null 2>&1
427 as_needed_ldflags="-Wl,--as-needed"
429 printf "No (nothing to worry about).\n"
434 printf "Checking for available C++ compiler warning flags... "
435 for flag in -Wall -Wextra -Wwrite-strings -Wswitch-enum; do
436 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
438 WARN_CXXFLAGS="${WARN_CXXFLAGS}${WARN_CXXFLAGS:+ }${flag}"
441 printf "\n\t${WARN_CXXFLAGS}\n"
443 WARN_CFLAGS="${WARN_CXXFLAGS}"
444 printf "Checking for available C compiler warning flags... "
445 for flag in -Wmissing-declarations; do
446 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
448 WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
451 printf "\n\t${WARN_CFLAGS}\n"
453 rm -f minimal minimal.c
457 All required packages were found. You may now run the following
458 commands to compile and install notmuch:
465 # construct the Makefile.config
466 cat > Makefile.config <<EOF
467 # This Makefile.config was automatically generated by the ./configure
468 # script of notmuch. If the configure script identified anything
469 # incorrectly, then you can edit this file to try to correct things,
470 # but be warned that if configure is run again it will destroy your
471 # changes, (and this could happen by simply calling "make" if the
472 # configure script is updated).
474 # The C compiler to use
477 # The C++ compiler to use
480 # Command to execute emacs from Makefiles
481 EMACS = emacs --quick
483 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
486 # Default FLAGS for C++ compiler (can be overridden by user such as "make CXXFLAGS=-g")
487 CXXFLAGS = ${CXXFLAGS}
489 # Default FLAGS for the linker (can be overridden by user such as "make LDFLAGS=-znow")
492 # Flags to enable warnings when using the C++ compiler
493 WARN_CXXFLAGS=${WARN_CXXFLAGS}
495 # Flags to enable warnings when using the C compiler
496 WARN_CFLAGS=${WARN_CFLAGS}
498 # The prefix to which notmuch should be installed
499 # Note: If you change this value here, be sure to ensure that the
500 # LIBDIR_IN_LDCONFIG value below is still set correctly.
503 # The directory to which libraries should be installed
504 # Note: If you change this value here, be sure to ensure that the
505 # LIBDIR_IN_LDCONFIG value below is still set correctly.
506 libdir = ${LIBDIR:=\$(prefix)/lib}
508 # Whether libdir is in a path configured into ldconfig
509 LIBDIR_IN_LDCONFIG = ${libdir_in_ldconfig}
511 # The directory to which header files should be installed
512 includedir = ${INCLUDEDIR:=\$(prefix)/include}
514 # The directory to which man pages should be installed
515 mandir = ${MANDIR:=\$(prefix)/share/man}
517 # The directory to which read-only (configuration) filesshould be installed
518 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
520 # The directory to which emacs lisp files should be installed
521 emacslispdir=${EMACSLISPDIR}
523 # Whether there's an emacs binary available for byte-compiling
524 HAVE_EMACS = ${have_emacs}
526 # The directory to which desktop files should be installed
527 desktop_dir = \$(prefix)/share/applications
529 # The directory to which bash completions files should be installed
530 bash_completion_dir = \$(sysconfdir)/bash_completion.d
532 # The directory to which zsh completions files should be installed
533 zsh_completion_dir = \$(prefix)/share/zsh/functions/Completion/Unix
535 # Whether the getline function is available (if not, then notmuch will
536 # build its own version)
537 HAVE_GETLINE = ${have_getline}
539 # Whether the strcasestr function is available (if not, then notmuch will
540 # build its own version)
541 HAVE_STRCASESTR = ${have_strcasestr}
543 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS
544 PLATFORM = ${platform}
546 # Whether the linker will automatically resolve the dependency of one
547 # library on another (if not, then linking a binary requires linking
548 # directly against both)
549 LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
551 # Flags needed to compile and link against Xapian
552 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
553 XAPIAN_LDFLAGS = ${xapian_ldflags}
555 # Flags needed to compile and link against GMime-2.4
556 GMIME_CFLAGS = ${gmime_cflags}
557 GMIME_LDFLAGS = ${gmime_ldflags}
559 # Flags needed to compile and link against talloc
560 TALLOC_CFLAGS = ${talloc_cflags}
561 TALLOC_LDFLAGS = ${talloc_ldflags}
563 # Flags needed to have linker set rpath attribute
564 RPATH_LDFLAGS = ${rpath_ldflags}
566 # Flags needed to have linker link only to necessary libraries
567 AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
569 # Whether valgrind header files are available
570 HAVE_VALGRIND = ${have_valgrind}
572 # And if so, flags needed at compile time for valgrind macros
573 VALGRIND_CFLAGS = ${valgrind_cflags}
575 # Combined flags for compiling and linking against all of the above
576 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
577 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
578 \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
579 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
580 \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
581 \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
582 -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
583 CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)