]> git.lizzy.rs Git - bspwm.git/blobdiff - Makefile
Fix window centering
[bspwm.git] / Makefile
index 2d838c0ab3fd5992de24bc116e9bd1a8d6ed4edc..2572636e99b85fe9bf64fb76a67935d128d1bc91 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,70 @@
-# CFLAGS=-Wall -g -pendantic
+VERSION = 0.8.8
 
-all:
-       gcc -Wall -g -pedantic -llua -lxcb -o bspwm main.c utils.c settings.c luautils.c messages.c commands.c events.c
+CC      ?= gcc
+LIBS     = -lm -lxcb -lxcb-icccm -lxcb-ewmh -lxcb-randr -lxcb-xinerama
+CFLAGS  += -std=c99 -pedantic -Wall -Wextra -I$(PREFIX)/include
+CFLAGS  += -D_POSIX_C_SOURCE=200112L -DVERSION=\"$(VERSION)\"
+LDFLAGS += -L$(PREFIX)/lib
+
+PREFIX   ?= /usr/local
+BINPREFIX = $(PREFIX)/bin
+MANPREFIX = $(PREFIX)/share/man
+BASHCPL = $(PREFIX)/share/bash-completion/completions
+ZSHCPL = $(PREFIX)/share/zsh/site-functions
+
+WM_SRC = bspwm.c helpers.c settings.c monitor.c desktop.c tree.c stack.c history.c \
+        events.c pointer.c window.c messages.c query.c restore.c rule.c ewmh.c subscribe.c
+WM_OBJ = $(WM_SRC:.c=.o)
+CL_SRC = bspc.c helpers.c
+CL_OBJ = $(CL_SRC:.c=.o)
+
+all: CFLAGS += -Os
+all: LDFLAGS += -s
+all: bspwm bspc
+
+debug: CFLAGS += -O0 -g -DDEBUG
+debug: bspwm bspc
+
+include Sourcedeps
+
+$(WM_OBJ) $(CL_OBJ): Makefile
+
+.c.o:
+       $(CC) $(CFLAGS) $(OPTFLAGS) -c -o $@ $<
+
+bspwm: $(WM_OBJ)
+       $(CC) -o $@ $(WM_OBJ) $(LDFLAGS) $(LIBS)
+
+bspc: $(CL_OBJ)
+       $(CC) -o $@ $(CL_OBJ) $(LDFLAGS) $(LIBS)
+
+install:
+       mkdir -p "$(DESTDIR)$(BINPREFIX)"
+       cp -p bspwm "$(DESTDIR)$(BINPREFIX)"
+       cp -p bspc "$(DESTDIR)$(BINPREFIX)"
+       mkdir -p "$(DESTDIR)$(MANPREFIX)"/man1
+       cp -p doc/bspwm.1 "$(DESTDIR)$(MANPREFIX)"/man1
+       cp -Pp doc/bspc.1 "$(DESTDIR)$(MANPREFIX)"/man1
+       mkdir -p "$(DESTDIR)$(BASHCPL)"
+       cp -p contrib/bash_completion "$(DESTDIR)$(BASHCPL)"/bspc
+       mkdir -p "$(DESTDIR)$(ZSHCPL)"
+       cp -p contrib/zsh_completion "$(DESTDIR)$(ZSHCPL)"/_bspc
+
+uninstall:
+       rm -f "$(DESTDIR)$(BINPREFIX)"/bspwm
+       rm -f "$(DESTDIR)$(BINPREFIX)"/bspc
+       rm -f "$(DESTDIR)$(MANPREFIX)"/man1/bspwm.1
+       rm -f "$(DESTDIR)$(MANPREFIX)"/man1/bspc.1
+       rm -f "$(DESTDIR)$(BASHCPL)"/bspc
+       rm -f "$(DESTDIR)$(ZSHCPL)"/_bspc
+
+deps:
+       $(CC) -MM *.c > Sourcedeps
+
+doc:
+       a2x -v -d manpage -f manpage -a revnumber=$(VERSION) doc/bspwm.1.txt
 
 clean:
-       rm -f bspwm
+       rm -f $(WM_OBJ) $(CL_OBJ) bspwm bspc
+
+.PHONY: all debug install uninstall doc deps clean