[weston,5/8] Use getprogname as fallback for program_invocation_short_name

Submitted by Greg V on Dec. 17, 2017, 7:04 p.m.

Details

Message ID 20171217190442.29265-6-greg@unrelenting.technology
State New
Headers show
Series "Portability patches" ( rev: 1 ) in Wayland

Not browsing as part of any series.

Commit Message

Greg V Dec. 17, 2017, 7:04 p.m.
---
 configure.ac | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Patch hide | download patch | download mbox

diff --git a/configure.ac b/configure.ac
index 253f7e73..c800d1aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,6 +107,27 @@  AC_CHECK_HEADERS([execinfo.h linux/memfd.h])
 
 AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
 
+AC_MSG_CHECKING([for program_invocation_short_name])
+AC_TRY_COMPILE([#include <errno.h>],
+	       [const char *pn = program_invocation_short_name;],
+	       AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME, 1, [Define to 1 if program_invocation_short_name exists])
+	       AC_MSG_RESULT(yes),
+	       AC_MSG_RESULT(no))
+
+AC_MSG_CHECKING([for getprogname])
+AC_TRY_COMPILE([#include <stdlib.h>],
+	       [getprogname();],
+	       AC_DEFINE(HAVE_GETPROGNAME, 1, [Define to 1 if getprogname exists])
+	       AC_MSG_RESULT(yes),
+	       AC_MSG_RESULT(no))
+
+AH_BOTTOM([#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
+#ifdef HAVE_GETPROGNAME
+#include <stdlib.h>
+#define program_invocation_short_name getprogname()
+#endif
+#endif])
+
 # check for libdrm as a build-time dependency only
 # libdrm 2.4.30 introduced drm_fourcc.h.
 PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.30], [], [AC_MSG_ERROR([