rosenrot/makefile

60 lines
1.4 KiB
Makefile
Raw Normal View History

# C compiler
# CC=gcc # alternatives: tcc, clang, zig cc
CC=tcc
2023-03-28 16:59:38 +00:00
# Dependencies
2024-03-12 16:37:28 +00:00
DEPS='webkit2gtk-4.1'
2023-03-28 16:59:38 +00:00
INCS=`pkg-config --cflags ${DEPS}`
LIBS=`pkg-config --libs ${DEPS}`
# Code
SRC=rosenrot.c
2023-03-28 17:11:18 +00:00
2024-03-24 01:24:38 +00:00
## Runtime files
MAINTAINER_CACHE_DIR=/home/nuno/.cache/rosenrot
USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot
2023-03-28 17:11:18 +00:00
2024-03-24 01:24:38 +00:00
build: $(SRC) user_cache
2024-03-24 00:51:55 +00:00
$(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
2024-03-24 00:51:55 +00:00
install: rosenrot
cp -f rosenrot /usr/bin
2023-03-28 16:59:38 +00:00
depsdebian:
sudo apt install tcc make
sudo apt install libwebkit2gtk-4.1-dev
2024-03-24 01:24:38 +00:00
## Additional niceties
### Formatter
STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true, AllowShortEnumsOnASingleLine: true}"
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
2024-03-24 02:29:26 +00:00
stats:
cat rosenrot.c | wc -l
gcc -fpreprocessed -dD -E -P rosenrot.c | wc -l
2024-03-24 01:24:38 +00:00
format: $(SRC)
$(FORMATTER) $(SRC)
lint:
clang-tidy $(SRC) -- -Wall $(INCS) -o rosenrot $(LIBS)
### Cleanup functions
2023-03-28 17:44:54 +00:00
uninstall:
rm /usr/bin/rosenrot
rm $(USER_CACHE_DIR)
2023-03-28 17:44:54 +00:00
clean:
rm rosenrot
rm $(USER_CACHE_DIR)
2023-03-28 17:44:54 +00:00