Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
vor 10 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. # Makefile --- 10sr make dotfiles
  2. # 2014, 10sr. Unlicensed <http://unlicense.org>
  3. # Variable definitions
  4. home ?= $(HOME)
  5. dotfiles_url_base := https://raw.githubusercontent.com/10sr/dotfiles/master
  6. use_git ?= t
  7. git_auth ?= t
  8. ifneq (,$(git_auth))
  9. dotfiles_git := git@github.com:10sr/dotfiles.git
  10. else
  11. $(warning 'git_auth' is empty. Use public read-only git repository.)
  12. dotfiles_git := http://github.com/10sr/dotfiles.git
  13. endif
  14. current_origin_url := $(shell git config remote.origin.url)
  15. ifeq ($(current_origin_url), $(dotfiles_git))
  16. $(warning Currently in dotfiles repository)
  17. dotfiles_dir := $(PWD)
  18. else
  19. ifeq (,$(dotfiles_dir))
  20. ifeq (,$(DOTFILES_DIR))
  21. $(warning Neigher DOTFILES_DIR nor dotfiles_dir not defined)
  22. $(warning Use default value)
  23. dotfiles_dir := $(home)/10sr_dotfiles
  24. else
  25. $(warning dotfiles_dir is set from DOTFILES_DIR)
  26. dotfiles_dir := $(DOTFILES_DIR)
  27. endif
  28. endif
  29. endif
  30. $(warning dotfiles_dir: $(dotfiles_dir))
  31. localdir := $(home)/.local
  32. vardir := $(home)/.var
  33. bindir := $(localdir)/bin
  34. current := $(shell date)
  35. uname := $(shell uname)
  36. shrc_loadables := sh bash zsh
  37. emacs ?= $(shell which emacs 2>/dev/null)
  38. git ?= $(shell which git 2>/dev/null)
  39. curl ?= $(shell which curl 2>/dev/null)
  40. grep ?= GREP_OPTIONS= $(shell which grep 2>/dev/null)
  41. # Targets
  42. all: default
  43. tests := test-el
  44. test: test-syntax $(tests)
  45. test_syntaxes := test-syntax-el test-syntax-sh
  46. test-syntax: $(test_syntaxes)
  47. setups := setup-darwin setup-directories setup-emacs setup-gitconf \
  48. setup-repository setup-util setup-rc
  49. # `make setup` to setup these all sounds to be too match
  50. setup-all: $(setups)
  51. # `make check` is just an alias for `make test`
  52. check: test
  53. # Similarly, check-syntax is test-syntax
  54. check-syntax: test-syntax
  55. .PHONY: all default \
  56. test check $(tests) \
  57. test-syntax check-syntax $(test_syntaxes)\
  58. setup-all $(setups)
  59. # System detection
  60. # ================
  61. # Is this usefull? Just checking uname is not enough?
  62. ismsys :=
  63. iscygwin :=
  64. iswindows :=
  65. isdarwin :=
  66. isfreebsd :=
  67. isbsd :=
  68. islinux :=
  69. ifneq (,$(findstring MINGW,$(uname)))
  70. ismsys := t
  71. endif
  72. ifneq (,$(findstring CYGWIN,$(uname)))
  73. iscygwin := t
  74. endif
  75. ifneq (,$(ismsys)$(iscygwin))
  76. iswindows := t
  77. endif
  78. ifneq (,$(findstring Darwin,$(uname)))
  79. isdarwin := t
  80. endif
  81. ifneq (,$(findstring FreeBSD,$(uname)))
  82. isfreebsd := t
  83. endif
  84. ifneq (,$(isdarwin)$(isfreebsd))
  85. isbsd := t
  86. endif
  87. ifneq (,$(findstring Linux,$(uname)))
  88. islinux := t
  89. endif
  90. # preparing files
  91. # ===============
  92. ifeq (,$(use_git))
  93. $(warning 'use_git' is set to empty. Use curl to fetch files)
  94. $(dotfiles_dir)/%:
  95. mkdir -vp $(dotfiles_dir)
  96. curl --url $(dotfiles_url_base)/$* --output $@
  97. else
  98. $(warning 'use_git' is set to non-empty. Use git to retrieve files)
  99. $(dotfiles_dir)/%: setup-repository
  100. test -f "$@"
  101. endif
  102. # Shortcut target for interactive usage
  103. # For example, `make file-emacs.el use_git=` will fetch emacs.el from web with
  104. # curl program.
  105. # NOTE: Is there any way to make all `file-%` targets phony?
  106. file-%: $(dotfiles_dir)/%
  107. test -f "$<"
  108. # Make sure $(dotfiles_dir)/% wont be removed as intermidiate files
  109. .PRECIOUS: $(dotfiles_dir)/%
  110. # setups
  111. # ======
  112. # setup git repository
  113. # --------------------
  114. setup-repository: $(dotfiles_dir)/.git
  115. $(dotfiles_dir)/.git:
  116. ifeq (,$(git))
  117. false "Git not installed"
  118. endif
  119. $(git) clone $(dotfiles_git) $(dotfiles_dir)
  120. # utils
  121. # -----
  122. setup_utils := colortable16.sh 256colors2.pl pacapt ack-2.12
  123. setup-util: $(setup_utils)
  124. .PHONY: $(setup_utils)
  125. setup_utils_path := $(setup_utils:%=$(bindir)/%)
  126. $(setup_utils): %: $(bindir)/%
  127. $(setup_utils_path):
  128. $(curl) -L --url "$(util_url)" --output "$@"
  129. chmod +x "$@"
  130. colortable16.sh: \
  131. util_url := https://gist.github.com/10sr/6852317/raw/colortable16.sh
  132. 256colors2.pl: util_url := https://gist.github.com/10sr/6852331/raw/256colors2.pl
  133. pacapt: util_url := https://github.com/icy/pacapt/raw/ng/pacapt
  134. ack-2.12: util_url := http://beyondgrep.com/ack-2.12-single-file
  135. # create directories
  136. # ------------------
  137. setup_directories := $(localdir) $(vardir) $(bindir)
  138. setup-directory: $(setup_directories)
  139. $(localdir) $(vardir) $(bindir):
  140. mkdir -vp $@
  141. # darwin setup
  142. # ------------
  143. setup_darwins := setup-darwin-defaults setup-darwin-daemon
  144. setup-darwin: $(setup_darwins)
  145. .PHONY: $(setup_darwins)
  146. setup-darwin-defaults:
  147. # http://appdrill.net/60641/mac-boot-mute.html
  148. #sudo nvram SystemAudioVolume=%80
  149. # add quit entry in menu
  150. defaults write com.apple.finder QuitMenuItem -bool YES
  151. # show full path on titlebar
  152. defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
  153. # do not show desktop icons
  154. defaults write com.apple.finder CreateDesktop -boolean false
  155. killall Finder
  156. # disable dashboard
  157. #defaults write com.apple.dashboard mcx-disabled -bool YES
  158. setup-darwin-daemon:
  159. test "`launchctl getenv LC_ALL`" = C || sudo launchctl setenv LC_ALL C
  160. if ! (launchctl list | grep com.apple.locate) >/dev/null ;\
  161. then \
  162. sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist ;\
  163. fi
  164. # emacs setup
  165. # -----------
  166. setup-emacs: $(dotfiles_dir)/emacs.el
  167. $(emacs) -q --debug-init --batch --load $< -f my-auto-install-package
  168. # git config setup
  169. # ----------------
  170. ifneq (,$(git))
  171. git_conf := $(git) config --global
  172. endif
  173. xz := $(shell which xz 2>/dev/null)
  174. setup-gitconf:
  175. ifeq (,$(git))
  176. $(warnning "Git program not found")
  177. else
  178. $(git_conf) user.name '10sr'
  179. $(git_conf) user.email '8slashes+git@gmail.com'
  180. $(git_conf) core.autocrlf false
  181. $(git_conf) core.excludesfile '~/.gitignore'
  182. $(git_conf) color.ui auto
  183. $(git_conf) status.relativePaths false
  184. $(git_conf) status.showUntrackedFiles normal
  185. $(git_conf) log.date iso
  186. $(git_conf) push.default current
  187. ifneq (,$(xz))
  188. $(git_conf) tar.txz.command "xz -c"
  189. endif
  190. $(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"
  191. $(git_conf) alias.st "status -s -b"
  192. $(git_conf) alias.b "branch"
  193. $(git_conf) alias.sb "show-branch"
  194. $(git_conf) alias.ci "commit --verbose"
  195. $(git_conf) alias.co "checkout"
  196. $(git_conf) alias.cim "commit --verbose -m"
  197. $(git_conf) alias.di "diff --color"
  198. $(git_conf) alias.me "merge --no-ff --stat --verbose"
  199. $(git_conf) alias.ffme "merge --ff-only --stat --verbose"
  200. $(git_conf) alias.gr "grep -n"
  201. $(git_conf) alias.ls "ls-files"
  202. # $(git_conf) alias.ls "ls-files -v --full-name"
  203. # $(git_conf) alias.ls "status -u -s ."
  204. $(git_conf) alias.sl "!sl"
  205. # $(git_conf) alias.my-ls "ls-files | xargs ls"
  206. # $(git_conf) alias.ll "!git ls-files | xargs ls -l -CFG --color=auto --time-style=long-iso"
  207. $(git_conf) alias.addi "add -i"
  208. # Add patch to index
  209. $(git_conf) alias.ap "apply --cached"
  210. $(git_conf) alias.clean-p "diff --quiet"
  211. $(git_conf) alias.echo-ref "for-each-ref --format='%(refname:short)'"
  212. $(git_conf) alias.todo "grep -nH -E -i 'todo:|note:|fixme:'"
  213. $(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'
  214. #$(git_conf) alias.wc "!git ls-files -z | xargs -0 wc"
  215. # $(git_conf) push.default "simple"
  216. ifneq (,$(iswindows))
  217. $(git_conf) core.fileMode false
  218. endif
  219. endif
  220. # setup rc files
  221. # --------------
  222. # Generate load codes from the files themselves.
  223. # Load codes are defined by following SETUP_LOAD: indicator.
  224. # String DOTFILES_DIR in the load codes will be replaced into the value of
  225. # $(dotfiles_dir).
  226. # If append_load is non-empty, the load codes are appended to $(topfile),
  227. # otherwise the code will be just printed out to stdout.
  228. setup_rcs := setup-rc-vimrc setup-rc-tmux.conf setup-rc-emacs.el
  229. setup-rc: $(setup_rcs)
  230. .PHONY: $(setup_rcs)
  231. command_extract_setup_load := $(grep) -e 'SETUP_LOAD: ' | \
  232. sed -e 's/^.*SETUP_LOAD: //' -e 's|DOTFILES_DIR|$(dotfiles_dir)|'
  233. $(setup_rcs): setup-rc-%: $(dotfiles_dir)/%
  234. ifeq (,$(append_load))
  235. @echo "\`append_load' is not defined. Just print load command."
  236. cat "$<" | $(command_extract_setup_load)
  237. else
  238. cat "$<" | $(command_extract_setup_load) | tee -a "$(topfile)"
  239. endif
  240. setup-rc-vimrc: topfile := $(home)/.vimrc
  241. setup-rc-tmux.conf: topfile := $(home)/.tmux.conf
  242. setup-rc-emacs.el: topfile := $(home)/.emacs.d/init.el
  243. # test
  244. # ====
  245. test_els := test-el-emacs.el
  246. test-el: $(test_els)
  247. .PHONY: $(test_els)
  248. $(test_els): test-el-%: $(dotfiles_dir)/%
  249. $(emacs) -Q -batch -f batch-byte-compile $<
  250. EMACS_EL_DRY_RUN=t $(emacs) -q --debug-init --batch \
  251. --eval "(setq debug-on-error t)" --load $<c --kill
  252. # test syntax
  253. # ===========
  254. test_syntax_shs := test-syntax-shrc test-syntax-profile \
  255. test-syntax-xinitrc test-syntax-xprograms
  256. test-syntax-sh: $(test_syntax_shs)
  257. .PHONY: $(test_syntax_shs)
  258. $(test_syntax_shs): test-syntax-%: $(dotfiles_dir)/%
  259. sh -ec 'for sh in $(shrc_loadables); do $$sh -n $<; done'
  260. test_syntax_els := test-syntax-emacs.el
  261. test-syntax-el: $(test_syntax_els)
  262. .PHONY: $(test_syntax_els)
  263. sexp_elisp_syntax_check := \
  264. (with-temp-buffer \
  265. (emacs-lisp-mode) \
  266. (insert-file-contents file) \
  267. (condition-case err \
  268. (check-parens) \
  269. (user-error \
  270. (error (format "%s:%d:%d:Unmatched brancet or quote" \
  271. file \
  272. (line-number-at-pos) \
  273. (- (point) (point-at-bol)))))))
  274. $(test_syntax_els): test-syntax-%: $(dotfiles_dir)/%
  275. $(emacs) -Q --debug-init --batch \
  276. --eval '(let ((file "$<")) $(sexp_elisp_syntax_check))' --kill