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