aboutsummaryrefslogtreecommitdiff
path: root/src/libparsec/sys_date.cpp
blob: a68c2eeb952fe2f4cb63dc7aa0dd1aec96ae65ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * PARSEC - Build Info
 *
 * $Author: uberlinuxguy $ - $Date: 2004/09/15 12:25:42 $
 *
 * Orginally written by:
 *   Copyright (c) Clemens Beer        <cbx@parsec.org>   2002
 *   Copyright (c) Markus Hadwiger     <msh@parsec.org>   1996-1999
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */ 

// C library
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

// compilation flags/debug support
#include "config.h"
#include "debug.h"

// local module header
#include "sys_date.h"



// determine target system

#if defined( SYSTEM_TARGET_WINDOWS )
	#define SYSTEM_TEXT			"/windows "
#elif defined( SYSTEM_TARGET_LINUX )
	#define SYSTEM_TEXT			"/linux "
#elif defined( SYSTEM_TARGET_OSX )
	#define SYSTEM_TEXT			"/osx "
#else
	#define SYSTEM_TEXT			"/unknown "
#endif


// determine build

#ifdef DEBUG
	#define BUILD_TEXT "openparsec" SYSTEM_TEXT "debug build " CLIENT_BUILD_NUMBER
#else
	#define BUILD_TEXT "openparsec" SYSTEM_TEXT "release build " CLIENT_BUILD_NUMBER
#endif


// helper macros

#define BUILD_STR(x)			#x
#define BUILD_VER(x)			BUILD_STR(x)


// determine compiler

#if defined( SYSTEM_COMPILER_MSVC )
	#define BUILD_COMPILER		"compiler: microsoft visual c++ (" BUILD_VER(_MSC_VER) ")"
#elif defined( SYSTEM_COMPILER_CLANG )
	#define BUILD_COMPILER		"compiler: clang " BUILD_VER(__clang_major__.__clang_minor__.__clang_patchlevel__)
#elif defined( SYSTEM_COMPILER_LLVM_GCC )
	#define BUILD_COMPILER		"compiler: llvm-gcc " BUILD_VER(__GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__)
#elif defined( SYSTEM_COMPILER_GCC )
	#define BUILD_COMPILER		"compiler: gnu c++ " BUILD_VER(__GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__)
#else
	#error "unsupported compiler!"
#endif


// determine binding

#define BUILD_BINDING			"subsystem binding: static"


// determine endianness

#if defined( SYSTEM_BIG_ENDIAN )
	#define BUILD_ENDIANNESS	"endianness: big endian"
#else
	#define BUILD_ENDIANNESS	"endianness: little endian"
#endif


//NOTE:
// create build information.
// this module is compiled on every make/build to
// ensure build information is always up to date.

const char build_text[] = BUILD_TEXT;
const char build_date[] = __DATE__;
const char build_time[] = __TIME__;

const char build_comp[] = BUILD_COMPILER;
const char build_bind[] = BUILD_BINDING;
const char build_endn[] = BUILD_ENDIANNESS;



// return current system date and time ----------------------------------------
//
char *SYS_SystemTime()
{
	// fetch system time
	time_t curtime = time( NULL );
	char * timestr = ctime( &curtime );

	return timestr;
}