]> git.sur5r.net Git - i3/i3lock/blobdiff - Makefile
print version number when invoked with -v
[i3/i3lock] / Makefile
index 1fd76b9436b7d4fd7b2410c7036f8ba9c38e1c1f..6b00e9a86b71c6551ebd59b63d6e23e75fa2039a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,51 +1,39 @@
-# slock - simple screen locker
-# © 2006-2007 Anselm R. Garbe, Sander van Dijk
-# © 2009 Michael Stapelberg
+INSTALL=install
+PREFIX=/usr
 
-include config.mk
+# Check if pkg-config is installed, we need it for building CFLAGS/LDFLAGS
+ifeq ($(shell which pkg-config 2>/dev/null 1>/dev/null || echo 1),1)
+$(error "pkg-config was not found")
+endif
 
-SRC = i3lock.c
-OBJ = ${SRC:.c=.o}
+CFLAGS += -std=c99
+CFLAGS += -pipe
+CFLAGS += -Wall
+CFLAGS += -D_GNU_SOURCE
+CFLAGS += $(shell pkg-config --cflags cairo xcb-keysyms xcb-dpms)
+LDFLAGS += $(shell pkg-config --libs cairo xcb-keysyms xcb-dpms xcb-image)
+LDFLAGS += -lpam
 
-all: options i3lock
+FILES:=$(wildcard *.c)
+FILES:=$(FILES:.c=.o)
 
-options:
-       @echo i3lock build options:
-       @echo "CFLAGS   = ${CFLAGS}"
-       @echo "LDFLAGS  = ${LDFLAGS}"
-       @echo "CC       = ${CC}"
+VERSION:=$(shell git describe --tags --abbrev=0)
+GIT_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1))"
+CFLAGS += -DVERSION=\"${GIT_VERSION}\"
 
-.c.o:
-       @echo CC $<
-       @${CC} -c ${CFLAGS} $<
+.PHONY: install clean uninstall
 
-${OBJ}: config.mk
+all: i3lock
 
-i3lock: ${OBJ}
-       @echo CC -o $@
-       @${CC} -o $@ ${OBJ} ${LDFLAGS}
+i3lock: ${FILES}
+       $(CC) -o $@ $^ $(LDFLAGS)
 
 clean:
-       @echo cleaning
-       @rm -f i3lock ${OBJ} i3lock-${VERSION}.tar.gz
-
-dist: clean
-       @echo creating dist tarball
-       @mkdir -p i3lock-${VERSION}
-       @cp -R LICENSE Makefile README config.mk i3lock.1 ${SRC} i3lock-${VERSION}
-       @tar -cf i3lock-${VERSION}.tar i3lock-${VERSION}
-       @gzip i3lock-${VERSION}.tar
-       @rm -rf i3lock-${VERSION}
+       rm -f i3lock ${FILES} i3lock-${VERSION}.tar.gz
 
 install: all
-       @echo installing executable file to $(DESTDIR)$(PREFIX)/bin
        $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
-       $(INSTALL) -d $(MANDIR)/man1
        $(INSTALL) -m 755 i3lock $(DESTDIR)$(PREFIX)/bin/i3lock
-       $(INSTALL) -m 644 i3lock.1 $(MANDIR)/man1/i3lock.1
 
 uninstall:
-       @echo removing executable file from $(DESTDIR)$(PREFIX)/bin
-       @rm -f $(DESTDIR)$(PREFIX)/bin/i3lock
-
-.PHONY: all options clean dist install uninstall
+       rm -f $(DESTDIR)$(PREFIX)/bin/i3lock