aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile57
1 files changed, 57 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..635673e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,57 @@
+.POSIX:
+
+BIN := dwmblocks
+BUILD_DIR := build
+SRC_DIR := src
+INC_DIR := include
+
+DEBUG := 0
+VERBOSE := 0
+LIBS := xcb-atom
+
+PREFIX := /usr/local
+CFLAGS := -Ofast -I. -I$(INC_DIR) -std=c99
+CFLAGS += -DBINARY=\"$(BIN)\" -D_POSIX_C_SOURCE=200809L
+CFLAGS += -Wall -Wpedantic -Wextra -Wswitch-enum
+CFLAGS += $(shell pkg-config --cflags $(LIBS))
+LDLIBS := $(shell pkg-config --libs $(LIBS))
+
+SRCS := $(wildcard $(SRC_DIR)/*.c)
+OBJS := $(subst $(SRC_DIR)/,$(BUILD_DIR)/,$(SRCS:.c=.o))
+
+INSTALL_DIR := $(DESTDIR)$(PREFIX)/bin
+
+# Prettify output
+PRINTF := @printf "%-8s %s\n"
+ifeq ($(VERBOSE), 0)
+ Q := @
+endif
+
+ifeq ($(DEBUG), 1)
+ CFLAGS += -g
+endif
+
+all: $(BUILD_DIR)/$(BIN)
+
+$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c config.h
+ $Qmkdir -p $(@D)
+ $(PRINTF) "CC" $@
+ $Q$(COMPILE.c) -o $@ $<
+
+$(BUILD_DIR)/$(BIN): $(OBJS)
+ $(PRINTF) "LD" $@
+ $Q$(LINK.o) $^ $(LDLIBS) -o $@
+
+clean:
+ $(PRINTF) "CLEAN" $(BUILD_DIR)
+ $Q$(RM) $(BUILD_DIR)/*
+
+install: $(BUILD_DIR)/$(BIN)
+ $(PRINTF) "INSTALL" $(INSTALL_DIR)/$(BIN)
+ $Qinstall -D -m 755 $< $(INSTALL_DIR)/$(BIN)
+
+uninstall:
+ $(PRINTF) "RM" $(INSTALL_DIR)/$(BIN)
+ $Q$(RM) $(INSTALL_DIR)/$(BIN)
+
+.PHONY: all clean install uninstall