From ad28e78d131f4bfc5aca93cf5840a45f21d44f50 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Fri, 25 Jan 2008 11:49:12 +0100 Subject: [PATCH] Use pre-defined values for build infos (ifdef) Use information autoconf determines anyway (machine type building for, name of machine building on). Only print build information if it is actually available (defined). Add descriptions to all AC_DEFINE* macro definitions. Signed-off-by: Julien Danjou --- awesome.c | 18 +++++++++--------- configure.ac | 15 +++++++++++---- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/awesome.c b/awesome.c index b63c1a2f..24d62a4f 100644 --- a/awesome.c +++ b/awesome.c @@ -219,18 +219,18 @@ main(int argc, char *argv[]) args_ok = 0; if(!a_strcmp("-v", argv[1]) || !a_strcmp("--version", argv[1])) { - printf("awesome version " VERSION " (" RELEASE ")\ncompiled on "__DATE__" "__TIME__); + printf("awesome version " VERSION " (" RELEASE ")\ncompiled"); +#if defined(__DATE__) && defined(__TIME__) + printf(" at " __DATE__ " " __TIME__); +#endif + printf(" for %s", AWESOME_COMPILE_MACHINE); #if defined(__GNUC__) \ && defined(__GNUC_MINOR__) \ - && defined(__GNUC_PATCHLEVEL__) \ - && defined(AWESOME_COMPILE_MACHINE) - printf(" for %s by gcc version %d.%d.%d", - AWESOME_COMPILE_MACHINE, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); + && defined(__GNUC_PATCHLEVEL__) + printf(" by gcc version %d.%d.%d", + __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); #endif -#if defined(AWESOME_COMPILE_HOST) && defined(AWESOME_COMPILE_BY) - printf(" (" AWESOME_COMPILE_BY "@" AWESOME_COMPILE_HOST ")"); -#endif - printf("\n"); + printf(" (%s@%s)\n", AWESOME_COMPILE_BY, AWESOME_COMPILE_HOSTNAME); return EXIT_SUCCESS; } else if(!a_strcmp("-h", argv[1]) || !a_strcmp("--help", argv[1])) diff --git a/configure.ac b/configure.ac index 69c559d9..0fe4e898 100644 --- a/configure.ac +++ b/configure.ac @@ -24,10 +24,7 @@ std-options subdir-objects ]) -AC_DEFINE_UNQUOTED([RELEASE], ["Productivity Breaker"]) -AC_DEFINE_UNQUOTED([AWESOME_COMPILE_HOST], ["`type hostname > /dev/null && hostname`"]) -AC_DEFINE_UNQUOTED([AWESOME_COMPILE_BY], ["`type whoami > /dev/null && whoami`"]) -AC_DEFINE_UNQUOTED([AWESOME_COMPILE_MACHINE], ["`type uname > /dev/null && uname -m`"]) +AC_DEFINE_UNQUOTED([RELEASE], ["Productivity Breaker"], [release code name]) AC_MSG_CHECKING([package version according to autoconf]) AC_MSG_RESULT([${PACKAGE_VERSION}]) @@ -59,6 +56,16 @@ AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$DOXYGEN" != "x:"]) AM_CONDITIONAL([USING_GCC], [test "x$GCC" = "xyes"]) +AC_CANONICAL_HOST +AC_DEFINE_UNQUOTED([AWESOME_COMPILE_MACHINE], ["$host"], [build for this machine]) + +AC_DEFINE_UNQUOTED([AWESOME_COMPILE_HOSTNAME], ["${ac_hostname}"], [build host]) + +AC_ARG_VAR([WHOAMI], [whoami(1) command]) +AC_PATH_PROG([WHOAMI], [whoami], [false]) +AS_IF([test "x$WHOAMI" = "xfalse"], [aw_whoami="???"], [aw_whoami=`$WHOAMI`]) +AC_DEFINE_UNQUOTED([AWESOME_COMPILE_BY], ["$aw_whoami"], [build user]) + # Checks for libraries. AC_PATH_XTRA PKG_CHECK_MODULES([CAIRO], [cairo],,