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.

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