]> git.notmuchmail.org Git - notmuch/blob - configure
test: redirect man output to /dev/null
[notmuch] / configure
1 #! /bin/sh
2
3 # Test whether this shell is capable of parameter substring processing.
4 ( option='a/b'; : ${option#*/} ) 2>/dev/null || {
5     echo "
6 The shell interpreting '$0' is lacking some required features.
7
8 To work around this problem you may try to execute:
9
10     ksh $0 $*
11  or
12     bash $0 $*
13 "
14     exit 1
15 }
16
17 # Store original IFS value so it can be changed (and restored) in many places.
18 readonly DEFAULT_IFS="$IFS"
19
20 srcdir=$(dirname "$0")
21
22 subdirs="util compat lib parse-time-string completion doc emacs"
23 subdirs="${subdirs} performance-test test test/test-databases"
24
25 # For a non-srcdir configure invocation (such as ../configure), create
26 # the directory structure and copy Makefiles.
27 if [ "$srcdir" != "." ]; then
28
29     for dir in . ${subdirs}; do
30         mkdir -p "$dir"
31         cp "$srcdir"/"$dir"/Makefile.local "$dir"
32         cp "$srcdir"/"$dir"/Makefile "$dir"
33     done
34
35     # Easiest way to get the test suite to work is to just copy the
36     # whole thing into the build directory.
37     cp -a "$srcdir"/test/* test
38
39     # Emacs only likes to generate compiled files next to the .el files
40     # by default so copy these as well (which is not ideal0.
41     cp -a "$srcdir"/emacs/*.el emacs
42 fi
43
44 # Set several defaults (optionally specified by the user in
45 # environment variables)
46 CC=${CC:-cc}
47 CXX=${CXX:-c++}
48 CFLAGS=${CFLAGS:--g -O2}
49 CPPFLAGS=${CPPFLAGS:-}
50 CXXFLAGS_for_sh=${CXXFLAGS:-${CFLAGS}}
51 CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
52 LDFLAGS=${LDFLAGS:-}
53 XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config}
54 PYTHON=${PYTHON:-}
55
56 # We don't allow the EMACS or GZIP Makefile variables inherit values
57 # from the environment as we do with CC and CXX above. The reason is
58 # that these names as environment variables have existing uses other
59 # than the program name that we want. (EMACS is set to 't' when a
60 # shell is running within emacs and GZIP specifies arguments to pass
61 # on the gzip command line).
62
63 # Set the defaults for values the user can specify with command-line
64 # options.
65 PREFIX=/usr/local
66 LIBDIR=
67 WITH_EMACS=1
68 WITH_BASH=1
69 WITH_ZSH=1
70
71 # Compatible GMime versions (with constraints).
72 # If using GMime 2.6, we need to have a version >= 2.6.5 to avoid a
73 # crypto bug. We need 2.6.7 for permissive "From " header handling.
74 GMIME_24_VERSION_CTR=''
75 GMIME_24_VERSION="gmime-2.4 $GMIME_24_VERSION_CTR"
76 GMIME_26_VERSION_CTR='>= 2.6.7'
77 GMIME_26_VERSION="gmime-2.6 $GMIME_26_VERSION_CTR"
78
79 WITH_GMIME_VERSIONS="$GMIME_26_VERSION;$GMIME_24_VERSION"
80
81 usage ()
82 {
83     cat <<EOF
84 Usage: ./configure [options]...
85
86 This script configures notmuch to build on your system.
87
88 It verifies that dependencies are available, determines flags needed
89 to compile and link against various required libraries, and identifies
90 whether various system functions can be used or if locally-provided
91 replacements will be built instead.
92
93 Finally, it allows you to control various aspects of the build and
94 installation process.
95
96 First, some common variables can specified via environment variables:
97
98         CC              The C compiler to use
99         CFLAGS          Flags to pass to the C compiler
100         CPPFLAGS        Flags to pass to the C preprocessor
101         CXX             The C++ compiler to use
102         CXXFLAGS        Flags to pass to the C compiler
103         LDFLAGS         Flags to pass when linking
104
105 Each of these values can further be controlled by specifying them
106 later on the "make" command line.
107
108 Other environment variables can be used to control configure itself,
109 (and for which there is no equivalent build-time control):
110
111         XAPIAN_CONFIG   The program to use to determine flags for
112                         compiling and linking against the Xapian
113                         library. [$XAPIAN_CONFIG]
114
115 Additionally, various options can be specified on the configure
116 command line.
117
118         --prefix=PREFIX Install files in PREFIX [$PREFIX]
119
120 By default, "make install" will install the resulting program to
121 $PREFIX/bin, documentation to $PREFIX/man, etc. You can
122 specify an installation prefix other than $PREFIX using
123 --prefix, for instance:
124
125         ./configure --prefix=\$HOME
126
127 Fine tuning of some installation directories is available:
128
129         --libdir=DIR            Install libraries to DIR [PREFIX/lib]
130         --includedir=DIR        Install header files to DIR [PREFIX/include]
131         --mandir=DIR            Install man pages to DIR [PREFIX/share/man]
132         --sysconfdir=DIR        Read-only single-machine data [PREFIX/etc]
133         --emacslispdir=DIR      Emacs code [PREFIX/share/emacs/site-lisp]
134         --emacsetcdir=DIR       Emacs miscellaneous files [PREFIX/share/emacs/site-lisp]
135         --bashcompletiondir=DIR Bash completions files [SYSCONFDIR/bash_completion.d]
136         --zshcompletiondir=DIR  Zsh completions files [PREFIX/share/zsh/functions/Completion/Unix]
137
138 Some specific library versions can be specified (auto-detected otherwise):
139
140         --with-gmime-version=VERS       Specify GMIME version (2.4 or 2.6)
141
142 Some features can be disabled (--with-feature=no is equivalent to
143 --without-feature) :
144
145         --without-emacs                 Do not install lisp file
146         --without-bash-completion       Do not install bash completions files
147         --without-zsh-completion        Do not install zsh completions files
148
149 Additional options are accepted for compatibility with other
150 configure-script calling conventions, but don't do anything yet:
151
152         --build=<cpu>-<vendor>-<os>     Currently ignored
153         --host=<cpu>-<vendor>-<os>      Currently ignored
154         --infodir=DIR                   Currently ignored
155         --datadir=DIR                   Currently ignored
156         --localstatedir=DIR             Currently ignored
157         --libexecdir=DIR                Currently ignored
158         --disable-maintainer-mode       Currently ignored
159         --disable-dependency-tracking   Currently ignored
160
161 EOF
162 }
163
164 # Parse command-line options
165 for option; do
166     if [ "${option}" = '--help' ] ; then
167         usage
168         exit 0
169     elif [ "${option%%=*}" = '--prefix' ] ; then
170         PREFIX="${option#*=}"
171     elif [ "${option%%=*}" = '--libdir' ] ; then
172         LIBDIR="${option#*=}"
173     elif [ "${option%%=*}" = '--includedir' ] ; then
174         INCLUDEDIR="${option#*=}"
175     elif [ "${option%%=*}" = '--mandir' ] ; then
176         MANDIR="${option#*=}"
177     elif [ "${option%%=*}" = '--sysconfdir' ] ; then
178         SYSCONFDIR="${option#*=}"
179     elif [ "${option%%=*}" = '--emacslispdir' ] ; then
180         EMACSLISPDIR="${option#*=}"
181     elif [ "${option%%=*}" = '--emacsetcdir' ] ; then
182         EMACSETCDIR="${option#*=}"
183     elif [ "${option%%=*}" = '--bashcompletiondir' ] ; then
184         BASHCOMPLETIONDIR="${option#*=}"
185     elif [ "${option%%=*}" = '--zshcompletiondir' ] ; then
186         ZSHCOMLETIONDIR="${option#*=}"
187     elif [ "${option%%=*}" = '--with-emacs' ]; then
188         if [ "${option#*=}" = 'no' ]; then
189             WITH_EMACS=0
190         else
191             WITH_EMACS=1
192         fi
193     elif [ "${option}" = '--without-emacs' ] ; then
194         WITH_EMACS=0
195     elif [ "${option%%=*}" = '--with-bash-completion' ]; then
196         if [ "${option#*=}" = 'no' ]; then
197             WITH_BASH=0
198         else
199             WITH_BASH=1
200         fi
201     elif [ "${option}" = '--without-bash-completion' ] ; then
202         WITH_BASH=0
203     elif [ "${option%%=*}" = '--with-zsh-completion' ]; then
204         if [ "${option#*=}" = 'no' ]; then
205             WITH_ZSH=0
206         else
207             WITH_ZSH=1
208         fi
209     elif [ "${option}" = '--without-zsh-completion' ] ; then
210         WITH_ZSH=0
211     elif [ "${option%%=*}" = '--with-gmime-version' ] ; then
212         if [ "${option#*=}" = '2.4' ]; then
213              WITH_GMIME_VERSIONS=$GMIME_24_VERSION
214          elif [ "${option#*=}" = '2.6' ]; then
215              WITH_GMIME_VERSIONS=$GMIME_26_VERSION
216         fi
217     elif [ "${option%%=*}" = '--build' ] ; then
218         true
219     elif [ "${option%%=*}" = '--host' ] ; then
220         true
221     elif [ "${option%%=*}" = '--infodir' ] ; then
222         true
223     elif [ "${option%%=*}" = '--datadir' ] ; then
224         true
225     elif [ "${option%%=*}" = '--localstatedir' ] ; then
226         true
227     elif [ "${option%%=*}" = '--libexecdir' ] ; then
228         true
229     elif [ "${option}" = '--disable-maintainer-mode' ] ; then
230         true
231     elif [ "${option}" = '--disable-dependency-tracking' ] ; then
232         true
233     else
234         echo "Unrecognized option: ${option}"
235         echo "See:"
236         echo "  $0 --help"
237         echo ""
238         exit 1
239     fi
240 done
241
242 # We set this value early, (rather than just while printing the
243 # Makefile.config file later like most values), because we need to
244 # actually investigate this value compared to the ldconfig_paths value
245 # below.
246 if [ -z "$LIBDIR" ] ; then
247     libdir_expanded="${PREFIX}/lib"
248 else
249     # very non-general variable expansion
250     libdir_expanded=`echo "$LIBDIR" | sed "s|\\${prefix}|${PREFIX}|g; s|\\$prefix/|${PREFIX}/|; s|//*|/|g"`
251 fi
252
253 cat <<EOF
254 Welcome to Notmuch, a system for indexing, searching and tagging your email.
255
256 We hope that the process of building and installing notmuch is quick
257 and smooth so that you can soon be reading and processing your email
258 more efficiently than ever.
259
260 If anything goes wrong in the configure process, you can override any
261 decisions it makes by manually editing the Makefile.config file that
262 it creates. Also please do as much as you can to figure out what could
263 be different on your machine compared to those of the notmuch
264 developers. Then, please email those details to the Notmuch list
265 (notmuch@notmuchmail.org) so that we can hopefully make future
266 versions of notmuch easier for you to use.
267
268 We'll now investigate your system to verify that all required
269 dependencies are available:
270
271 EOF
272
273 errors=0
274 printf "int main(void){return 0;}\n" > minimal.c
275
276 printf "Sanity checking C compilation environment... "
277 if ${CC} ${CFLAGS} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal > /dev/null 2>&1
278 then
279     printf "OK.\n"
280 else
281     printf "Fail.\n"
282     errors=$((errors + 1))
283 fi
284
285 printf "Sanity checking C++ compilation environment... "
286 if ${CXX} ${CXXFLAGS_for_sh} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal > /dev/null 2>&1
287 then
288     printf "OK.\n"
289 else
290     printf "Fail.\n"
291     errors=$((errors + 1))
292 fi
293
294 if [ $errors -gt 0 ]; then
295     cat <<EOF
296 *** Error: Initial sanity checking of environment failed.  Please try
297 running configure in a clean environment, and if the problem persists,
298 report a bug.
299 EOF
300     rm -f minimal minimal.c
301     exit 1
302 fi
303
304 if pkg-config --version > /dev/null 2>&1; then
305     have_pkg_config=1
306 else
307     have_pkg_config=0
308 fi
309
310 printf "Checking for Xapian development files... "
311 have_xapian=0
312 for xapian_config in ${XAPIAN_CONFIG}; do
313     if ${xapian_config} --version > /dev/null 2>&1; then
314         xapian_version=$(${xapian_config} --version | sed -e 's/.* //')
315         printf "Yes (%s).\n" ${xapian_version}
316         have_xapian=1
317         xapian_cxxflags=$(${xapian_config} --cxxflags)
318         xapian_ldflags=$(${xapian_config} --libs)
319         break
320     fi
321 done
322 if [ ${have_xapian} = "0" ]; then
323     printf "No.\n"
324     errors=$((errors + 1))
325 fi
326
327 # Compaction is only supported on Xapian > 1.2.6
328 have_xapian_compact=0
329 if [ ${have_xapian} = "1" ]; then
330     printf "Checking for Xapian compaction support... "
331     case "${xapian_version}" in
332         0.*|1.[01].*|1.2.[0-5])
333             printf "No (only available with Xapian > 1.2.6).\n" ;;
334         [1-9]*.[0-9]*.[0-9]*)
335             have_xapian_compact=1
336             printf "Yes.\n" ;;
337         *)
338             printf "Unknown version.\n" ;;
339     esac
340 fi
341
342 printf "Checking for GMime development files... "
343 have_gmime=0
344 IFS=';'
345 for gmimepc in $WITH_GMIME_VERSIONS; do
346     if pkg-config --exists $gmimepc; then
347         printf "Yes ($gmimepc).\n"
348         have_gmime=1
349         gmime_cflags=$(pkg-config --cflags $gmimepc)
350         gmime_ldflags=$(pkg-config --libs $gmimepc)
351         break
352     fi
353 done
354 IFS=$DEFAULT_IFS
355 if [ "$have_gmime" = "0" ]; then
356     printf "No.\n"
357     errors=$((errors + 1))
358 fi
359
360 # GMime already depends on Glib >= 2.12, but we use at least one Glib
361 # function that only exists as of 2.22, (g_array_unref)
362 printf "Checking for Glib development files (>= 2.22)... "
363 have_glib=0
364 if pkg-config --exists 'glib-2.0 >= 2.22'; then
365     printf "Yes.\n"
366     have_glib=1
367     glib_cflags=$(pkg-config --cflags glib-2.0)
368     glib_ldflags=$(pkg-config --libs glib-2.0)
369 else
370     printf "No.\n"
371     errors=$((errors + 1))
372 fi
373
374 if ! pkg-config --exists zlib; then
375   ${CC} ${zlib_cflags} -o compat/gen_zlib_pc \
376           "$srcdir"/compat/gen_zlib_pc.c ${zlib_ldflags} > /dev/null 2>&1 &&
377   compat/gen_zlib_pc > compat/zlib.pc &&
378   PKG_CONFIG_PATH="$PKG_CONFIG_PATH":compat &&
379   export PKG_CONFIG_PATH
380   rm -f compat/gen_zlib_pc
381 fi
382
383 printf "Checking for zlib (>= 1.2.5.2)... "
384 have_zlib=0
385 if pkg-config --atleast-version=1.2.5.2 zlib; then
386     printf "Yes.\n"
387     have_zlib=1
388     zlib_cflags=$(pkg-config --cflags zlib)
389     zlib_ldflags=$(pkg-config --libs zlib)
390 else
391     printf "No.\n"
392     errors=$((errors + 1))
393 fi
394
395 printf "Checking for talloc development files... "
396 if pkg-config --exists talloc; then
397     printf "Yes.\n"
398     have_talloc=1
399     talloc_cflags=$(pkg-config --cflags talloc)
400     talloc_ldflags=$(pkg-config --libs talloc)
401 else
402     printf "No.\n"
403     have_talloc=0
404     talloc_cflags=
405     errors=$((errors + 1))
406 fi
407
408 printf "Checking for python... "
409 have_python=0
410
411 for name in ${PYTHON} python python2 python3; do
412     if command -v $name > /dev/null; then
413         have_python=1
414         python=$name
415         printf "Yes ($name).\n"
416         break
417     fi
418 done
419
420 if [ $have_python -eq 0 ]; then
421     printf "No.\n"
422     errors=$((errors + 1))
423 fi
424
425 printf "Checking for valgrind development files... "
426 if pkg-config --exists valgrind; then
427     printf "Yes.\n"
428     have_valgrind=1
429     valgrind_cflags=$(pkg-config --cflags valgrind)
430 else
431     printf "No (but that's fine).\n"
432     have_valgrind=0
433 fi
434
435 printf "Checking for bash-completion (>= 1.90)... "
436 if pkg-config --atleast-version=1.90 bash-completion; then
437     printf "Yes.\n"
438 else
439     printf "No (will not install bash completion).\n"
440     WITH_BASH=0
441 fi
442
443 if [ -z "${EMACSLISPDIR}" ]; then
444     if pkg-config --exists emacs; then
445         EMACSLISPDIR=$(pkg-config emacs --variable sitepkglispdir)
446     else
447         EMACSLISPDIR='$(prefix)/share/emacs/site-lisp'
448     fi
449 fi
450
451 if [ -z "${EMACSETCDIR}" ]; then
452     if pkg-config --exists emacs; then
453         EMACSETCDIR=$(pkg-config emacs --variable sitepkglispdir)
454     else
455         EMACSETCDIR='$(prefix)/share/emacs/site-lisp'
456     fi
457 fi
458
459 printf "Checking if emacs is available... "
460 if emacs --quick --batch > /dev/null 2>&1; then
461     printf "Yes.\n"
462     have_emacs=1
463 else
464     printf "No (so will not byte-compile emacs code)\n"
465     have_emacs=0
466 fi
467
468 printf "Checking if doxygen is available... "
469 if command -v doxygen > /dev/null; then
470     printf "Yes.\n"
471     have_doxygen=1
472 else
473     printf "No (so will not install api docs)\n"
474     have_doxygen=0
475 fi
476
477 printf "Checking if sphinx is available and supports nroff output... "
478 if command -v sphinx-build > /dev/null && ${python} -m sphinx.writers.manpage > /dev/null 2>&1 ; then
479     printf "Yes.\n"
480     have_sphinx=1
481 else
482     printf "No (so will not install man pages).\n"
483     have_sphinx=0
484 fi
485
486 libdir_in_ldconfig=0
487
488 printf "Checking which platform we are on... "
489 uname=`uname`
490 if [ $uname = "Darwin" ] ; then
491     printf "Mac OS X.\n"
492     platform=MACOSX
493     linker_resolves_library_dependencies=0
494 elif [ $uname = "SunOS" ] ; then
495     printf "Solaris.\n"
496     platform=SOLARIS
497     linker_resolves_library_dependencies=0
498 elif [ $uname = "FreeBSD" ] ; then
499     printf "FreeBSD.\n"
500     platform=FREEBSD
501     linker_resolves_library_dependencies=0
502 elif [ $uname = "OpenBSD" ] ; then
503     printf "OpenBSD.\n"
504     platform=OPENBSD
505     linker_resolves_library_dependencies=0
506 elif [ $uname = "Linux" ] || [ $uname = "GNU" ] ; then
507     printf "$uname\n"
508     platform="$uname"
509     linker_resolves_library_dependencies=1
510
511     printf "Checking for $libdir_expanded in ldconfig... "
512     ldconfig_paths=$(/sbin/ldconfig -N -X -v 2>/dev/null | sed -n -e 's,^\(/.*\):\( (.*)\)\?$,\1,p')
513     # Separate ldconfig_paths only on newline (not on any potential
514     # embedded space characters in any filenames). Note, we use a
515     # literal newline in the source here rather than something like:
516     #
517     #   IFS=$(printf '\n')
518     #
519     # because the shell's command substitution deletes any trailing newlines.
520     IFS="
521 "
522     for path in $ldconfig_paths; do
523         if [ "$path" = "$libdir_expanded" ]; then
524             libdir_in_ldconfig=1
525         fi
526     done
527     IFS=$DEFAULT_IFS
528     if [ "$libdir_in_ldconfig" = '0' ]; then
529         printf "No (will set RPATH)\n"
530     else
531         printf "Yes\n"
532     fi
533 else
534     printf "Unknown.\n"
535     cat <<EOF
536
537 *** Warning: Unknown platform. Notmuch might or might not build correctly.
538
539 EOF
540 fi
541
542 printf "Checking byte order... "
543 cat> _byteorder.c <<EOF
544 #include <stdio.h>
545 #include <stdint.h>
546 uint32_t test = 0x34333231;
547 int main() { printf("%.4s\n", (const char*)&test); return 0; }
548 EOF
549 ${CC} ${CFLAGS} _byteorder.c -o _byteorder > /dev/null 2>&1
550 util_byte_order=$(./_byteorder)
551 echo $util_byte_order
552
553 rm -f _byteorder _byteorder.c
554
555 if [ $errors -gt 0 ]; then
556     cat <<EOF
557
558 *** Error: The dependencies of notmuch could not be satisfied. You will
559 need to install the following packages before being able to compile
560 notmuch:
561
562 EOF
563     if [ $have_python -eq 0 ]; then
564         echo "  python interpreter"
565     fi
566     if [ $have_xapian -eq 0 ]; then
567         echo "  Xapian library (including development files such as headers)"
568         echo "  http://xapian.org/"
569     fi
570     if [ $have_zlib -eq 0 ]; then
571         echo "  zlib library (>= version 1.2.5.2, including development files such as headers)"
572         echo "  http://zlib.net/"
573         echo
574     fi
575     if [ $have_gmime -eq 0 ]; then
576         echo "  Either GMime 2.4 library" $GMIME_24_VERSION_CTR "or GMime 2.6 library" $GMIME_26_VERSION_CTR
577         echo "  (including development files such as headers)"
578         echo "  http://spruce.sourceforge.net/gmime/"
579         echo
580     fi
581     if [ $have_glib -eq 0 ]; then
582         echo "  Glib library >= 2.22 (including development files such as headers)"
583         echo "  http://ftp.gnome.org/pub/gnome/sources/glib/"
584         echo
585     fi
586     if [ $have_talloc -eq 0 ]; then
587         echo "  The talloc library (including development files such as headers)"
588         echo "  http://talloc.samba.org/"
589         echo
590     fi
591     cat <<EOF
592 With any luck, you're using a modern, package-based operating system
593 that has all of these packages available in the distribution. In that
594 case a simple command will install everything you need. For example:
595
596 On Debian and similar systems:
597
598         sudo apt-get install libxapian-dev libgmime-2.6-dev libtalloc-dev zlib1g-dev
599
600 Or on Fedora and similar systems:
601
602         sudo yum install xapian-core-devel gmime-devel libtalloc-devel zlib-devel
603
604 On other systems, similar commands can be used, but the details of the
605 package names may be different.
606
607 EOF
608     if [ $have_pkg_config -eq 0 ]; then
609 cat <<EOF
610 Note: the pkg-config program is not available. This configure script
611 uses pkg-config to find the compilation flags required to link against
612 the various libraries needed by notmuch. It's possible you simply need
613 to install pkg-config with a command such as:
614
615         sudo apt-get install pkg-config
616 Or:
617         sudo yum install pkgconfig
618
619 But if pkg-config is not available for your system, then you will need
620 to modify the configure script to manually set the cflags and ldflags
621 variables to the correct values to link against each library in each
622 case that pkg-config could not be used to determine those values.
623
624 EOF
625     fi
626 cat <<EOF
627 When you have installed the necessary dependencies, you can run
628 configure again to ensure the packages can be found, or simply run
629 "make" to compile notmuch.
630
631 EOF
632     exit 1
633 fi
634
635 printf "Checking for canonicalize_file_name... "
636 if ${CC} -o compat/have_canonicalize_file_name "$srcdir"/compat/have_canonicalize_file_name.c > /dev/null 2>&1
637 then
638     printf "Yes.\n"
639     have_canonicalize_file_name=1
640 else
641     printf "No (will use our own instead).\n"
642     have_canonicalize_file_name=0
643 fi
644 rm -f compat/have_canonicalize_file_name
645
646
647 printf "Checking for getline... "
648 if ${CC} -o compat/have_getline "$srcdir"/compat/have_getline.c > /dev/null 2>&1
649 then
650     printf "Yes.\n"
651     have_getline=1
652 else
653     printf "No (will use our own instead).\n"
654     have_getline=0
655 fi
656 rm -f compat/have_getline
657
658 printf "Checking for strcasestr... "
659 if ${CC} -o compat/have_strcasestr "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1
660 then
661     printf "Yes.\n"
662     have_strcasestr=1
663 else
664     printf "No (will use our own instead).\n"
665     have_strcasestr=0
666 fi
667 rm -f compat/have_strcasestr
668
669 printf "Checking for strsep... "
670 if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
671 then
672     printf "Yes.\n"
673     have_strsep="1"
674 else
675     printf "No (will use our own instead).\n"
676     have_strsep="0"
677 fi
678 rm -f compat/have_strsep
679
680 printf "Checking for timegm... "
681 if ${CC} -o compat/have_timegm "$srcdir"/compat/have_timegm.c > /dev/null 2>&1
682 then
683     printf "Yes.\n"
684     have_timegm="1"
685 else
686     printf "No (will use our own instead).\n"
687     have_timegm="0"
688 fi
689 rm -f compat/have_timegm
690
691 printf "Checking for dirent.d_type... "
692 if ${CC} -o compat/have_d_type "$srcdir"/compat/have_d_type.c > /dev/null 2>&1
693 then
694     printf "Yes.\n"
695     have_d_type="1"
696 else
697     printf "No (will use stat instead).\n"
698     have_d_type="0"
699 fi
700 rm -f compat/have_d_type
701
702 printf "Checking for standard version of getpwuid_r... "
703 if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
704 then
705     printf "Yes.\n"
706     std_getpwuid=1
707 else
708     printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
709     std_getpwuid=0
710 fi
711 rm -f compat/check_getpwuid
712
713 printf "Checking for standard version of asctime_r... "
714 if ${CC} -o compat/check_asctime "$srcdir"/compat/check_asctime.c > /dev/null 2>&1
715 then
716     printf "Yes.\n"
717     std_asctime=1
718 else
719     printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
720     std_asctime=0
721 fi
722 rm -f compat/check_asctime
723
724 printf "Checking for rpath support... "
725 if ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1
726 then
727     printf "Yes.\n"
728     rpath_ldflags="-Wl,--enable-new-dtags -Wl,-rpath,\$(libdir)"
729 else
730     printf "No (nothing to worry about).\n"
731     rpath_ldflags=""
732 fi
733
734 printf "Checking for -Wl,--as-needed... "
735 if ${CC} -Wl,--as-needed -o minimal minimal.c >/dev/null 2>&1
736 then
737     printf "Yes.\n"
738     as_needed_ldflags="-Wl,--as-needed"
739 else
740     printf "No (nothing to worry about).\n"
741     as_needed_ldflags=""
742 fi
743
744 WARN_CXXFLAGS=""
745 printf "Checking for available C++ compiler warning flags... "
746 for flag in -Wall -Wextra -Wwrite-strings; do
747     if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
748     then
749         WARN_CXXFLAGS="${WARN_CXXFLAGS}${WARN_CXXFLAGS:+ }${flag}"
750     fi
751 done
752 printf "\n\t${WARN_CXXFLAGS}\n"
753
754 WARN_CFLAGS="${WARN_CXXFLAGS}"
755 printf "Checking for available C compiler warning flags... "
756 for flag in -Wmissing-declarations; do
757     if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
758     then
759         WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
760     fi
761 done
762 printf "\n\t${WARN_CFLAGS}\n"
763
764 rm -f minimal minimal.c
765
766 # construct the Makefile.config
767 cat > Makefile.config <<EOF
768 # This Makefile.config was automatically generated by the ./configure
769 # script of notmuch. If the configure script identified anything
770 # incorrectly, then you can edit this file to try to correct things,
771 # but be warned that if configure is run again it will destroy your
772 # changes, (and this could happen by simply calling "make" if the
773 # configure script is updated).
774
775 # The top-level directory for the source, (the directory containing
776 # the configure script). This may be different than the build
777 # directory (the current directory at the time configure was run).
778 srcdir = ${srcdir}
779
780 # subdirectories to build
781 subdirs = ${subdirs}
782
783 configure_options = $@
784
785 # We use vpath directives (rather than the VPATH variable) since the
786 # VPATH variable matches targets as well as prerequisites, (which is
787 # not useful since then a target left-over from a srcdir build would
788 # cause a target to not be built in the non-srcdir build).
789 #
790 # Also, we don't use a single "vpath % \$(srcdir)" here because we
791 # don't want the vpath to trigger for our emacs lisp compilation,
792 # (unless we first find a way to convince emacs to build the .elc
793 # target in a directory other than the directory of the .el
794 # prerequisite). In the meantime, we're actually copying in the .el
795 # files, (which is quite ugly).
796 vpath %.c \$(srcdir)
797 vpath %.cc \$(srcdir)
798 vpath Makefile.% \$(srcdir)
799 vpath %.py \$(srcdir)
800 vpath %.rst \$(srcdir)
801
802 # The C compiler to use
803 CC = ${CC}
804
805 # The C++ compiler to use
806 CXX = ${CXX}
807
808 # Command to execute emacs from Makefiles
809 EMACS = emacs --quick
810
811 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
812 CFLAGS = ${CFLAGS}
813
814 # Default FLAGS for C preprocessor (can be overridden by user such as "make CPPFLAGS=-I/usr/local/include")
815 CPPFLAGS = ${CPPFLAGS}
816
817 # Default FLAGS for C++ compiler (can be overridden by user such as "make CXXFLAGS=-g")
818 CXXFLAGS = ${CXXFLAGS}
819
820 # Default FLAGS for the linker (can be overridden by user such as "make LDFLAGS=-znow")
821 LDFLAGS = ${LDFLAGS}
822
823 # Flags to enable warnings when using the C++ compiler
824 WARN_CXXFLAGS=${WARN_CXXFLAGS}
825
826 # Flags to enable warnings when using the C compiler
827 WARN_CFLAGS=${WARN_CFLAGS}
828
829 # Name of python interpreter
830 PYTHON = ${python}
831
832 # The prefix to which notmuch should be installed
833 # Note: If you change this value here, be sure to ensure that the
834 # LIBDIR_IN_LDCONFIG value below is still set correctly.
835 prefix = ${PREFIX}
836
837 # The directory to which libraries should be installed
838 # Note: If you change this value here, be sure to ensure that the
839 # LIBDIR_IN_LDCONFIG value below is still set correctly.
840 libdir = ${LIBDIR:=\$(prefix)/lib}
841
842 # byte order within a 32 bit word. 1234 = little, 4321 = big, 0 = guess
843 UTIL_BYTE_ORDER = ${util_byte_order}
844
845 # Whether libdir is in a path configured into ldconfig
846 LIBDIR_IN_LDCONFIG = ${libdir_in_ldconfig}
847
848 # The directory to which header files should be installed
849 includedir = ${INCLUDEDIR:=\$(prefix)/include}
850
851 # The directory to which man pages should be installed
852 mandir = ${MANDIR:=\$(prefix)/share/man}
853
854 # The directory to which read-only (configuration) files should be installed
855 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
856
857 # The directory to which emacs lisp files should be installed
858 emacslispdir=${EMACSLISPDIR}
859
860 # The directory to which emacs miscellaneous (machine-independent) files should
861 # be installed
862 emacsetcdir=${EMACSETCDIR}
863
864 # Whether there's an emacs binary available for byte-compiling
865 HAVE_EMACS = ${have_emacs}
866
867 # Whether there's a sphinx-build binary available for building documentation
868 HAVE_SPHINX=${have_sphinx}
869
870 # Whether there's a doxygen binary available for building api documentation
871 HAVE_DOXYGEN=${have_doxygen}
872
873 # The directory to which desktop files should be installed
874 desktop_dir = \$(prefix)/share/applications
875
876 # The directory to which bash completions files should be installed
877 bash_completion_dir = ${BASHCOMPLETIONDIR:=\$(sysconfdir)/bash_completion.d}
878
879 # The directory to which zsh completions files should be installed
880 zsh_completion_dir = ${ZSHCOMLETIONDIR:=\$(prefix)/share/zsh/functions/Completion/Unix}
881
882 # Whether the canonicalize_file_name function is available (if not, then notmuch will
883 # build its own version)
884 HAVE_CANONICALIZE_FILE_NAME = ${have_canonicalize_file_name}
885
886 # Whether the getline function is available (if not, then notmuch will
887 # build its own version)
888 HAVE_GETLINE = ${have_getline}
889
890 # Whether the strcasestr function is available (if not, then notmuch will
891 # build its own version)
892 HAVE_STRCASESTR = ${have_strcasestr}
893
894 # Whether the strsep function is available (if not, then notmuch will
895 # build its own version)
896 HAVE_STRSEP = ${have_strsep}
897
898 # Whether struct dirent has d_type (if not, then notmuch will use stat)
899 HAVE_D_TYPE = ${have_d_type}
900
901 # Whether the Xapian version in use supports compaction
902 HAVE_XAPIAN_COMPACT = ${have_xapian_compact}
903
904 # Whether the getpwuid_r function is standards-compliant
905 # (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
906 # to enable the standards-compliant version -- needed for Solaris)
907 STD_GETPWUID = ${std_getpwuid}
908
909 # Whether the asctime_r function is standards-compliant
910 # (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
911 # to enable the standards-compliant version -- needed for Solaris)
912 STD_ASCTIME = ${std_asctime}
913
914 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS, FREEBSD, OPENBSD
915 PLATFORM = ${platform}
916
917 # Whether the linker will automatically resolve the dependency of one
918 # library on another (if not, then linking a binary requires linking
919 # directly against both)
920 LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
921
922 # Flags needed to compile and link against Xapian
923 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
924 XAPIAN_LDFLAGS = ${xapian_ldflags}
925
926 # Flags needed to compile and link against GMime-2.4
927 GMIME_CFLAGS = ${gmime_cflags}
928 GMIME_LDFLAGS = ${gmime_ldflags}
929
930 # Flags needed to compile and link against zlib
931 ZLIB_CFLAGS = ${zlib_cflags}
932 ZLIB_LDFLAGS = ${zlib_ldflags}
933
934 # Flags needed to compile and link against talloc
935 TALLOC_CFLAGS = ${talloc_cflags}
936 TALLOC_LDFLAGS = ${talloc_ldflags}
937
938 # Flags needed to have linker set rpath attribute
939 RPATH_LDFLAGS = ${rpath_ldflags}
940
941 # Flags needed to have linker link only to necessary libraries
942 AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
943
944 # Whether valgrind header files are available
945 HAVE_VALGRIND = ${have_valgrind}
946
947 # And if so, flags needed at compile time for valgrind macros
948 VALGRIND_CFLAGS = ${valgrind_cflags}
949
950 # Support for emacs
951 WITH_EMACS = ${WITH_EMACS}
952
953 # Support for bash completion
954 WITH_BASH = ${WITH_BASH}
955
956 # Support for zsh completion
957 WITH_ZSH = ${WITH_ZSH}
958
959 # Combined flags for compiling and linking against all of the above
960 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\
961                    -DHAVE_CANONICALIZE_FILE_NAME=\$(HAVE_CANONICALIZE_FILE_NAME) \\
962                    \$(ZLIB_CFLAGS)                                       \\
963                    \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\
964                    \$(VALGRIND_CFLAGS)                                   \\
965                    -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)                 \\
966                    -DHAVE_STRSEP=\$(HAVE_STRSEP)                         \\
967                    -DHAVE_D_TYPE=\$(HAVE_D_TYPE)                         \\
968                    -DSTD_GETPWUID=\$(STD_GETPWUID)                       \\
969                    -DSTD_ASCTIME=\$(STD_ASCTIME)                         \\
970                    -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)         \\
971                    -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER)
972
973 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\
974                      -DHAVE_CANONICALIZE_FILE_NAME=\$(HAVE_CANONICALIZE_FILE_NAME) \\
975                      \$(ZLIB_CFLAGS)                                     \\
976                      \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
977                      \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\
978                      -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)               \\
979                      -DHAVE_STRSEP=\$(HAVE_STRSEP)                       \\
980                      -DHAVE_D_TYPE=\$(HAVE_D_TYPE)                       \\
981                      -DSTD_GETPWUID=\$(STD_GETPWUID)                     \\
982                      -DSTD_ASCTIME=\$(STD_ASCTIME)                       \\
983                      -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)       \\
984                      -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER)
985
986 CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(ZLIB_LDFLAGS) \$(XAPIAN_LDFLAGS)
987 EOF
988
989 # construct the sh.config
990 cat > sh.config <<EOF
991 # This sh.config was automatically generated by the ./configure
992 # script of notmuch.
993
994 # Whether the Xapian version in use supports compaction
995 NOTMUCH_HAVE_XAPIAN_COMPACT=${have_xapian_compact}
996
997 # do we have man pages?
998 NOTMUCH_HAVE_MAN=$((have_sphinx))
999
1000 # Name of python interpreter
1001 NOTMUCH_PYTHON=${python}
1002 EOF
1003
1004 # Finally, after everything configured, inform the user how to continue.
1005 cat <<EOF
1006
1007 All required packages were found. You may now run the following
1008 commands to compile and install notmuch:
1009
1010         make
1011         sudo make install
1012
1013 EOF