Skip to content

Instantly share code, notes, and snippets.

@xemoe
Forked from DerekV/Makefile
Created April 15, 2019 17:06
Show Gist options
  • Select an option

  • Save xemoe/3fd842f9b9db3850327869c77f541208 to your computer and use it in GitHub Desktop.

Select an option

Save xemoe/3fd842f9b9db3850327869c77f541208 to your computer and use it in GitHub Desktop.

Revisions

  1. Derek VerLee revised this gist Jul 2, 2012. 1 changed file with 77 additions and 7 deletions.
    84 changes: 77 additions & 7 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,92 @@
    #gnu makefile

    REQUIRED-SOFTWARE=emacs git svn wget
    REQUIRED-SOFTWARE=emacs git sudo

    EMACS-INIT-FILE?=~/.emacs
    EMACS-LISP-BASE?=~/.emacs.d/lisp
    DOTFILES-DIR?=~/dotfiles

    all: $(REQUIRED-SOFTWARE)
    ## DOTFILES-REPO?= YOUR DOTFILES REPO HERE

    ## generate needed software dependancie targets
    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)) ) \
    @if ( $(call is-not-installed,$(1)) ) ; \
    then \
    echo $(1) " not found in path."; \
    echo "Installing " $(1); \
    portmaster $$(bsd-port-$(1)); \
    sudo portmaster $$(bsd-port-$(1)); \
    else \
    echo $(1) "found"; \
    fi
    @@ -26,11 +96,11 @@ 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) \
    @$(call is-not-installed,portmaster) \
    && cd /usr/ports/ports-mgmt/portmaster \
    && make install clean \
    || echo "found portmaster"
  2. Derek VerLee created this gist Jul 2, 2012.
    36 changes: 36 additions & 0 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #gnu makefile

    REQUIRED-SOFTWARE=emacs git svn wget


    all: $(REQUIRED-SOFTWARE)

    ## 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); \
    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

    $(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"