diff options
author | Aaron Ball <nullspoon@oper.io> | 2019-10-28 19:20:01 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2019-10-28 19:20:01 -0600 |
commit | 5d08f81419e728ebeec196c26b541163b1786a51 (patch) | |
tree | 698bbf23a1d76bf97efb9a3fa0ab14ab98f570f0 | |
parent | 037736c60d3361b1acae57ed1e8913ba0ac4c9b7 (diff) | |
parent | 97410850f9d8ffd6846bd8f19ecf9e7e5d9cb48e (diff) | |
download | luminous-5d08f81419e728ebeec196c26b541163b1786a51.tar.gz luminous-5d08f81419e728ebeec196c26b541163b1786a51.tar.xz |
Merge branch 'version'
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | src/main.c | 31 |
2 files changed, 35 insertions, 6 deletions
@@ -5,10 +5,18 @@ BINDIR=/usr/bin INITDIR=/etc/rc.d CONFDIR=/etc/ +VERSION = 1 +PATCHLEVEL = 1 +SUBLEVEL = 0 +EXTRAVERSION = -rc1 + +VERSTR = "$(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL))$(EXTRAVERSION)" + + all: if [ ! -d obj ]; then mkdir obj; fi cc $(CCOPTS) $(DBG) src/config.c -c -o obj/config.o - cc $(CCOPTS) $(DBG) obj/*.o src/main.c -o luminous + cc $(CCOPTS) $(DBG) -DVERSTR=$(VERSTR) obj/*.o src/main.c -o luminous install: install -D luminous ${DESTDIR}/${BINDIR}/luminous @@ -24,6 +24,10 @@ #define CONF "/etc/luminous.conf" +// For string macros +#define xstr(s) str(s) +#define str(s) #s + struct props { int lvl; @@ -48,6 +52,19 @@ void props_new(struct props* p) { /** + * version_print: + * @fd File descriptor to print version information to + * + * Prints version information for the current build to the specified file + * descriptor. + * NOTE: Version information is pulled from a macro defined by the Makefile. + */ +void version_print(FILE* fd) { + fprintf(fd, "luminous %s\n", xstr(VERSTR)); +} + + +/** * fgeti: * @path * @@ -177,11 +194,12 @@ void usage() { " luminous --rate 10 --step 8 --level [+-]400\n" "\n" "Arguments:\n" -" -h,--help Print this helptext\n" -" -s,--step Fade step (default: 6)\n" -" -r,--rate Time in milliseconds between fade steps (default: 10)\n" -" -l,--level Brightness level to change to. Supports absolute values and\n" -" relative values prefixed with + and -." +" -h,--help Print this helptext\n" +" -s,--step Fade step (default: 6)\n" +" -r,--rate Time in milliseconds between fade steps (default: 10)\n" +" -l,--level Brightness level to change to. Supports absolute values and\n" +" relative values prefixed with + and -.\n" +" -V,--version Print program version" "\n\n" ); } @@ -226,6 +244,9 @@ int parseargs(struct props* out, int argc, char* argv[]) { } else { out->lvl = atoi(argv[i]); } + } else if(strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) { + version_print(stdout); + return -2; } else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { usage(); return -2; |