confOS/Makefile
2023-03-26 17:55:42 +02:00

177 lines
5.7 KiB
Makefile

# Version control
VC = git
# Util
RM = rm -f
# Downloaders
WGET = wget -q --show-progress
CURL = curl -s
# Checkers
ARCH = $(shell grep -c "archlinux" /proc/version)
WSL = $(shell grep -c "WSL2" /proc/version)
# Hide some verbose messages from Make
MAKEFLAGS += --no-print-directory
# Location
WIN_USER = anri
PFx86 = /mnt/c/Program\ Files\ \(x86\)
WIN_HOME = /mnt/c/Users/$(WIN_USER)
APPDATA = $(WIN_HOME)/AppData/Roaming
WIN_STEAM_USERDATA = $(filter-out "userdata",$(shell find $(PFx86)/Steam/userdata -maxdepth 1 -type d -printf "\"%f\" "))
CSGO_CFG = $(PFx86)/Steam/steamapps/common/Counter-Strike\ Global\ Offensive/csgo/cfg
all: full-sync
# Pull latest changes
refresh:
@echo "Pull latest changes from repository..."
@$(VC) pull
@echo
# Pull and sync
full-sync:
@$(MAKE) refresh
@$(MAKE) sync
# === All platforms ==
# .config
sync-dotconfig:
# Fish
@mkdir -p $(HOME)/.config/fish/conf.d
@mkdir -p $(HOME)/.config/fish/functions
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/functions/fish_prompt.fish -O $(HOME)/.config/fish/functions/fish_prompt.fish
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/promp_color.fish -O $(HOME)/.config/fish/conf.d/promp_color.fish
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/abbr.fish -O $(HOME)/.config/fish/conf.d/abbr.fish
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/alias.fish -O $(HOME)/.config/fish/conf.d/alias.fish
# Micro
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/micro/settings.json -O $(HOME)/.config/micro/settings.json
# END
@echo ".config directory synced!"
@echo
# .emacs.d
sync-emacs:
@mkdir -p $(HOME)/.emacs.d
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.emacs.d/init.el -O $(HOME)/.emacs.d/init.el
# END
@echo "Emacs config synced!"
@echo
# .dotfiles
sync-dotfiles:
# .gitconfig
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/dotfiles/.gitconfig -O $(HOME)/.gitconfig
# .ocamlformat
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/dotfiles/.ocamlformat -O $(HOME)/.ocamlformat
# .clang-format
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/dotfiles/.clang-format -O $(HOME)/.clang-format
# End
@echo "dotfiles synced!"
@echo
# === Specific platforms ==
# Arch distro
sync-arch:
# Fish
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/config_arch.fish -O $(HOME)/.config/fish/config.fish
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/abbr.fish -O $(HOME)/.config/fish/conf.d/abbr.fish
@$(CURL) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/abbr_arch.fish >> $(HOME)/.config/fish/conf.d/abbr.fish
# Emoji Picker
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/gazatu.xyz/emoji-picker.ini -O $(HOME)/.config/gazatu.xyz/emoji-picker.ini
# Firefox
-@$(RM) $(HOME)/.mozilla/firefox/*.default-release/user.js
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.mozilla/firefox/user.js -P $(HOME)/.mozilla/firefox/*.default-release
# VSCodium
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/VSCodium/product.json -O $(HOME)/.config/VSCodium/product.json
# Windows Subsystem for Linux
sync-wsl:
# Fish
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/config_wsl.fish -O $(HOME)/.config/fish/config.fish
@$(CURL) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.config/fish/conf.d/abbr_wsl.fish >> $(HOME)/.config/fish/conf.d/abbr.fish
# Unison
@mkdir -p $(HOME)/.unison
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.unison/default.prf -O $(HOME)/.unison/default.prf
# Windows through WSL
sync-windows:
# Scripts
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/windows/ctmpf.bat -O $(WIN_HOME)/Documents/Local/ctmpf.bat
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/windows/spotx.bat -O $(WIN_HOME)/Documents/Local/spotx.bat
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/windows/update.bat -O $(WIN_HOME)/Documents/Local/update.bat
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/windows/fix_nvidia_wsl.bat -O $(WIN_HOME)/Documents/Local/fix_nvidia_wsl.bat
@echo "(Windows) Scripts synced!"
@echo
# CSGO (only if installed)
@if [ -d $(CSGO_CFG) ]; then \
$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/games/csgo/autoexec.cfg -O $(CSGO_CFG)/autoexec.cfg; \
$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/games/csgo/myconfig.cfg -O $(CSGO_CFG)/myconfig.cfg; \
$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/games/csgo/customgame.cfg -O $(CSGO_CFG)/customgame.cfg; \
$(foreach d,$(WIN_STEAM_USERDATA), $(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/games/csgo/video.txt -O $(PFx86)/Steam/userdata/$(d)/730/local/cfg/video.txt;) \
echo "(Windows) CS:GO synced!"; \
echo; \
fi
# Firefox
@$(WGET) https://git.mylloon.fr/Anri/confOS/raw/branch/main/.mozilla/firefox/user.js -O $(APPDATA)/Mozilla/Firefox/Profiles/*.default-release/user.js
@echo "(Windows) Firefox synced!"
@echo
sync:
# Check if at least the platform is supported
ifneq (1, $(filter 1, $(ARCH) $(WSL)))
@echo "Unsupported platform"
else
# Call target of compatible with all supported platforms
@$(MAKE) sync-dotconfig
@$(MAKE) sync-dotfiles
@$(MAKE) sync-emacs
# Specific to Arch
ifeq ($(ARCH), 1)
@$(MAKE) sync-arch
@echo "Arch synced!"
@echo
# Specific to WSL
else ifeq ($(WSL), 1)
@$(MAKE) sync-wsl
@echo "WSL synced!"
@echo
# Windows
@$(MAKE) sync-windows
@echo "Windows synced!"
@echo
endif
# END
@echo "🎉 Sync complete!"
endif