Add some simple tests to the configure script to detect strndup and
getline. It's not important that the tests run, just that they
compile and link without any errors.
Signed-off-by: Jeffrey C. Ollie
---
configure | 20 +++-
getlinetest.c | 13 +
strnduptest.c | 10 ++
3 files changed, 42 insertions(+), 1 deletions(-)
create mode 100644 getlinetest.c
create mode 100644 strnduptest.c
diff --git a/configure b/configure
index b4770ec..44c1700 100755
--- a/configure
+++ b/configure
@@ -118,6 +118,24 @@ EOF
exit 1
fi
+if ! gcc -o strnduptest strnduptest.c > /dev/null 2>&1
+then
+echo "Checking for strndup... No."
+strndup=-Dstrndup=_notmuch_strndup
+else
+echo "Checking for strndup... Yes."
+fi
+rm -f strnduptest
+
+if ! gcc -o getlinetest getlinetest.c > /dev/null 2>&1
+then
+echo "Checking for getline... No."
+getline=-Dgetline=_notmuch_getline
+else
+echo "Checking for getline... Yes."
+fi
+rm -f getlinetest
+
cat < Makefile.config <
+#include
+
+int main()
+{
+ ssize_t count = 0;
+ size_t n = 0;
+ char **lineptr = NULL;
+ FILE *stream = NULL;
+
+ count = getline(lineptr, , stream);
+}
diff --git a/strnduptest.c b/strnduptest.c
new file mode 100644
index 000..97c7c80
--- /dev/null
+++ b/strnduptest.c
@@ -0,0 +1,10 @@
+#include
+
+int main()
+{
+ char *d;
+ const char *s = "";
+ size_t n = 0;
+
+ d = strndup(s, n);
+}
--
1.6.5.2