replace: Add check for variable program_invocation_short_name
authorMartin Schwenke <martin@meltin.net>
Mon, 12 Nov 2018 23:05:21 +0000 (10:05 +1100)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 13 Nov 2018 10:11:11 +0000 (11:11 +0100)
It appears that wafsamba's configure() defines _GNU_SOURCE
unconditionally, so checking _GNU_SOURCE isn't enough to know if this
variable is available.

For example, it isn't available on AIX with the xlc compiler:

  [ 6/10] Compiling lib/replace/replace.c
  ...
  "../../lib/replace/replace.c", line 991.16: 1506-045 (S) Undeclared identifier program_invocation_short_name.

Instead, add a configure check for program_invocation_short_name and
use it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Nov 13 11:11:11 CET 2018 on sn-devel-144

lib/replace/replace.c
lib/replace/wscript

index 9b1df3dc3bde0fb3b943aef02e5f6f7579e37b9f..a14322b8e578a94f693b53478829a1d55cd5d043 100644 (file)
@@ -980,16 +980,16 @@ int rep_memset_s(void *dest, size_t destsz, int ch, size_t count)
 #endif /* HAVE_MEMSET_S */
 
 #ifndef HAVE_GETPROGNAME
-# ifndef _GNU_SOURCE
+# ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
 # define PROGNAME_SIZE 32
 static char rep_progname[PROGNAME_SIZE];
-# endif /* _GNU_SOURCE */
+# endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */
 
 const char *rep_getprogname(void)
 {
-#ifdef _GNU_SOURCE
+#ifdef HAVE_PROGRAM_INVOCATION_SHORT_NAME
        return program_invocation_short_name;
-#else /* _GNU_SOURCE */
+#else /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */
        FILE *fp = NULL;
        char cmdline[4096] = {0};
        char *p = NULL;
@@ -1053,6 +1053,6 @@ const char *rep_getprogname(void)
        (void)snprintf(rep_progname, sizeof(rep_progname), "%s", p);
 
        return rep_progname;
-#endif /* _GNU_SOURCE */
+#endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */
 }
 #endif /* HAVE_GETPROGNAME */
index c8693a3f2e17fbde4005a790f210a844441391f7..ff918146ffa46383cafd2148b05ac4afd83688f1 100644 (file)
@@ -607,6 +607,7 @@ def configure(conf):
 
     conf.CHECK_VARIABLE('rl_event_hook', define='HAVE_DECL_RL_EVENT_HOOK', always=True,
                         headers='readline.h readline/readline.h readline/history.h')
+    conf.CHECK_VARIABLE('program_invocation_short_name', headers='errno.h')
 
     conf.CHECK_DECLS('snprintf vsnprintf asprintf vasprintf')