From 752997462a922402531c92b22dd7ab5af352f408 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 3 Jan 2012 08:58:01 +0100 Subject: [PATCH] Base getprogname() on program_invocation_short_name presence instead of glibc --- configure.ac | 9 +++++++++ src/progname.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0304f57..54da101 100644 --- a/configure.ac +++ b/configure.ac @@ -45,6 +45,15 @@ AC_CHECK_DECL([F_CLOSEM], #include ]) # Checks for library functions. +AC_MSG_CHECKING([for program_invocation_short_name]) +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[const char *p = program_invocation_short_name;]])], + [AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1], + [Define to 1 if you have program_invocation_short_name]) + AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])]) + AC_MSG_CHECKING([for __progname]) AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], diff --git a/src/progname.c b/src/progname.c index 4d0fee7..9bc5e4b 100644 --- a/src/progname.c +++ b/src/progname.c @@ -42,7 +42,7 @@ static const char *__progname = NULL; const char * getprogname(void) { -#ifdef __GLIBC__ +#if defined(HAVE_PROGRAM_INVOCATION_SHORT_NAME) if (__progname == NULL) __progname = program_invocation_short_name; #elif defined(HAVE_GETEXECNAME)