Commit graph

33 commits

Author SHA1 Message Date
Michael J Gruber
a84dc2f7e6 compat: probe for strcasestr more thoroughly
Depending on compiler (gcc, g++, clang) and standard options (c99, c11),
string.h may or may not include strings.h, leading to possibly missing
or conflicting declarations of strcasestr.

Include both so that both detection and compilation phases use the same
(possibly optimised) implementations.

Suggested-by: Thomas Schneider <qsx@chaotikum.eu>
Suggested-by: Florian Weimer <fweimer@redhat.com>
Suggested-by: Tomi Ollila <tomi.ollila@iki.fi>
2023-08-27 19:39:23 -03:00
Đoàn Trần Công Danh
441a327051 compat: rename {,notmuch_}canonicalize_file_name
When compat canonicalize_file_name was introduced, it was limited to
C code only because it was used by C code only during that time.

>From 5ec6fd4d, (lib/open: check for split configuration when creating
database., 2021-02-16), lib/open.cc, which is C++, relies on the
existent of canonicalize_file_name.

However, we can't blindly enable canonicalize_file_name for C++ code,
because different implementation has different additional signature for
C++ and users can arbitrarily add -DHAVE_CANONICALIZE_FILE_NAME=0 to
{C,CXX}FLAGS.

Let's move our implementation into a util library.

Helped-by: Tomi Ollila <tomi.ollila@iki.fi>
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
2021-04-24 08:07:00 -03:00
Jonas Bernoulli
c454135376 emacs: Use makefile-gmake-mode in Makefile*s
Use `makefile-gmake-mode' instead of `makefile-mode' because the
former also highlights ifdef et al. while the latter does not.

"./Makefile.global" and one "Makefile.local" failed to specify any
major mode at all but doing so is necessary because Emacs does not
automatically figure out that these are Makefiles (of any flavor).
2020-08-09 21:14:36 -03:00
uncrustify
8099050c71 compat: run uncrustify
This is the result of running

     $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h

in the compat directory
2019-06-14 07:41:27 -03:00
Vladimir Panteleev
ca4688e103 Use rooted paths in .gitignore files
A leading / in paths in a .gitignore file matches the beginning of the
path, meaning that for patterns without slashes, git will match files
only in the current directory as opposed to in any subdirectory.

Prefix relevant paths with / in .gitignore files, to prevent
accidentally ignoring files in subdirectories and possibly slightly
improve the performance of "git status".
2017-08-18 19:42:35 -03:00
Jani Nikula
544b8ec90e compat: don't include compat.h from the feature test source
The feature test code should test the build environment, and none of
the compat code should interfere with that. Don't include compat.h
from the feature test source. There should be no functional changes
here, but this is just the right thing to do.
2017-05-11 20:42:37 -03:00
Daniel Kahn Gillmor
6a833a6e83 Use https instead of http where possible
Many of the external links found in the notmuch source can be resolved
using https instead of http.  This changeset addresses as many as i
could find, without touching the e-mail corpus or expected outputs
found in tests.
2016-06-05 08:32:17 -03:00
Felipe Contreras
0c698ef037 configure: add workaround for systems without zlib.pc
Some systems (e.g. FreeBSD) might not have installed the appropriate
pkg-config file as they should. We can workaround the issue by creating
the .pc file they should have distributed.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-06-21 16:40:39 -03:00
David Bremner
af5c3afa91 compat: add canonicalize_file_name
the POSIX 2008 behaviour of realpath is not available everywhere so we
provide a simple wrapper function.  We use (and provide) the gnu
extension canonicalize_file_name to make it cleaner to test for the
feature we need; otherwise we have to rely on realpath segfaulting if
the second argument is null.
2014-04-08 07:27:14 -03:00
Austin Clements
b1fa95721b new: Detect dirent.d_type support at configure time
Support for dirent.d_type is OS-specific.  Previously, we used
_DIRENT_HAVE_D_TYPE to detect support for this, but this is apparently
a glic-ism (FreeBSD, for example, supports d_type, but does not define
this).  Since there's no cross-platform way to detect support for
dirent.d_type, detect it using a test compile at configure time.
2014-02-14 08:42:45 -04:00
Blake Jones
8c6b2e7e9d 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.

Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
2013-08-23 17:57:35 +02:00
Blake Jones
43843745dc 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).

Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
2013-08-23 17:55:39 +02:00
Vladimir Marek
49a0b96486 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.

Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
2013-08-23 17:55:23 +02:00
Blake Jones
31c7001c99 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.

Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
2013-08-23 17:53:17 +02:00
Justus Winter
8f0a4c80ff Extend compat/README
Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-09-27 12:51:01 -03:00
Justus Winter
25d97b9791 Provide a NORETURN_ATTRIBUTE macro similar to PRINTF_ATTRIBUTE
This attribute is understood by gcc since version 2.5. clang provides
support for testing for function attributes using __has_attribute. For
other compilers this macro evaluates to the empty string.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-09-27 12:50:22 -03:00
Justus Winter
da12807734 Provide a __has_attribute compatibility macro
__has_attribute is defined by clang and tests whether a given function
attribute is supported by clang.

Add a compatibility macro for other compilers.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
2012-09-27 12:49:13 -03:00
Austin Clements
a9a9e374e2 Silence buildbot warnings about unused results
This ignores the results of the two writes in sigint handlers even
harder than before.

