| 1 | MAKEFLAGS := --no-builtin-rules |
| 2 | |
| 3 | DEPS := $(wildcard deps/*) |
| 4 | |
| 5 | ifeq ($(shell uname),Darwin) |
| 6 | GREP := ggrep |
| 7 | SED := gsed |
| 8 | DIFF := $(shell gls -t1 /usr/local/Cellar/diffutils/*/bin/diff | head -1) |
| 9 | else |
| 10 | GREP := grep |
| 11 | SED := sed |
| 12 | DIFF := diff |
| 13 | endif |
| 14 | |
| 15 | .PHONY: \ |
| 16 | default \ |
| 17 | clean \ |
| 18 | $(DEPS) \ |
| 19 | deps \ |
| 20 | home \ |
| 21 | diff \ |
| 22 | pull \ |
| 23 | mpdconf \ |
| 24 | pkgs_brew_cask_install \ |
| 25 | pkgs_brew_install \ |
| 26 | pkgs_cargo \ |
| 27 | pkgs_deb_install \ |
| 28 | pkgs_deb_purge \ |
| 29 | pkgs_debian \ |
| 30 | pkgs_mac \ |
| 31 | pkgs_pip_install \ |
| 32 | pkgs_pip_upgrade \ |
| 33 | pkgs_snap_classic \ |
| 34 | pkgs_snap_strict |
| 35 | |
| 36 | default: |
| 37 | @echo '================================================================================' |
| 38 | @echo '| Default target disabled. Specify a concrete one.' |
| 39 | @echo '================================================================================' |
| 40 | @exit 1 |
| 41 | |
| 42 | home: mpdconf compiled |
| 43 | cp -Rp bin $(HOME)/ |
| 44 | # Limit depth because directories are copied recursively: |
| 45 | find home -maxdepth 1 -print0 \ |
| 46 | | $(GREP) -zv '^home$$' \ |
| 47 | | xargs -0 -I% cp -Rp % ~ |
| 48 | |
| 49 | mpdconf: |
| 50 | mkdir -p ~/Archives/Audio |
| 51 | mkdir -p ~/var/lib/mpd/playlists |
| 52 | mkdir -p ~/var/log/mpd |
| 53 | mkdir -p ~/var/run/mpd |
| 54 | cp home/.mpdconf $(HOME)/ |
| 55 | |
| 56 | compiled: |
| 57 | mkdir -p bin |
| 58 | cd src && make |
| 59 | mv src/clockloop bin/ |
| 60 | |
| 61 | font_cache: |
| 62 | fc-cache -fv |
| 63 | |
| 64 | # |
| 65 | # Golang |
| 66 | # |
| 67 | pkgs_golang: list pkgs-golang.list |
| 68 | go get $(shell ./list pkgs-golang.list) |
| 69 | |
| 70 | # |
| 71 | # Ubuntu |
| 72 | # |
| 73 | pkgs_ubuntu: list pkgs-ubuntu.list |
| 74 | sudo apt install $(shell ./list pkgs-ubuntu.list) |
| 75 | |
| 76 | pkgs_ubuntu_debfiles: list pkgs-ubuntu-debfiles.list |
| 77 | ./install-debfiles pkgs-ubuntu-debfiles.list |
| 78 | |
| 79 | # |
| 80 | # PIP |
| 81 | # |
| 82 | pkgs_pip_install: |
| 83 | pip3 install --user $(shell ./list pkgs-pip.list) |
| 84 | |
| 85 | pkgs_pip_upgrade: |
| 86 | pip3 install --user --upgrade $(shell ./list pkgs-pip.list) |
| 87 | |
| 88 | # |
| 89 | # Rust (cargo) |
| 90 | # |
| 91 | |
| 92 | pkgs_cargo: list pkgs-cargo.list |
| 93 | cargo install $(shell ./list pkgs-cargo.list) |
| 94 | |
| 95 | # |
| 96 | # Homebrew/Mac |
| 97 | # |
| 98 | |
| 99 | pkgs_mac: |
| 100 | $(MAKE) pkgs_brew_install |
| 101 | $(MAKE) pkgs_brew_cask_install |
| 102 | |
| 103 | # TODO: Test pkgs_brew_tap when list contains multiple items |
| 104 | pkgs_brew_tap: list pkgs-brew-tap.list |
| 105 | brew tap $(shell ./list pkgs-brew-tap.list) |
| 106 | |
| 107 | pkgs_brew_install: list pkgs-brew-install.list |
| 108 | brew install $(shell ./list pkgs-brew-install.list) |
| 109 | |
| 110 | pkgs_brew_cask_install: list pkgs-brew-cask-install.list |
| 111 | brew cask install $(shell ./list pkgs-brew-cask-install.list) |
| 112 | |
| 113 | # |
| 114 | # Debian |
| 115 | # |
| 116 | pkgs_deb_install: list pkgs-deb-install.list |
| 117 | sudo apt install $(shell ./list pkgs-deb-install.list) |
| 118 | |
| 119 | pkgs_deb_purge: list pkgs-deb-purge.list |
| 120 | sudo apt purge $(shell ./list pkgs-deb-purge.list) |
| 121 | |
| 122 | # |
| 123 | # Snap |
| 124 | # |
| 125 | pkgs_snap_classic: list pkgs-snap-classic.list |
| 126 | @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-classic.list),pkg_snap_classic_$(p)) |
| 127 | |
| 128 | pkgs_snap_strict: list pkgs-snap-strict.list |
| 129 | @$(MAKE) $(foreach p,$(shell ./list pkgs-snap-strict.list),pkg_snap_strict_$(p)) |
| 130 | |
| 131 | # 'snap' command comes from 'snapd' deb pkg |
| 132 | pkg_snap_classic_%: |
| 133 | sudo snap install --classic $* |
| 134 | pkg_snap_strict_%: |
| 135 | sudo snap install $* |
| 136 | |
| 137 | deps: $(DEPS) |
| 138 | |
| 139 | define GEN_DEP_RULE |
| 140 | $(1): |
| 141 | cd $1 && make |
| 142 | endef |
| 143 | |
| 144 | $(foreach d,$(DEPS),$(eval $(call GEN_DEP_RULE,$(d)))) |
| 145 | |
| 146 | diff: |
| 147 | find home -type f -print0 \ |
| 148 | | $(SED) -z 's/^home\///g' \ |
| 149 | | xargs -0 -I% sh -c 'echo %; $(DIFF) --color=always ~/% home/%' |
| 150 | |
| 151 | pull: |
| 152 | find home -type f -print0 \ |
| 153 | | $(SED) -z 's/^home\///g' \ |
| 154 | | xargs -0 -I% sh -c '$(DIFF) -q ~/% home/% > /dev/null || cp ~/% home/%' |
| 155 | |
| 156 | clean: |
| 157 | rm -rf ./debfiles |
| 158 | cd src && make clean |