What's cooking (2024/09 #06)
[git.git] / Make
blob7d6907b1452837d259c271c168fea739d2b1b024
1 #!/bin/sh
3 MASTER=master
5 if test -z "$GIT"
6 then
7 case "$(git version 2>/dev/null)" in
8 "git version"*)
9 GIT=git ;;
11 echo >&2 "No git to bootstrap"
12 exit 1 ;;
13 esac
16 inst_prefix=$(
17 IFS=:
18 for p in $PATH
20 probed=${p%/git-active/bin}
21 if test "$probed" != "$p"
22 then
23 echo "$probed"
24 exit
26 done
27 echo $HOME
30 LANG=C
32 for cv in PYTHON_PATH=python TCL_PATH=tclsh TCLTKPATH=wish
34 cmd=${cv#*=}
35 var=${cv%=*}
36 eval $(
37 if test -f "/usr/bin/$cmd"
38 then
39 break
41 for p in /usr/bin /usr/local/bin
43 if test -f "$p/$cmd"
44 then
45 echo "$var=$p/$cmd; export $var"
46 break
48 found=$(find "$p/$cmd"* -type f 2>/dev/null | head -n 1)
49 if test -f "$found"
50 then
51 echo "$var=$found; export $var"
52 break
54 done
56 done
58 tests= jobs= oldtest= with_shell= testpen=
59 clean=:
61 determine_branch () {
62 expr "$($GIT symbolic-ref --no-recurse HEAD 2>/dev/null ||
63 $GIT symbolic-ref HEAD 2>/dev/null)" : 'refs/heads/\(.*\)' ||
64 echo detached
67 determine_version () {
68 v=`$GIT describe HEAD`
69 expr "$v" : '.*-g[0-9a-f]*$' >/dev/null && {
70 echo >&2 "You are on 'snap' but $v is not an official version."
71 exit 1
73 echo "$v"
76 determine_long_version () {
77 $GIT describe HEAD 2>/dev/null || echo unknown-g00000000 |
78 sed -e 's/-/./g'
81 BUILTIN_CLEAN_FIX=8687f777
82 if ! git merge-base --is-ancestor $BUILTIN_CLEAN_FIX HEAD
83 then
84 NO_PEDANTIC=YesPlease
87 DEVELOPER=
88 case "$NO_PEDANTIC" in
89 ?*) ;;
90 '')
91 DEVELOPER=1
93 'not-used-anymore')
94 # PEDANT="-Wtypedef-redefinition $PEDANT"
95 PEDANT="-Werror -Wold-style-definition $PEDANT"
96 PEDANT="-Wpointer-arith -Woverflow -Wunused $PEDANT"
97 PEDANT="-Wold-style-declaration -Wstrict-prototypes $PEDANT"
98 PEDANT="-Wstrict-prototypes $PEDANT"
100 esac
102 while case $# in 0) break ;; esac
104 case "$1" in
105 --pedantic)
106 echo >&2 "(no need to say --pedantic)"
108 -j*)
109 case "$NO_JOBS" in
110 ?*) jobs= ;;
111 '') jobs=$1 ;;
112 esac
114 -noprove | --noprove)
115 oldtest=t
117 -loose | --loose)
118 DEVELOPER= PEDANT=
120 --memtrash)
121 testpen=testpen.$$
123 --memtrash=*)
124 testpen=testpen.${1#--memtrash=}
126 --locale=*)
127 LANG=${1#*=}
129 --test=*)
130 tests=$(
131 cd t &&
132 IFS="$IFS,"
133 for t in ${1#*=}
135 eval echo "t$t-*.sh"
136 done | tr '\012' ' '
139 --long)
140 GIT_TEST_LONG=YesPlease
141 export GIT_TEST_LONG
143 --bash)
144 with_shell=/bin/bash
146 --dash)
147 with_shell=/bin/dash
149 --ksh)
150 with_shell=/bin/ksh
153 shift
154 break
157 echo >&2 "Eh $1?"
158 exit 1
161 break
163 esac
164 shift
165 done
167 if test -n "$testpen"
168 then
169 for TRASH in /dev/shm /tmp ""
171 if test -n "$TRASH" &&
172 mkdir -p "$TRASH/$testpen" 2>/dev/null &&
173 test -w "$TRASH/$testpen"
174 then
175 testpen=$(cd "$TRASH/$testpen" && /bin/pwd)
176 TRASH="--root=$testpen"
177 clean="$clean; rmdir '$testpen'"
178 break
180 done
181 GIT_TEST_OPTS="$TRASH${GIT_TEST_OPTS+" $GIT_TEST_OPTS"}"
182 export GIT_TEST_OPTS
185 if test -z "$oldtest" &&
186 sh -c 'prove --version >/dev/null 2>&1' &&
187 sh -c 'prove --exec : >/dev/null 2>&1'
188 then
189 # --state=slow,save
190 DEFAULT_TEST_TARGET=prove
191 GIT_PROVE_OPTS="${GIT_PROVE_OPTS:+$GIT_PROVE_OPTS }--timer $jobs"
192 export DEFAULT_TEST_TARGET GIT_PROVE_OPTS
195 LC_ALL=$LANG
196 export LANG LC_ALL
198 branch=$(determine_branch)
200 case "$branch" in
201 next | maint | $MASTER | seen | jch)
202 prefix="$inst_prefix/git-$branch"
204 snap)
205 v=$(determine_version)
206 prefix="$inst_prefix/git-snap-$v"
209 prefix="$inst_prefix/git-test" ;;
210 esac
212 clean="$clean; rm -f version"
213 determine_long_version >version
215 set "prefix=$prefix" "$@"
216 if test -n "$with_shell" && test -f "$with_shell"
217 then
218 set "SHELL_PATH=$with_shell" "$@"
221 if grep >/dev/null DC_SHA1 Makefile
222 then
223 SHA1IMPLEMENTATION=DC_SHA1=YesPlease
224 elif grep >/dev/null BLK_SHA1 Makefile
225 then
226 SHA1IMPLEMENTATION=BLK_SHA1=YesPlease
227 else
228 SHA1IMPLEMENTATION=
231 if test -f sha256/nettle.h && test -f /usr/include/nettle/sha2.h
232 then
233 SHA1IMPLEMENTATION="$SHA1IMPLEMENTATION NETTLE_SHA256=YesPlease"
236 set MAN_BASE_URL='"http://www.kernel.org/pub/software/scm/git/docs/"' \
237 $SHA1IMPLEMENTATION \
238 USE_ASCIIDOCTOR=YesPlease \
239 USE_LIBPCRE=YesPlease \
240 "$@"
242 # Platform hack
243 if test -z "${make:+set}" && {
244 test -x /usr/local/bin/gmake ||
245 test -x /usr/pkg/bin/gmake ||
246 test -x /usr/bin/gmake
248 then
249 make=gmake
251 if test -f /bin/ginstall
252 then
253 set INSTALL=ginstall "$@"
256 GIT_SKIP_TESTS=${GIT_SKIP_TESTS:+"$GIT_SKIP_TESTS "}"t9999"
257 export GIT_SKIP_TESTS
259 unset SSH_AGENT_PID SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION \
260 GPG_AGENT_INFO GNOME_KEYRING_CONTROL GNOME_KEYRING_PID \
261 XDG_SESSION_COOKIE XDG_SESSION_PATH XDG_SEAT_PATH XDG_DATA_DIRS \
262 PGPPATH AUTO_PROXY WINDOWID SESSION_MANAGER XDG_CONFIG_DIRS STY \
263 GDMSESSION KRB5CCNAME GNOME_DESKTOP_SESSION_ID \
264 DBUS_SESSION_BUS_ADDRESS LESSOPEN WINDOW DISPLAY GTK_IM_MODULE \
265 XDG_CURRENT_DESKTOP LESSCLOSE XAUTHORITY
267 # O=-fsanitize=address Meta/Make
269 ${make-make} \
270 $jobs \
271 ETC_GITCONFIG=$prefix/etc/gitconfig \
272 ${DEVELOPER:+"DEVELOPER=YesPlease"} \
273 SPATCH_FLAGS="--all-includes --recursive-includes --patch ." \
274 SPATCH_BATCH_SIZE=16 \
275 CFLAGS="-g -Wall -Wunused -Wdeclaration-after-statement -std=gnu99${O:+ $O}" \
276 ${tests:+"T=$tests"} ${tests:+UNIT_TESTS=} \
277 "$@"
278 status=$?
279 eval "$clean"
280 exit $status