Skip to content

Instantly share code, notes, and snippets.

@ryan-williams
Last active December 7, 2020 16:09
Show Gist options
  • Save ryan-williams/1186900f796abc1d4a41da15e7e478fc to your computer and use it in GitHub Desktop.
Save ryan-williams/1186900f796abc1d4a41da15e7e478fc to your computer and use it in GitHub Desktop.
installing git from source (optionally in home directory / with prefix)

Install libpcre2

In some situations, I've observed make below to fail for lack of a locatable libpcre2:

v=10.36
wget https://downloads.sourceforge.net/pcre/pcre2-$v.tar.bz2
tar -xvjf pcre2-$v.tar.bz2
pushd pcre2-$v
./configure --prefix="$HOME"
make
make install
popd

Install git

On Ubuntu, these packages needed to be installed:

apt-get install autoconf gettext libcurl4-openssl-dev gcc

On CentOS, these seem necessary:

yum install autoconf zlib-devel libcurl-devel gcc

Download + Install Git:

# wget https://github.com/asciidoc/asciidoc/archive/8.6.10.tar.gz
v=2.29.2
wget https://github.com/git/git/archive/v$v.tar.gz
tar -xvzf v$v.tar.gz
pushd git-$v
make configure
export CFLAGS="-I$HOME/include"
export LDFLAGS="-L$HOME/lib"
./configure --prefix="$HOME"
make
make install
popd

Troubleshooting

CFLAGS

The CFLAGS is necessary to avoid a make error like;

    CC bisect.o
In file included from revision.h:6:0,
                 from bisect.c:5:
grep.h:15:19: fatal error: pcre2.h: No such file or directory
 #include <pcre2.h>
                   ^
compilation terminated.
make: *** [bisect.o] Error 1

LDFLAGS

The LDFLAGS is necessary to avoid a make error like:

    LINK git-credential-store
/usr/bin/ld: cannot find -lpcre2-8
collect2: error: ld returned 1 exit status
make: *** [git-credential-store] Error 1

In both cases, if you try to make, hit that error, then update the appropriate flag, you'll need to re-run ./configure --prefix="$HOME" to pick up the flag change, before running make again.

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