| #gnu makefile | |
| REQUIRED-SOFTWARE=emacs git sudo | |
| EMACS-INIT-FILE?=~/.emacs | |
| EMACS-LISP-BASE?=~/.emacs.d/lisp | |
| DOTFILES-DIR?=~/dotfiles | |
| ## DOTFILES-REPO?= YOUR DOTFILES REPO HERE | |
| all: $(EMACS-LISP-BASE) color-theme magit | |
| ssh-public-key: ~/.ssh/id_rsa.pub | |
| @echo "We need an ssh public key" | |
| ~/.ssh/id_rsa.pub: | |
| @ssh-keygen | |
| bitbucket-configured: ssh-public-key | |
| @ssh -T hg@bitbucket.org \ | |
| || (echo "You need to add your new public key to bitbucket" \ | |
| && cat ~/.ssh/id_rsa.pub \ | |
| && exit 1) | |
| github-configured: ssh-public-key | |
| @ssh -T git@github.com \ | |
| || (echo "You need to add your new public key to github" \ | |
| && cat ~/.ssh/id_rsa.pub \ | |
| && exit 1) | |
| .PHONY: dotfiles | |
| dotfiles : github-configured | |
| @if [ ! -d $(DOTFILES-DIR) ] ;\ | |
| then \ | |
| echo "dotfiles does not exist, fetching"; \ | |
| git clone $(DOTFILES-REPO); \ | |
| fi | |
| # TODO handle case that existing file isn't a link | |
| .PHONY: $(EMACS-INIT-FILE) | |
| $(EMACS-INIT-FILE): dotfiles | |
| @if [ ! -e $(EMACS-INIT-FILE) ] ; then \ | |
| ln -s $(DOTFILES-DIR)/dot.emacs ~/.emacs ; \ | |
| fi | |
| .PHONY: $(EMACS-LISP-BASE) | |
| $(EMACS-LISP-BASE): | |
| @mkdir -p $(EMACS-LISP-BASE) | |
| ###### Emacs utils ########################################################### | |
| ## Color Theme | |
| # http://www.nongnu.org/color-theme/ | |
| # The color theme page recommends using your package manager to install ... | |
| # we can't use the current install-program-template because it isn't an | |
| # executable so for the moment I'll just cheat and hard-code it | |
| # (this won't be portable) | |
| COLOR-THEME-LOCATION?=/usr/local/share/site-lisp | |
| .PHONY: color-theme | |
| color-theme: sudo | |
| @if( ! pkg_info -x color-theme.el ) then \ | |
| sudo portmaster misc/color-theme.el; \ | |
| fi | |
| ## Magit | |
| # best git client ever | |
| # http://philjackson.github.com/magit/ | |
| MAGIT_REPO=https://github.com/magit/magit.git | |
| .PHONY: magit | |
| magit: $(EMACS-LISP-BASE)/magit $(EMACS-INIT-FILE) | |
| $(EMACS-LISP-BASE)/magit: | |
| @if [ ! -d $@ ]; then (git clone $(MAGIT_REPO) $@); fi | |
| ### generate needed software dependancie targets | |
| is-not-installed=! (command -v $(1)) | |
| define install-program-template | |
| $(1): package-installer | |
| @if ( $(call is-not-installed,$(1)) ) ; \ | |
| then \ | |
| echo $(1) " not found in path."; \ | |
| echo "Installing " $(1); \ | |
| sudo portmaster $$(bsd-port-$(1)); \ | |
| else \ | |
| echo $(1) "found"; \ | |
| fi | |
| endef | |
| bsd-port-emacs:=editor/emacs | |
| bsd-port-svn:=devel/svn | |
| bsd-port-git:=devel/git | |
| bsd-port-wget:=ftp/wget | |
| bsd-port-sudo:=security/sudo | |
| $(foreach pkg,$(REQUIRED-SOFTWARE),$(eval $(call install-program-template,$(pkg)))) | |
| package-installer : | |
| @$(call is-not-installed,portmaster) \ | |
| && cd /usr/ports/ports-mgmt/portmaster \ | |
| && make install clean \ | |
| || echo "found portmaster" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment