This repository was archived by the owner on Feb 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
82 lines (62 loc) · 1.78 KB
/
makefile
File metadata and controls
82 lines (62 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
.PHONY: all clean run run-log debug profile install uninstall
.ONESHELL:
PREFIX ?= /usr
VERSION ?= 0.1.0
NAME ?= halen
BUILD_DIR ?= build
DEPS := x11 xtst xext xfixes fontconfig xft
CC ?= gcc
CFLAGS += -Wall -Wextra -std=gnu99 -O0 -I$(BUILD_DIR) -I$(SRC_DIR) \
$(shell pkg-config --cflags $(DEPS))
LIBS = -lpthread $(shell pkg-config --libs $(DEPS))
SRC_DIR = src
ifdef DEBUG
CFLAGS += -fsanitize=address -fno-omit-frame-pointer -g
LDFLAGS += -fsanitize=address
endif
ifdef PROFILE
CFLAGS += -g -O1
endif
SRC = $(wildcard $(SRC_DIR)/*.c)
OBJ = $(SRC:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
EXEC = $(BUILD_DIR)/$(NAME)
LOG = .gcc
DATA_DIR := $(DESTDIR)$(PREFIX)/share/$(NAME)
all: $(EXEC)
install: $(EXEC)
install -Dm644 ./data/config $(DATA_DIR)/config
install -Dm755 $(EXEC) $(DESTDIR)$(PREFIX)/bin/$(NAME)
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(NAME) $(DATA_DIR)/config
$(EXEC): $(OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
$(BUILD_DIR)/%.o: src/%.c $(BUILD_DIR)/config.h | $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
run:
rm -f .log $(LOG)
$(MAKE) clean
$(MAKE) $(EXEC) --no-print-directory 2>&1 | tee -a $(LOG)
./$(EXEC) -c .config -V
run-log:
# signals doesnt work perfect when we PIPE to tee..
rm -f .log $(LOG)
$(MAKE) clean
$(MAKE) $(EXEC) --no-print-directory 2>&1 | tee -a $(LOG)
./$(EXEC) -c .config -V | tee -a .log
clean:
rm -rf $(BUILD_DIR) $(LOG)
$(BUILD_DIR)/config.h: makefile | $(BUILD_DIR)
@echo "/* Generated by makefile */" > $@
@echo "#define VERSION \"$(VERSION)\"" >> $@
@echo "#define PROGRAM_NAME \"$(NAME)\"" >> $@
@echo "#define DATA_DIR \"$(DATA_DIR)\"" >> $@
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
debug:
$(MAKE) clean
$(MAKE) DEBUG=1 $(EXEC)
./$(EXEC) -c .config -V
profile:
$(MAKE) clean
$(MAKE) PROFILE=1 $(EXEC)
heaptrack ./$(EXEC) -c .config -V