2024-02-11 21:13:53 +00:00
|
|
|
# C compiler
|
2024-03-14 22:31:04 +00:00
|
|
|
CC=gcc # alternatives: tcc, clang, zig cc
|
2023-07-27 12:34:16 +00:00
|
|
|
WARNINGS=-Wall
|
2024-02-11 21:13:53 +00:00
|
|
|
OPTIMIZED_SOME=-O3
|
|
|
|
OPTIMIZED_MORE=-Ofast -march=native -funit-at-a-time -flto # binary will not be compatible with other computers, but may be much faster
|
2024-07-21 15:09:33 +00:00
|
|
|
DEBUG=#-g
|
2024-03-24 11:54:33 +00:00
|
|
|
STD=-std=c99 # maybe consider moving to c11 and using safer string handling
|
2023-03-28 16:59:38 +00:00
|
|
|
|
2024-07-20 22:24:03 +00:00
|
|
|
# Dependencies for WebkitGTK4/GTK3
|
|
|
|
SRC_3=rosenrot3.c
|
|
|
|
DEPS_3='webkit2gtk-4.1'
|
|
|
|
INCS_3=`pkg-config --cflags ${DEPS_3}`
|
|
|
|
LIBS_3=`pkg-config --libs ${DEPS_3}`
|
|
|
|
|
|
|
|
# Dependencies for WebkitGTK6/GTK4
|
2024-07-21 14:44:45 +00:00
|
|
|
SRC_4=rosenrot4.c
|
2024-07-20 22:24:03 +00:00
|
|
|
DEPS_4='webkitgtk-6.0'
|
2024-07-21 00:02:19 +00:00
|
|
|
INCS_4=`pkg-config --cflags ${DEPS_4}` `pkg-config --cflags gtk4`
|
|
|
|
LIBS_4=`pkg-config --libs ${DEPS_4}` `pkg-config --libs gtk4`
|
2024-07-21 15:09:33 +00:00
|
|
|
DEPRECATION_FLAGS=-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED
|
2024-07-20 22:24:03 +00:00
|
|
|
|
|
|
|
# User config
|
2024-02-11 21:13:53 +00:00
|
|
|
CONFIG=config.h
|
2023-03-28 17:11:18 +00:00
|
|
|
|
2024-03-14 22:31:04 +00:00
|
|
|
# Plugins
|
2024-03-14 22:33:52 +00:00
|
|
|
include plugins/plugins.mk
|
|
|
|
# PLUGINS=./plugins/stand_in/stand_in.c
|
2024-03-24 11:07:29 +00:00
|
|
|
ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' # optional adblocking; depends on https://github.com/jun7/wyebadblock
|
2023-03-28 16:59:38 +00:00
|
|
|
|
2023-03-28 17:11:18 +00:00
|
|
|
## Formatter
|
2024-03-23 21:10:59 +00:00
|
|
|
STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true, AllowShortEnumsOnASingleLine: true}"
|
2024-04-14 13:00:54 +00:00
|
|
|
FORMATTER_C=clang-format -i -style=$(STYLE_BLUEPRINT)
|
|
|
|
FORMATTER_JS=npx prettier -w
|
2023-03-28 17:11:18 +00:00
|
|
|
|
2024-03-14 22:31:04 +00:00
|
|
|
# Runtime files
|
|
|
|
MAINTAINER_CACHE_DIR=/home/nuno/.cache/rosenrot
|
|
|
|
USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot
|
|
|
|
RUNTIME_FILES_DIR=/opt/rosenrot/
|
|
|
|
|
2024-07-21 15:09:33 +00:00
|
|
|
build: $(SRC_4) $(PLUGINS) $(CONFIG) constants user_cache
|
2024-07-20 22:24:03 +00:00
|
|
|
$(CC) $(STD) $(WARNINGS) $(DEPRECATION_FLAGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK)
|
2024-05-09 13:20:52 +00:00
|
|
|
@echo
|
2024-03-14 22:31:04 +00:00
|
|
|
|
2024-07-21 15:29:08 +00:00
|
|
|
build3: $(SRC_3) $(PLUGINS) $(CONFIG) constants user_cache
|
|
|
|
$(CC) $(STD) $(WARNINGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS_3) $(PLUGINS) $(SRC_3) -o rosenrot $(LIBS_3) $(ADBLOCK)
|
|
|
|
@echo
|
|
|
|
|
2024-07-21 15:09:33 +00:00
|
|
|
format: $(SRC_3) $(SRC_4) $(PLUGINS)
|
|
|
|
$(FORMATTER_C) $(SRC_3) $(PLUGINS) $(config.h)
|
|
|
|
$(FORMATTER_C) $(SRC_4_greenfield) $(PLUGINS) $(config.h)
|
|
|
|
$(FORMATTER_JS) plugins/readability/readability.js
|
|
|
|
$(FORMATTER_JS) plugins/style/style.js
|
|
|
|
|
|
|
|
# Installation
|
|
|
|
|
|
|
|
install: rosenrot runtime_files
|
|
|
|
cp -f rosenrot /usr/bin
|
|
|
|
cp rosenrot-mklink /usr/bin
|
|
|
|
@echo
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -r /opt/rosenrot
|
|
|
|
rm /usr/bin/rosenrot
|
|
|
|
rm /usr/bin/rosenrot-mklink
|
|
|
|
rm $(USER_CACHE_DIR)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm rosenrot
|
|
|
|
rm $(USER_CACHE_DIR)
|
2024-07-21 00:35:15 +00:00
|
|
|
|
2024-03-14 22:31:04 +00:00
|
|
|
constants:
|
2024-05-09 13:20:52 +00:00
|
|
|
@echo
|
2024-03-15 00:05:56 +00:00
|
|
|
@echo "# Computing constants"
|
2023-04-22 01:31:11 +00:00
|
|
|
cd plugins/readability/ && sh recompute_READABILITY_N.sh
|
|
|
|
cd plugins/style && sh recompute_STYLE_N.sh
|
2024-03-15 00:05:56 +00:00
|
|
|
@echo
|
2023-05-09 02:48:22 +00:00
|
|
|
|
2024-03-14 22:31:04 +00:00
|
|
|
user_cache:
|
2024-03-15 00:05:56 +00:00
|
|
|
@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"
|
2024-03-14 22:31:04 +00:00
|
|
|
mkdir -p $(USER_CACHE_DIR)
|
2024-05-09 13:20:52 +00:00
|
|
|
find . -type f -not -path "*.git*" -not -path "*makefile*" \
|
|
|
|
-exec sed -i "s|$(MAINTAINER_CACHE_DIR)|$(USER_CACHE_DIR)|g" {} +
|
2024-03-15 00:05:56 +00:00
|
|
|
@echo
|
2024-03-14 22:31:04 +00:00
|
|
|
|
|
|
|
runtime_files:
|
2024-05-09 13:20:52 +00:00
|
|
|
@echo
|
2024-03-14 22:31:04 +00:00
|
|
|
sudo mkdir -p /opt/rosenrot/
|
2024-07-21 15:09:33 +00:00
|
|
|
sudo cp styles-gtk/style-gtk3.css /opt/rosenrot/
|
|
|
|
sudo cp styles-gtk/style-gtk4.css /opt/rosenrot/
|
2024-07-24 16:58:54 +00:00
|
|
|
sudo touch /opt/rosenrot/uris.txt
|
|
|
|
sudo chmod a+rw /opt/rosenrot/uris.txt
|
2024-03-14 22:31:04 +00:00
|
|
|
sudo cp -r images/flower-imgs /opt/rosenrot/
|
2024-03-18 00:31:11 +00:00
|
|
|
sudo cp plugins/style/style.js /opt/rosenrot/
|
|
|
|
sudo cp plugins/readability/readability.js /opt/rosenrot/
|
2024-03-14 22:31:04 +00:00
|
|
|
|
2024-07-21 15:09:33 +00:00
|
|
|
# More misc recipes
|
2024-03-12 17:16:29 +00:00
|
|
|
|
2024-03-14 17:58:59 +00:00
|
|
|
lint:
|
2024-03-18 00:31:11 +00:00
|
|
|
clang-tidy $(SRC) $(PLUGINS) -- -Wall -O3 $(INCS) -o rosenrot $(LIBS)
|
2024-03-14 17:58:59 +00:00
|
|
|
|
|
|
|
fast: $(SRC) $(PLUGINS) $(CONFIG)
|
|
|
|
rm -f *.gcda
|
|
|
|
GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/
|
2024-07-21 15:09:33 +00:00
|
|
|
$(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-generate $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK)
|
2024-03-14 17:58:59 +00:00
|
|
|
@echo "Now use the browser for a while to gather some profiling data"
|
|
|
|
sleep 2
|
2024-03-14 18:47:36 +00:00
|
|
|
./rosenrot
|
2024-07-21 15:09:33 +00:00
|
|
|
$(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-use $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK)
|
2024-03-14 17:58:59 +00:00
|
|
|
rm -f *.gcda
|
|
|
|
|
2024-03-14 22:33:52 +00:00
|
|
|
inspect: rosenrot
|
2024-03-14 18:47:36 +00:00
|
|
|
GTK_DEBUG=interactive ./rosenrot
|
2024-03-14 17:58:59 +00:00
|
|
|
|
2024-03-14 22:33:52 +00:00
|
|
|
diagnose_deprecations: rosenrot
|
2024-03-14 18:47:36 +00:00
|
|
|
G_ENABLE_DIAGNOSTIC=1 ./rosenrot
|
2024-03-12 17:46:41 +00:00
|
|
|
|
|
|
|
view-gtk3-version:
|
|
|
|
dpkg -l libgtk-3-0
|
2024-03-14 22:31:04 +00:00
|
|
|
|
|
|
|
twitter:
|
|
|
|
sudo mkdir -p /usr/bin/rosenrot-browser
|
|
|
|
sudo cp rosenrot /usr/bin/rosenrot-browser/twitter
|