2024-02-11 21:13:53 +00:00
# C compiler
CC = gcc # other options: tcc, clang, zig cc
2023-07-27 12:34:16 +00:00
WARNINGS = -Wall
2023-05-15 16:11:34 +00:00
DEBUG = #'-g'
2024-03-12 18:10:20 +00:00
COMPILETIME_DEPRECATION_WARNINGS = #-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED # turns out that webkit2gtk-4.1 is using some deprecated stuff, lol
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
2023-03-28 16:59:38 +00:00
2024-02-11 21:13:53 +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 } `
2024-02-11 21:13:53 +00:00
# Code
SRC = rose.c
CONFIG = config.h
2023-03-28 17:11:18 +00:00
## Plugins
2023-05-14 03:50:14 +00:00
LIBRE_REDIRECT = ./plugins/libre_redirect/libre_redirect.c ./plugins/libre_redirect/str_replace_start.c ./plugins/libre_redirect/str_init.c
2023-03-28 17:11:18 +00:00
CUSTOM_STYLES = ./plugins/style/style.c
2023-05-14 03:24:52 +00:00
READABILITY = ./plugins/readability/readability.c
SHORTCUTS = ./plugins/shortcuts/shortcuts.c
2023-03-28 16:59:38 +00:00
STAND_IN = ./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing
2024-02-11 14:56:53 +00:00
PLUGINS = $( LIBRE_REDIRECT) $( READABILITY) $( CUSTOM_STYLES) $( SHORTCUTS)
2024-02-11 21:13:53 +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
STYLE_BLUEPRINT = webkit
FORMATTER = clang-format -i -style= $( STYLE_BLUEPRINT)
2024-02-11 21:13:53 +00:00
# Change hardcoded paths when building
2024-03-12 18:10:20 +00:00
## Data dirs
2023-03-29 04:07:25 +00:00
USER = ` whoami`
2024-03-12 17:16:29 +00:00
DEFAULT_DATA_DIR = /home/nuno/.cache/rose
CURRENT_DATA_DIR = /home/$( USER) /.cache/rose
2023-03-29 04:07:25 +00:00
## dir
2024-03-12 18:10:20 +00:00
DEFAULT_DIR = /home/nuno/Documents/workspace/rosenrot
2023-03-29 04:07:25 +00:00
CURRENT_DIR = ` pwd `
2024-02-11 14:56:53 +00:00
build : $( SRC ) $( PLUGINS ) $( CONFIG )
2023-04-21 23:19:11 +00:00
# Recompute 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
2023-03-29 04:07:25 +00:00
# Make cache
2024-03-12 17:16:29 +00:00
mkdir -p $( CURRENT_DATA_DIR)
2023-03-29 04:07:25 +00:00
# Hardcode cache path
find $( CURRENT_DIR) -type f -not -path "*.git*" -not -path "*makefile*" -exec \
2024-03-12 17:16:29 +00:00
sed -i " s| $( DEFAULT_DATA_DIR) | $( CURRENT_DATA_DIR) |g " { } +
2023-03-29 04:07:25 +00:00
# Hardcode git repository path
find $( CURRENT_DIR) -type f -not -path "*.git*" -not -path "*makefile*" -exec \
sed -i " s| $( DEFAULT_DIR) | $( CURRENT_DIR) |g " { } +
# Compile rosenrot
2023-05-04 02:14:46 +00:00
GIO_MODULE_DIR = /usr/lib/x86_64-linux-gnu/gio/modules/
2024-03-12 19:01:31 +00:00
$( CC) $( WARNINGS) $( OPTIMIZED_MORE) $( DEBUG) $( INCS) $( PLUGINS) $( SRC) $( COMPILETIME_DEPRECATION_WARNINGS) -o rose $( LIBS) $( ADBLOCK)
2023-03-28 16:59:38 +00:00
2024-02-11 21:13:53 +00:00
fast : $( SRC ) $( PLUGINS ) $( CONFIG )
rm -f *.gcda
2024-02-11 18:00:04 +00:00
GIO_MODULE_DIR = /usr/lib/x86_64-linux-gnu/gio/modules/
2024-02-11 21:13:53 +00:00
$( CC) $( WARNINGS) $( OPTIMIZED_MORE) -fprofile-generate $( INCS) $( PLUGINS) $( SRC) -o rose $( LIBS) $( ADBLOCK)
@echo "Now use the browser for a while to gather some profiling data"
2024-02-11 23:00:05 +00:00
sleep 2
2024-02-11 21:13:53 +00:00
./rose
$( CC) $( WARNINGS) $( OPTIMIZED_MORE) -fprofile-use $( INCS) $( PLUGINS) $( SRC) -o rose $( LIBS) $( ADBLOCK)
rm -f *.gcda
2024-02-11 18:00:04 +00:00
2023-08-19 17:37:30 +00:00
lint :
2024-03-12 17:39:03 +00:00
clang-tidy $( SRC) $( PLUGINS) -- -Wall -O3 ` pkg-config --cflags 'webkit2gtk-4.1' ` -o rose ` pkg-config --libs 'webkit2gtk-4.1' `
2023-08-19 17:37:30 +00:00
2023-05-09 02:48:22 +00:00
inspect : build
GTK_DEBUG = interactive ./rose
2023-03-28 16:59:38 +00:00
install : rose
2023-05-04 02:14:46 +00:00
GIO_MODULE_DIR = /usr/lib/x86_64-linux-gnu/gio/modules/
2023-03-28 16:59:38 +00:00
cp -f rose /usr/bin
mkdir -p /usr/share/themes/rose
cp style.css /usr/share/themes/rose/
cp rose-mklink /usr/bin
2024-03-12 17:13:47 +00:00
sudo mkdir -p /usr/bin/rose-browser
2023-11-20 00:50:27 +00:00
sudo cp rose /usr/bin/rose-browser/twitter # custom twitter tweaks
2023-03-28 16:59:38 +00:00
2023-03-28 17:44:54 +00:00
uninstall :
rm -r /usr/share/themes/rose
rm /usr/bin/rose
rm /usr/bin/rose-mklink
2024-03-12 17:16:29 +00:00
rm $( DATA_DIR)
2023-03-28 17:44:54 +00:00
clean :
rm rose
2024-03-12 17:16:29 +00:00
rm $( DATA_DIR)
2023-03-28 17:44:54 +00:00
2024-02-11 14:56:53 +00:00
format : $( SRC ) $( PLUGINS )
$( FORMATTER) $( SRC) $( PLUGINS) $( rose.h)
2024-03-12 17:16:29 +00:00
diagnose_deprecations :
2024-03-12 18:10:20 +00:00
G_ENABLE_DIAGNOSTIC = 1 ./rose
2024-03-12 17:46:41 +00:00
view-gtk3-version :
dpkg -l libgtk-3-0