diff --git a/ccache.c b/ccache.c index bef9d08..eef28a5 100644 --- a/ccache.c +++ b/ccache.c @@ -128,7 +128,9 @@ static const char *tmp_string(void) if (!ret) { char hostname[200]; strcpy(hostname, "unknown"); +#if HAVE_GETHOSTNAME gethostname(hostname, sizeof(hostname)-1); +#endif hostname[sizeof(hostname)-1] = 0; asprintf(&ret, "%s.%u", hostname, (unsigned)getpid()); } diff --git a/config.h.in b/config.h.in index 74d6f29..286f038 100644 --- a/config.h.in +++ b/config.h.in @@ -16,6 +16,9 @@ */ #undef HAVE_DIRENT_H +/* Define to 1 if you have the `gethostname' function. */ +#undef HAVE_GETHOSTNAME + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H diff --git a/configure b/configure index 5ef7df7..4eea3b8 100755 --- a/configure +++ b/configure @@ -3269,7 +3269,8 @@ done -for ac_func in realpath snprintf vsnprintf vasprintf asprintf mkstemp + +for ac_func in realpath snprintf vsnprintf vasprintf asprintf mkstemp gethostname do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 diff --git a/configure.in b/configure.in index 8ae73b3..5f59109 100644 --- a/configure.in +++ b/configure.in @@ -29,7 +29,7 @@ AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h) -AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) +AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp gethostname) AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [ AC_TRY_COMPILE(