]> rtime.felk.cvut.cz Git - sojka/sterm.git/blobdiff - Makefile
Add --help and --version command line switches
[sojka/sterm.git] / Makefile
index 6aa5b90fab7031f06a97628886a80e4e726f9384..6c04adf52a3fd4acfe062a3ce187b6d5e2e19728 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,42 @@
-CFLAGS = -O2 -Wall
-LDFLAGS = -llockdev
+CFLAGS = -O2 -Wall -g -DSTERM_VERSION='"$(shell git describe)"'
 
-all: sterm
+ifneq ($(findstring HAVE_LOCKDEV,$(CFLAGS)),)
+LDLIBS = -llockdev
+endif
+
+PREFIX ?= /usr/local
+INSTALL ?= install
+INSTALL_BIN ?= install -s
 
-%: %.c
-       $(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
+all: sterm
 
 clean:
        rm -f sterm
 
 install: all
-       install -d $(DESTDIR)/usr/bin
-       install -m 755 sterm $(DESTDIR)/usr/bin
-       install -d $(DESTDIR)/usr/local/man/man1
-       install -m 644 sterm.man $(DESTDIR)/usr/local/man/man1/sterm.1
-       gzip -f $(DESTDIR)/usr/local/man/man1/sterm.1
+       $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
+       $(INSTALL_BIN) -m 755 sterm $(DESTDIR)$(PREFIX)/bin
+ifneq ($(NO_MAN),1)
+       $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/man/man1
+       $(INSTALL) -m 644 sterm.man $(DESTDIR)$(PREFIX)/share/man/man1/sterm.1
+       gzip -f $(DESTDIR)$(PREFIX)/share/man/man1/sterm.1
+endif
+ifneq ($(NO_COMP),1)
+       $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/bash-completion/completions/
+       $(INSTALL) -m 644 completion.bash $(DESTDIR)$(PREFIX)/share/bash-completion/completions/sterm
+       $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/zsh/functions/Completion/Unix/
+       $(INSTALL) -m 644 completion.zsh $(DESTDIR)$(PREFIX)/share/zsh/functions/Completion/Unix/_sterm
+endif
+
+deb:
+       sbuild
+
+# Deb cross-building (% stands for debian architecture such as armhf)
+deb-%:
+       sbuild --host=$* --add-depends=libc-dev:$* --build-failed-commands='%s'
+
+release:
+       gbp dch --release -N $(shell date +%Y%m%d) --commit
+       gbp buildpackage --git-tag -b
+       debrelease rtime
+       git push --follow-tags