In the last 6 months, out of many new things I've tried, building git has been quite an interesting one. Steve Streeting's blog post was the primary reference for this activity.
As Steve rightly mentions, it is important that you install command line tools for XCode before attempting to build. Run this in terminal to install Xcode command line tools.
xcode-select --install
Clone the source code of git from https://github.com/git/git/
You need to select the right tag of the version which you need to build and checkout the tag.
If you have not used homebrew before, its time for you to install homebrew. Learn more about Homebrew. Run this in terminal to install homebrew,
usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Why do you need Homebrew?
Well, Homebrew is a package manager for Mac and will help you install some missing packages here. Want to know more about Homebrew? Check this out - http://brew.sh
Next up, OS 10.11 SDK does not include OpenSSL. You need to install this using brew. To do so, run this in terminal,
brew install openssl
If you want to install git in a specific location, make sure you set the right path before building. And to do so, you may need autoconf. If you do not have autoconf installed, you can do so by running this in terminal,
brew install autoconf
You can now set the path for the build products by running,
./configure --prefix=<path_to_build>
Now, you are ready to build git from the source code. Run this variant of make to build and install git,
NO_GETTEXT=1 make NO_INSTALL_HARDLINKS=1 CFLAGS="-I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib" install
You should now be able to find the git build in the path you've specified. However, there are a few things still missing. You'll need to install git-subtree which can be found in git's source. Navigate to "git/contrib/subtree" and run this command to install git-subtree,
sudo make install
Finally, make sure you have the git's credential helper in place. This is also found in the source. Navigate to "git/contrib/credential/osxkeychain/" and run "make" in terminal to get an executable. Move this executable to the build path under "bin" folder.
The build products are now ready to be used. You can check the version by running this in terminal,
<path_to_build>/bin/git --version
Hope this helps some one.
References:
No comments:
Post a Comment