* [PATCH v2 01/10] getpwuid: check for standards compliance (Solaris support)
2012-11-05 19:01 [PATCH v2 00/10] Solaris support Blake Jones
@ 2012-11-05 19:01 ` Blake Jones
2012-11-05 19:01 ` [PATCH v2 02/10] asctime: " Blake Jones
` (8 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Blake Jones @ 2012-11-05 19:01 UTC (permalink / raw)
To: notmuch
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.
---
compat/check_getpwuid.c | 11 +++++++++++
compat/compat.h | 4 ++++
configure | 23 +++++++++++++++++++++--
3 files changed, 36 insertions(+), 2 deletions(-)
create mode 100644 compat/check_getpwuid.c
diff --git a/compat/check_getpwuid.c b/compat/check_getpwuid.c
new file mode 100644
index 0000000..c435eb8
--- /dev/null
+++ b/compat/check_getpwuid.c
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <pwd.h>
+
+int main()
+{
+ struct passwd passwd, *ignored;
+
+ (void) getpwuid_r (0, &passwd, NULL, 0, &ignored);
+
+ return (0);
+}
diff --git a/compat/compat.h b/compat/compat.h
index b2e2736..efea023 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -54,6 +54,10 @@ char* strcasestr(const char *haystack, const char *needle);
#define IGNORE_RESULT(x) x
#endif /* __GNUC__ */
+#if !STD_GETPWUID
+#define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/configure b/configure
index ea8a1ad..bb5031e 100755
--- a/configure
+++ b/configure
@@ -512,6 +512,17 @@ else
fi
rm -f compat/have_strcasestr
+printf "Checking for standard version of getpwuid_r... "
+if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
+then
+ printf "Yes.\n"
+ std_getpwuid=1
+else
+ printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
+ std_getpwuid=0
+fi
+rm -f compat/check_getpwuid
+
printf "int main(void){return 0;}\n" > minimal.c
printf "Checking for rpath support... "
@@ -671,6 +682,11 @@ HAVE_GETLINE = ${have_getline}
# build its own version)
HAVE_STRCASESTR = ${have_strcasestr}
+# Whether the getpwuid_r function is standards-compliant
+# (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
+# to enable the standards-compliant version -- needed for Solaris)
+STD_GETPWUID = ${std_getpwuid}
+
# Supported platforms (so far) are: LINUX, MACOSX, SOLARIS, FREEBSD, OPENBSD
PLATFORM = ${platform}
@@ -715,10 +731,13 @@ WITH_ZSH = ${WITH_ZSH}
# Combined flags for compiling and linking against all of the above
CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
- \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
+ \$(VALGRIND_CFLAGS) \\
+ -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
+ -DSTD_GETPWUID=\$(STD_GETPWUID)
CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
- -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
+ -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
+ -DSTD_GETPWUID=\$(STD_GETPWUID)
CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
EOF
--
1.7.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 02/10] asctime: check for standards compliance (Solaris support)
2012-11-05 19:01 [PATCH v2 00/10] Solaris support Blake Jones
2012-11-05 19:01 ` [PATCH v2 01/10] getpwuid: check for standards compliance (Solaris support) Blake Jones
@ 2012-11-05 19:01 ` Blake Jones
2012-11-05 19:01 ` [PATCH v2 03/10] gethostbyname: check for libnsl " Blake Jones
` (7 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Blake Jones @ 2012-11-05 19:01 UTC (permalink / raw)
To: notmuch
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.
---
compat/check_asctime.c | 18 ++++++++++++++++++
compat/compat.h | 3 +++
configure | 22 ++++++++++++++++++++--
3 files changed, 41 insertions(+), 2 deletions(-)
create mode 100644 compat/check_asctime.c
diff --git a/compat/check_asctime.c b/compat/check_asctime.c
new file mode 100644
index 0000000..c508fbf
--- /dev/null
+++ b/compat/check_asctime.c
@@ -0,0 +1,18 @@
+/*
+ * This compatibility check actually succeeds (on Solaris) if
+ * _POSIX_PTHREAD_SEMANTICS is not defined. But we need to #define that to get
+ * the right version of getpwuid_r(), so we define it here to ensure that the
+ * compatibility check ends up doing the same thing as the rest of the code.
+ */
+#define _POSIX_PTHREAD_SEMANTICS 1
+#include <time.h>
+#include <stdio.h>
+
+int main()
+{
+ struct tm tm;
+
+ (void) asctime_r (&tm, NULL, 0);
+
+ return (0);
+}
diff --git a/compat/compat.h b/compat/compat.h
index efea023..e5f833e 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -57,6 +57,9 @@ char* strcasestr(const char *haystack, const char *needle);
#if !STD_GETPWUID
#define _POSIX_PTHREAD_SEMANTICS 1
#endif
+#if !STD_ASCTIME
+#define _POSIX_PTHREAD_SEMANTICS 1
+#endif
#ifdef __cplusplus
}
diff --git a/configure b/configure
index bb5031e..d153f57 100755
--- a/configure
+++ b/configure
@@ -523,6 +523,17 @@ else
fi
rm -f compat/check_getpwuid
+printf "Checking for standard version of asctime_r... "
+if ${CC} -o compat/check_asctime "$srcdir"/compat/check_asctime.c > /dev/null 2>&1
+then
+ printf "Yes.\n"
+ std_asctime=1
+else
+ printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
+ std_asctime=0
+fi
+rm -f compat/check_asctime
+
printf "int main(void){return 0;}\n" > minimal.c
printf "Checking for rpath support... "
@@ -687,6 +698,11 @@ HAVE_STRCASESTR = ${have_strcasestr}
# to enable the standards-compliant version -- needed for Solaris)
STD_GETPWUID = ${std_getpwuid}
+# Whether the asctime_r function is standards-compliant
+# (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
+# to enable the standards-compliant version -- needed for Solaris)
+STD_ASCTIME = ${std_asctime}
+
# Supported platforms (so far) are: LINUX, MACOSX, SOLARIS, FREEBSD, OPENBSD
PLATFORM = ${platform}
@@ -733,11 +749,13 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\$(VALGRIND_CFLAGS) \\
-DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
- -DSTD_GETPWUID=\$(STD_GETPWUID)
+ -DSTD_GETPWUID=\$(STD_GETPWUID) \\
+ -DSTD_ASCTIME=\$(STD_ASCTIME)
CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
-DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
- -DSTD_GETPWUID=\$(STD_GETPWUID)
+ -DSTD_GETPWUID=\$(STD_GETPWUID) \\
+ -DSTD_ASCTIME=\$(STD_ASCTIME)
CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
EOF
--
1.7.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 03/10] gethostbyname: check for libnsl (Solaris support)
2012-11-05 19:01 [PATCH v2 00/10] Solaris support Blake Jones
2012-11-05 19:01 ` [PATCH v2 01/10] getpwuid: check for standards compliance (Solaris support) Blake Jones
2012-11-05 19:01 ` [PATCH v2 02/10] asctime: " Blake Jones
@ 2012-11-05 19:01 ` Blake Jones
2012-11-05 19:01 ` [PATCH v2 04/10] configure: check for -Wl,-rpath " Blake Jones
` (6 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Blake Jones @ 2012-11-05 19:01 UTC (permalink / raw)
To: notmuch
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.
---
compat/check_ghbn.c | 9 +++++++++
configure | 17 ++++++++++++++++-
2 files changed, 25 insertions(+), 1 deletions(-)
create mode 100644 compat/check_ghbn.c
diff --git a/compat/check_ghbn.c b/compat/check_ghbn.c
new file mode 100644
index 0000000..4858d5c
--- /dev/null
+++ b/compat/check_ghbn.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <netdb.h>
+
+int main()
+{
+ (void) gethostbyname(NULL);
+
+ return (0);
+}
diff --git a/configure b/configure
index d153f57..9707f11 100755
--- a/configure
+++ b/configure
@@ -534,6 +534,17 @@ else
fi
rm -f compat/check_asctime
+printf "Checking whether libnsl is needed for gethostbyname... "
+if ${CC} -o compat/check_ghbn "$srcdir"/compat/check_ghbn.c > /dev/null 2>&1
+then
+ printf "No.\n"
+ libnsl_ldflags=""
+else
+ printf "Yes.\n"
+ libnsl_ldflags="-lnsl"
+fi
+rm -f compat/check_ghbn
+
printf "int main(void){return 0;}\n" > minimal.c
printf "Checking for rpath support... "
@@ -723,6 +734,9 @@ GMIME_LDFLAGS = ${gmime_ldflags}
TALLOC_CFLAGS = ${talloc_cflags}
TALLOC_LDFLAGS = ${talloc_ldflags}
+# Flags needed to get gethostbyname() at link time
+LIBNSL_LDFLAGS = ${libnsl_ldflags}
+
# Flags needed to have linker set rpath attribute
RPATH_LDFLAGS = ${rpath_ldflags}
@@ -757,5 +771,6 @@ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
-DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
-DSTD_GETPWUID=\$(STD_GETPWUID) \\
-DSTD_ASCTIME=\$(STD_ASCTIME)
-CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
+CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS) \\
+ \$(LIBNSL_LDFLAGS)
EOF
--
1.7.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 04/10] configure: check for -Wl,-rpath (Solaris support)
2012-11-05 19:01 [PATCH v2 00/10] Solaris support Blake Jones
` (2 preceding siblings ...)
2012-11-05 19:01 ` [PATCH v2 03/10] gethostbyname: check for libnsl " Blake Jones
@ 2012-11-05 19:01 ` Blake Jones
2012-11-05 19:01 ` [PATCH v2 05/10] install: check for non-SysV version " Blake Jones
` (5 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Blake Jones @ 2012-11-05 19:01 UTC (permalink / raw)
To: notmuch
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.
---
configure | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index 9707f11..c9da667 100755
--- a/configure
+++ b/configure
@@ -552,6 +552,10 @@ if ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null
then
printf "Yes.\n"
rpath_ldflags="-Wl,--enable-new-dtags -Wl,-rpath,\$(libdir)"
+elif ${CC} -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1
+then
+ printf "Yes.\n"
+ rpath_ldflags="-Wl,-rpath,\$(libdir)"
else
printf "No (nothing to worry about).\n"
rpath_ldflags=""
--
1.7.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 05/10] install: check for non-SysV version (Solaris support)
2012-11-05 19:01 [PATCH v2 00/10] Solaris support Blake Jones
` (3 preceding siblings ...)
2012-11-05 19:01 ` [PATCH v2 04/10] configure: check for -Wl,-rpath " Blake Jones
@ 2012-11-05 19:01 ` Blake Jones
2012-11-06 16:51 ` Tomi Ollila
2012-11-05 19:01 ` [PATCH v2 06/10] strsep: check for availability " Blake Jones
` (4 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Blake Jones @ 2012-11-05 19:01 UTC (permalink / raw)
To: notmuch
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.
---
Makefile.local | 2 +-
completion/Makefile.local | 4 ++--
configure | 19 +++++++++++++++++++
emacs/Makefile.local | 6 +++---
lib/Makefile.local | 4 ++--
man/Makefile.local | 6 +++---
vim/Makefile | 6 ++----
7 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/Makefile.local b/Makefile.local
index 2b91946..7ccb1cd 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -286,7 +286,7 @@ notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
.PHONY: install
install: all install-man
mkdir -p "$(DESTDIR)$(prefix)/bin/"
- install notmuch-shared "$(DESTDIR)$(prefix)/bin/notmuch"
+ $(INSTALL) notmuch-shared "$(DESTDIR)$(prefix)/bin/notmuch"
ifeq ($(MAKECMDGOALS), install)
@echo ""
@echo "Notmuch is now installed to $(DESTDIR)$(prefix)"
diff --git a/completion/Makefile.local b/completion/Makefile.local
index dfc1271..a648a78 100644
--- a/completion/Makefile.local
+++ b/completion/Makefile.local
@@ -14,9 +14,9 @@ install-$(dir):
@echo $@
ifeq ($(WITH_BASH),1)
mkdir -p "$(DESTDIR)$(bash_completion_dir)"
- install -m0644 $(bash_script) "$(DESTDIR)$(bash_completion_dir)/notmuch"
+ $(INSTALL) -m0644 $(bash_script) "$(DESTDIR)$(bash_completion_dir)/notmuch"
endif
ifeq ($(WITH_ZSH),1)
mkdir -p "$(DESTDIR)$(zsh_completion_dir)"
- install -m0644 $(zsh_script) "$(DESTDIR)$(zsh_completion_dir)/_notmuch"
+ $(INSTALL) -m0644 $(zsh_script) "$(DESTDIR)$(zsh_completion_dir)/_notmuch"
endif
diff --git a/configure b/configure
index c9da667..d9a101f 100755
--- a/configure
+++ b/configure
@@ -591,6 +591,21 @@ for flag in -Wmissing-declarations; do
done
printf "\n\t${WARN_CFLAGS}\n"
+INSTALL="install"
+printf "Checking for working \"install\" program... "
+mkdir _tmp_
+cd _tmp_
+echo 1 > 1
+mkdir dest
+if install 1 dest > /dev/null 2>&1 ; then
+ printf "\"install\" works fine.\n"
+else
+ INSTALL="ginstall"
+ printf "using \"ginstall\".\n"
+fi
+cd ..
+rm -rf _tmp_
+
rm -f minimal minimal.c
cat <<EOF
@@ -777,4 +792,8 @@ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
-DSTD_ASCTIME=\$(STD_ASCTIME)
CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS) \\
\$(LIBNSL_LDFLAGS)
+
+# Which "install" program to use
+INSTALL = ${INSTALL}
+
EOF
diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index fb82247..ee778cb 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -36,11 +36,11 @@ endif
.PHONY: install-emacs
install-emacs:
mkdir -p "$(DESTDIR)$(emacslispdir)"
- install -m0644 $(emacs_sources) "$(DESTDIR)$(emacslispdir)"
+ $(INSTALL) -m0644 $(emacs_sources) "$(DESTDIR)$(emacslispdir)"
ifeq ($(HAVE_EMACS),1)
- install -m0644 $(emacs_bytecode) "$(DESTDIR)$(emacslispdir)"
+ $(INSTALL) -m0644 $(emacs_bytecode) "$(DESTDIR)$(emacslispdir)"
endif
mkdir -p "$(DESTDIR)$(emacsetcdir)"
- install -m0644 $(emacs_images) "$(DESTDIR)$(emacsetcdir)"
+ $(INSTALL) -m0644 $(emacs_images) "$(DESTDIR)$(emacsetcdir)"
CLEAN := $(CLEAN) $(emacs_bytecode)
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 7785944..0c6b258 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -89,11 +89,11 @@ install: install-$(dir)
install-$(dir): $(dir)/$(LIBNAME)
mkdir -p "$(DESTDIR)$(libdir)/"
- install -m0644 "$(lib)/$(LIBNAME)" "$(DESTDIR)$(libdir)/"
+ $(INSTALL) -m0644 "$(lib)/$(LIBNAME)" "$(DESTDIR)$(libdir)/"
ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(SONAME)"
ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(LINKER_NAME)"
mkdir -p "$(DESTDIR)$(includedir)"
- install -m0644 "$(srcdir)/$(lib)/notmuch.h" "$(DESTDIR)$(includedir)/"
+ $(INSTALL) -m0644 "$(srcdir)/$(lib)/notmuch.h" "$(DESTDIR)$(includedir)/"
$(LIBRARY_INSTALL_POST_COMMAND)
SRCS := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
diff --git a/man/Makefile.local b/man/Makefile.local
index 72e2a18..07dcf4c 100644
--- a/man/Makefile.local
+++ b/man/Makefile.local
@@ -38,9 +38,9 @@ install-man: $(COMPRESSED_MAN)
mkdir -p "$(DESTDIR)$(mandir)/man1"
mkdir -p "$(DESTDIR)$(mandir)/man5"
mkdir -p "$(DESTDIR)$(mandir)/man7"
- install -m0644 $(MAN1_GZ) $(DESTDIR)/$(mandir)/man1
- install -m0644 $(MAN5_GZ) $(DESTDIR)/$(mandir)/man5
- install -m0644 $(MAN7_GZ) $(DESTDIR)/$(mandir)/man7
+ $(INSTALL) -m0644 $(MAN1_GZ) $(DESTDIR)/$(mandir)/man1
+ $(INSTALL) -m0644 $(MAN5_GZ) $(DESTDIR)/$(mandir)/man5
+ $(INSTALL) -m0644 $(MAN7_GZ) $(DESTDIR)/$(mandir)/man7
cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
update-man-versions: $(MAN_SOURCE)
diff --git a/vim/Makefile b/vim/Makefile
index f17bebf..7ceba7a 100644
--- a/vim/Makefile
+++ b/vim/Makefile
@@ -5,8 +5,6 @@ files = plugin/notmuch.vim \
prefix = $(HOME)/.vim
destdir = $(prefix)/plugin
-INSTALL = install -D -m644
-
all: help
help:
@@ -17,7 +15,7 @@ help:
@echo " make symlink - create symlinks in ~/.vim (useful for development)"
install:
- @for x in $(files); do $(INSTALL) $(CURDIR)/$$x $(prefix)/$$x; done
+ @for x in $(files); do $(INSTALL) -D -m644 $(CURDIR)/$$x $(prefix)/$$x; done
-link symlink: INSTALL = ln -fs
link symlink: install
+ @for x in $(files); do ln -fs $(CURDIR)/$$x $(prefix)/$$x; done
--
1.7.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v2 05/10] install: check for non-SysV version (Solaris support)
2012-11-05 19:01 ` [PATCH v2 05/10] install: check for non-SysV version " Blake Jones
@ 2012-11-06 16:51 ` Tomi Ollila
2012-11-08 6:22 ` Blake Jones
0 siblings, 1 reply; 17+ messages in thread
From: Tomi Ollila @ 2012-11-06 16:51 UTC (permalink / raw)
To: Blake Jones, notmuch
On Mon, Nov 05 2012, Blake Jones <blakej@foo.net> wrote:
Some quick comments, haven't got time to test yet.
// stuff deleted //
> diff --git a/vim/Makefile b/vim/Makefile
> index f17bebf..7ceba7a 100644
> --- a/vim/Makefile
> +++ b/vim/Makefile
> @@ -5,8 +5,6 @@ files = plugin/notmuch.vim \
> prefix = $(HOME)/.vim
> destdir = $(prefix)/plugin
>
> -INSTALL = install -D -m644
> -
> all: help
>
> help:
> @@ -17,7 +15,7 @@ help:
> @echo " make symlink - create symlinks in ~/.vim (useful for development)"
>
> install:
> - @for x in $(files); do $(INSTALL) $(CURDIR)/$$x $(prefix)/$$x; done
> + @for x in $(files); do $(INSTALL) -D -m644 $(CURDIR)/$$x $(prefix)/$$x; done
>
> -link symlink: INSTALL = ln -fs
> link symlink: install
> + @for x in $(files); do ln -fs $(CURDIR)/$$x $(prefix)/$$x; done
> --
Here you'd need to remove the 'install' dependency as it would first
do it and then overwriting the results with dependency..
another option is to use other variable like
__INSTALL = $(INSTALL) -D -m644
and then replace other uses of INSTALL with __INSTALL
(this doesn't look too good but that was what I could come
quickly)
> 1.7.3.2
Tomi
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 05/10] install: check for non-SysV version (Solaris support)
2012-11-06 16:51 ` Tomi Ollila
@ 2012-11-08 6:22 ` Blake Jones
0 siblings, 0 replies; 17+ messages in thread
From: Blake Jones @ 2012-11-08 6:22 UTC (permalink / raw)
To: Tomi Ollila; +Cc: notmuch
> > diff --git a/vim/Makefile b/vim/Makefile
> > index f17bebf..7ceba7a 100644
> > --- a/vim/Makefile
> > +++ b/vim/Makefile
> > @@ -5,8 +5,6 @@ files = plugin/notmuch.vim \
> > prefix = $(HOME)/.vim
> > destdir = $(prefix)/plugin
> >
> > -INSTALL = install -D -m644
> > -
> > all: help
> >
> > help:
> > @@ -17,7 +15,7 @@ help:
> > @echo " make symlink - create symlinks in ~/.vim (useful for dev
> elopment)"
> >
> > install:
> > - @for x in $(files); do $(INSTALL) $(CURDIR)/$$x $(prefix)/$$x; done
> > + @for x in $(files); do $(INSTALL) -D -m644 $(CURDIR)/$$x $(prefix)/$$x;
> done
> >
> > -link symlink: INSTALL = ln -fs
> > link symlink: install
> > + @for x in $(files); do ln -fs $(CURDIR)/$$x $(prefix)/$$x; done
> > --
>
> Here you'd need to remove the 'install' dependency as it would first
> do it and then overwriting the results with dependency.
Good catch, thanks; that's what I'll do. I also noticed a couple other
things in this file -- I need to "include ../Makefile.config" to get the
definition of $INSTALL, and $destdir isn't used in that Makefile.
Blake
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 06/10] strsep: check for availability (Solaris support)
2012-11-05 19:01 [PATCH v2 00/10] Solaris support Blake Jones
` (4 preceding siblings ...)
2012-11-05 19:01 ` [PATCH v2 05/10] install: check for non-SysV version " Blake Jones
@ 2012-11-05 19:01 ` Blake Jones
2012-11-05 19:02 ` [PATCH v2 07/10] gen-version-script: parse Solaris "nm" output " Blake Jones
` (3 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: Blake Jones @ 2012-11-05 19:01 UTC (permalink / raw)
To: notmuch
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).
---
compat/Makefile.local | 4 +++
compat/compat.h | 4 +++
compat/have_strsep.c | 10 +++++++
compat/strsep.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
configure | 17 +++++++++++++
5 files changed, 100 insertions(+), 0 deletions(-)
create mode 100644 compat/have_strsep.c
create mode 100644 compat/strsep.c
diff --git a/compat/Makefile.local b/compat/Makefile.local
index 13f16cd..2c4f65f 100644
--- a/compat/Makefile.local
+++ b/compat/Makefile.local
@@ -13,4 +13,8 @@ ifneq ($(HAVE_STRCASESTR),1)
notmuch_compat_srcs += $(dir)/strcasestr.c
endif
+ifneq ($(HAVE_STRSEP),1)
+notmuch_compat_srcs += $(dir)/strsep.c
+endif
+
SRCS := $(SRCS) $(notmuch_compat_srcs)
diff --git a/compat/compat.h b/compat/compat.h
index e5f833e..0b5e465 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -46,6 +46,10 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);
char* strcasestr(const char *haystack, const char *needle);
#endif /* !HAVE_STRCASESTR */
+#if !HAVE_STRSEP
+char *strsep(char **stringp, const char *delim);
+#endif /* !HAVE_STRSEP */
+
/* Silence gcc warnings about unused results. These warnings exist
* for a reason; any use of this needs to be justified. */
#ifdef __GNUC__
diff --git a/compat/have_strsep.c b/compat/have_strsep.c
new file mode 100644
index 0000000..5bd396c
--- /dev/null
+++ b/compat/have_strsep.c
@@ -0,0 +1,10 @@
+#define _GNU_SOURCE
+#include <string.h>
+
+int main()
+{
+ char *found;
+ char **stringp, const char *delim;
+
+ found = strsep(stringp, delim);
+}
diff --git a/compat/strsep.c b/compat/strsep.c
new file mode 100644
index 0000000..78ab9e7
--- /dev/null
+++ b/compat/strsep.c
@@ -0,0 +1,65 @@
+/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <string.h>
+
+/* Taken from glibc 2.6.1 */
+
+char *strsep (char **stringp, const char *delim)
+{
+ char *begin, *end;
+
+ begin = *stringp;
+ if (begin == NULL)
+ return NULL;
+
+ /* A frequent case is when the delimiter string contains only one
+ character. Here we don't need to call the expensive `strpbrk'
+ function and instead work using `strchr'. */
+ if (delim[0] == '\0' || delim[1] == '\0')
+ {
+ char ch = delim[0];
+
+ if (ch == '\0')
+ end = NULL;
+ else
+ {
+ if (*begin == ch)
+ end = begin;
+ else if (*begin == '\0')
+ end = NULL;
+ else
+ end = strchr (begin + 1, ch);
+ }
+ }
+ else
+ /* Find the end of the token. */
+ end = strpbrk (begin, delim);
+
+ if (end)
+ {
+ /* Terminate the token and set *STRINGP past NUL character. */
+ *end++ = '\0';
+ *stringp = end;
+ }
+ else
+ /* No more delimiters; this is the last token. */
+ *stringp = NULL;
+
+ return begin;
+}
diff --git a/configure b/configure
index d9a101f..ab8357f 100755
--- a/configure
+++ b/configure
@@ -512,6 +512,17 @@ else
fi
rm -f compat/have_strcasestr
+printf "Checking for strsep... "
+if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
+then
+ printf "Yes.\n"
+ have_strsep="1"
+else
+ printf "No (will use our own instead).\n"
+ have_strsep="0"
+fi
+rm -f compat/have_strsep
+
printf "Checking for standard version of getpwuid_r... "
if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
then
@@ -723,6 +734,10 @@ HAVE_GETLINE = ${have_getline}
# build its own version)
HAVE_STRCASESTR = ${have_strcasestr}
+# Whether the strsep function is available (if not, then notmuch will
+# build its own version)
+HAVE_STRSEP = ${have_strsep}
+
# Whether the getpwuid_r function is standards-compliant
# (if not, then notmuch will #define _POSIX_PTHREAD_SEMANTICS
# to enable the standards-compliant version -- needed for Solaris)
@@ -782,12 +797,14 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\$(VALGRIND_CFLAGS) \\
-DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
+ -DHAVE_STRSEP=\$(HAVE_STRSEP) \\
-DSTD_GETPWUID=\$(STD_GETPWUID) \\
-DSTD_ASCTIME=\$(STD_ASCTIME)
CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS) \\
\$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
\$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS) \\
-DHAVE_STRCASESTR=\$(HAVE_STRCASESTR) \\
+ -DHAVE_STRSEP=\$(HAVE_STRSEP) \\
-DSTD_GETPWUID=\$(STD_GETPWUID) \\
-DSTD_ASCTIME=\$(STD_ASCTIME)
CONFIGURE_LDFLAGS = \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS) \\
--
1.7.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 07/10] gen-version-script: parse Solaris "nm" output (Solaris support)
2012-11-05 19:01 [PATCH v2 00/10] Solaris support Blake Jones
` (5 preceding siblings ...)
2012-11-05 19:01 ` [PATCH v2 06/10] strsep: check for availability " Blake Jones
@ 2012-11-05 19:02 ` Blake Jones
2012-11-06 16:58 ` Tomi Ollila
2012-11-05 19:02 ` [PATCH v2 08/10] notmuch-config: use strchr(), not index() " Blake Jones
` (2 subsequent siblings)
9 siblings, 1 reply; 17+ messages in thread
From: Blake Jones @ 2012-11-05 19:02 UTC (permalink / raw)
To: notmuch
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.
---
lib/Makefile.local | 4 +++
lib/gen-version-script.sh | 50 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 0c6b258..2068e4a 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -30,7 +30,11 @@ LIBRARY_SUFFIX = so
LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
SONAME = $(LINKER_NAME).$(LIBNOTMUCH_VERSION_MAJOR)
LIBNAME = $(SONAME).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
+ifeq ($(PLATFORM),SOLARIS)
+LIBRARY_LINK_FLAG = -shared -Wl,-M notmuch.sym -Wl,-soname=$(SONAME) -Wl,--no-undefined -lc
+else
LIBRARY_LINK_FLAG = -shared -Wl,--version-script=notmuch.sym,-soname=$(SONAME) -Wl,--no-undefined
+endif
ifeq ($(PLATFORM),OPENBSD)
LIBRARY_LINK_FLAG += -lc
endif
diff --git a/lib/gen-version-script.sh b/lib/gen-version-script.sh
index 76670d5..d7d96da 100644
--- a/lib/gen-version-script.sh
+++ b/lib/gen-version-script.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
# we go through a bit of work to get the unmangled names of the
# typeinfo symbols because of
@@ -11,10 +12,44 @@ fi
HEADER=$1
shift
+if [ `uname -s` == SunOS ] ; then
+ #
+ # Using Solaris "nm", a defined symbol looks like this:
+ #
+ # [Index] Value Size Type Bind Other Shndx Name
+ # [15] | 128| 16|FUNC |GLOB |0 |1 |notmuch_tags_get
+ #
+ # and an undefined symbol looks like this:
+ #
+ # [Index] Value Size Type Bind Other Shndx Name
+ # [35] | 0| 0|NOTY |GLOB |0 |UNDEF |notmuch_tags_get
+ #
+ find_xapian_error() {
+ nawk -F'\|' '$7 !~ "UNDEF" && $8 ~ "Xapian.*Error" { print $8 }'
+ }
+ find_compat_syms() {
+ nawk -F'\|' '$7 !~ "UNDEF" && $8 ~ "get(line|delim)" { print $8 ";" }'
+ }
+ demangle() {
+ gc++filt "$@"
+ }
+else
+ find_xapian_error() {
+ awk '$1 ~ "^[0-9a-fA-F][0-9a-fA-F]*$" && $3 ~ "Xapian.*Error" {print $3}'
+ }
+ find_compat_syms() {
+ awk '$1 ~ "^[0-9a-fA-F][0-9a-fA-F]*$" && $2 == "T" && $3 ~ "^get(line|delim)$" {print $3 ";"}'
+ }
+ demangle() {
+ c++filt "$@"
+ }
+fi
+
printf '{\nglobal:\n'
-nm $* | awk '$1 ~ "^[0-9a-fA-F][0-9a-fA-F]*$" && $3 ~ "Xapian.*Error" {print $3}' | sort | uniq | \
-while read sym; do
- demangled=$(c++filt $sym)
+
+# Find the typeinfo for "Xapian::*Error"s.
+nm $* | find_xapian_error | sort | uniq | while read sym; do
+ demangled=$(demangle $sym)
case $demangled in
typeinfo*)
printf "\t$sym;\n"
@@ -23,6 +58,11 @@ while read sym; do
;;
esac
done
-nm $* | awk '$1 ~ "^[0-9a-fA-F][0-9a-fA-F]*$" && $2 == "T" && $3 ~ "^get(line|delim)$" {print $3 ";"}'
-sed -n 's/^[[:space:]]*\(notmuch_[a-z_]*\)[[:space:]]*(.*/ \1;/p' $HEADER
+
+# Find the "compat" syms that we need to export.
+nm $* | find_compat_syms
+
+# Finally, get the real notmuch symbols.
+sed -n 's/^[ ]*\(notmuch_[a-z_]*\)[ ]*(.*/ \1;/p' $HEADER
+
printf "local: *;\n};\n"
--
1.7.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v2 07/10] gen-version-script: parse Solaris "nm" output (Solaris support)
2012-11-05 19:02 ` [PATCH v2 07/10] gen-version-script: parse Solaris "nm" output " Blake Jones
@ 2012-11-06 16:58 ` Tomi Ollila
2012-11-08 6:29 ` Blake Jones
0 siblings, 1 reply; 17+ messages in thread
From: Tomi Ollila @ 2012-11-06 16:58 UTC (permalink / raw)
To: Blake Jones, notmuch
On Mon, Nov 05 2012, Blake Jones <blakej@foo.net> wrote:
> 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.
// stuff deleted
> index 76670d5..d7d96da 100644
> --- a/lib/gen-version-script.sh
> +++ b/lib/gen-version-script.sh
> @@ -1,3 +1,4 @@
> +#!/bin/sh
>
> # we go through a bit of work to get the unmangled names of the
> # typeinfo symbols because of
> @@ -11,10 +12,44 @@ fi
> HEADER=$1
> shift
>
> +if [ `uname -s` == SunOS ] ; then
> + #
> + # Using Solaris "nm", a defined symbol looks like this:
> + #
The POSIX / Bourne -comformant equality comparison is '='.
e.g.
$ ./heirloom-sh/sh -c ' [ a == b ] || echo x'
./heirloom-sh/sh: test: unknown operator ==
zsh: exit 1 ./heirloom-sh/sh -c ' [ a == b ] || echo x'
Interesting that Solaris /bin/sh did not fail there...
Hmm, gen-version-script doesn't have shebang... it is run like:
sh $(srcdir)/$(lib)/gen-version-script.sh $< $(libnotmuch_modules) > $@
in lib/Makefile.local -- taking sh fron PATH.
Tomi
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 07/10] gen-version-script: parse Solaris "nm" output (Solaris support)
2012-11-06 16:58 ` Tomi Ollila
@ 2012-11-08 6:29 ` Blake Jones
2012-11-08 8:55 ` Tomi Ollila
0 siblings, 1 reply; 17+ messages in thread
From: Blake Jones @ 2012-11-08 6:29 UTC (permalink / raw)
To: Tomi Ollila; +Cc: notmuch
>> @@ -11,10 +12,44 @@ fi
>> HEADER=$1
>> shift
>>
>> +if [ `uname -s` == SunOS ] ; then
>> + #
>> + # Using Solaris "nm", a defined symbol looks like this:
>> + #
>
> The POSIX / Bourne -comformant equality comparison is '='.
Sigh, of course it is. Fixed.
> e.g.
>
> $ ./heirloom-sh/sh -c ' [ a == b ] || echo x'
> ./heirloom-sh/sh: test: unknown operator ==
> zsh: exit 1 ./heirloom-sh/sh -c ' [ a == b ] || echo x'
>
> Interesting that Solaris /bin/sh did not fail there...
I was running on Solaris 11.1, which uses ksh93 as its /bin/sh. You're
absolutely right that Solaris 10 would fall over, though.
Similarly, the following line:
demangled=$(demangle $sym)
doesn't work on traditional sh. I've replaced $() with ``.
> Hmm, gen-version-script doesn't have shebang... it is run like:
>
> sh $(srcdir)/$(lib)/gen-version-script.sh $< $(libnotmuch_modules) > $@
>
> in lib/Makefile.local -- taking sh fron PATH.
I updated the first line from the #! invocation to a comment saying
# This script is invoked via "sh .../gen-version-script.sh".
Would a respun version of these patches help toward testing?
Blake
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 07/10] gen-version-script: parse Solaris "nm" output (Solaris support)
2012-11-08 6:29 ` Blake Jones
@ 2012-11-08 8:55 ` Tomi Ollila
2012-11-08 15:40 ` Blake Jones
0 siblings, 1 reply; 17+ messages in thread
From: Tomi Ollila @ 2012-11-08 8:55 UTC (permalink / raw)
To: Blake Jones; +Cc: notmuch
On Thu, Nov 08 2012, Blake Jones <blakej@foo.net> wrote:
>>> @@ -11,10 +12,44 @@ fi
>>> HEADER=$1
>>> shift
>>>
>>> +if [ `uname -s` == SunOS ] ; then
>>> + #
>>> + # Using Solaris "nm", a defined symbol looks like this:
>>> + #
>>
>> The POSIX / Bourne -comformant equality comparison is '='.
>
> Sigh, of course it is. Fixed.
>
>> e.g.
>>
>> $ ./heirloom-sh/sh -c ' [ a == b ] || echo x'
>> ./heirloom-sh/sh: test: unknown operator ==
>> zsh: exit 1 ./heirloom-sh/sh -c ' [ a == b ] || echo x'
>>
>> Interesting that Solaris /bin/sh did not fail there...
>
> I was running on Solaris 11.1, which uses ksh93 as its /bin/sh. You're
> absolutely right that Solaris 10 would fall over, though.
>
> Similarly, the following line:
>
> demangled=$(demangle $sym)
>
> doesn't work on traditional sh. I've replaced $() with ``.
>
>> Hmm, gen-version-script doesn't have shebang... it is run like:
>>
>> sh $(srcdir)/$(lib)/gen-version-script.sh $< $(libnotmuch_modules) > $@
>>
>> in lib/Makefile.local -- taking sh fron PATH.
>
> I updated the first line from the #! invocation to a comment saying
>
> # This script is invoked via "sh .../gen-version-script.sh".
looks good
> Would a respun version of these patches help toward testing?
$ grep vim test/*
zsh: exit 1 grep vim test/*
i.e. no vim tests...
Also, as *I* will execute my tests in Linux these won't make things
fail -- and probably no-one else eager to test won't have problems
either
So I think these patches are good until someone(tm) finds other
issues (if any),
> Blake
Tomi
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2 07/10] gen-version-script: parse Solaris "nm" output (Solaris support)
2012-11-08 8:55 ` Tomi Ollila
@ 2012-11-08 15:40 ` Blake Jones
0 siblings, 0 replies; 17+ messages in thread
From: Blake Jones @ 2012-11-08 15:40 UTC (permalink / raw)
To: Tomi Ollila; +Cc: notmuch
>> Would a respun version of these patches help toward testing?
>
> $ grep vim test/*
> zsh: exit 1 grep vim test/*
>
> i.e. no vim tests...
Sure -- I was referring to any more general testing you might do.
Anyway, thanks for your comments. Barring any more comments I'll
probably send out an updated patch set later today.
Blake
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 08/10] notmuch-config: use strchr(), not index() (Solaris support)
2012-11-05 19:01 [PATCH v2 00/10] Solaris support Blake Jones
` (6 preceding siblings ...)
2012-11-05 19:02 ` [PATCH v2 07/10] gen-version-script: parse Solaris "nm" output " Blake Jones
@ 2012-11-05 19:02 ` Blake Jones
2012-11-05 19:02 ` [PATCH v2 09/10] debugger.c: correct return type from getppid() " Blake Jones
2012-11-05 19:02 ` [PATCH v2 10/10] timegm: add portable implementation " Blake Jones
9 siblings, 0 replies; 17+ messages in thread
From: Blake Jones @ 2012-11-05 19:02 UTC (permalink / raw)
To: notmuch
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.)
---
notmuch-config.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/notmuch-config.c b/notmuch-config.c
index 3e37a2d..47eb743 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -688,7 +688,7 @@ _item_split (char *item, char **group, char **key)
*group = item;
- period = index (item, '.');
+ period = strchr (item, '.');
if (period == NULL || *(period+1) == '\0') {
fprintf (stderr,
"Invalid configuration name: %s\n"
--
1.7.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 09/10] debugger.c: correct return type from getppid() (Solaris support)
2012-11-05 19:01 [PATCH v2 00/10] Solaris support Blake Jones
` (7 preceding siblings ...)
2012-11-05 19:02 ` [PATCH v2 08/10] notmuch-config: use strchr(), not index() " Blake Jones
@ 2012-11-05 19:02 ` Blake Jones
2012-11-05 19:02 ` [PATCH v2 10/10] timegm: add portable implementation " Blake Jones
9 siblings, 0 replies; 17+ messages in thread
From: Blake Jones @ 2012-11-05 19:02 UTC (permalink / raw)
To: notmuch
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.
---
debugger.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/debugger.c b/debugger.c
index e8b9378..8ff13d6 100644
--- a/debugger.c
+++ b/debugger.c
@@ -36,7 +36,7 @@ debugger_is_active (void)
if (RUNNING_ON_VALGRIND)
return TRUE;
- sprintf (buf, "/proc/%d/exe", getppid ());
+ sprintf (buf, "/proc/%d/exe", (int) getppid ());
if (readlink (buf, buf, sizeof (buf)) != -1 &&
strncmp (basename (buf), "gdb", 3) == 0)
{
--
1.7.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 10/10] timegm: add portable implementation (Solaris support)
2012-11-05 19:01 [PATCH v2 00/10] Solaris support Blake Jones
` (8 preceding siblings ...)
2012-11-05 19:02 ` [PATCH v2 09/10] debugger.c: correct return type from getppid() " Blake Jones
@ 2012-11-05 19:02 ` Blake Jones
9 siblings, 0 replies; 17+ messages in thread
From: Blake Jones @ 2012-11-05 19:02 UTC (permalink / raw)
To: notmuch
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.
---
compat/Makefile.local | 4 +++
compat/compat.h | 19 ++++++++++------
compat/have_timegm.c | 7 ++++++
compat/timegm.c | 37 +++++++++++++++++++++++++++++++++
configure | 11 +++++++++
parse-time-string/Makefile.local | 4 ++-
parse-time-string/parse-time-string.c | 1 +
7 files changed, 75 insertions(+), 8 deletions(-)
create mode 100644 compat/have_timegm.c
create mode 100644 compat/timegm.c
diff --git a/compat/Makefile.local b/compat/Makefile.local
index 2c4f65f..b0d5417 100644
--- a/compat/Makefile.local
+++ b/compat/Makefile.local
@@ -17,4 +17,8 @@ ifneq ($(HAVE_STRSEP),1)
notmuch_compat_srcs += $(dir)/strsep.c
endif
+ifneq ($(HAVE_TIMEGM),1)
+notmuch_compat_srcs += $(dir)/timegm.c
+endif
+
SRCS := $(SRCS) $(notmuch_compat_srcs)
diff --git a/compat/compat.h b/compat/compat.h
index 0b5e465..5a402d5 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -30,6 +30,13 @@
extern "C" {
#endif
+#if !STD_GETPWUID
+#define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+#if !STD_ASCTIME
+#define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+
#if !HAVE_GETLINE
#include <stdio.h>
#include <unistd.h>
@@ -50,6 +57,11 @@ char* strcasestr(const char *haystack, const char *needle);
char *strsep(char **stringp, const char *delim);
#endif /* !HAVE_STRSEP */
+#if !HAVE_TIMEGM
+#include <time.h>
+time_t timegm (struct tm *tm);
+#endif /* !HAVE_TIMEGM */
+
/* Silence gcc warnings about unused results. These warnings exist
* for a reason; any use of this needs to be justified. */
#ifdef __GNUC__
@@ -58,13 +70,6 @@ char *strsep(char **stringp, const char *delim);
#define IGNORE_RESULT(x) x
#endif /* __GNUC__ */
-#if !STD_GETPWUID
-#define _POSIX_PTHREAD_SEMANTICS 1
-#endif
-#if !STD_ASCTIME
-#define _POSIX_PTHREAD_SEMANTICS 1
-#endif
-
#ifdef __cplusplus
}
#endif
diff --git a/compat/have_timegm.c b/compat/have_timegm.c
new file mode 100644
index 0000000..b62b793
--- /dev/null
+++ b/compat/have_timegm.c
@@ -0,0 +1,7 @@
+#include <time.h>
+#include "compat.h"
+
+int main()
+{
+ return (int) timegm((struct tm *)0);
+}
diff --git a/compat/timegm.c b/compat/timegm.c
new file mode 100644
index 0000000..6d76164
--- /dev/null
+++ b/compat/timegm.c
@@ -0,0 +1,37 @@
+#include <time.h>
+#include "compat.h"
+
+static int
+leapyear (int year)
+{
+ return ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0));
+}
+
+/*
+ * This is a simple implementation of timegm() which does what is needed
+ * by create_output() -- just turns the "struct tm" into a GMT time_t.
+ * It does not normalize any of the fields of the "struct tm", nor does
+ * it set tm_wday or tm_yday.
+ */
+time_t
+timegm (struct tm *tm)
+{
+ int monthlen[2][12] = {
+ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+ { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+ };
+ int year, month, days;
+
+ days = 365 * (tm->tm_year - 70);
+ for (year = 70; year < tm->tm_year; year++) {
+ if (leapyear(1900 + year)) {
+ days++;
+ }
+ }
+ for (month = 0; month < tm->tm_mon; month++) {
+ days += monthlen[leapyear(1900 + year)][month];
+ }
+ days += tm->tm_mday - 1;
+
+ return ((((days * 24) + tm->tm_hour) * 60 + tm->tm_min) * 60 + tm->tm_sec);
+}
diff --git a/configure b/configure
index ab8357f..f3ec9a2 100755
--- a/configure
+++ b/configure
@@ -523,6 +523,17 @@ else
fi
rm -f compat/have_strsep
+printf "Checking for timegm... "
+if ${CC} -o compat/have_timegm "$srcdir"/compat/have_timegm.c > /dev/null 2>&1
+then
+ printf "Yes.\n"
+ have_timegm="1"
+else
+ printf "No (will use our own instead).\n"
+ have_timegm="0"
+fi
+rm -f compat/have_timegm
+
printf "Checking for standard version of getpwuid_r... "
if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
then
diff --git a/parse-time-string/Makefile.local b/parse-time-string/Makefile.local
index 53534f3..c011e0b 100644
--- a/parse-time-string/Makefile.local
+++ b/parse-time-string/Makefile.local
@@ -1,7 +1,9 @@
dir := parse-time-string
extra_cflags += -I$(srcdir)/$(dir)
-libparse-time-string_c_srcs := $(dir)/parse-time-string.c
+libparse-time-string_c_srcs := \
+ $(notmuch_compat_srcs) \
+ $(dir)/parse-time-string.c
libparse-time-string_modules := $(libparse-time-string_c_srcs:.c=.o)
diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c
index 584067d..ccad422 100644
--- a/parse-time-string/parse-time-string.c
+++ b/parse-time-string/parse-time-string.c
@@ -32,6 +32,7 @@
#include <sys/time.h>
#include <sys/types.h>
+#include "compat.h"
#include "parse-time-string.h"
/*
--
1.7.3.2
^ permalink raw reply related [flat|nested] 17+ messages in thread