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 <julien@danjou.info>
This commit is contained in:
Hans Ulrich Niedermann 2008-01-25 11:49:12 +01:00 committed by Julien Danjou
parent 8434040cb2
commit ad28e78d13
2 changed files with 20 additions and 13 deletions

View file

@ -219,18 +219,18 @@ main(int argc, char *argv[])
args_ok = 0; args_ok = 0;
if(!a_strcmp("-v", argv[1]) || !a_strcmp("--version", argv[1])) 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__) \ #if defined(__GNUC__) \
&& defined(__GNUC_MINOR__) \ && defined(__GNUC_MINOR__) \
&& defined(__GNUC_PATCHLEVEL__) \ && defined(__GNUC_PATCHLEVEL__)
&& defined(AWESOME_COMPILE_MACHINE) printf(" by gcc version %d.%d.%d",
printf(" for %s by gcc version %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
AWESOME_COMPILE_MACHINE, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#endif #endif
#if defined(AWESOME_COMPILE_HOST) && defined(AWESOME_COMPILE_BY) printf(" (%s@%s)\n", AWESOME_COMPILE_BY, AWESOME_COMPILE_HOSTNAME);
printf(" (" AWESOME_COMPILE_BY "@" AWESOME_COMPILE_HOST ")");
#endif
printf("\n");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
else if(!a_strcmp("-h", argv[1]) || !a_strcmp("--help", argv[1])) else if(!a_strcmp("-h", argv[1]) || !a_strcmp("--help", argv[1]))

View file

@ -24,10 +24,7 @@ std-options
subdir-objects subdir-objects
]) ])
AC_DEFINE_UNQUOTED([RELEASE], ["Productivity Breaker"]) AC_DEFINE_UNQUOTED([RELEASE], ["Productivity Breaker"], [release code name])
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_MSG_CHECKING([package version according to autoconf]) AC_MSG_CHECKING([package version according to autoconf])
AC_MSG_RESULT([${PACKAGE_VERSION}]) 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"]) 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. # Checks for libraries.
AC_PATH_XTRA AC_PATH_XTRA
PKG_CHECK_MODULES([CAIRO], [cairo],, PKG_CHECK_MODULES([CAIRO], [cairo],,