Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

315 rindas
7.0 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. uname = $(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. # System detection
  37. # ================
  38. # Is this usefull? Just checking uname is not enough?
  39. ismsys =
  40. iscygwin =
  41. iswindows =
  42. isdarwin =
  43. isfreebsd =
  44. isbsd =
  45. islinux =
  46. ifneq (,$(findstring MINGW,$(uname)))
  47. ismsys = t
  48. endif
  49. ifneq (,$(findstring CYGWIN,$(uname)))
  50. iscygwin = t
  51. endif
  52. ifneq (,$(ismsys)$(iscygwin))
  53. iswindows = t
  54. endif
  55. ifneq (,$(findstring Darwin,$(uname)))
  56. isdarwin = t
  57. endif
  58. ifneq (,$(findstring FreeBSD,$(uname)))
  59. isfreebsd = t
  60. endif
  61. ifneq (,$(isdarwin)$(isfreebsd))
  62. isbsd = t
  63. endif
  64. ifneq (,$(findstring Linux,$(uname)))
  65. islinux = t
  66. endif
  67. # setups
  68. # ======
  69. # setup repository
  70. # ----------------
  71. setup-repository:
  72. ifeq (,$(git))
  73. false "Git not installed"
  74. endif
  75. if ssh git@github.com 2>&1 | grep 'successfully authenticated'; \
  76. then \
  77. echo "Using $(dotfiles_git)"; \
  78. $(git) clone $(dotfiles_git) $(dotfiles_dir); \
  79. else \
  80. echo "Using $(dotfiles_git_pub)"; \
  81. $(git) clone $(dotfiles_git_pub) $(dotfiles_dir); \
  82. fi
  83. # utils
  84. # -----
  85. setup_utils = colortable16.sh 256colors2.pl pacapt ack-2.12
  86. setup-util: $(setup_utils)
  87. .PHONY: $(setup_utils)
  88. setup_utils_path = $(setup_utils:%=$(bindir)/%)
  89. $(setup_utils): %: $(bindir)/%
  90. $(setup_utils_path):
  91. $(curl) -L --url "$(util_url)" --output "$@"
  92. chmod +x "$@"
  93. colortable16.sh: \
  94. util_url = https://gist.github.com/10sr/6852317/raw/colortable16.sh
  95. 256colors2.pl: util_url = https://gist.github.com/10sr/6852331/raw/256colors2.pl
  96. pacapt: util_url = https://github.com/icy/pacapt/raw/ng/pacapt
  97. ack-2.12: util_url = http://beyondgrep.com/ack-2.12-single-file
  98. # create directories
  99. # ------------------
  100. setup_directories = $(localdir) $(vardir) $(bindir)
  101. setup-directory: $(setup_directories)
  102. $(localdir) $(vardir) $(bindir):
  103. mkdir -vp $@
  104. # darwin setup
  105. # ------------
  106. setup_darwins = setup-darwin-defaults setup-darwin-daemon
  107. setup-darwin: $(setup_darwins)
  108. .PHONY: $(setup_darwins)
  109. setup-darwin-defaults:
  110. # http://appdrill.net/60641/mac-boot-mute.html
  111. #sudo nvram SystemAudioVolume=%80
  112. # add quit entry in menu
  113. defaults write com.apple.finder QuitMenuItem -bool YES
  114. # show full path on titlebar
  115. defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
  116. # do not show desktop icons
  117. defaults write com.apple.finder CreateDesktop -boolean false
  118. killall Finder
  119. # disable dashboard
  120. #defaults write com.apple.dashboard mcx-disabled -bool YES
  121. setup-darwin-daemon:
  122. test "`launchctl getenv LC_ALL`" = C || sudo launchctl setenv LC_ALL C
  123. if ! (launchctl list | grep com.apple.locate) >/dev/null ;\
  124. then \
  125. sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist ;\
  126. fi
  127. # emacs setup
  128. # -----------
  129. setup-emacs: emacs.el
  130. $(emacs) -q --debug-init --batch --load $< -f my-auto-install-package
  131. # git config setup
  132. # ----------------
  133. ifneq (,$(git))
  134. git_conf = $(git) config --global
  135. endif
  136. xz = $(shell which xz 2>/dev/null)
  137. setup-gitconf:
  138. ifeq (,$(git))
  139. $(warnning "Git program not found")
  140. else
  141. $(git_conf) user.name '10sr'
  142. $(git_conf) user.email '8slashes+git@gmail.com'
  143. $(git_conf) core.autocrlf false
  144. $(git_conf) core.excludesfile '~/.gitignore'
  145. $(git_conf) color.ui auto
  146. $(git_conf) status.relativePaths false
  147. $(git_conf) status.showUntrackedFiles normal
  148. $(git_conf) log.date iso
  149. $(git_conf) push.default current
  150. ifneq (,$(xz))
  151. $(git_conf) tar.txz.command "xz -c"
  152. endif
  153. $(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"
  154. $(git_conf) alias.st "status -s -b"
  155. $(git_conf) alias.b "branch"
  156. $(git_conf) alias.sb "show-branch"
  157. $(git_conf) alias.ci "commit --verbose"
  158. $(git_conf) alias.co "checkout"
  159. $(git_conf) alias.cim "commit --verbose -m"
  160. $(git_conf) alias.di "diff --color"
  161. $(git_conf) alias.me "merge --no-ff --stat --verbose"
  162. $(git_conf) alias.ffme "merge --ff-only --stat --verbose"
  163. $(git_conf) alias.gr "grep -n"
  164. $(git_conf) alias.ls "ls-files"
  165. # $(git_conf) alias.ls "ls-files -v --full-name"
  166. # $(git_conf) alias.ls "status -u -s ."
  167. $(git_conf) alias.sl "!sl"
  168. # $(git_conf) alias.my-ls "ls-files | xargs ls"
  169. # $(git_conf) alias.ll "!git ls-files | xargs ls -l -CFG --color=auto --time-style=long-iso"
  170. $(git_conf) alias.addi "add -i"
  171. # Add patch to index
  172. $(git_conf) alias.ap "apply --cached"
  173. $(git_conf) alias.clean-p "diff --quiet"
  174. $(git_conf) alias.echo-ref "for-each-ref --format='%(refname:short)'"
  175. $(git_conf) alias.todo "grep -nH -E -i 'todo:|note:|fixme:'"
  176. $(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'
  177. #$(git_conf) alias.wc "!git ls-files -z | xargs -0 wc"
  178. # $(git_conf) push.default "simple"
  179. ifneq (,$(iswindows))
  180. $(git_conf) core.fileMode false
  181. endif
  182. endif
  183. # tmux setup
  184. # ----------
  185. setup-tmux:
  186. # test
  187. # ====
  188. test_els = test-el-emacs.el
  189. test-el: $(test_els)
  190. .PHONY: $(test_els)
  191. $(test_els): test-el-%: %
  192. $(emacs) -Q -batch -f batch-byte-compile $<
  193. EMACS_EL_DRY_RUN=t $(emacs) -q --debug-init --batch \
  194. --eval "(setq debug-on-error t)" --load $<c --kill
  195. # test syntax
  196. # ===========
  197. test_syntax_shs = test-syntax-shrc test-syntax-profile \
  198. test-syntax-xinitrc test-syntax-xprograms
  199. test-syntax-sh: $(test_syntax_shs)
  200. .PHONY: $(test_syntax_shs)
  201. $(test_syntax_shs): test-syntax-%: %
  202. sh -ec 'for sh in $(shrc_loadables); do $$sh -n $<; done'
  203. test_syntax_els = test-syntax-emacs.el
  204. test-syntax-el: $(test_syntax_els)
  205. .PHONY: $(test_syntax_els)
  206. sexp_elisp_syntax_check = \
  207. (with-temp-buffer \
  208. (emacs-lisp-mode) \
  209. (insert-file-contents file) \
  210. (condition-case err \
  211. (check-parens) \
  212. (user-error \
  213. (error (format "%s:%d:%d:Unmatched brancet or quote" \
  214. file \
  215. (line-number-at-pos) \
  216. (- (point) (point-at-bol)))))))
  217. $(test_syntax_els): test-syntax-%: %
  218. $(emacs) -Q --debug-init --batch \
  219. --eval '(let ((file "$<")) $(sexp_elisp_syntax_check))' --kill