-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
73 lines (55 loc) · 1.7 KB
/
Makefile
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
#### variables section
# change them if needed
# xpaint version
VERSION = 0.3.0
# instalation path
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
# tools
CC ?= clang
CLANGTIDY ?= clang-tidy
#### targets section
SRC = ./xpaint.c
DEPS = $(SRC) ./res ./types.h ./config.h
all: help ## default target
help: ## display this help
@echo 'Usage: make [TARGET]... [ARGS="..."]'
@echo ''
@echo 'targets:'
@sed -ne '/@sed/!s/:.*##//p' $(MAKEFILE_LIST) | column -tl 2
run: xpaint-d ## run application with ARGS
./xpaint-d -v $(ARGS)
xpaint: $(DEPS) ## build release application
@$(CC) -o $@ $(SRC) $(CCFLAGS) -O2 -DNDEBUG
xpaint-d: $(DEPS) ## build debug application
@$(CC) -o $@ $(SRC) $(CCFLAGS) -g
clean: ## remove generated files
@rm -f xpaint xpaint-d
install: xpaint ## install application
@mkdir -p $(PREFIX)/bin
cp -f xpaint $(PREFIX)/bin
@chmod 755 $(PREFIX)/bin/xpaint
@mkdir -p $(MANPREFIX)/man1
sed "s/VERSION/$(VERSION)/g" < xpaint.1 > $(MANPREFIX)/man1/xpaint.1
@chmod 644 $(MANPREFIX)/man1/xpaint.1
uninstall: ## uninstall application
rm -f $(PREFIX)/bin/xpaint
rm -f $(MANPREFIX)/man1/xpaint.1
check: ## check code with clang-tidy
$(CLANGTIDY) $(SRC)
dev: clean ## generate dev files
bear -- $(MAKE) xpaint-d
.PHONY: all help run clean install uninstall check dev
#### compiler and linker flags
INCS = -I/usr/X11R6/include -I/usr/include/freetype2
LIBS = -L/usr/X11R6/lib -lX11 -lX11 -lm -lXext -lXft -lXrender
DEFINES = -DVERSION=\"$(VERSION)\" \
$(shell \
for res in ./res/* ; do \
echo -n $$(basename $$res) \
| tr '-' '_' \
| sed -En 's/(.*)\..*/\U-DRES_SZ_\1/p'; \
echo -n "=$$(stat -c %s $$res) "; \
done \
)
CCFLAGS = -std=c99 -pedantic -Wall $(INCS) $(LIBS) $(DEFINES)