選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

268 行
6.4 KiB

  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
  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. # test
  153. # ====
  154. test_els = test-el-emacs.el
  155. test-el: $(test_els)
  156. .PHONY: $(test_els)
  157. $(test_els): test-el-%: %
  158. $(emacs) -Q -batch -f batch-byte-compile $<
  159. EMACS_EL_DRY_RUN=t $(emacs) -q --debug-init --batch \
  160. --eval "(setq debug-on-error t)" --load $<c --kill
  161. # test syntax
  162. # ===========
  163. test_syntax_shs = test-syntax-shrc test-syntax-profile \
  164. test-syntax-xinitrc test-syntax-xprograms
  165. test-syntax-sh: $(test_syntax_shs)
  166. .PHONY: $(test_syntax_shs)
  167. $(test_syntax_shs): test-syntax-%: %
  168. sh -ec 'for sh in $(shrc_loadables); do $$sh -n $<; done'
  169. test_syntax_els = test-syntax-emacs.el
  170. test-syntax-el: $(test_syntax_els)
  171. .PHONY: $(test_syntax_els)
  172. sexp_elisp_syntax_check = \
  173. (with-temp-buffer \
  174. (emacs-lisp-mode) \
  175. (insert-file-contents file) \
  176. (condition-case err \
  177. (check-parens) \
  178. (user-error \
  179. (error (format "%s:%d:%d:Unmatched brancet or quote" \
  180. file \
  181. (line-number-at-pos) \
  182. (- (point) (point-at-bol)))))))
  183. $(test_syntax_els): test-syntax-%: %
  184. $(emacs) -Q --debug-init --batch \
  185. --eval '(let ((file "$<")) $(sexp_elisp_syntax_check))' --kill