Merge pull request #26 from dseguin/integrate-version-in-makefile

Integrate version number into makefile (fixes #6)
This commit is contained in:
Murilo Pereira 2018-07-27 16:04:28 +02:00 committed by GitHub
commit c60f1bb11f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 14 deletions

View File

@ -1,5 +1,7 @@
VERSION = 1.0.0
CC = gcc CC = gcc
CFLAGS = -W -Wall -pedantic -ansi -std=c99 -g CFLAGS = -W -Wall -pedantic -ansi -std=c99 -g -DTS_VERSION=\"$(VERSION)\"
LDFLAGS = -lncursesw LDFLAGS = -lncursesw

View File

@ -1 +0,0 @@
1.0.0

View File

@ -8,6 +8,10 @@
#include "keyboard.h" #include "keyboard.h"
#include "common.h" #include "common.h"
#ifndef TS_VERSION
#define TS_VERSION "n/a"
#endif
const char *program_name; const char *program_name;
struct game game; struct game game;
@ -123,16 +127,5 @@ void usage(const char *program_name) {
} }
void version() { void version() {
FILE *version_file; printf("%s\n", TS_VERSION);
char version_string[6];
if (!(version_file = fopen("VERSION", "rb"))) {
tty_solitaire_generic_error(errno, __FILE__, __LINE__);
}
if (!fread(version_string, 1, 5, version_file)) {
// TODO: handle this.
}
version_string[5] = '\0';
printf("%s\n", version_string);
fclose(version_file);
} }