Build: Only define HAVE_PROGRAM_INVOCATION_NAME if it is set to 1.

HAVE_DECL_PROGRAM_INVOCATION_NAME is renamed to
HAVE_PROGRAM_INVOCATION_NAME. Previously,
HAVE_DECL_PROGRAM_INVOCATION_NAME was always set when
building with autotools. CMake would only set this when it was 1, and the
dos/config.h did not define it. The new macro definition is consistent
across build systems.
This commit is contained in:
Jia Tan 2023-01-02 22:33:48 +08:00 committed by GitHub
parent dfecda8752
commit bb740e3b11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View File

@ -13,7 +13,6 @@ include(CheckSymbolExists)
function(tuklib_progname TARGET_OR_ALL) function(tuklib_progname TARGET_OR_ALL)
# NOTE: This glibc extension requires _GNU_SOURCE. # NOTE: This glibc extension requires _GNU_SOURCE.
check_symbol_exists(program_invocation_name errno.h check_symbol_exists(program_invocation_name errno.h
HAVE_DECL_PROGRAM_INVOCATION_NAME) HAVE_PROGRAM_INVOCATION_NAME)
tuklib_add_definition_if("${TARGET_OR_ALL}" tuklib_add_definition_if("${TARGET_OR_ALL}" HAVE_PROGRAM_INVOCATION_NAME)
HAVE_DECL_PROGRAM_INVOCATION_NAME)
endfunction() endfunction()

View File

@ -21,5 +21,8 @@
AC_DEFUN_ONCE([TUKLIB_PROGNAME], [ AC_DEFUN_ONCE([TUKLIB_PROGNAME], [
AC_REQUIRE([TUKLIB_COMMON]) AC_REQUIRE([TUKLIB_COMMON])
AC_CHECK_DECLS([program_invocation_name], [], [], [#include <errno.h>]) AC_CHECK_DECL([program_invocation_name], [AC_DEFINE(
[HAVE_PROGRAM_INVOCATION_NAME], [1],
[Define to 1 if PROGRAM_INVOCATION_NAME is declared in <errno.h>])],
[], [#include <errno.h>])
])dnl ])dnl

View File

@ -14,7 +14,7 @@
#include <string.h> #include <string.h>
#if !HAVE_DECL_PROGRAM_INVOCATION_NAME #ifndef HAVE_PROGRAM_INVOCATION_NAME
char *progname = NULL; char *progname = NULL;
#endif #endif

View File

@ -18,7 +18,7 @@
TUKLIB_DECLS_BEGIN TUKLIB_DECLS_BEGIN
#if HAVE_DECL_PROGRAM_INVOCATION_NAME #ifdef HAVE_PROGRAM_INVOCATION_NAME
# define progname program_invocation_name # define progname program_invocation_name
#else #else
# define progname TUKLIB_SYMBOL(tuklib_progname) # define progname TUKLIB_SYMBOL(tuklib_progname)