Add version-option
This commit is contained in:
parent
e7ba3183df
commit
04e2cd1dfe
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <socket_path>: Connect to i3 via <socket_path>\n");
|
||||
|
|
Loading…
Reference in New Issue