2021/11/22

build static-linked git from source

因為要在自己的 target board 上 run,一個一個找 so copy 太麻煩,所以 build 一版 statis linked version 好了。
先是 configure,新的要自己 build 了,clone 下來後,我選 2.28.1..
make configure
之後,就可以 run configure 了。
git 的 configure 沒有支援 static ,所以是要自己加進 CFLAGS 中。
但是只家 -static 的話,build 還是 fail,說一些 linked library function undefined。
參考這個 link
$ ./configure --without-tcltk --without-curl --without-openssl CFLAGS="${CFLAGS}  -static -static-libgcc" NO_OPENSSL=1
之後就 build 成功了。
build git 需要 gettext。剩下的 make fail 都是 host build package 缺。

這樣build 好的 git 就可以放到 target board 上用了。
target board 有提供 ssh server 連線的話,可以用 git clone ssh:// 這個 link 來 clone。
這時候,就要把剛剛build 好的 folder 中, git-upload-pack 也放到 target board PATH 所在的folder 上。
git clone ssh:// 會叫起 targetboard 上的 git-upload-pack 來做傳輸。