-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (63 loc) · 1.96 KB
/
Makefile
File metadata and controls
85 lines (63 loc) · 1.96 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
83
84
85
INCLUDE_DIRS = -Isrc/rb-tree -Isrc/c-vector -Isrc/ini
CC = gcc
CFLAGS = -Wall -Wextra $(INCLUDE_DIRS)
LDFLAGS = -lm -pthread
VGFLAGS = --track-origins=yes --leak-check=full
LDFLAGS += $(shell pkg-config --libs ncursesw)
PREFIX ?= ~/.local/bin
# Install path to use in mod_and_install since it has to be run as root so we can't use ~
_SU_INSTALL_PATH = $(shell echo "`pwd | cut -d/ -f1-3`/`echo $(PREFIX) | cut -d/ -f3-`")
ifneq (, $(shell which mold))
LDFLAGS += -fuse-ld=mold
endif
ifdef DEBUG
CFLAGS += -O0 -g
else
CFLAGS += -O3 -march=native -mtune=native
endif
ifdef PROFILE
CFLAGS += -pg
LDFLAGS += -pg
endif
source_files = $(wildcard src/*.c src/canvas/*.c src/ps/*.c) \
src/nc-help/help.c src/ini/ini.c
object_files = $(patsubst src/%.c,build/%.o,$(source_files))
formatting_files = $(wildcard src/*.c src/*.h src/canvas/*.c src/canvas/*.h \
src/ps/*.c src/ps/*.h)
# Changing the theme structure requires a full rebuild or colors will be
# messed up due to wrong offsets into the theme structure
# XXX: should really just use correct dependencies for all files
deps = src/stdafx.h src/theme.h
all: build_dirs build/stdafx.h.gch sm
build_dirs:
@mkdir -p build
@mkdir -p build/nc-help
@mkdir -p build/canvas
@mkdir -p build/ps
@mkdir -p build/rb-tree
@mkdir -p build/ini
build/stdafx.h.gch: src/stdafx.h
$(CC) $(INCLUDE_DIRS) -o $@ -x c-header $<
build/%.o: src/%.c $(deps)
$(CC) $(CFLAGS) -c -o $@ $<
sm: $(object_files)
$(CC) -o $@ $^ $(LDFLAGS)
vgclean:
rm -f vgcore.* callgrind.out.*
clean: vgclean
rm -rf build sm
vg: sm
valgrind $(VGFLAGS) ./sm $(VGARGS) 2>err
cg: sm
valgrind --tool=callgrind -v ./sm -r 100 2>err
install: sm
cp sm $(PREFIX)/sm
mod: sm
@echo "Warning: Giving sm root permissions under normal execution from now on."
chown root sm
chmod +s sm
mod_and_install: mod
cp sm $(_SU_INSTALL_PATH)/sm
format:
@clang-format -i $(formatting_files)
.PHONY: clean vg cg install mod mod_and_install format