From: Axel Wagner Date: Sat, 7 Aug 2010 01:50:22 +0000 (+0200) Subject: Add version-option X-Git-Tag: 4.0.1~7^2~80 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=04e2cd1dfea4c59924acbe4fa17d6c7da1c966e9;p=i3%2Fi3 Add version-option --- diff --git a/i3bar/Makefile b/i3bar/Makefile index 172a442d..57af15e1 100644 --- a/i3bar/Makefile +++ b/i3bar/Makefile @@ -14,5 +14,12 @@ src/%.o: src/%.c ${HEADERS} echo "CC $<" $(CC) $(CFLAGS) -c -o $@ $< +install: all + echo "INSTALL" + $(INSTALL) -d -m 0755 $(DESTDIR)$(PREFIX)/bin + $(INSTALL) -m 0755 i3bar $(DESTDIR)$(PREFIX)/bin + clean: rm src/*.o + +.PHONY: install clean diff --git a/i3bar/common.mk b/i3bar/common.mk index e2be3aab..65588314 100644 --- a/i3bar/common.mk +++ b/i3bar/common.mk @@ -1,9 +1,28 @@ +INSTALL=install +DEBUG=1 +PREFIX=/usr + +# The escaping is absurd, but we need to escape for shell, sed, make, define +GIT_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1), branch $(shell [ -f .git/HEAD ] && sed 's/ref: refs\/heads\/\(.*\)/\\\\\\"\1\\\\\\"/g' .git/HEAD || echo 'unknown'))" + CFLAGS += -Wall CFLAGS += -pipe CFLAGS += -Iinclude CFLAGS += -g +CFLAGS += -DI3BAR_VERSION=\"${GIT_VERSION}\" + LDFLAGS += -lev LDFLAGS += -lyajl LDFLAGS += -lxcb LDFLAGS += -lxcb-atom +LDFLAGS += -L/usr/local/lib + +ifeq ($(DEBUG),1) +CFLAGS += -g3 +else +CFLAGS += -O2 +endif + .SILENT: + +.PHONY: install clean diff --git a/i3bar/src/main.c b/i3bar/src/main.c index 4cb2fcb2..909106b3 100644 --- a/i3bar/src/main.c +++ b/i3bar/src/main.c @@ -39,10 +39,11 @@ int main(int argc, char **argv) { { "command", required_argument, 0, 'c' }, { "font", required_argument, 0, 'f' }, { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'v' }, { NULL, 0, 0, 0} }; - while ((opt = getopt_long(argc, argv, "s:c:f:h", long_opt, &option_index)) != -1) { + while ((opt = getopt_long(argc, argv, "s:c:f:hv", long_opt, &option_index)) != -1) { switch (opt) { case 's': socket_path = expand_path(optarg); @@ -53,6 +54,9 @@ int main(int argc, char **argv) { case 'f': fontname = strdup(optarg); break; + case 'v': + printf("i3bar version " I3BAR_VERSION " © 2010 Axel Wagner and contributors\n"); + exit(EXIT_SUCCESS); default: printf("Usage: %s [-s socket_path] [-c command] [-f font] [-h]\n", argv[0]); printf("-s : Connect to i3 via \n");