-
Notifications
You must be signed in to change notification settings - Fork 10
/
version_info.c
64 lines (54 loc) · 1.73 KB
/
version_info.c
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
/**
* Function that prints version info. This file should be compiled with the following defined:
* - PACKAGE_VERSION, e.g. with `-DPACKAGE_VERSION="\"$(LC_ALL=C git --git-dir .git describe --tags --dirty)\""`
* - DATETIME, e.g. with `-DDATETIME="\"$(date +'%F %T UTC%z')\""`
*
* The code in this file is mostly taken from
* - CPython: https://github.com/python/cpython/, licensed under the PSF, available here: https://docs.python.org/3/license.html
* - The Ocarina of Time practice rom, gz: https://github.com/glankk/gz/
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
#if defined(IDO53)
#define IDO_VERSION "IDO 5.3"
#elif defined(IDO71)
#define IDO_VERSION "IDO 7.1"
#else
#define IDO_VERSION ""
#endif
#ifndef COMPILER
// Note the __clang__ conditional has to come before the __GNUC__ one because
// clang pretends to be GCC.
#if defined(__clang__)
#define COMPILER "Clang " __clang_version__
#elif defined(__GNUC__)
#define COMPILER "GCC " __VERSION__
// Generic fallbacks.
#elif defined(__cplusplus)
#define COMPILER "C++"
#else
#define COMPILER "C"
#endif
#endif /* !COMPILER */
/* git */
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION "Unknown version"
#endif
/* Date and time */
#ifndef DATETIME
#define DATETIME "Unknown date"
#endif
extern char* progname;
void print_version_info(void) {
char* buf = malloc(strlen(progname) + 1);
strcpy(buf, progname);
char* name = basename(buf);
printf("%s `%s` static recompilation, Decompals version\n", IDO_VERSION, name);
printf("Source: https://github.com/decompals/ido-static-recomp\n");
printf("Version: %s\n", PACKAGE_VERSION);
printf("Build date: %s\n", DATETIME);
printf("Compiler: %s\n", COMPILER);
free(buf);
}