makefile (3927B)
1 # C compiler 2 CC=gcc # alternatives: tcc, clang, zig cc 3 WARNINGS=-Wall 4 OPTIMIZED_SOME=-O3 5 OPTIMIZED_MORE=-Ofast -march=native -funit-at-a-time -flto # binary will not be compatible with other computers, but may be much faster 6 DEBUG=#-g 7 STD=-std=c99 # maybe consider moving to c11 and using safer string handling 8 9 # Dependencies for WebkitGTK4/GTK3 10 SRC_3=rosenrot3.c 11 DEPS_3='webkit2gtk-4.1' 12 INCS_3=`pkg-config --cflags ${DEPS_3}` 13 LIBS_3=`pkg-config --libs ${DEPS_3}` 14 15 # Dependencies for WebkitGTK6/GTK4 16 SRC_4=rosenrot4.c 17 DEPS_4='webkitgtk-6.0' 18 INCS_4=`pkg-config --cflags ${DEPS_4}` `pkg-config --cflags gtk4` 19 LIBS_4=`pkg-config --libs ${DEPS_4}` `pkg-config --libs gtk4` 20 DEPRECATION_FLAGS=-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED 21 22 # User config 23 CONFIG=config.h 24 25 # Plugins 26 include plugins/plugins.mk 27 # PLUGINS=./plugins/stand_in/stand_in.c 28 ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' # optional adblocking; depends on https://github.com/jun7/wyebadblock 29 30 ## Formatter 31 STYLE_BLUEPRINT="{BasedOnStyle: webkit, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: true, AllowShortEnumsOnASingleLine: true}" 32 FORMATTER_C=clang-format -i -style=$(STYLE_BLUEPRINT) 33 FORMATTER_JS=npx prettier -w 34 35 # Runtime files 36 MAINTAINER_CACHE_DIR=/home/nuno/.cache/rosenrot 37 USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot 38 RUNTIME_FILES_DIR=/opt/rosenrot/ 39 40 build: $(SRC_4) $(PLUGINS) $(CONFIG) constants user_cache 41 $(CC) $(STD) $(WARNINGS) $(DEPRECATION_FLAGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK) 42 @echo 43 44 build3: $(SRC_3) $(PLUGINS) $(CONFIG) constants user_cache 45 $(CC) $(STD) $(WARNINGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS_3) $(PLUGINS) $(SRC_3) -o rosenrot $(LIBS_3) $(ADBLOCK) 46 @echo 47 48 format: $(SRC_3) $(SRC_4) $(PLUGINS) 49 $(FORMATTER_C) $(SRC_3) $(PLUGINS) $(config.h) 50 $(FORMATTER_C) $(SRC_4_greenfield) $(PLUGINS) $(config.h) 51 $(FORMATTER_JS) plugins/readability/readability.js 52 $(FORMATTER_JS) plugins/style/style.js 53 54 # Installation 55 56 install: rosenrot runtime_files 57 cp -f rosenrot /usr/bin 58 cp rosenrot-mklink /usr/bin 59 @echo 60 61 uninstall: 62 rm -r /opt/rosenrot 63 rm /usr/bin/rosenrot 64 rm /usr/bin/rosenrot-mklink 65 rm $(USER_CACHE_DIR) 66 67 clean: 68 rm rosenrot 69 rm $(USER_CACHE_DIR) 70 71 constants: 72 @echo 73 @echo "# Computing constants" 74 cd plugins/readability/ && sh recompute_READABILITY_N.sh 75 cd plugins/style && sh recompute_STYLE_N.sh 76 @echo 77 78 user_cache: 79 @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 80 @echo "# Create user cache" 81 mkdir -p $(USER_CACHE_DIR) 82 find . -type f -not -path "*.git*" -not -path "*makefile*" \ 83 -exec sed -i "s|$(MAINTAINER_CACHE_DIR)|$(USER_CACHE_DIR)|g" {} + 84 @echo 85 86 runtime_files: 87 @echo 88 sudo mkdir -p /opt/rosenrot/ 89 sudo cp styles-gtk/style-gtk3.css /opt/rosenrot/ 90 sudo cp styles-gtk/style-gtk4.css /opt/rosenrot/ 91 sudo touch /opt/rosenrot/uris.txt 92 sudo chmod a+rw /opt/rosenrot/uris.txt 93 sudo cp -r images/flower-imgs /opt/rosenrot/ 94 sudo cp plugins/style/style.js /opt/rosenrot/ 95 sudo cp plugins/readability/readability.js /opt/rosenrot/ 96 97 # More misc recipes 98 99 lint: 100 clang-tidy $(SRC) $(PLUGINS) -- -Wall -O3 $(INCS) -o rosenrot $(LIBS) 101 102 fast: $(SRC) $(PLUGINS) $(CONFIG) 103 rm -f *.gcda 104 GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/ 105 $(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-generate $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK) 106 @echo "Now use the browser for a while to gather some profiling data" 107 sleep 2 108 ./rosenrot 109 $(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-use $(INCS_4) $(PLUGINS) $(SRC_4) -o rosenrot $(LIBS_4) $(ADBLOCK) 110 rm -f *.gcda 111 112 inspect: rosenrot 113 GTK_DEBUG=interactive ./rosenrot 114 115 diagnose_deprecations: rosenrot 116 G_ENABLE_DIAGNOSTIC=1 ./rosenrot 117 118 view-gtk3-version: 119 dpkg -l libgtk-3-0 120 121 twitter: 122 sudo mkdir -p /usr/bin/rosenrot-browser 123 sudo cp rosenrot /usr/bin/rosenrot-browser/twitter