test: add some config file tests

Test the --config=FILE option, and add a broken test for writing
config file through a symbolic link.
cli: config: do not overwrite symlinks when saving config file

Use realpath to canonicalize the config path before writing.

Previously 'notmuch setup' and 'notmuch config set' overwrote the
config file even if it was a symbolic link.
TODO: remove some completed todo items from the list

Bash completion has been rewritten. Configuration file saves follow
symlinks. There is --config=FILE top level option to specify
configuration file.
cli: mime node: fix compiler warning when building against gmime 2.4

commit d487ef9e58bcd193118f19f771d5ef3984616be5
Author: Jani Nikula <jani@nikula.org>
Date:   Sat Mar 30 15:53:16 2013 +0200

    cli: mime node: abstract decryption and signature verification

introduced a compiler warning, reported by Mark Walters, when building
against gmime 2.4:

mime-node.c:224:9: warning: assignment discards ‘const’ qualifier from
pointer target type [enabled by default]

Pass the non-const signature validity to the destructor to fix this.
getpwuid: check for standards compliance (Solaris support)

Add checks to "configure" to see whether _POSIX_PTHREAD_SEMANTICS needs
to be defined to get the right number of arguments in the prototypes for
getpwuid_r().  Solaris' default implementation conforms to POSIX.1c
Draft 6, rather than the final POSIX.1c spec.  The standards-compliant
version can be used by defining _POSIX_PTHREAD_SEMANTICS.

This change also adds the file "compat/check_getpwuid.c", which
configure uses to perform its check, and modifies compat/compat.h to
define _POSIX_PTHREAD_SEMANTICS if configure detected it was needed.
asctime: check for standards compliance (Solaris support)

Add checks to "configure" to see whether _POSIX_PTHREAD_SEMANTICS needs
to be defined to get the right number of arguments in the prototypes for
asctime_r().  Solaris' default implementation conforms to POSIX.1c
Draft 6, rather than the final POSIX.1c spec.  The standards-compliant
version can be used by defining _POSIX_PTHREAD_SEMANTICS.

This change also adds the file "compat/check_asctime.c", which
configure uses to perform its check, and modifies compat/compat.h to
define _POSIX_PTHREAD_SEMANTICS if configure detected it was needed.
gethostbyname: check for libnsl (Solaris support)

Add a check to "configure" to see whether -lnsl is needed for programs
that are using gethostbyname().  This change also adds the file
"compat/check_ghbn.c", which configure uses to perform its check.
configure: check for -Wl,-rpath (Solaris support)

Add a check to "configure" to see whether -Wl,-rpath can be used without
--enable-new-dtags.  Solaris needs the former and doesn't know about the
latter.
install: check for non-SysV version (Solaris support)

Solaris ships a program called "install" in /usr/sbin, which performs a
task that's fairly similar to the GNU and BSD "install" programs but
which uses very different command line arguments.  In particular, if it
is invoked without "-c", "-f", or "-n", it will search the target
directory for a file with the same name as the one being installed, and
it will only install the file if it finds a matching name.  More
excitingly, if it doesn't find a match, it will look in /bin, /usr/bin,
/etc, /lib, and /usr/lib and try to do the same there.

The standard workaround for this is to use GNU install.
It is available via the standard Solaris packaging system (in
"file/gnu-coreutils"), and installs itself as /usr/bin/ginstall.

This patch adds a check to "configure" to see if "install" behaves in a
way that's compatible with GNU and BSD install, and if not, it uses a
program called "ginstall" instead.  It also modifies "configure" to set
the $(INSTALL) variable, and changes various Makefiles to use it.
strsep: check for availability (Solaris support)

Solaris does not ship a version of the strsep() function.  This change
adds a check to "configure" to see whether notmuch needs to provide its
own implementation, and if so, it uses the new version in
"compat/strsep.c" (which was copied from Mutt, and apparently before
that from glibc).
gen-version-script: parse Solaris "nm" output (Solaris support)

The output of "nm" on Solaris is substantially different from that on
Linux, and the current version of gen-version-script is tied to the
Linux "nm" output.  This patch separates the parts of "nm" processing
which are dependent on the output format into a couple shell functions,
and makes another shell function to use the appropriate version of
"c++filt" to demangle symbols.  It also modifies lib/Makefile.local
to pass the generated symbol table correctly to the Solaris linker.
notmuch-config: use strchr(), not index() (Solaris support)

notmuch-config.c has the only use of the function named "index()" in the
notmuch source.  Several other places use the equivalent function
"strchr()"; this patch just fixes notmuch-config.c to use strchr()
instead.  (Solaris needs to include <strings.h> to get the prototype for
index(), and notmuch-config.c was failing to include that header, so it
wasn't compiling as-is.)
debugger.c: correct return type from getppid() (Solaris support)

Cast the return value of getppid() to "int" from "pid_t" in debugger.c,
since it is being passed to sprintf("%d"), which wants an "int"
argument.  On Solaris, "pid_t" is a "long" for 32-bit programs.
timegm: add portable implementation (Solaris support)

The timegm(3) function is a non-standard extension to libc which is
available in GNU libc and on some BSDs.  Although SunOS had this
function in its libc, Solaris (unfortunately) removed it.  This patch
implements a very simple version of timegm() which is good enough for
parse-time-string.c.

One complication of this fix is that libnotmuch.a includes a call to
parse_time_string() from parse-time-vrp.o, and parse_time_string() in
libparse-time-string.a is the thing which needs to call timegm().  A
straightforward attempt to have the two static libraries reconcile their
symbols from one another fails, because the symbols come from different
.o's, and the linker only does a single pass on each ".a" looking for
dependencies.  To solve this, libparse-time-string includes "compat.h",
and pulls in .o's from the compat directory, in order to get everything
that it needs.
Makefile.local: dependecies compiler flags (Solaris Studio support)

Adds check to "configure" to see whether '-MD -MP -MF' or '-xMD -xMF'
should be used. The change also makes it possible to set the DEPFLAGS
from environment variable similarly to for example CFLAGS.
Replace GNU extension ##__VA_ARGS__ by portable substitution

If you have macro
 #define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__)
the extension '##' removes preceeding comma ',' if __VA_ARGS__ is empty.
This is however not portable.

The fix uses portable solution described by Richard Hansen:
http://stackoverflow.com/questions/5588855/standard-alternative-to-gccs-va-args-trick
notmuch-new.c: mistakenly used asprintf instead of talloc_asprintf
lib/database.cc: fix declaration and definition discrepancy (Solaris Studio support)

lib/notmuch.h defines all the function in extern "C" { ... } block,
while lib/database.cc does not. This causes problems during linking
because notmuch_database_upgrade is exported in "C" linkage while
notmuch-new.o expects it in "C++" linkage
lib/gen-version-script.sh: standard compliance
lib/Makefile.local: solaris linker has -z defs