While my libc lacks the declarations that trigger these warnings, this
can be tested by adding the following to notmuch.h:

__attribute__((warn_unused_result))
ssize_t write(int fd, const void *buf, size_t count);
2012-01-21 08:49:50 -04:00
Austin Clements
5c12ee4b5d Fix dependency generation for compat, test, and util
This adds source files in compat, test, and util to SRCS so that the
top-level Makefile.local will generate dependency files for them.
2012-01-19 09:19:12 -04:00
Pieter Praet
18bf91def9 fix sum moar typos [text files]
Various typo fixes in auxiliary text files included with the source,
(README, TODO, etc.).

Signed-off-by: Pieter Praet <pieter@praet.org>

Edited-by: Carl Worth <cworth@cworth.org> Restricted to just text files.
2011-06-23 15:40:50 -07:00
Carl Worth
3e4a9d60a9 build: Add support for non-source-directory builds.
Such as:

     mkdir build
     cd build
     ../configure
     make

This is implemented by having the configure script set a srcdir
variable in Makefile.config, and then sprinkling $(srcdir) into
various make rules. We also use vpath directives to convince GNU make
to find the source files from the original source directory.
2011-03-09 15:10:03 -08:00
Tomas Carnecky
aab54b4ce7 Wrap the compat header in extern "C" { } when compiling C++ sources
This fixes a build error on OpenSolaris where the final liking of
notmuch fails because the linker can't find strcasestr() referenced
from thread.cc.
2010-04-27 10:39:54 -07:00
Dirk Hohndel
d09154465a Add simplistic reimplementation of strcasestr to compat library
While all systems that I have access to support strcasestr, it is
in fact not part of POSIX. So here's a fallback reimplementation
based on POSIX functions.

Signed-off-by: Dirk Hohndel <hohndel@infradead.org>

Tested-by: Tomas Carnecky <tom@dbservice.com> (on OpenSolaris snv_134)
2010-04-14 11:34:12 -07:00
Aaron Ecay
c10085c77b Fix up Makefile for build.
Must set extra_c(xx)flags before including subdir Makefile.local's,
so that there is a blank slate that the subdirs can add on to.

Must include subdir Makefile.local's before global one, otherwise
the compat sources are not added to the list of those to be
compiled.

Signed-off-by: Aaron Ecay <aaronecay@gmail.com>
2010-04-14 10:46:36 -07:00
Carl Worth
d8192a4d7f Move "config" test programs to "compat".
It makes sense to me to have the little tests for functionality right
next to the comptability implementations of that same functionality.

But also, this means I can now tab-complete ./configure from the three
initial characters (rather than the seven required previously).
2010-04-06 14:36:31 -07:00
David Edmondson
d3884a5984 Makefile.local: Automatically use makefile mode
We add a magic line to the beginning of each Makefile.local file to
help the editor know that it should use makefile mode for editing the
file, (even though the filename isn't exactly "Makefile").

Edited-by: Carl Worth <cworth@cworth.org>: Expand treatment from
emacs/Makefile.local to each instance of Makefile.local.
2010-04-03 12:31:49 -07:00
Carl Worth
86232e62ab Makefile: Fix Makefiles to depend on all child Makefile fragments.
We were previously maintaining two lists of the child Makefile
fragments---one for the includes and another for the dependencies. So,
of course, they drifted and the dependency list wasn't up to date.

We fix this by adding a single subdirs variable, and then using GNU
Makefile substitution to generate both the include and the dependency
lists.

Some side effect of this change caused the '=' assignment of the dir
variable to not work anymore. I'm not sure why that is, but using ':='
makes sense here and fixes the problem.
2010-03-10 10:59:57 -08:00
Carl Worth
341d49b061 Makefiles: Use .DEFAULT to support arbitrary targets from sub directories.
Taking advantage of the .DEFAULT construct means that we won't need to
explicitly list targets such as "clean", etc. in each sub-Makefile.
2010-01-06 10:32:06 -08:00
Carl Worth
1466e249e7 getdelim: Silence a (bogus) compiler warning.
Some compilers complain that result might be used uninitialized in
this function. I believe such compilers simply aren't looking hard
enough, but it's easy enough to silence them.
2009-12-01 16:46:21 -08:00
Carl Worth
880b21a097 Makefile: Incorporate getline implementation into the build.
It's unconditional for a very short time. We expect to soon be
building it only if necessary.
2009-12-01 16:33:17 -08:00
Carl Worth
7fd7611b23 compat/getdelim: Silence a warning about mixing of signed/unsigned.
If the length is ever so large as to overflow, then we'll end up
returning a negative value (which indicates an error anyway).
2009-12-01 16:27:35 -08:00
Carl Worth
c04a432ef2 compat: Change includes from config.h to compat.h.
We may switch to using an autoconf-like config.h, but we're not doing
that just yet.
2009-12-01 16:27:29 -08:00
Carl Worth
96c9109d94 compat: Add implementation of getline from gnulib.
These were copied from the gnulib git repository as of:

	commit 563c779682040ed4b89c9b4bbe428dcd8157c90a

They come under the GNU GPL v3 (or later) exactly as notmuch is
licensed.
2009-12-01 14:06:41 -08:00