|
@@ -3,8 +3,6 @@ |
|
|
|
|
|
|
|
|
# Variable definitions |
|
|
# Variable definitions |
|
|
|
|
|
|
|
|
home ?= $(HOME) |
|
|
|
|
|
|
|
|
|
|
|
dotfiles_url_base := https://raw.githubusercontent.com/10sr/dotfiles/master |
|
|
dotfiles_url_base := https://raw.githubusercontent.com/10sr/dotfiles/master |
|
|
use_git ?= t |
|
|
use_git ?= t |
|
|
git_auth ?= t |
|
|
git_auth ?= t |
|
@@ -32,7 +30,7 @@ ifeq (,$(dotfiles_dir)) |
|
|
ifeq (,$(DOTFILES_DIR)) |
|
|
ifeq (,$(DOTFILES_DIR)) |
|
|
$(warning Neigher DOTFILES_DIR nor dotfiles_dir is defined) |
|
|
$(warning Neigher DOTFILES_DIR nor dotfiles_dir is defined) |
|
|
$(warning Use default value) |
|
|
$(warning Use default value) |
|
|
dotfiles_dir := $(home)/10sr_dotfiles |
|
|
|
|
|
|
|
|
dotfiles_dir := $(HOME)/10sr_dotfiles |
|
|
else |
|
|
else |
|
|
# dotfiles_dir is empty but DOTFILES_DIR has a value |
|
|
# dotfiles_dir is empty but DOTFILES_DIR has a value |
|
|
$(warning dotfiles_dir is set from DOTFILES_DIR) |
|
|
$(warning dotfiles_dir is set from DOTFILES_DIR) |
|
@@ -46,9 +44,23 @@ endif |
|
|
$(warning dotfiles_dir: $(dotfiles_dir)) |
|
|
$(warning dotfiles_dir: $(dotfiles_dir)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ifeq ($(home),) |
|
|
|
|
|
ifeq ($(global_home),) |
|
|
|
|
|
$(warning home not set and global_home is empty) |
|
|
|
|
|
# TODO: What this should be? |
|
|
|
|
|
home := $(dotfiles_dir)/.home |
|
|
|
|
|
else |
|
|
|
|
|
home := $(HOME) |
|
|
|
|
|
endif |
|
|
|
|
|
endif |
|
|
|
|
|
$(warning home: $(home)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
localdir := $(home)/.local |
|
|
localdir := $(home)/.local |
|
|
vardir := $(home)/.var |
|
|
vardir := $(home)/.var |
|
|
bindir := $(localdir)/bin |
|
|
bindir := $(localdir)/bin |
|
|
|
|
|
directories := $(dotfiles_dir) $(home) $(localdir) $(vardir) $(bindir) \ |
|
|
|
|
|
$(home)/.emacs.d |
|
|
|
|
|
|
|
|
current := $(shell date) |
|
|
current := $(shell date) |
|
|
uname := $(shell uname) |
|
|
uname := $(shell uname) |
|
@@ -60,6 +72,8 @@ git ?= $(shell which git 2>/dev/null) |
|
|
curl ?= $(shell which curl 2>/dev/null) |
|
|
curl ?= $(shell which curl 2>/dev/null) |
|
|
grep ?= GREP_OPTIONS= $(shell which grep 2>/dev/null) |
|
|
grep ?= GREP_OPTIONS= $(shell which grep 2>/dev/null) |
|
|
|
|
|
|
|
|
|
|
|
files := Makefile emacs.el profile shrc tmux.conf vimrc _keysnail.js |
|
|
|
|
|
|
|
|
# Targets |
|
|
# Targets |
|
|
|
|
|
|
|
|
all: default |
|
|
all: default |
|
@@ -76,6 +90,9 @@ setups := setup-darwin setup-directories setup-emacs setup-gitconf \ |
|
|
setup-all: $(setups) |
|
|
setup-all: $(setups) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
runs := run-emacs run-bash run-zsh |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# `make check` is just an alias for `make test` |
|
|
# `make check` is just an alias for `make test` |
|
|
check: test |
|
|
check: test |
|
@@ -90,6 +107,10 @@ check-syntax: test-syntax |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(directories): |
|
|
|
|
|
test -d "$@" || mkdir -vp "$@" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# System detection |
|
|
# System detection |
|
|
# ================ |
|
|
# ================ |
|
@@ -135,26 +156,23 @@ endif |
|
|
# preparing files |
|
|
# preparing files |
|
|
# =============== |
|
|
# =============== |
|
|
|
|
|
|
|
|
ifeq (,$(use_git)) |
|
|
|
|
|
$(warning 'use_git' is set to empty. Use curl to fetch files) |
|
|
|
|
|
$(dotfiles_dir)/%: |
|
|
|
|
|
mkdir -vp $(dotfiles_dir) |
|
|
|
|
|
|
|
|
files_fullpath := $(files:%=$(dotfiles_dir)/%) |
|
|
|
|
|
fetch_files := $(files:%=fetch-%) |
|
|
|
|
|
.PHONY: $(fetch_files) |
|
|
|
|
|
|
|
|
|
|
|
$(fetch_files): fetch-%: $(dotfiles_dir) |
|
|
curl --url $(dotfiles_url_base)/$* --output $@ |
|
|
curl --url $(dotfiles_url_base)/$* --output $@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ifeq (,$(use_git)) |
|
|
|
|
|
$(files_fullpath): $(dotfiles_dir)/%: fetch-% |
|
|
|
|
|
$(warning 'use_git' is empty. Use curl to fetch files) |
|
|
else |
|
|
else |
|
|
$(warning 'use_git' is set to non-empty. Use git to retrieve files) |
|
|
|
|
|
$(dotfiles_dir)/%: setup-repository |
|
|
|
|
|
|
|
|
$(warning 'use_git' is not empty. Use git to retrieve files) |
|
|
|
|
|
$(files_fullpath): setup-repository |
|
|
test -f "$@" |
|
|
test -f "$@" |
|
|
endif |
|
|
endif |
|
|
|
|
|
|
|
|
# Shortcut target for interactive usage |
|
|
|
|
|
# For example, `make file-emacs.el use_git=` will fetch emacs.el from web with |
|
|
|
|
|
# curl program. |
|
|
|
|
|
# NOTE: Is there any way to make all `file-%` targets phony? |
|
|
|
|
|
file-%: $(dotfiles_dir)/% |
|
|
|
|
|
test -f "$<" |
|
|
|
|
|
|
|
|
|
|
|
# Make sure $(dotfiles_dir)/% wont be removed as intermidiate files |
|
|
|
|
|
.PRECIOUS: $(dotfiles_dir)/% |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -187,7 +205,7 @@ setup_utils_path := $(setup_utils:%=$(bindir)/%) |
|
|
|
|
|
|
|
|
$(setup_utils): %: $(bindir)/% |
|
|
$(setup_utils): %: $(bindir)/% |
|
|
|
|
|
|
|
|
$(setup_utils_path): |
|
|
|
|
|
|
|
|
$(setup_utils_path): $(bindir) |
|
|
$(curl) -L --url "$(util_url)" --output "$@" |
|
|
$(curl) -L --url "$(util_url)" --output "$@" |
|
|
chmod +x "$@" |
|
|
chmod +x "$@" |
|
|
|
|
|
|
|
@@ -199,17 +217,6 @@ ack-2.12: util_url := http://beyondgrep.com/ack-2.12-single-file |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# create directories |
|
|
|
|
|
# ------------------ |
|
|
|
|
|
|
|
|
|
|
|
setup_directories := $(localdir) $(vardir) $(bindir) |
|
|
|
|
|
setup-directory: $(setup_directories) |
|
|
|
|
|
|
|
|
|
|
|
$(localdir) $(vardir) $(bindir): |
|
|
|
|
|
mkdir -vp $@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# darwin setup |
|
|
# darwin setup |
|
|
# ------------ |
|
|
# ------------ |
|
|
|
|
|
|
|
@@ -320,27 +327,43 @@ endif |
|
|
# Load codes are defined by following SETUP_LOAD: indicator. |
|
|
# Load codes are defined by following SETUP_LOAD: indicator. |
|
|
# String DOTFILES_DIR in the load codes will be replaced into the value of |
|
|
# String DOTFILES_DIR in the load codes will be replaced into the value of |
|
|
# $(dotfiles_dir). |
|
|
# $(dotfiles_dir). |
|
|
# If append_load is non-empty, the load codes are appended to $(topfile), |
|
|
|
|
|
# otherwise the code will be just printed out to stdout. |
|
|
|
|
|
|
|
|
# The load codes are appended to $(topfile). |
|
|
|
|
|
|
|
|
setup_rcs := setup-rc-vimrc setup-rc-tmux.conf setup-rc-emacs.el |
|
|
setup_rcs := setup-rc-vimrc setup-rc-tmux.conf setup-rc-emacs.el |
|
|
setup-rc: $(setup_rcs) |
|
|
setup-rc: $(setup_rcs) |
|
|
.PHONY: $(setup_rcs) |
|
|
.PHONY: $(setup_rcs) |
|
|
|
|
|
|
|
|
|
|
|
setup-rc-vimrc: $(home)/.vimrc |
|
|
|
|
|
setup-rc-tmux.conf: $(home)/.tmux.conf |
|
|
|
|
|
setup-rc-emacs.el: $(home)/.emacs.d/init.el |
|
|
|
|
|
|
|
|
|
|
|
$(home)/.emacs.d/init.el: $(dotfiles_dir)/emacs.el $(home) $(home)/.emacs.d |
|
|
|
|
|
$(home)/.vimrc: $(dotfiles_dir)/vimrc $(home) |
|
|
|
|
|
$(home)/.tmux.conf: $(dotfiles_dir)/tmux.conf $(home) |
|
|
|
|
|
|
|
|
command_extract_setup_load := $(grep) -e 'SETUP_LOAD: ' | \ |
|
|
command_extract_setup_load := $(grep) -e 'SETUP_LOAD: ' | \ |
|
|
sed -e 's/^.*SETUP_LOAD: //' -e 's|DOTFILES_DIR|$(dotfiles_dir)|' |
|
|
sed -e 's/^.*SETUP_LOAD: //' -e 's|DOTFILES_DIR|$(dotfiles_dir)|' |
|
|
|
|
|
|
|
|
$(setup_rcs): setup-rc-%: $(dotfiles_dir)/% |
|
|
|
|
|
ifeq (,$(append_load)) |
|
|
|
|
|
@echo "\`append_load' is not defined. Just print load command." |
|
|
|
|
|
cat "$<" | $(command_extract_setup_load) |
|
|
|
|
|
else |
|
|
|
|
|
cat "$<" | $(command_extract_setup_load) | tee -a "$(topfile)" |
|
|
|
|
|
endif |
|
|
|
|
|
|
|
|
setup_rc_marker := ADDED BY 10sr_dotfiles/Makefile |
|
|
|
|
|
|
|
|
|
|
|
$(home)/.emacs.d/init.el $(home)/.vimrc $(home)/.tmux.conf: |
|
|
|
|
|
set -x; if ! $(grep) "$(setup_rc_marker)" "$@"; \ |
|
|
|
|
|
then \ |
|
|
|
|
|
(echo '$(line_comment)' $(setup_rc_marker); cat "$<" | $(command_extract_setup_load)) \ |
|
|
|
|
|
| tee -a "$@"; \ |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
$(home)/.emacs.d/init.el: line_comment := ;; |
|
|
|
|
|
$(home)/.vimrc: line_comment := \" |
|
|
|
|
|
$(home)/.tmux.conf: line_comment := \# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setup-rc-vimrc: topfile := $(home)/.vimrc |
|
|
|
|
|
setup-rc-tmux.conf: topfile := $(home)/.tmux.conf |
|
|
|
|
|
setup-rc-emacs.el: topfile := $(home)/.emacs.d/init.el |
|
|
|
|
|
|
|
|
# run |
|
|
|
|
|
# === |
|
|
|
|
|
|
|
|
|
|
|
run-emacs: $(home)/.emacs.d/init.el |
|
|
|
|
|
$(emacs) -q --eval "(setq user-emacs-directory \"$(home)/.emacs.d/\")" --load "$<" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -395,8 +418,3 @@ sexp_elisp_syntax_check := \ |
|
|
$(test_syntax_els): test-syntax-%: $(dotfiles_dir)/% |
|
|
$(test_syntax_els): test-syntax-%: $(dotfiles_dir)/% |
|
|
$(emacs) -Q --debug-init --batch \ |
|
|
$(emacs) -Q --debug-init --batch \ |
|
|
--eval '(let ((file "$<")) $(sexp_elisp_syntax_check))' --kill |
|
|
--eval '(let ((file "$<")) $(sexp_elisp_syntax_check))' --kill |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
run-emacs: |
|
|
|
|
|
$(emacs) -nw |
|
|
|