2021-03-20 10:52:45 +01:00
|
|
|
.POSIX:
|
|
|
|
|
2023-04-01 07:51:42 +02:00
|
|
|
BIN := dwmblocks
|
2023-03-25 17:08:05 +01:00
|
|
|
BUILD_DIR := build
|
|
|
|
SRC_DIR := src
|
2023-10-24 05:14:31 +02:00
|
|
|
INC_DIR := include
|
2022-08-24 16:34:53 +02:00
|
|
|
|
2024-03-19 02:22:21 +01:00
|
|
|
DEBUG := 0
|
2023-04-01 07:51:42 +02:00
|
|
|
VERBOSE := 0
|
2023-10-24 05:14:31 +02:00
|
|
|
LIBS := xcb-atom
|
2023-04-01 07:51:42 +02:00
|
|
|
|
2023-03-25 17:08:05 +01:00
|
|
|
PREFIX := /usr/local
|
2023-10-25 16:30:08 +02:00
|
|
|
CFLAGS := -Ofast -I. -I$(INC_DIR) -std=c99
|
2023-10-24 05:14:31 +02:00
|
|
|
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))
|
2022-08-24 16:34:53 +02:00
|
|
|
|
2023-10-24 05:14:31 +02:00
|
|
|
SRCS := $(wildcard $(SRC_DIR)/*.c)
|
|
|
|
OBJS := $(subst $(SRC_DIR)/,$(BUILD_DIR)/,$(SRCS:.c=.o))
|
2023-03-25 17:08:05 +01:00
|
|
|
|
2023-04-06 02:48:16 +02:00
|
|
|
INSTALL_DIR := $(DESTDIR)$(PREFIX)/bin
|
2023-04-01 07:51:42 +02:00
|
|
|
|
|
|
|
# Prettify output
|
|
|
|
PRINTF := @printf "%-8s %s\n"
|
|
|
|
ifeq ($(VERBOSE), 0)
|
|
|
|
Q := @
|
|
|
|
endif
|
|
|
|
|
2024-03-19 02:22:21 +01:00
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -g
|
|
|
|
endif
|
|
|
|
|
2023-03-25 17:08:05 +01:00
|
|
|
all: $(BUILD_DIR)/$(BIN)
|
|
|
|
|
2023-10-24 05:14:31 +02:00
|
|
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c config.h
|
|
|
|
$Qmkdir -p $(@D)
|
2023-04-01 07:51:42 +02:00
|
|
|
$(PRINTF) "CC" $@
|
|
|
|
$Q$(COMPILE.c) -o $@ $<
|
2023-03-25 17:08:05 +01:00
|
|
|
|
2023-10-24 05:14:31 +02:00
|
|
|
$(BUILD_DIR)/$(BIN): $(OBJS)
|
|
|
|
$(PRINTF) "LD" $@
|
|
|
|
$Q$(LINK.o) $^ $(LDLIBS) -o $@
|
2021-03-20 10:52:45 +01:00
|
|
|
|
|
|
|
clean:
|
2023-04-06 02:48:16 +02:00
|
|
|
$(PRINTF) "CLEAN" $(BUILD_DIR)
|
|
|
|
$Q$(RM) $(BUILD_DIR)/*
|
2022-08-24 16:34:53 +02:00
|
|
|
|
2023-03-25 17:08:05 +01:00
|
|
|
install: $(BUILD_DIR)/$(BIN)
|
2023-04-01 07:51:42 +02:00
|
|
|
$(PRINTF) "INSTALL" $(INSTALL_DIR)/$(BIN)
|
|
|
|
$Qinstall -D -m 755 $< $(INSTALL_DIR)/$(BIN)
|
2022-08-24 16:34:53 +02:00
|
|
|
|
2021-03-20 10:52:45 +01:00
|
|
|
uninstall:
|
2023-04-01 07:51:42 +02:00
|
|
|
$(PRINTF) "RM" $(INSTALL_DIR)/$(BIN)
|
|
|
|
$Q$(RM) $(INSTALL_DIR)/$(BIN)
|
2021-03-20 10:52:45 +01:00
|
|
|
|
2023-03-25 17:08:05 +01:00
|
|
|
.PHONY: all clean install uninstall
|