configure.ac: Hack around Termux syslog weirdness.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 19 May 2018 23:46:50 +0000 (00:46 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 19 May 2018 23:47:03 +0000 (00:47 +0100)
Termux's <syslog.h> has weird macros to redirect to Android's logcat
machinery, but these need a separate library to be linked in.  Notice
this weirdness and cope.

configure.ac
progs/Makefile.am

index 40353da..b41687a 100644 (file)
@@ -245,6 +245,29 @@ AC_SEARCH_LIBS([sqrt], [m])
 AC_SUBST([MATHLIBS], [$LIBS])
 LIBS=$mdw_ORIG_LIBS
 
+dnl Logging is weird under Termux.  Unfortunately, it involves macros, so we
+dnl have to do this the hard way.
+AC_CACHE_CHECK(
+  [library needed for syslog], [mdw_cv_syslog_lib],
+  [mdw_ORIG_LIBS=$LIBS LIBS=
+   for i in 0 1; do
+     AC_TRY_LINK([#include <syslog.h>],
+                [openlog("test", LOG_PID, LOG_DAEMON);
+                 syslog(LOG_ERR, "this is a test");],
+                [ok=t], [ok=nil])
+     case $i,$ok in
+       *,t) mdw_cv_syslog_lib=${LIBS:-none}; break ;;
+       0,nil) LIBS="-llog" ;;
+       1,nil) AC_MSG_ERROR("failed to link test program") ;;
+     esac
+   done
+   LIBS=$mdw_ORIG_LIBS])
+case $mdw_cv_syslog_lib in
+  none) LOGLIBS= ;;
+  *) LOGLIBS=$mdw_cv_syslog_lib ;;
+esac
+AC_SUBST([LOGLIBS])
+
 dnl Find out whether very long integer types are available.
 AC_CHECK_HEADERS([stdint.h])
 AC_SUBST([have_stdint_h])
index 883174d..ff7f5f7 100644 (file)
@@ -101,7 +101,7 @@ perftest_LDADD               = $(LDADD) $(MATHLIBS)
 ## Remember passphrases for limited periods of time.
 bin_PROGRAMS           += pixie
 pixie_SOURCES           = pixie.c
-pixie_LDADD             = $(UTILS_LIBS) $(PIXIE_LIBS)
+pixie_LDADD             = $(UTILS_LIBS) $(PIXIE_LIBS) $(LOGLIBS)
 dist_man_MANS          += pixie.1
 EXTRA_DIST             += xpixie