aboutsummaryrefslogtreecommitdiff
path: root/makefile
blob: 8beaf94de458165c77e0aa380d4d6e696a12d056 (plain)
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
# C compiler
# CC=gcc # alternatives: tcc, clang, zig cc 
CC=tcc

# Dependencies
DEPS='webkit2gtk-4.1'
INCS=`pkg-config --cflags ${DEPS}`
LIBS=`pkg-config --libs ${DEPS}`

# Code
SRC=rosenrot.c

## Runtime files
MAINTAINER_CACHE_DIR=/home/nuno/.cache/rosenrot
USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot

build: $(SRC)  user_cache
	$(CC) $(INCS) $(SRC) -o rosenrot $(LIBS) $(ADBLOCK)

user_cache:
	@if [ `id -u` -eq 0 ]; then echo "can't run make user_cache with sudo, because USER_CACHE_DIR would be /home/root/.cache"; return 1; fi
	@echo "# Create user cache"
	mkdir -p $(USER_CACHE_DIR)
	find . -type f -not -path "*.git*" -not -path "*makefile*" -exec \
		sed -i "s|$(MAINTAINER_CACHE_DIR)|$(USER_CACHE_DIR)|g" {} +
	@echo

install: rosenrot
	cp -f rosenrot /usr/bin

depsdebian:
	sudo apt install tcc make
	sudo apt install libwebkit2gtk-4.1-dev

## Additional niceties

### Formatter
STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true, AllowShortEnumsOnASingleLine: true}" 
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)

format: $(SRC) 
	$(FORMATTER) $(SRC) 

lint: 
	clang-tidy $(SRC) -- -Wall $(INCS) -o rosenrot $(LIBS)

### Cleanup functions
uninstall: 
	rm /usr/bin/rosenrot
	rm $(USER_CACHE_DIR)

clean:
	rm rosenrot
	rm $(USER_CACHE_DIR)