Skip to content

Instantly share code, notes, and snippets.

@bjhargrave
Last active September 26, 2015 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjhargrave/1076572 to your computer and use it in GitHub Desktop.
Save bjhargrave/1076572 to your computer and use it in GitHub Desktop.
Build git from source for Mac OS X 10.9 + XCode 64-bit. I also built libpcre 8.34 to use with Git.
.PHONY: git git-clean git-install git-install-man git-test git-uninstall
MYGIT_PREFIX=/usr/local/git
MYGIT_BUILD=git
MYGIT_BUILDOPTIONS = NO_DARWIN_PORTS=1 \
CFLAGS="-g -O2 -Wall -arch x86_64" \
LDFLAGS="-arch x86_64" \
NO_GETTEXT=YesPlease \
USE_LIBPCRE=YesPlease \
PERLLIB_EXTRA="/Applications/Xcode.app/Contents/Developer/Library/Perl/5.16/darwin-thread-multi-2level" \
prefix=$(MYGIT_PREFIX)
-include $(MYGIT_BUILD)/GIT-VERSION-FILE
#GIT_MAN_URL=http://www.kernel.org/pub/software/scm/git/
GIT_MAN_URL=http://git-core.googlecode.com/files/
GIT_MAN_FILE=git-manpages-$(GIT_VERSION).tar.gz
all:
echo Read the makefile!
git:
$(MAKE) -C $(MYGIT_BUILD) $(MYGIT_BUILDOPTIONS) all strip
$(MAKE) -C $(MYGIT_BUILD)/contrib/credential/osxkeychain $(MYGIT_BUILDOPTIONS) all
git-clean:
$(MAKE) -C $(MYGIT_BUILD) $(MYGIT_BUILDOPTIONS) clean
$(MAKE) -C $(MYGIT_BUILD)/contrib/credential/osxkeychain clean
#GIT_TEST_OPTS="--verbose --debug"
git-test:
$(MAKE) -C $(MYGIT_BUILD) $(MYGIT_BUILDOPTIONS) test
git-install:
sudo $(MAKE) -C $(MYGIT_BUILD) $(MYGIT_BUILDOPTIONS) install
sudo chown -R `id -un` $(MYGIT_BUILD)/git-gui/
sudo mkdir -p $(MYGIT_PREFIX)/share/git-core/templates/info
sudo sh -c "echo .DS_Store >> $(MYGIT_PREFIX)/share/git-core/templates/info/exclude"
sudo mkdir -p $(MYGIT_PREFIX)/contrib/completion
sudo cp $(MYGIT_BUILD)/contrib/completion/* $(MYGIT_PREFIX)/contrib/completion/
sudo mkdir -p $(MYGIT_PREFIX)/contrib/credential/osxkeychain
sudo cp $(MYGIT_BUILD)/contrib/credential/osxkeychain/git-credential-osxkeychain $(MYGIT_PREFIX)/contrib/credential/osxkeychain/
# -sudo xattr -d com.apple.quarantine ~/Downloads/$(GIT_MAN_FILE)
git-install-man:
test "$(GIT_VERSION)" -a "You need to build git first to create $(MYGIT_BUILD)/GIT-VERSION-FILE (or set GIT_VERSION make variable)"
curl --fail -o ~/Downloads/$(GIT_MAN_FILE) $(GIT_MAN_URL)$(GIT_MAN_FILE)
sudo rm -rf $(MYGIT_PREFIX)/share/man
sudo mkdir -p $(MYGIT_PREFIX)/share/man
sudo tar -xvo -C $(MYGIT_PREFIX)/share/man -f ~/Downloads/$(GIT_MAN_FILE)
sudo chmod +rx $(MYGIT_PREFIX)/share/man
rm -f ~/Downloads/$(GIT_MAN_FILE)
git-uninstall:
sudo rm -rf $(MYGIT_PREFIX)
@bjhargrave
Copy link
Author

I use this Makefile to build git from source for my Mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment