25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

Makefile 5.6 KiB

10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. $(git_conf) alias.clean-p "diff --quiet"
  106. $(git_conf) alias.echo-ref "for-each-ref --format='%(refname:short)'"
  107. # alias open-branch and close-branch, which will be useful for topic branch
  108. # workflow
  109. _git_open_branch="checkout -b"
  110. _git_close_branch="!sh -cx 'git stash && \
  111. git checkout master && git merge --no-ff --stat --verbose -'"
  112. $(git_conf) alias.open-branch "$_git_open_branch"
  113. $(git_conf) alias.close-branch "$_git_close_branch"
  114. $(git_conf) alias.o "$_git_open_branch"
  115. $(git_conf) alias.c "$_git_close_branch"
  116. $(git_conf) alias.todo "grep -nH -E -i 'todo:|note:|fixme:'"
  117. $(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'
  118. #$(git_conf) alias.wc "!git ls-files -z | xargs -0 wc"
  119. # $(git_conf) push.default "simple"
  120. ifneq (,$(iswindows))
  121. $(git_conf) core.fileMode false
  122. endif
  123. endif
  124. # test
  125. # ====
  126. test_els = test-el-emacs.el
  127. test-el: $(test_els)
  128. .PHONY: $(test_els)
  129. $(test_els): test-el-%: %
  130. $(emacs) -Q -batch -f batch-byte-compile $<
  131. EMACS_EL_DRY_RUN=t $(emacs) -q --debug-init --batch \
  132. --eval "(setq debug-on-error t)" --load $<c --kill
  133. # test syntax
  134. # ===========
  135. test_syntax_shs = test-syntax-shrc test-syntax-profile test-syntax-setup.sh \
  136. test-syntax-xinitrc test-syntax-xprograms
  137. test-syntax-sh: $(test_syntax_shs)
  138. .PHONY: $(test_syntax_shs)
  139. $(test_syntax_shs): test-syntax-%: %
  140. sh -ec 'for sh in $(shrc_loadables); do $$sh -n $<; done'
  141. test_syntax_els = test-syntax-emacs.el
  142. test-syntax-el: $(test_syntax_els)
  143. .PHONY: $(test_syntax_els)
  144. sexp_elisp_syntax_check = \
  145. (with-temp-buffer \
  146. (emacs-lisp-mode) \
  147. (insert-file-contents file) \
  148. (condition-case err \
  149. (check-parens) \
  150. (user-error \
  151. (error (format "%s:%d:%d:Unmatched brancet or quote" \
  152. file \
  153. (line-number-at-pos) \
  154. (- (point) (point-at-bol)))))))
  155. $(test_syntax_els): test-syntax-%: %
  156. $(emacs) -Q --debug-init --batch \
  157. --eval '(let ((file "$<")) $(sexp_elisp_syntax_check))' --kill