]> git.notmuchmail.org Git - notmuch/blob - configure
test: regression tests for n_d_status_string and n_d_get_path
[notmuch] / configure
1 #! /bin/sh
2
3 set -u
4
5 # Test whether this shell is capable of parameter substring processing.
6 ( option='a/b'; : ${option#*/} ) 2>/dev/null || {
7     echo "
8 The shell interpreting '$0' is lacking some required features.
9
10 To work around this problem you may try to execute:
11
12     ksh $0 $*
13  or
14     bash $0 $*
15 "
16     exit 1
17 }
18
19 # Store original IFS value so it can be changed (and restored) in many places.
20 readonly DEFAULT_IFS="$IFS"
21
22 # The top-level directory for the source. This ./configure and all Makefiles
23 # are good with ${srcdir} usually being relative. Some components (e.g. tests)
24 # are executed in subdirectories and for those it is simpler to use
25 # ${NOTMUCH_SRCDIR} which holds absolute path to the source.
26 srcdir=$(dirname "$0")
27 NOTMUCH_SRCDIR=$(cd "$srcdir" && pwd)
28
29 case $NOTMUCH_SRCDIR in ( *\'* | *['\"`$']* )
30         echo "Definitely unsafe characters in source path '$NOTMUCH_SRCDIR'".
31         exit 1
32 esac
33
34 case $PWD in ( *\'* | *['\"`$']* )
35         echo "Definitely unsafe characters in current directory '$PWD'".
36         exit 1
37 esac
38
39 # In case of whitespace, builds may work, tests definitely will not.
40 case $NOTMUCH_SRCDIR in ( *["$IFS"]* )
41         echo "Whitespace in source path '$NOTMUCH_SRCDIR' not supported".
42         exit 1
43 esac
44
45 case $PWD in ( *["$IFS"]* )
46         echo "Whitespace in current directory '$PWD' not supported".
47         exit 1
48 esac
49
50 subdirs="util compat lib parse-time-string completion doc emacs"
51 subdirs="${subdirs} performance-test test"
52 subdirs="${subdirs} bindings"
53
54 # For a non-srcdir configure invocation (such as ../configure), create
55 # the directory structure and copy Makefiles.
56 if [ "$srcdir" != "." ]; then
57
58     for dir in . ${subdirs}; do
59         mkdir -p "$dir"
60         cp "$srcdir"/"$dir"/Makefile.local "$dir"
61         cp "$srcdir"/"$dir"/Makefile "$dir"
62     done
63
64     # Emacs only likes to generate compiled files next to the .el files
65     # by default so copy these as well (which is not ideal).
66     cp -a "$srcdir"/emacs/*.el emacs
67
68     # We were not able to create fully working Makefile using ruby mkmf.rb
69     # so ruby bindings source files are copied as well (ditto -- not ideal).
70     mkdir bindings/ruby
71     cp -a "$srcdir"/bindings/ruby/*.[ch] bindings/ruby
72     cp -a "$srcdir"/bindings/ruby/extconf.rb bindings/ruby
73
74     # Use the same hack to replicate python-cffi source for
75     # out-of-tree builds (again, not ideal).
76     mkdir bindings/python-cffi
77     cp -a "$srcdir"/bindings/python-cffi/tests \
78        "$srcdir"/bindings/python-cffi/notmuch2 \
79        "$srcdir"/bindings/python-cffi/setup.py \
80        bindings/python-cffi/
81 fi
82
83 # Set several defaults (optionally specified by the user in
84 # environment variables)
85 BASHCMD=${BASHCMD:-bash}
86 PERL=${PERL:-perl}
87 CC=${CC:-cc}
88 CXX=${CXX:-c++}
89 CFLAGS=${CFLAGS:--g -O2}
90 CPPFLAGS=${CPPFLAGS:-}
91 CXXFLAGS_for_sh=${CXXFLAGS:-${CFLAGS}}
92 CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
93 LDFLAGS=${LDFLAGS:-}
94 XAPIAN_CONFIG=${XAPIAN_CONFIG:-}
95 PYTHON=${PYTHON:-}
96 RUBY=${RUBY:-ruby}
97
98 # We don't allow the EMACS or GZIP Makefile variables inherit values
99 # from the environment as we do with CC and CXX above. The reason is
100 # that these names as environment variables have existing uses other
101 # than the program name that we want. (EMACS is set to 't' when a
102 # shell is running within emacs and GZIP specifies arguments to pass
103 # on the gzip command line).
104
105 # Set the defaults for values the user can specify with command-line
106 # options.
107 PREFIX=/usr/local
108 LIBDIR=
109 WITH_DOCS=1
110 WITH_API_DOCS=1
111 WITH_PYTHON_DOCS=1
112 WITH_EMACS=1
113 WITH_DESKTOP=1
114 WITH_BASH=1
115 WITH_RPATH=1
116 WITH_RUBY=1
117 WITH_ZSH=1
118 WITH_RETRY_LOCK=1
119
120 usage ()
121 {
122     cat <<EOF
123 Usage: ./configure [options]...
124
125 This script configures notmuch to build on your system.
126
127 It verifies that dependencies are available, determines flags needed
128 to compile and link against various required libraries, and identifies
129 whether various system functions can be used or if locally-provided
130 replacements will be built instead.
131
132 Finally, it allows you to control various aspects of the build and
133 installation process.
134
135 First, some common variables can specified via environment variables:
136
137         CC              The C compiler to use
138         CFLAGS          Flags to pass to the C compiler
139         CPPFLAGS        Flags to pass to the C preprocessor
140         CXX             The C++ compiler to use
141         CXXFLAGS        Flags to pass to the C compiler
142         LDFLAGS         Flags to pass when linking
143
144 Each of these values can further be controlled by specifying them
145 later on the "make" command line.
146
147 Other environment variables can be used to control configure itself,
148 (and for which there is no equivalent build-time control):
149
150         XAPIAN_CONFIG   The program to use to determine flags for
151                         compiling and linking against the Xapian
152                         library. [$XAPIAN_CONFIG]
153         PYTHON          Name of python command to use in
154                         configure and the test suite.
155         RUBY            Name of ruby command to use in
156                         configure and the test suite.
157
158 Additionally, various options can be specified on the configure
159 command line.
160
161         --prefix=PREFIX Install files in PREFIX [$PREFIX]
162
163 By default, "make install" will install the resulting program to
164 $PREFIX/bin, documentation to $PREFIX/man, etc. You can
165 specify an installation prefix other than $PREFIX using
166 --prefix, for instance:
167
168         ./configure --prefix=\$HOME
169
170 Fine tuning of some installation directories is available:
171
172         --libdir=DIR            Install libraries to DIR [PREFIX/lib]
173         --includedir=DIR        Install header files to DIR [PREFIX/include]
174         --mandir=DIR            Install man pages to DIR [PREFIX/share/man]
175         --infodir=DIR           Install man pages to DIR [PREFIX/share/man]
176         --sysconfdir=DIR        Read-only single-machine data [PREFIX/etc]
177         --emacslispdir=DIR      Emacs code [PREFIX/share/emacs/site-lisp]
178         --emacsetcdir=DIR       Emacs miscellaneous files [PREFIX/share/emacs/site-lisp]
179         --bashcompletiondir=DIR Bash completions files [PREFIX/share/bash-completion/completions]
180         --zshcompletiondir=DIR  Zsh completions files [PREFIX/share/zsh/site-functions]
181
182 Some features can be disabled (--with-feature=no is equivalent to
183 --without-feature) :
184
185         --without-bash-completion       Do not install bash completions files
186         --without-docs                  Do not install documentation
187         --without-api-docs              Do not install API man page
188         --without-emacs                 Do not install lisp file
189         --without-desktop               Do not install desktop file
190         --without-ruby                  Do not install ruby bindings
191         --without-zsh-completion        Do not install zsh completions files
192         --without-retry-lock            Do not use blocking xapian opens, even if available
193
194 Additional options are accepted for compatibility with other
195 configure-script calling conventions, but don't do anything yet:
196
197         --build=<cpu>-<vendor>-<os>     Currently ignored
198         --host=<cpu>-<vendor>-<os>      Currently ignored
199         --datadir=DIR                   Currently ignored
200         --localstatedir=DIR             Currently ignored
201         --libexecdir=DIR                Currently ignored
202         --disable-maintainer-mode       Currently ignored
203         --disable-dependency-tracking   Currently ignored
204
205 EOF
206 }
207
208 # Parse command-line options
209 for option; do
210     if [ "${option}" = '--help' ] ; then
211         usage
212         exit 0
213     elif [ "${option%%=*}" = '--prefix' ] ; then
214         PREFIX="${option#*=}"
215     elif [ "${option%%=*}" = '--libdir' ] ; then
216         LIBDIR="${option#*=}"
217     elif [ "${option%%=*}" = '--includedir' ] ; then
218         INCLUDEDIR="${option#*=}"
219     elif [ "${option%%=*}" = '--mandir' ] ; then
220         MANDIR="${option#*=}"
221     elif [ "${option%%=*}" = '--infodir' ] ; then
222         INFODIR="${option#*=}"
223     elif [ "${option%%=*}" = '--sysconfdir' ] ; then
224         SYSCONFDIR="${option#*=}"
225     elif [ "${option%%=*}" = '--emacslispdir' ] ; then
226         EMACSLISPDIR="${option#*=}"
227     elif [ "${option%%=*}" = '--emacsetcdir' ] ; then
228         EMACSETCDIR="${option#*=}"
229     elif [ "${option%%=*}" = '--bashcompletiondir' ] ; then
230         BASHCOMPLETIONDIR="${option#*=}"
231     elif [ "${option%%=*}" = '--zshcompletiondir' ] ; then
232         ZSHCOMLETIONDIR="${option#*=}"
233     elif [ "${option%%=*}" = '--with-docs' ]; then
234         if [ "${option#*=}" = 'no' ]; then
235             WITH_DOCS=0
236             WITH_API_DOCS=0
237         else
238             WITH_DOCS=1
239         fi
240     elif [ "${option}" = '--without-docs' ] ; then
241         WITH_DOCS=0
242         WITH_API_DOCS=0
243     elif [ "${option%%=*}" = '--with-api-docs' ]; then
244         if [ "${option#*=}" = 'no' ]; then
245             WITH_API_DOCS=0
246         else
247             WITH_API_DOCS=1
248         fi
249     elif [ "${option}" = '--without-api-docs' ] ; then
250         WITH_API_DOCS=0
251     elif [ "${option%%=*}" = '--with-emacs' ]; then
252         if [ "${option#*=}" = 'no' ]; then
253             WITH_EMACS=0
254         else
255             WITH_EMACS=1
256         fi
257     elif [ "${option}" = '--without-emacs' ] ; then
258         WITH_EMACS=0
259     elif [ "${option%%=*}" = '--with-desktop' ]; then
260         if [ "${option#*=}" = 'no' ]; then
261             WITH_DESKTOP=0
262         else
263             WITH_DESKTOP=1
264         fi
265     elif [ "${option}" = '--without-desktop' ] ; then
266         WITH_DESKTOP=0
267     elif [ "${option%%=*}" = '--with-bash-completion' ]; then
268         if [ "${option#*=}" = 'no' ]; then
269             WITH_BASH=0
270         else
271             WITH_BASH=1
272         fi
273     elif [ "${option}" = '--without-bash-completion' ] ; then
274         WITH_BASH=0
275     elif [ "${option%%=*}" = '--with-rpath' ]; then
276         if [ "${option#*=}" = 'no' ]; then
277             WITH_RPATH=0
278         else
279             WITH_RPATH=1
280         fi
281     elif [ "${option}" = '--without-rpath' ] ; then
282         WITH_RPATH=0
283     elif [ "${option%%=*}" = '--with-ruby' ]; then
284         if [ "${option#*=}" = 'no' ]; then
285             WITH_RUBY=0
286         else
287             WITH_RUBY=1
288         fi
289     elif [ "${option}" = '--without-ruby' ] ; then
290         WITH_RUBY=0
291     elif [ "${option%%=*}" = '--with-retry-lock' ]; then
292         if [ "${option#*=}" = 'no' ]; then
293             WITH_RETRY_LOCK=0
294         else
295             WITH_RETRY_LOCK=1
296         fi
297     elif [ "${option}" = '--without-retry-lock' ] ; then
298         WITH_RETRY_LOCK=0
299     elif [ "${option%%=*}" = '--with-zsh-completion' ]; then
300         if [ "${option#*=}" = 'no' ]; then
301             WITH_ZSH=0
302         else
303             WITH_ZSH=1
304         fi
305     elif [ "${option}" = '--without-zsh-completion' ] ; then
306         WITH_ZSH=0
307     elif [ "${option%%=*}" = '--build' ] ; then
308         true
309     elif [ "${option%%=*}" = '--host' ] ; then
310         true
311     elif [ "${option%%=*}" = '--datadir' ] ; then
312         true
313     elif [ "${option%%=*}" = '--localstatedir' ] ; then
314         true
315     elif [ "${option%%=*}" = '--libexecdir' ] ; then
316         true
317     elif [ "${option}" = '--disable-maintainer-mode' ] ; then
318         true
319     elif [ "${option}" = '--disable-dependency-tracking' ] ; then
320         true
321     else
322         echo "Unrecognized option: ${option}"
323         echo "See:"
324         echo "  $0 --help"
325         echo ""
326         exit 1
327     fi
328 done
329
330 # We set this value early, (rather than just while printing the
331 # Makefile.config file later like most values), because we need to
332 # actually investigate this value compared to the ldconfig_paths value
333 # below.
334 if [ -z "$LIBDIR" ] ; then
335     libdir_expanded="${PREFIX}/lib"
336 else
337     # very non-general variable expansion
338     libdir_expanded=$(printf %s "$LIBDIR" | sed "s|\${prefix}|${PREFIX}|; s|\$prefix\>|${PREFIX}|; s|//*|/|g")
339 fi
340
341 cat <<EOF
342 Welcome to Notmuch, a system for indexing, searching and tagging your email.
343
344 We hope that the process of building and installing notmuch is quick
345 and smooth so that you can soon be reading and processing your email
346 more efficiently than ever.
347
348 If anything goes wrong in the configure process, you can override any
349 decisions it makes by manually editing the Makefile.config file that
350 it creates. Also please do as much as you can to figure out what could
351 be different on your machine compared to those of the notmuch
352 developers. Then, please email those details to the Notmuch list
353 (notmuch@notmuchmail.org) so that we can hopefully make future
354 versions of notmuch easier for you to use.
355
356 We'll now investigate your system to verify that all required
357 dependencies are available:
358
359 EOF
360
361 errors=0
362 printf "int main(void){return 0;}\n" > minimal.c
363
364 printf "Sanity checking C compilation environment... "
365 test_cmdline="${CC} ${CFLAGS} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal"
366 if  ${test_cmdline} > /dev/null 2>&1
367 then
368     printf "OK.\n"
369 else
370     printf "Fail.\n"
371     errors=$((errors + 1))
372     printf Executed:; printf ' %s' ${test_cmdline}; echo
373     ${test_cmdline}
374 fi
375
376 printf "Sanity checking C++ compilation environment... "
377 test_cmdline="${CXX} ${CXXFLAGS_for_sh} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal"
378 if ${test_cmdline} > /dev/null 2>&1
379 then
380     printf "OK.\n"
381 else
382     printf "Fail.\n"
383     errors=$((errors + 1))
384     printf Executed:; printf ' %s' ${test_cmdline}; echo
385     ${test_cmdline}
386 fi
387 unset test_cmdline
388
389 if [ $errors -gt 0 ]; then
390     cat <<EOF
391 *** Error: Initial sanity checking of environment failed.  Please try
392 running configure in a clean environment, and if the problem persists,
393 report a bug.
394 EOF
395     rm -f minimal minimal.c
396     exit 1
397 fi
398
399 printf "Reading libnotmuch version from source... "
400 cat > _libversion.c <<EOF
401 #include <stdio.h>
402 #include "lib/notmuch.h"
403 int main(void) {
404     printf("libnotmuch_version_major=%d\n",
405                 LIBNOTMUCH_MAJOR_VERSION);
406     printf("libnotmuch_version_minor=%d\n",
407                 LIBNOTMUCH_MINOR_VERSION);
408     printf("libnotmuch_version_release=%d\n",
409                 LIBNOTMUCH_MICRO_VERSION);
410     return 0;
411 }
412 EOF
413 if ${CC} ${CFLAGS} -I"$srcdir" _libversion.c -o _libversion > /dev/null 2>&1 \
414        && ./_libversion > _libversion.sh && . ./_libversion.sh
415 then
416     printf "OK.\n"
417 else
418     cat <<EOF
419
420 *** Error: Reading lib/notmuch.h failed.
421 Please try running configure again in a clean environment, and if the
422 problem persists, report a bug.
423 EOF
424     rm -f _libversion _libversion.c _libversion.sh
425     exit 1
426 fi
427
428 if pkg-config --version > /dev/null 2>&1; then
429     have_pkg_config=1
430 else
431     have_pkg_config=0
432 fi
433
434
435
436 printf "Checking for Xapian development files (>= 1.4.0)... "
437 have_xapian=0
438 for xapian_config in ${XAPIAN_CONFIG} xapian-config; do
439     if ${xapian_config} --version > /dev/null 2>&1; then
440         xapian_version=$(${xapian_config} --version | sed -e 's/.* //')
441         case $xapian_version in
442                 1.[4-9]* | 1.[1-9][0-9]* | [2-9]* | [1-9][0-9]*)
443                         printf "Yes (%s).\n" ${xapian_version}
444                         have_xapian=1
445                         xapian_cxxflags=$(${xapian_config} --cxxflags)
446                         xapian_ldflags=$(${xapian_config} --libs)
447                         ;;
448                 *) printf "Xapian $xapian_version not supported... "
449         esac
450         break
451     fi
452 done
453 if [ ${have_xapian} = "0" ]; then
454     printf "No.\n"
455     errors=$((errors + 1))
456 fi
457
458 if [ ${have_xapian} = "1" ]; then
459     default_xapian_backend=""
460     printf "Testing default Xapian backend... "
461     cat >_default_backend.cc <<EOF
462 #include <xapian.h>
463 int main(int argc, char** argv) {
464    Xapian::WritableDatabase db("test.db",Xapian::DB_CREATE_OR_OPEN);
465 }
466 EOF
467     ${CXX} ${CXXFLAGS_for_sh} ${xapian_cxxflags} _default_backend.cc -o _default_backend ${xapian_ldflags}
468     ./_default_backend
469     if [ -f test.db/iamglass ]; then
470         default_xapian_backend=glass
471     else
472         default_xapian_backend=chert
473     fi
474     printf "%s\n" "${default_xapian_backend}";
475     rm -rf test.db _default_backend _default_backend.cc
476 fi
477
478 GMIME_MINVER=3.0.3
479
480 printf "Checking for GMime development files (>= $GMIME_MINVER)... "
481 if pkg-config --exists "gmime-3.0 >= $GMIME_MINVER"; then
482     printf "Yes.\n"
483     have_gmime=1
484     gmime_cflags=$(pkg-config --cflags gmime-3.0)
485     gmime_ldflags=$(pkg-config --libs gmime-3.0)
486
487     printf "Checking for GMime session key extraction support... "
488
489     cat > _check_session_keys.c <<EOF
490 #include <gmime/gmime.h>
491 #include <stdio.h>
492
493 int main () {
494     GError *error = NULL;
495     GMimeParser *parser = NULL;
496     GMimeMultipartEncrypted *body = NULL;
497     GMimeDecryptResult *decrypt_result = NULL;
498     GMimeObject *output = NULL;
499
500     g_mime_init ();
501     parser = g_mime_parser_new ();
502     g_mime_parser_init_with_stream (parser, g_mime_stream_file_open("$srcdir/test/corpora/crypto/basic-encrypted.eml", "r", &error));
503     if (error) return !! fprintf (stderr, "failed to instantiate parser with test/corpora/crypto/basic-encrypted.eml\n");
504
505     body = GMIME_MULTIPART_ENCRYPTED(g_mime_message_get_mime_part (g_mime_parser_construct_message (parser, NULL)));
506     if (body == NULL) return !! fprintf (stderr, "did not find a multipart encrypted message\n");
507
508     output = g_mime_multipart_encrypted_decrypt (body, GMIME_DECRYPT_EXPORT_SESSION_KEY, NULL, &decrypt_result, &error);
509     if (error || output == NULL) return !! fprintf (stderr, "decryption failed\n");
510
511     if (decrypt_result == NULL) return !! fprintf (stderr, "no GMimeDecryptResult found\n");
512     if (decrypt_result->session_key == NULL) return !! fprintf (stderr, "GMimeDecryptResult has no session key\n");
513
514     printf ("%s\n", decrypt_result->session_key);
515     return 0;
516 }
517 EOF
518     if ! TEMP_GPG=$(mktemp -d "${TMPDIR:-/tmp}/notmuch.XXXXXX"); then
519         printf 'No.\nCould not make tempdir for testing session-key support.\n'
520         errors=$((errors + 1))
521     elif ${CC} ${CFLAGS} ${gmime_cflags} _check_session_keys.c ${gmime_ldflags} -o _check_session_keys \
522            && GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < "$srcdir"/test/gnupg-secret-key.asc \
523            && SESSION_KEY=$(GNUPGHOME=${TEMP_GPG} ./_check_session_keys) \
524            && [ $SESSION_KEY = 9:0BACD64099D1468AB07C796F0C0AC4851948A658A15B34E803865E9FC635F2F5 ]
525     then
526         printf "OK.\n"
527     else
528         cat <<EOF
529 No.
530 *** Error: Could not extract session keys from encrypted message.
531
532 This is likely due to your GMime having been built against a old
533 version of GPGME.
534
535 Please try to rebuild your version of GMime against a more recent
536 version of GPGME (at least GPGME 1.8.0).
537 EOF
538         if command -v gpgme-config >/dev/null; then
539             printf 'Your current GPGME development version is: %s\n' "$(gpgme-config --version)"
540         else
541             printf 'You do not have the GPGME development libraries installed.\n'
542         fi
543         errors=$((errors + 1))
544     fi
545     if [ -n "$TEMP_GPG" -a -d "$TEMP_GPG" ]; then
546         rm -rf "$TEMP_GPG"
547     fi
548
549     # see https://github.com/jstedfast/gmime/pull/90
550     # should be fixed in GMime in 3.2.7, but some distros might patch
551     printf "Checking for GMime X.509 certificate validity... "
552
553     cat > _check_x509_validity.c <<EOF
554 #include <stdio.h>
555 #include <gmime/gmime.h>
556
557 int main () {
558     GError *error = NULL;
559     GMimeParser *parser = NULL;
560     GMimeApplicationPkcs7Mime *body = NULL;
561     GMimeSignatureList *sig_list = NULL;
562     GMimeSignature *sig = NULL;
563     GMimeCertificate *cert = NULL;
564     GMimeObject *output = NULL;
565     GMimeValidity validity = GMIME_VALIDITY_UNKNOWN;
566     int len;
567
568     g_mime_init ();
569     parser = g_mime_parser_new ();
570     g_mime_parser_init_with_stream (parser, g_mime_stream_file_open("$srcdir/test/corpora/pkcs7/smime-onepart-signed.eml", "r", &error));
571     if (error) return !! fprintf (stderr, "failed to instantiate parser with test/corpora/pkcs7/smime-onepart-signed.eml\n");
572
573     body = GMIME_APPLICATION_PKCS7_MIME(g_mime_message_get_mime_part (g_mime_parser_construct_message (parser, NULL)));
574     if (body == NULL) return !! fprintf (stderr, "did not find a application/pkcs7 message\n");
575
576     sig_list = g_mime_application_pkcs7_mime_verify (body, GMIME_VERIFY_NONE, &output, &error);
577     if (error || output == NULL) return !! fprintf (stderr, "verify failed\n");
578
579     if (sig_list == NULL) return !! fprintf (stderr, "no GMimeSignatureList found\n");
580     len = g_mime_signature_list_length (sig_list);
581     if (len != 1) return !! fprintf (stderr, "expected 1 signature, got %d\n", len);
582     sig = g_mime_signature_list_get_signature (sig_list, 0);
583     if (sig == NULL) return !! fprintf (stderr, "no GMimeSignature found at position 0\n");
584     cert = g_mime_signature_get_certificate (sig);
585     if (cert == NULL) return !! fprintf (stderr, "no GMimeCertificate found\n");
586     validity = g_mime_certificate_get_id_validity (cert);
587     if (validity != GMIME_VALIDITY_FULL) return !! fprintf (stderr, "Got validity %d, expected %d\n", validity, GMIME_VALIDITY_FULL);
588
589     return 0;
590 }
591 EOF
592     if ! TEMP_GPG=$(mktemp -d "${TMPDIR:-/tmp}/notmuch.XXXXXX"); then
593         printf 'No.\nCould not make tempdir for testing X.509 certificate validity support.\n'
594         errors=$((errors + 1))
595     elif ${CC} ${CFLAGS} ${gmime_cflags} _check_x509_validity.c ${gmime_ldflags} -o _check_x509_validity \
596             && echo disable-crl-checks > "$TEMP_GPG/gpgsm.conf" \
597             && echo "4D:E0:FF:63:C0:E9:EC:01:29:11:C8:7A:EE:DA:3A:9A:7F:6E:C1:0D S" >> "$TEMP_GPG/trustlist.txt" \
598             && GNUPGHOME=${TEMP_GPG} gpgsm --batch --quiet --import < "$srcdir"/test/smime/ca.crt
599     then
600         if GNUPGHOME=${TEMP_GPG} ./_check_x509_validity; then
601             gmime_x509_cert_validity=1
602             printf "Yes.\n"
603         else
604             gmime_x509_cert_validity=0
605             printf "No.\n"
606             if pkg-config --exists "gmime-3.0 >= 3.2.7"; then
607                 cat <<EOF
608 *** Error: GMime fails to calculate X.509 certificate validity, and
609 is later than 3.2.7, which should have fixed this issue.
610
611 Please follow up on https://github.com/jstedfast/gmime/pull/90 with
612 more details.
613 EOF
614                 errors=$((errors + 1))
615             fi
616         fi
617     else
618         printf 'No.\nFailed to set up gpgsm for testing X.509 certificate validity support.\n'
619         errors=$((errors + 1))
620     fi
621     if [ -n "$TEMP_GPG" -a -d "$TEMP_GPG" ]; then
622         rm -rf "$TEMP_GPG"
623     fi
624
625     # see https://dev.gnupg.org/T3464
626     # there are problems verifying signatures when decrypting with session keys with GPGME 1.13.0 and 1.13.1
627     printf "Checking signature verification when decrypting using session keys... "
628
629     cat > _verify_sig_with_session_key.c <<EOF
630 #include <stdio.h>
631 #include <gmime/gmime.h>
632
633 int main () {
634     GError *error = NULL;
635     GMimeParser *parser = NULL;
636     GMimeMultipartEncrypted *body = NULL;
637     GMimeDecryptResult *result = NULL;
638     GMimeSignatureList *sig_list = NULL;
639     GMimeSignature *sig = NULL;
640     GMimeObject *output = NULL;
641     GMimeSignatureStatus status;
642     int len;
643
644     g_mime_init ();
645     parser = g_mime_parser_new ();
646     g_mime_parser_init_with_stream (parser, g_mime_stream_file_open("$srcdir/test/corpora/crypto/encrypted-signed.eml", "r", &error));
647     if (error) return !! fprintf (stderr, "failed to instantiate parser with test/corpora/pkcs7/smime-onepart-signed.eml\n");
648
649     body = GMIME_MULTIPART_ENCRYPTED(g_mime_message_get_mime_part (g_mime_parser_construct_message (parser, NULL)));
650     if (body == NULL) return !! fprintf (stderr, "did not find a multipart/encrypted message\n");
651
652     output = g_mime_multipart_encrypted_decrypt (body, GMIME_DECRYPT_NONE, "9:13607E4217515A70EC8DF9DBC16C5327B94577561D98AD1246FA8756659C7899", &result, &error);
653     if (error || output == NULL) return !! fprintf (stderr, "decrypt failed\n");
654
655     sig_list = g_mime_decrypt_result_get_signatures (result);
656     if (sig_list == NULL) return !! fprintf (stderr, "sig_list is NULL\n");
657
658     if (sig_list == NULL) return !! fprintf (stderr, "no GMimeSignatureList found\n");
659     len = g_mime_signature_list_length (sig_list);
660     if (len != 1) return !! fprintf (stderr, "expected 1 signature, got %d\n", len);
661     sig = g_mime_signature_list_get_signature (sig_list, 0);
662     if (sig == NULL) return !! fprintf (stderr, "no GMimeSignature found at position 0\n");
663     status = g_mime_signature_get_status (sig);
664     if (status & GMIME_SIGNATURE_STATUS_KEY_MISSING) return !! fprintf (stderr, "signature status contains KEY_MISSING (see https://dev.gnupg.org/T3464)\n");
665
666     return 0;
667 }
668 EOF
669     if ! TEMP_GPG=$(mktemp -d "${TMPDIR:-/tmp}/notmuch.XXXXXX"); then
670         printf 'No.\nCould not make tempdir for testing signature verification when decrypting with session keys.\n'
671         errors=$((errors + 1))
672     elif ${CC} ${CFLAGS} ${gmime_cflags} _verify_sig_with_session_key.c ${gmime_ldflags} -o _verify_sig_with_session_key \
673             && GNUPGHOME=${TEMP_GPG} gpg --batch --quiet --import < "$srcdir"/test/gnupg-secret-key.asc \
674             && rm -f ${TEMP_GPG}/private-keys-v1.d/*.key
675     then
676         if GNUPGHOME=${TEMP_GPG} ./_verify_sig_with_session_key; then
677             gmime_verify_with_session_key=1
678             printf "Yes.\n"
679         else
680             gmime_verify_with_session_key=0
681             printf "No.\n"
682             cat <<EOF
683 *** Error: GMime fails to verify signatures when decrypting with a session key.
684
685 This is most likely due to a buggy version of GPGME, which should be fixed in 1.13.2 or later.
686 See https://dev.gnupg.org/T3464 for more details.
687 EOF
688         fi
689     else
690         printf 'No.\nFailed to set up gpg for testing signature verification while decrypting with a session key.\n'
691         errors=$((errors + 1))
692     fi
693     if [ -n "$TEMP_GPG" -a -d "$TEMP_GPG" ]; then
694         rm -rf "$TEMP_GPG"
695     fi
696 else
697     have_gmime=0
698     printf "No.\n"
699     errors=$((errors + 1))
700 fi
701
702 # GMime already depends on Glib >= 2.12, but we use at least one Glib
703 # function that only exists as of 2.22, (g_array_unref)
704 printf "Checking for Glib development files (>= 2.22)... "
705 have_glib=0
706 if pkg-config --exists 'glib-2.0 >= 2.22'; then
707     printf "Yes.\n"
708     have_glib=1
709     # these are included in gmime cflags and ldflags
710     # glib_cflags=$(pkg-config --cflags glib-2.0)
711     # glib_ldflags=$(pkg-config --libs glib-2.0)
712 else
713     printf "No.\n"
714     errors=$((errors + 1))
715 fi
716
717 if ! pkg-config --exists zlib; then
718   ${CC} -o compat/gen_zlib_pc "$srcdir"/compat/gen_zlib_pc.c >/dev/null 2>&1 &&
719   compat/gen_zlib_pc > compat/zlib.pc &&
720   PKG_CONFIG_PATH=${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}compat &&
721   export PKG_CONFIG_PATH
722   rm -f compat/gen_zlib_pc
723 fi
724
725 printf "Checking for zlib (>= 1.2.5.2)... "
726 have_zlib=0
727 if pkg-config --atleast-version=1.2.5.2 zlib; then
728     printf "Yes.\n"
729     have_zlib=1
730     zlib_cflags=$(pkg-config --cflags zlib)
731     zlib_ldflags=$(pkg-config --libs zlib)
732 else
733     printf "No.\n"
734     errors=$((errors + 1))
735 fi
736
737 printf "Checking for talloc development files... "
738 if pkg-config --exists talloc; then
739     printf "Yes.\n"
740     have_talloc=1
741     talloc_cflags=$(pkg-config --cflags talloc)
742     talloc_ldflags=$(pkg-config --libs talloc)
743 else
744     printf "No.\n"
745     have_talloc=0
746     talloc_cflags=
747     errors=$((errors + 1))
748 fi
749
750 printf "Checking for bash... "
751 if command -v ${BASHCMD} > /dev/null; then
752     have_bash=1
753     bash_absolute=$(command -v ${BASHCMD})
754     printf "Yes (%s).\n" "$bash_absolute"
755 else
756     have_bash=0
757     printf "No. (%s not found)\n" "${BASHCMD}"
758 fi
759
760 printf "Checking for perl... "
761 if command -v ${PERL} > /dev/null; then
762     have_perl=1
763     perl_absolute=$(command -v ${PERL})
764     printf "Yes (%s).\n" "$perl_absolute"
765 else
766     have_perl=0
767     printf "No. (%s not found)\n" "${PERL}"
768 fi
769
770 printf "Checking for python... "
771 have_python=0
772
773 for name in ${PYTHON} python3 python python2; do
774     if command -v $name > /dev/null; then
775         have_python=1
776         python=$name
777         printf "Yes (%s).\n" "$name"
778         break
779     fi
780 done
781
782 if [ $have_python -eq 0 ]; then
783     printf "No.\n"
784     errors=$((errors + 1))
785 fi
786
787 have_python3=0
788 if [ $have_python -eq 1 ]; then
789     printf "Checking for python3 (>= 3.5)..."
790     if "$python" -c 'import sys, sysconfig; assert sys.version_info >= (3,5)'; >/dev/null 2>&1; then
791         printf "Yes.\n"
792         have_python3=1
793     else
794         printf "No (will not install CFFI-based python bindings).\n"
795     fi
796 fi
797
798 have_python3_cffi=0
799 have_python3_pytest=0
800 if [ $have_python3 -eq 1 ]; then
801     printf "Checking for python3 cffi and setuptools... "
802     if "$python" -c 'import cffi,setuptools; cffi.FFI().verify()' >/dev/null 2>&1; then
803         printf "Yes.\n"
804         have_python3_cffi=1
805         WITH_PYTHON_DOCS=1
806     else
807         WITH_PYTHON_DOCS=0
808         printf "No (will not install CFFI-based python bindings).\n"
809     fi
810     rm -rf __pycache__  # cffi.FFI().verify() uses this space
811
812     printf "Checking for python3 pytest (>= 3.0)... "
813     conf=$(mktemp)
814     printf "[pytest]\nminversion=3.0\n" > $conf
815     if pytest-3 -c $conf --version >/dev/null 2>&1; then
816         printf "Yes.\n"
817         have_python3_pytest=1
818     else
819         printf "No (will not test CFFI-based python bindings).\n"
820     fi
821     rm -f $conf
822 fi
823
824 printf "Checking for valgrind development files... "
825 if pkg-config --exists valgrind; then
826     printf "Yes.\n"
827     have_valgrind=1
828     valgrind_cflags=$(pkg-config --cflags valgrind)
829 else
830     printf "No (but that's fine).\n"
831     have_valgrind=0
832     valgrind_cflags=
833 fi
834
835 printf "Checking for bash-completion (>= 1.90)... "
836 if pkg-config --atleast-version=1.90 bash-completion; then
837     printf "Yes.\n"
838 else
839     printf "No (will not install bash completion).\n"
840     WITH_BASH=0
841 fi
842
843 if [ -z "${EMACSLISPDIR-}" ]; then
844     EMACSLISPDIR="\$(prefix)/share/emacs/site-lisp"
845 fi
846
847 if [ -z "${EMACSETCDIR-}" ]; then
848     EMACSETCDIR="\$(prefix)/share/emacs/site-lisp"
849 fi
850
851 if [ $WITH_EMACS = "1" ]; then
852     printf "Checking if emacs (>= 24) is available... "
853     if emacs --quick --batch --eval '(if (< emacs-major-version 24) (kill-emacs 1))' > /dev/null 2>&1; then
854         printf "Yes.\n"
855     else
856         printf "No (disabling emacs related parts of build)\n"
857         WITH_EMACS=0
858     fi
859 fi
860
861 have_doxygen=0
862 if [ $WITH_API_DOCS = "1" ] ; then
863     printf "Checking if doxygen is available... "
864     if command -v doxygen > /dev/null; then
865         printf "Yes.\n"
866         have_doxygen=1
867     else
868         printf "No (so will not install api docs)\n"
869     fi
870 fi
871
872 have_ruby_dev=0
873 if [ $WITH_RUBY = "1" ] ; then
874     printf "Checking for ruby development files... "
875     if ${RUBY} -e "require 'mkmf'"> /dev/null 2>&1; then
876         printf "Yes.\n"
877         have_ruby_dev=1
878     else
879         printf "No (skipping ruby bindings)\n"
880     fi
881 fi
882
883 have_sphinx=0
884 have_makeinfo=0
885 have_install_info=0
886 if [ $WITH_DOCS = "1" ] ; then
887     printf "Checking if sphinx is available and supports nroff output... "
888     if command -v sphinx-build > /dev/null && ${python} -m sphinx.writers.manpage > /dev/null 2>&1 ; then
889         printf "Yes.\n"
890         have_sphinx=1
891     else
892         printf "No (so will not install man pages).\n"
893     fi
894     printf "Checking if makeinfo is available... "
895     if command -v makeinfo > /dev/null; then
896         printf "Yes.\n"
897         have_makeinfo=1
898     else
899         printf "No (so will not build info pages).\n"
900     fi
901     printf "Checking if install-info is available... "
902     if command -v install-info > /dev/null; then
903         printf "Yes.\n"
904         have_install_info=1
905     else
906         printf "No (so will not install info pages).\n"
907     fi
908 fi
909
910 if [ $WITH_DESKTOP = "1" ]; then
911     printf "Checking if desktop-file-install is available... "
912     if command -v desktop-file-install > /dev/null; then
913         printf "Yes.\n"
914     else
915         printf "No (so will not install .desktop file).\n"
916         WITH_DESKTOP=0
917     fi
918 fi
919
920 printf "Checking for cppcheck... "
921 if command -v cppcheck > /dev/null; then
922     have_cppcheck=1
923     printf "Yes.\n"
924 else
925     have_cppcheck=0
926     printf "No.\n"
927 fi
928
929 libdir_in_ldconfig=0
930
931 printf "Checking which platform we are on... "
932 uname=$(uname)
933 if [ $uname = "Darwin" ] ; then
934     printf "Mac OS X.\n"
935     platform=MACOSX
936     linker_resolves_library_dependencies=0
937 elif [ $uname = "SunOS" ] ; then
938     printf "Solaris.\n"
939     platform=SOLARIS
940     linker_resolves_library_dependencies=0
941 elif [ $uname = "FreeBSD" ] ; then
942     printf "FreeBSD.\n"
943     platform=FREEBSD
944     linker_resolves_library_dependencies=0
945 elif [ $uname = "OpenBSD" ] ; then
946     printf "OpenBSD.\n"
947     platform=OPENBSD
948     linker_resolves_library_dependencies=0
949 elif [ $uname = "Linux" ] || [ $uname = "GNU" ] ; then
950     printf "%s\n" "$uname"
951     platform="$uname"
952     linker_resolves_library_dependencies=1
953
954     printf "Checking for %s in ldconfig... " "$libdir_expanded"
955     ldconfig_paths=$(/sbin/ldconfig -N -X -v 2>/dev/null | sed -n -e 's,^\(/.*\):\( (.*)\)\?$,\1,p')
956     # Separate ldconfig_paths only on newline (not on any potential
957     # embedded space characters in any filenames). Note, we use a
958     # literal newline in the source here rather than something like:
959     #
960     #   IFS=$(printf '\n')
961     #
962     # because the shell's command substitution deletes any trailing newlines.
963     IFS="
964 "
965     for path in $ldconfig_paths; do
966         if [ "$path" -ef "$libdir_expanded" ]; then
967             libdir_in_ldconfig=1
968         fi
969     done
970     IFS=$DEFAULT_IFS
971     if [ "$libdir_in_ldconfig" = '0' ]; then
972         printf "No (will set RPATH)\n"
973     else
974         printf "Yes\n"
975     fi
976 else
977     printf "Unknown.\n"
978     platform="$uname"
979     linker_resolves_library_dependencies=0
980     cat <<EOF
981
982 *** Warning: Unknown platform. Notmuch might or might not build correctly.
983
984 EOF
985 fi
986
987 if [ $errors -gt 0 ]; then
988     cat <<EOF
989
990 *** Error: The dependencies of notmuch could not be satisfied. You will
991 need to install the following packages before being able to compile
992 notmuch:
993
994 EOF
995     if [ $have_python -eq 0 ]; then
996         echo "  python interpreter"
997     fi
998     if [ $have_xapian -eq 0 ]; then
999         echo "  Xapian library (>= version 1.4.0, including development files such as headers)"
1000         echo "  https://xapian.org/"
1001     fi
1002     if [ $have_zlib -eq 0 ]; then
1003         echo "  zlib library (>= version 1.2.5.2, including development files such as headers)"
1004         echo "  https://zlib.net/"
1005         echo
1006     fi
1007     if [ $have_gmime -eq 0 ]; then
1008         echo "  GMime library >= $GMIME_MINVER"
1009         echo "  (including development files such as headers)"
1010         echo "  https://github.com/jstedfast/gmime/"
1011         echo
1012     fi
1013     if [ $have_glib -eq 0 ]; then
1014         echo "  Glib library >= 2.22 (including development files such as headers)"
1015         echo "  https://ftp.gnome.org/pub/gnome/sources/glib/"
1016         echo
1017     fi
1018     if [ $have_talloc -eq 0 ]; then
1019         echo "  The talloc library (including development files such as headers)"
1020         echo "  https://talloc.samba.org/"
1021         echo
1022     fi
1023     cat <<EOF
1024 With any luck, you're using a modern, package-based operating system
1025 that has all of these packages available in the distribution. In that
1026 case a simple command will install everything you need. For example:
1027
1028 On Debian and similar systems:
1029
1030         sudo apt-get install libxapian-dev libgmime-3.0-dev libtalloc-dev zlib1g-dev
1031
1032 Or on Fedora and similar systems:
1033
1034         sudo dnf install xapian-core-devel gmime30-devel libtalloc-devel zlib-devel
1035
1036 On other systems, similar commands can be used, but the details of the
1037 package names may be different.
1038
1039 EOF
1040     if [ $have_pkg_config -eq 0 ]; then
1041 cat <<EOF
1042 Note: the pkg-config program is not available. This configure script
1043 uses pkg-config to find the compilation flags required to link against
1044 the various libraries needed by notmuch. It's possible you simply need
1045 to install pkg-config with a command such as:
1046
1047         sudo apt-get install pkg-config
1048 Or:
1049         sudo dnf install pkgconfig
1050
1051 But if pkg-config is not available for your system, then you will need
1052 to modify the configure script to manually set the cflags and ldflags
1053 variables to the correct values to link against each library in each
1054 case that pkg-config could not be used to determine those values.
1055
1056 EOF
1057     fi
1058 cat <<EOF
1059 When you have installed the necessary dependencies, you can run
1060 configure again to ensure the packages can be found, or simply run
1061 "make" to compile notmuch.
1062
1063 EOF
1064     exit 1
1065 fi
1066
1067 printf "Checking for canonicalize_file_name... "
1068 if ${CC} -o compat/have_canonicalize_file_name "$srcdir"/compat/have_canonicalize_file_name.c > /dev/null 2>&1
1069 then
1070     printf "Yes.\n"
1071     have_canonicalize_file_name=1
1072 else
1073     printf "No (will use our own instead).\n"
1074     have_canonicalize_file_name=0
1075 fi
1076 rm -f compat/have_canonicalize_file_name
1077
1078
1079 printf "Checking for getline... "
1080 if ${CC} -o compat/have_getline "$srcdir"/compat/have_getline.c > /dev/null 2>&1
1081 then
1082     printf "Yes.\n"
1083     have_getline=1
1084 else
1085     printf "No (will use our own instead).\n"
1086     have_getline=0
1087 fi
1088 rm -f compat/have_getline
1089
1090 printf "Checking for strcasestr... "
1091 if ${CC} -o compat/have_strcasestr "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1
1092 then
1093     printf "Yes.\n"
1094     have_strcasestr=1
1095 else
1096     printf "No (will use our own instead).\n"
1097     have_strcasestr=0
1098 fi
1099 rm -f compat/have_strcasestr
1100
1101 printf "Checking for strsep... "
1102 if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
1103 then
1104     printf "Yes.\n"
1105     have_strsep="1"
1106 else
1107     printf "No (will use our own instead).\n"
1108     have_strsep="0"
1109 fi
1110 rm -f compat/have_strsep
1111
1112 printf "Checking for timegm... "
1113 if ${CC} -o compat/have_timegm "$srcdir"/compat/have_timegm.c > /dev/null 2>&1
1114 then
1115     printf "Yes.\n"
1116     have_timegm="1"
1117 else
1118     printf "No (will use our own instead).\n"
1119     have_timegm="0"
1120 fi
1121 rm -f compat/have_timegm
1122
1123 cat <<EOF > _time_t.c
1124 #include <time.h>
1125 #include <assert.h>
1126 static_assert(sizeof(time_t) >= 8, "sizeof(time_t) < 8");
1127 EOF
1128
1129 printf "Checking for 64 bit time_t... "
1130 if ${CC} -c _time_t.c -o /dev/null
1131 then
1132     printf "Yes.\n"
1133     have_64bit_time_t=1
1134 else
1135     printf "No.\n"
1136     have_64bit_time_t=0
1137 fi
1138
1139 printf "Checking for dirent.d_type... "
1140 if ${CC} -o compat/have_d_type "$srcdir"/compat/have_d_type.c > /dev/null 2>&1
1141 then
1142     printf "Yes.\n"
1143     have_d_type="1"
1144 else
1145     printf "No (will use stat instead).\n"
1146     have_d_type="0"
1147 fi
1148 rm -f compat/have_d_type
1149
1150 printf "Checking for standard version of getpwuid_r... "
1151 if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
1152 then
1153     printf "Yes.\n"
1154     std_getpwuid=1
1155 else
1156     printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
1157     std_getpwuid=0
1158 fi
1159 rm -f compat/check_getpwuid
1160
1161 printf "Checking for standard version of asctime_r... "
1162 if ${CC} -o compat/check_asctime "$srcdir"/compat/check_asctime.c > /dev/null 2>&1
1163 then
1164     printf "Yes.\n"
1165     std_asctime=1
1166 else
1167     printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
1168     std_asctime=0
1169 fi
1170 rm -f compat/check_asctime
1171
1172 printf "Checking for rpath support... "
1173 if [ $WITH_RPATH = "1" ] && ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1
1174 then
1175     printf "Yes.\n"
1176     rpath_ldflags="-Wl,--enable-new-dtags -Wl,-rpath,\$(libdir)"
1177 else
1178     printf "No (nothing to worry about).\n"
1179     rpath_ldflags=""
1180 fi
1181
1182 printf "Checking for -Wl,--as-needed... "
1183 if ${CC} -Wl,--as-needed -o minimal minimal.c >/dev/null 2>&1
1184 then
1185     printf "Yes.\n"
1186     as_needed_ldflags="-Wl,--as-needed"
1187 else
1188     printf "No (nothing to worry about).\n"
1189     as_needed_ldflags=""
1190 fi
1191
1192 printf "Checking for -Wl,--no-undefined... "
1193 if ${CC} -Wl,--no-undefined -o minimal minimal.c >/dev/null 2>&1
1194 then
1195     printf "Yes.\n"
1196     no_undefined_ldflags="-Wl,--no-undefined"
1197 else
1198     printf "No (nothing to worry about).\n"
1199     no_undefined_ldflags=""
1200 fi
1201
1202 WARN_CXXFLAGS=""
1203 printf "Checking for available C++ compiler warning flags... "
1204 for flag in -Wall -Wextra -Wwrite-strings; do
1205     if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
1206     then
1207         WARN_CXXFLAGS="${WARN_CXXFLAGS}${WARN_CXXFLAGS:+ }${flag}"
1208     fi
1209 done
1210 printf "\n\t%s\n" "${WARN_CXXFLAGS}"
1211
1212 WARN_CFLAGS="${WARN_CXXFLAGS}"
1213 printf "Checking for available C compiler warning flags... "
1214 for flag in -Wmissing-declarations; do
1215     if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
1216     then
1217         WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
1218     fi
1219 done
1220 printf "\n\t%s\n" "${WARN_CFLAGS}"
1221
1222 rm -f minimal minimal.c _time_t.c _libversion.c _libversion _libversion.sh _check_session_keys.c _check_session_keys _check_x509_validity.c _check_x509_validity \
1223    _verify_sig_with_session_key.c _verify_sig_with_session_key
1224
1225 # construct the Makefile.config
1226 cat > Makefile.config <<EOF
1227 # This Makefile.config was automatically generated by the ./configure
1228 # script of notmuch. If the configure script identified anything
1229 # incorrectly, then you can edit this file to try to correct things,
1230 # but be warned that if configure is run again it will destroy your
1231 # changes, (and this could happen by simply calling "make" if the
1232 # configure script is updated).
1233
1234 # The top-level directory for the source, (the directory containing
1235 # the configure script). This may be different than the build
1236 # directory (the current directory at the time configure was run).
1237 srcdir = ${srcdir}
1238 NOTMUCH_SRCDIR = ${NOTMUCH_SRCDIR}
1239
1240 # subdirectories to build
1241 subdirs = ${subdirs}
1242
1243 configure_options = $@
1244
1245 # We use vpath directives (rather than the VPATH variable) since the
1246 # VPATH variable matches targets as well as prerequisites, (which is
1247 # not useful since then a target left-over from a srcdir build would
1248 # cause a target to not be built in the non-srcdir build).
1249 #
1250 # Also, we don't use a single "vpath % \$(srcdir)" here because we
1251 # don't want the vpath to trigger for our emacs lisp compilation,
1252 # (unless we first find a way to convince emacs to build the .elc
1253 # target in a directory other than the directory of the .el
1254 # prerequisite). In the meantime, we're actually copying in the .el
1255 # files, (which is quite ugly).
1256 vpath %.c \$(srcdir)
1257 vpath %.cc \$(srcdir)
1258 vpath Makefile.% \$(srcdir)
1259 vpath %.py \$(srcdir)
1260 vpath %.rst \$(srcdir)
1261
1262 # Library versions (used to make SONAME)
1263 # The major version of the library interface. This will control the soname.
1264 # As such, this number must be incremented for any incompatible change to
1265 # the library interface, (such as the deletion of an API or a major
1266 # semantic change that breaks formerly functioning code).
1267 #
1268 LIBNOTMUCH_VERSION_MAJOR = ${libnotmuch_version_major}
1269
1270 # The minor version of the library interface. This should be incremented at
1271 # the time of release for any additions to the library interface,
1272 # (and when it is incremented, the release version of the library should
1273 #  be reset to 0).
1274 LIBNOTMUCH_VERSION_MINOR = ${libnotmuch_version_minor}
1275
1276 # The release version the library interface. This should be incremented at
1277 # the time of release if there have been no changes to the interface, (but
1278 # simply compatible changes to the implementation).
1279 LIBNOTMUCH_VERSION_RELEASE = ${libnotmuch_version_release}
1280
1281 # These are derived from the VERSION macros in lib/notmuch.h so
1282 # if you have to change them, something is wrong.
1283
1284 # The C compiler to use
1285 CC = ${CC}
1286
1287 # The C++ compiler to use
1288 CXX = ${CXX}
1289
1290 # Command to execute emacs from Makefiles
1291 EMACS = emacs --quick
1292
1293 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
1294 CFLAGS = ${CFLAGS}
1295
1296 # Default FLAGS for C preprocessor (can be overridden by user such as "make CPPFLAGS=-I/usr/local/include")
1297 CPPFLAGS = ${CPPFLAGS}
1298
1299 # Default FLAGS for C++ compiler (can be overridden by user such as "make CXXFLAGS=-g")
1300 CXXFLAGS = ${CXXFLAGS}
1301
1302 # Default FLAGS for the linker (can be overridden by user such as "make LDFLAGS=-znow")
1303 LDFLAGS = ${LDFLAGS}
1304
1305 # Flags to enable warnings when using the C++ compiler
1306 WARN_CXXFLAGS=${WARN_CXXFLAGS}
1307
1308 # Flags to enable warnings when using the C compiler
1309 WARN_CFLAGS=${WARN_CFLAGS}
1310
1311 # Name of python interpreter
1312 PYTHON = ${python}
1313
1314 # Name of ruby interpreter
1315 RUBY = ${RUBY}
1316
1317 # The prefix to which notmuch should be installed
1318 # Note: If you change this value here, be sure to ensure that the
1319 # LIBDIR_IN_LDCONFIG value below is still set correctly.
1320 prefix = ${PREFIX}
1321
1322 # The directory to which libraries should be installed
1323 # Note: If you change this value here, be sure to ensure that the
1324 # LIBDIR_IN_LDCONFIG value below is still set correctly.
1325 libdir = ${LIBDIR:=\$(prefix)/lib}
1326
1327 # Whether libdir is in a path configured into ldconfig
1328 LIBDIR_IN_LDCONFIG = ${libdir_in_ldconfig}
1329
1330 # The directory to which header files should be installed
1331 includedir = ${INCLUDEDIR:=\$(prefix)/include}
1332
1333 # The directory to which man pages should be installed
1334 mandir = ${MANDIR:=\$(prefix)/share/man}
1335
1336 # The directory to which man pages should be installed
1337 infodir = ${INFODIR:=\$(prefix)/share/info}
1338
1339 # The directory to which read-only (configuration) files should be installed
1340 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
1341
1342 # The directory to which emacs lisp files should be installed
1343 emacslispdir=${EMACSLISPDIR}
1344
1345 # The directory to which emacs miscellaneous (machine-independent) files should
1346 # be installed
1347 emacsetcdir=${EMACSETCDIR}
1348
1349 # Whether bash exists, and if so where
1350 HAVE_BASH = ${have_bash}
1351 BASH_ABSOLUTE = ${bash_absolute}
1352
1353 # Whether perl exists, and if so where
1354 HAVE_PERL = ${have_perl}
1355 PERL_ABSOLUTE = ${perl_absolute}
1356
1357 # Whether there's a sphinx-build binary available for building documentation
1358 HAVE_SPHINX=${have_sphinx}
1359
1360 # Whether there's a makeinfo binary available for building info format documentation
1361 HAVE_MAKEINFO=${have_makeinfo}
1362
1363 # Whether there's an install-info binary available for installing info format documentation
1364 HAVE_INSTALL_INFO=${have_install_info}
1365
1366 # Whether there's a doxygen binary available for building api documentation
1367 HAVE_DOXYGEN=${have_doxygen}
1368
1369 # The directory to which desktop files should be installed
1370 desktop_dir = \$(prefix)/share/applications
1371
1372 # The directory to which bash completions files should be installed
1373 bash_completion_dir = ${BASHCOMPLETIONDIR:=\$(prefix)/share/bash-completion/completions}
1374
1375 # The directory to which zsh completions files should be installed
1376 zsh_completion_dir = ${ZSHCOMLETIONDIR:=\$(prefix)/share/zsh/site-functions}
1377
1378 # Whether the canonicalize_file_name function is available (if not, then notmuch will
1379 # build its own version)
1380 HAVE_CANONICALIZE_FILE_NAME = ${have_canonicalize_file_name}
1381
1382 # Whether the cppcheck static checker is available
1383 HAVE_CPPCHECK = ${have_cppcheck}
1384
1385 # Whether the getline function is available (if not, then notmuch will
1386 # build its own version)
1387 HAVE_GETLINE = ${have_getline}
1388
1389 # Are the ruby development files (and ruby) available? If not skip
1390 # building/testing ruby bindings.
1391 HAVE_RUBY_DEV = ${have_ruby_dev}
1392
1393 # Is the python cffi package available?
1394 HAVE_PYTHON3_CFFI = ${have_python3_cffi}
1395
1396 # Is the python pytest package available?
1397 HAVE_PYTHON3_PYTEST = ${have_python3_pytest}
1398
1399 # Whether the strcasestr function is available (if not, then notmuch will
1400 # build its own version)
1401 HAVE_STRCASESTR = ${have_strcasestr}
1402
1403 # Whether the strsep function is available (if not, then notmuch will
1404 # build its own version)
1405 HAVE_STRSEP = ${have_strsep}
1406
1407 # Whether the timegm function is available (if not, then notmuch will
1408 # build its own version)
1409 HAVE_TIMEGM = ${have_timegm}
1410
1411 # Whether struct dirent has d_type (if not, then notmuch will use stat)
1412 HAVE_D_TYPE = ${have_d_type}
1413
1414 # Whether to have Xapian retry lock
1415 HAVE_XAPIAN_DB_RETRY_LOCK = ${WITH_RETRY_LOCK}
1416
1417 # Whether the getpwuid_r function is standards-compliant
1418 # (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
1419 # to enable the standards-compliant version -- needed for Solaris)
1420 STD_GETPWUID = ${std_getpwuid}
1421
1422 # Whether the asctime_r function is standards-compliant
1423 # (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
1424 # to enable the standards-compliant version -- needed for Solaris)
1425 STD_ASCTIME = ${std_asctime}
1426
1427 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS, FREEBSD, OPENBSD
1428 PLATFORM = ${platform}
1429
1430 # Whether the linker will automatically resolve the dependency of one
1431 # library on another (if not, then linking a binary requires linking
1432 # directly against both)
1433 LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
1434
1435 # Flags needed to compile and link against Xapian
1436 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
1437 XAPIAN_LDFLAGS = ${xapian_ldflags}
1438
1439 # Flags needed to compile and link against GMime
1440 GMIME_CFLAGS = ${gmime_cflags}
1441 GMIME_LDFLAGS = ${gmime_ldflags}
1442
1443 # Flags needed to compile and link against zlib
1444 ZLIB_CFLAGS = ${zlib_cflags}
1445 ZLIB_LDFLAGS = ${zlib_ldflags}
1446
1447 # Flags needed to compile and link against talloc
1448 TALLOC_CFLAGS = ${talloc_cflags}
1449 TALLOC_LDFLAGS = ${talloc_ldflags}
1450
1451 # Flags needed to have linker set rpath attribute
1452 RPATH_LDFLAGS = ${rpath_ldflags}
1453
1454 # Flags needed to have linker link only to necessary libraries
1455 AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
1456
1457 # Flags to have the linker flag undefined symbols in object files
1458 NO_UNDEFINED_LDFLAGS = ${no_undefined_ldflags}
1459
1460 # Whether valgrind header files are available
1461 HAVE_VALGRIND = ${have_valgrind}
1462
1463 # And if so, flags needed at compile time for valgrind macros
1464 VALGRIND_CFLAGS = ${valgrind_cflags}
1465
1466 # Support for emacs
1467 WITH_EMACS = ${WITH_EMACS}
1468
1469 # Support for desktop file
1470 WITH_DESKTOP = ${WITH_DESKTOP}
1471
1472 # Support for bash completion
1473 WITH_BASH = ${WITH_BASH}
1474
1475 # Support for zsh completion
1476 WITH_ZSH = ${WITH_ZSH}
1477
1478 # Combined flags for compiling and linking against all of the above
1479 COMMON_CONFIGURE_CFLAGS = \\
1480         \$(GMIME_CFLAGS) \$(TALLOC_CFLAGS) \$(ZLIB_CFLAGS)      \\
1481         -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \$(VALGRIND_CFLAGS)   \\
1482         -DHAVE_GETLINE=\$(HAVE_GETLINE)                         \\
1483         -DWITH_EMACS=\$(WITH_EMACS)                             \\
1484         -DHAVE_CANONICALIZE_FILE_NAME=\$(HAVE_CANONICALIZE_FILE_NAME) \\
1485         -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)                   \\
1486         -DHAVE_STRSEP=\$(HAVE_STRSEP)                           \\
1487         -DHAVE_TIMEGM=\$(HAVE_TIMEGM)                           \\
1488         -DHAVE_D_TYPE=\$(HAVE_D_TYPE)                           \\
1489         -DSTD_GETPWUID=\$(STD_GETPWUID)                         \\
1490         -DSTD_ASCTIME=\$(STD_ASCTIME)                           \\
1491         -DSILENCE_XAPIAN_DEPRECATION_WARNINGS                   \\
1492         -DHAVE_XAPIAN_DB_RETRY_LOCK=\$(HAVE_XAPIAN_DB_RETRY_LOCK)
1493
1494 CONFIGURE_CFLAGS = \$(COMMON_CONFIGURE_CFLAGS)
1495
1496 CONFIGURE_CXXFLAGS = \$(COMMON_CONFIGURE_CFLAGS) \$(XAPIAN_CXXFLAGS)
1497
1498 CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(ZLIB_LDFLAGS) \$(XAPIAN_LDFLAGS)
1499 EOF
1500
1501 # construct the sh.config
1502 cat > sh.config <<EOF
1503 # This sh.config was automatically generated by the ./configure
1504 # script of notmuch.
1505
1506 NOTMUCH_SRCDIR='${NOTMUCH_SRCDIR}'
1507
1508 # Whether to have Xapian retry lock
1509 NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK=${WITH_RETRY_LOCK}
1510
1511 # Which backend will Xapian use by default?
1512 NOTMUCH_DEFAULT_XAPIAN_BACKEND=${default_xapian_backend}
1513
1514 # Whether GMime can verify X.509 certificate validity
1515 NOTMUCH_GMIME_X509_CERT_VALIDITY=${gmime_x509_cert_validity}
1516
1517 # Whether GMime can verify signatures when decrypting with a session key:
1518 NOTMUCH_GMIME_VERIFY_WITH_SESSION_KEY=${gmime_verify_with_session_key}
1519
1520 # do we have man pages?
1521 NOTMUCH_HAVE_MAN=$((have_sphinx))
1522
1523 # Whether bash exists, and if so where
1524 NOTMUCH_HAVE_BASH=${have_bash}
1525 NOTMUCH_BASH_ABSOLUTE=${bash_absolute}
1526
1527 # Whether time_t is 64 bits (or more)
1528 NOTMUCH_HAVE_64BIT_TIME_T=${have_64bit_time_t}
1529
1530 # Whether perl exists, and if so where
1531 NOTMUCH_HAVE_PERL=${have_perl}
1532 NOTMUCH_PERL_ABSOLUTE=${perl_absolute}
1533
1534 # Name of python interpreter
1535 NOTMUCH_PYTHON=${python}
1536
1537 # Name of ruby interpreter
1538 NOTMUCH_RUBY=${RUBY}
1539
1540 # Are the ruby development files (and ruby) available? If not skip
1541 # building/testing ruby bindings.
1542 NOTMUCH_HAVE_RUBY_DEV=${have_ruby_dev}
1543
1544 # Is the python cffi package available?
1545 NOTMUCH_HAVE_PYTHON3_CFFI=${have_python3_cffi}
1546
1547 # Is the python pytest package available?
1548 NOTMUCH_HAVE_PYTHON3_PYTEST=${have_python3_pytest}
1549
1550 # Platform we are run on
1551 PLATFORM=${platform}
1552 EOF
1553
1554 {
1555     echo "# Generated by configure, run from doc/conf.py"
1556     if [ $WITH_EMACS = "1" ]; then
1557         echo "tags.add('WITH_EMACS')"
1558     fi
1559     if [ $WITH_PYTHON_DOCS = "1" ]; then
1560         echo "tags.add('WITH_PYTHON')"
1561     fi
1562     printf "rsti_dir = '%s'\n" $(realpath emacs)
1563 } > sphinx.config
1564
1565 # Finally, after everything configured, inform the user how to continue.
1566 cat <<EOF
1567
1568 All required packages were found. You may now run the following
1569 commands to compile and install notmuch:
1570
1571         make
1572         sudo make install
1573
1574 EOF