diff --git a/configure.ac b/configure.ac index 3d42057..1cccdf0 100644 --- a/configure.ac +++ b/configure.ac @@ -182,6 +182,13 @@ elif test -f /etc/mtab; then mtab_type=file fi +# Check program_invocation_short_name and getprogname() +AC_CHECK_DECLS([program_invocation_short_name], [], [], + [[#include ]]) + +AS_IF([test "x$ac_cv_have_decl_program_invocation_short_name" != "xyes"], + [AC_CHECK_FUNCS([getprogname])]) + # Check for conditional libraries and headers. AS_IF([test "${with_blkid}" = "yes"], [ NILFS_UTILS_PKG_CHECK([BLKID], [blkid], [ diff --git a/include/compat.h b/include/compat.h index 214bbca..c52229a 100644 --- a/include/compat.h +++ b/include/compat.h @@ -203,4 +203,14 @@ #endif /* HAVE_SYS_SYSMACROS_H */ +#ifndef HAVE_GETPROGNAME +#if defined(HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME) && \ + HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME +#include +#define getprogname() ((const char *)program_invocation_short_name) +#else +#error "No way to retrieve the program name" +#endif +#endif /* HAVE_GETPROGNAME */ + #endif /* __COMPAT_H__ */