25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

223 lines
5.3 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. localdir = $(home)/.local
  8. vardir = $(home)/.var
  9. bindir = $(localdir)/bin
  10. current = $(shell date)
  11. ostype = $(shell uname)
  12. shrc_loadables = sh bash zsh
  13. shrc_common_tpl =
  14. emacs ?= $(shell which emacs 2>/dev/null)
  15. git ?= $(shell which git 2>/dev/null)
  16. # Targets
  17. all: default
  18. tests = test-el
  19. test: test-syntax $(tests)
  20. test_syntaxes = test-syntax-el test-syntax-sh
  21. test-syntax: $(test_syntaxes)
  22. setups = setup-darwin setup-directories setup-emacs setup-gitconf
  23. setup: $(setups)
  24. # `make check` is just an alias for `make test`
  25. check: test
  26. # Similarly, check-syntax is test-syntax
  27. check-syntax: test-syntax
  28. .PHONY: all default \
  29. test check $(tests) \
  30. test-syntax check-syntax $(test_syntaxes)\
  31. setup $(setups)
  32. # setups
  33. # ======
  34. # create directories
  35. # ------------------
  36. setup_directories = $(localdir) $(vardir) $(bindir)
  37. setup-directory: $(setup_directories)
  38. $(localdir) $(vardir) $(bindir):
  39. mkdir -vp $@
  40. # darwin
  41. # ------
  42. setup_darwins = setup-darwin-defaults setup-darwin-daemon
  43. setup-darwin: $(setup_darwins)
  44. .PHONY: $(setup_darwins)
  45. setup-darwin-defaults:
  46. # http://appdrill.net/60641/mac-boot-mute.html
  47. #sudo nvram SystemAudioVolume=%80
  48. # add quit entry in menu
  49. defaults write com.apple.finder QuitMenuItem -bool YES
  50. # show full path on titlebar
  51. defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
  52. # do not show desktop icons
  53. defaults write com.apple.finder CreateDesktop -boolean false
  54. killall Finder
  55. # disable dashboard
  56. #defaults write com.apple.dashboard mcx-disabled -bool YES
  57. setup-darwin-daemon:
  58. test "`launchctl getenv LC_ALL`" = C || sudo launchctl setenv LC_ALL C
  59. if ! (launchctl list | grep com.apple.locate) >/dev/null ;\
  60. then \
  61. sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist ;\
  62. fi
  63. # emacs setup
  64. # -----------
  65. setup-emacs: emacs.el
  66. $(emacs) -q --debug-init --batch --load $< -f my-auto-install-package
  67. # git config setup
  68. # ----------------
  69. ifneq (,$(git))
  70. git_conf = $(git) config --global
  71. endif
  72. xz = $(shell which xz 2>/dev/null)
  73. setup-gitconf:
  74. ifeq (,$(git))
  75. $(warnning "Git program not found")
  76. else
  77. $(git_conf) user.name '10sr'
  78. $(git_conf) user.email '8slashes+git@gmail.com'
  79. $(git_conf) core.autocrlf false
  80. $(git_conf) core.excludesfile '~/.gitignore'
  81. $(git_conf) color.ui auto
  82. $(git_conf) status.relativePaths false
  83. $(git_conf) status.showUntrackedFiles normal
  84. $(git_conf) log.date iso
  85. $(git_conf) push.default current
  86. ifneq (,$(xz))
  87. $(git_conf) tar.txz.command "xz -c"
  88. endif
  89. $(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"
  90. $(git_conf) alias.st "status -s -b"
  91. $(git_conf) alias.b "branch"
  92. $(git_conf) alias.sb "show-branch"
  93. $(git_conf) alias.ci "commit --verbose"
  94. $(git_conf) alias.co "checkout"
  95. $(git_conf) alias.cim "commit --verbose -m"
  96. $(git_conf) alias.di "diff --color"
  97. $(git_conf) alias.me "merge --no-ff --stat --verbose"
  98. $(git_conf) alias.ffme "merge --ff-only --stat --verbose"
  99. $(git_conf) alias.gr "grep -n"
  100. $(git_conf) alias.ls "ls-files"
  101. # $(git_conf) alias.ls "ls-files -v --full-name"
  102. # $(git_conf) alias.ls "status -u -s ."
  103. $(git_conf) alias.sl "!sl"
  104. # $(git_conf) alias.my-ls "ls-files | xargs ls"
  105. # $(git_conf) alias.ll "!git ls-files | xargs ls -l -CFG --color=auto --time-style=long-iso"
  106. $(git_conf) alias.addi "add -i"
  107. # Add patch to index
  108. $(git_conf) alias.ap "apply --cached"
  109. $(git_conf) alias.clean-p "diff --quiet"
  110. $(git_conf) alias.echo-ref "for-each-ref --format='%(refname:short)'"
  111. $(git_conf) alias.todo "grep -nH -E -i 'todo:|note:|fixme:'"
  112. $(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'
  113. #$(git_conf) alias.wc "!git ls-files -z | xargs -0 wc"
  114. # $(git_conf) push.default "simple"
  115. ifneq (,$(iswindows))
  116. $(git_conf) core.fileMode false
  117. endif
  118. endif
  119. # test
  120. # ====
  121. test_els = test-el-emacs.el
  122. test-el: $(test_els)
  123. .PHONY: $(test_els)
  124. $(test_els): test-el-%: %
  125. $(emacs) -Q -batch -f batch-byte-compile $<
  126. EMACS_EL_DRY_RUN=t $(emacs) -q --debug-init --batch \
  127. --eval "(setq debug-on-error t)" --load $<c --kill
  128. # test syntax
  129. # ===========
  130. test_syntax_shs = test-syntax-shrc test-syntax-profile \
  131. test-syntax-xinitrc test-syntax-xprograms
  132. test-syntax-sh: $(test_syntax_shs)
  133. .PHONY: $(test_syntax_shs)
  134. $(test_syntax_shs): test-syntax-%: %
  135. sh -ec 'for sh in $(shrc_loadables); do $$sh -n $<; done'
  136. test_syntax_els = test-syntax-emacs.el
  137. test-syntax-el: $(test_syntax_els)
  138. .PHONY: $(test_syntax_els)
  139. sexp_elisp_syntax_check = \
  140. (with-temp-buffer \
  141. (emacs-lisp-mode) \
  142. (insert-file-contents file) \
  143. (condition-case err \
  144. (check-parens) \
  145. (user-error \
  146. (error (format "%s:%d:%d:Unmatched brancet or quote" \
  147. file \
  148. (line-number-at-pos) \
  149. (- (point) (point-at-bol)))))))
  150. $(test_syntax_els): test-syntax-%: %
  151. $(emacs) -Q --debug-init --batch \
  152. --eval '(let ((file "$<")) $(sexp_elisp_syntax_check))' --kill