libs/libc/misc/lib_utsname.c: Add build date and time to uname output (like Linux).

This commit is contained in:
Gregory Nutt 2019-01-27 06:24:24 -06:00
parent d6740a6678
commit c40daffb5b
2 changed files with 11 additions and 0 deletions

View File

@ -109,6 +109,11 @@ ifeq ($(CONFIG_LIB_ENVPATH),y)
CSRCS += lib_envpath.c
endif
# To ensure uname information is newest,
# add lib_utsname.o to phony target for force rebuild
.PHONY: lib_utsname$(OBJEXT)
# Add the misc directory to the build
DEPPATH += --dep-path misc

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <sys/utsname.h>
#include <stdio.h>
#include <string.h>
#include <nuttx/version.h>
@ -115,7 +116,12 @@ int uname(FAR struct utsname *name)
strncpy(name->release, CONFIG_VERSION_STRING, SYS_NAMELEN);
name->release[SYS_NAMELEN-1] = '\0';
#if defined(__DATE__) && defined(__TIME__)
snprintf(name->version, VERSION_NAMELEN, "%s %s %s",
CONFIG_VERSION_BUILD, __DATE__, __TIME__);
#else
strncpy(name->version, CONFIG_VERSION_BUILD, VERSION_NAMELEN);
#endif
name->version[VERSION_NAMELEN-1] = '\0';
strncpy(name->machine, CONFIG_ARCH, SYS_NAMELEN);