You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 6.5 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. # Makefile --- 10sr make dotfiles
  2. # 2014, 10sr. Unlicensed <http://unlicense.org>
  3. # Variable definitions
  4. home ?= $(HOME)
  5. dotfiles_dir ?= $(home)/10sr_dotfiles
  6. dotfiles_url_base = https://raw.githubusercontent.com/10sr/dotfiles/master/
  7. dotfiles_git = git@github.com:10sr/dotfiles.git
  8. dotfiles_git_pub = http://github.com/10sr/dotfiles.git
  9. localdir = $(home)/.local
  10. vardir = $(home)/.var
  11. bindir = $(localdir)/bin
  12. current = $(shell date)
  13. ostype = $(shell uname)
  14. shrc_loadables = sh bash zsh
  15. shrc_common_tpl =
  16. emacs ?= $(shell which emacs 2>/dev/null)
  17. git ?= $(shell which git 2>/dev/null)
  18. curl ?= $(shell which curl 2>/dev/null)
  19. # Targets
  20. all: default
  21. tests = test-el
  22. test: test-syntax $(tests)
  23. test_syntaxes = test-syntax-el test-syntax-sh
  24. test-syntax: $(test_syntaxes)
  25. setups = setup-darwin setup-directories setup-emacs setup-gitconf \
  26. setup-repository setup-util setup-tmux
  27. setup: $(setups)
  28. # `make check` is just an alias for `make test`
  29. check: test
  30. # Similarly, check-syntax is test-syntax
  31. check-syntax: test-syntax
  32. .PHONY: all default \
  33. test check $(tests) \
  34. test-syntax check-syntax $(test_syntaxes)\
  35. setup $(setups)
  36. # setups
  37. # ======
  38. # setup repository
  39. # ----------------
  40. setup-repository:
  41. ifeq (,$(git))
  42. false "Git not installed"
  43. endif
  44. if ssh git@github.com 2>&1 | grep 'successfully authenticated'; \
  45. then \
  46. echo "Using $(dotfiles_git)"; \
  47. $(git) clone $(dotfiles_git) $(dotfiles_dir); \
  48. else \
  49. echo "Using $(dotfiles_git_pub)"; \
  50. $(git) clone $(dotfiles_git_pub) $(dotfiles_dir); \
  51. fi
  52. # utils
  53. # -----
  54. setup_utils = colortable16.sh 256colors2.pl pacapt ack-2.12
  55. setup-util: $(setup_utils)
  56. .PHONY: $(setup_utils)
  57. setup_utils_path = $(setup_utils:%=$(bindir)/%)
  58. $(setup_utils): %: $(bindir)/%
  59. $(setup_utils_path):
  60. $(curl) -L --url "$(util_url)" --output "$@"
  61. chmod +x "$@"
  62. colortable16.sh: \
  63. util_url = https://gist.github.com/10sr/6852317/raw/colortable16.sh
  64. 256colors2.pl: util_url = https://gist.github.com/10sr/6852331/raw/256colors2.pl
  65. pacapt: util_url = https://github.com/icy/pacapt/raw/ng/pacapt
  66. ack-2.12: util_url = http://beyondgrep.com/ack-2.12-single-file
  67. # create directories
  68. # ------------------
  69. setup_directories = $(localdir) $(vardir) $(bindir)
  70. setup-directory: $(setup_directories)
  71. $(localdir) $(vardir) $(bindir):
  72. mkdir -vp $@
  73. # darwin setup
  74. # ------------
  75. setup_darwins = setup-darwin-defaults setup-darwin-daemon
  76. setup-darwin: $(setup_darwins)
  77. .PHONY: $(setup_darwins)
  78. setup-darwin-defaults:
  79. # http://appdrill.net/60641/mac-boot-mute.html
  80. #sudo nvram SystemAudioVolume=%80
  81. # add quit entry in menu
  82. defaults write com.apple.finder QuitMenuItem -bool YES
  83. # show full path on titlebar
  84. defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
  85. # do not show desktop icons
  86. defaults write com.apple.finder CreateDesktop -boolean false
  87. killall Finder
  88. # disable dashboard
  89. #defaults write com.apple.dashboard mcx-disabled -bool YES
  90. setup-darwin-daemon:
  91. test "`launchctl getenv LC_ALL`" = C || sudo launchctl setenv LC_ALL C
  92. if ! (launchctl list | grep com.apple.locate) >/dev/null ;\
  93. then \
  94. sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist ;\
  95. fi
  96. # emacs setup
  97. # -----------
  98. setup-emacs: emacs.el
  99. $(emacs) -q --debug-init --batch --load $< -f my-auto-install-package
  100. # git config setup
  101. # ----------------
  102. ifneq (,$(git))
  103. git_conf = $(git) config --global
  104. endif
  105. xz = $(shell which xz 2>/dev/null)
  106. setup-gitconf:
  107. ifeq (,$(git))
  108. $(warnning "Git program not found")
  109. else
  110. $(git_conf) user.name '10sr'
  111. $(git_conf) user.email '8slashes+git@gmail.com'
  112. $(git_conf) core.autocrlf false
  113. $(git_conf) core.excludesfile '~/.gitignore'
  114. $(git_conf) color.ui auto
  115. $(git_conf) status.relativePaths false
  116. $(git_conf) status.showUntrackedFiles normal
  117. $(git_conf) log.date iso
  118. $(git_conf) push.default current
  119. ifneq (,$(xz))
  120. $(git_conf) tar.txz.command "xz -c"
  121. endif
  122. $(git_conf) alias.graph "log --graph --date-order -C -M --pretty=tformat:\"%C(green)%h%C(reset) %C(white)%ad%C(reset) %C(red)%an%C(reset)%C(yellow)%d%C(reset) %C(white bold)%s%C(reset)\" --date=short -n 499"
  123. $(git_conf) alias.st "status -s -b"
  124. $(git_conf) alias.b "branch"
  125. $(git_conf) alias.sb "show-branch"
  126. $(git_conf) alias.ci "commit --verbose"
  127. $(git_conf) alias.co "checkout"
  128. $(git_conf) alias.cim "commit --verbose -m"
  129. $(git_conf) alias.di "diff --color"
  130. $(git_conf) alias.me "merge --no-ff --stat --verbose"
  131. $(git_conf) alias.ffme "merge --ff-only --stat --verbose"
  132. $(git_conf) alias.gr "grep -n"
  133. $(git_conf) alias.ls "ls-files"
  134. # $(git_conf) alias.ls "ls-files -v --full-name"
  135. # $(git_conf) alias.ls "status -u -s ."
  136. $(git_conf) alias.sl "!sl"
  137. # $(git_conf) alias.my-ls "ls-files | xargs ls"
  138. # $(git_conf) alias.ll "!git ls-files | xargs ls -l -CFG --color=auto --time-style=long-iso"
  139. $(git_conf) alias.addi "add -i"
  140. # Add patch to index
  141. $(git_conf) alias.ap "apply --cached"
  142. $(git_conf) alias.clean-p "diff --quiet"
  143. $(git_conf) alias.echo-ref "for-each-ref --format='%(refname:short)'"
  144. $(git_conf) alias.todo "grep -nH -E -i 'todo:|note:|fixme:'"
  145. $(git_conf) alias.snap '! gitdir="`git rev-parse --git-dir`" && : >>"$gitdir"/logs/refs/snapshot && cmt=`git stash create` && test -n "$cmt" && git update-ref refs/snapshot $cmt && echo Snapshot created: $cmt'
  146. #$(git_conf) alias.wc "!git ls-files -z | xargs -0 wc"
  147. # $(git_conf) push.default "simple"
  148. ifneq (,$(iswindows))
  149. $(git_conf) core.fileMode false
  150. endif
  151. endif
  152. # tmux setup
  153. # ----------
  154. setup-tmux:
  155. # test
  156. # ====
  157. test_els = test-el-emacs.el
  158. test-el: $(test_els)
  159. .PHONY: $(test_els)
  160. $(test_els): test-el-%: %
  161. $(emacs) -Q -batch -f batch-byte-compile $<
  162. EMACS_EL_DRY_RUN=t $(emacs) -q --debug-init --batch \
  163. --eval "(setq debug-on-error t)" --load $<c --kill
  164. # test syntax
  165. # ===========
  166. test_syntax_shs = test-syntax-shrc test-syntax-profile \
  167. test-syntax-xinitrc test-syntax-xprograms
  168. test-syntax-sh: $(test_syntax_shs)
  169. .PHONY: $(test_syntax_shs)
  170. $(test_syntax_shs): test-syntax-%: %
  171. sh -ec 'for sh in $(shrc_loadables); do $$sh -n $<; done'
  172. test_syntax_els = test-syntax-emacs.el
  173. test-syntax-el: $(test_syntax_els)
  174. .PHONY: $(test_syntax_els)
  175. sexp_elisp_syntax_check = \
  176. (with-temp-buffer \
  177. (emacs-lisp-mode) \
  178. (insert-file-contents file) \
  179. (condition-case err \
  180. (check-parens) \
  181. (user-error \
  182. (error (format "%s:%d:%d:Unmatched brancet or quote" \
  183. file \
  184. (line-number-at-pos) \
  185. (- (point) (point-at-bol)))))))
  186. $(test_syntax_els): test-syntax-%: %
  187. $(emacs) -Q --debug-init --batch \
  188. --eval '(let ((file "$<")) $(sexp_elisp_syntax_check))' --kill