What's cooking (2018/08 #03)
[alt-git.git] / Make
blobc12a1c715046375a3563977614bf87cf8bccf7f7
1 #!/bin/sh
3 if test -z "$GIT"
4 then
5 case "$(git version 2>/dev/null)" in
6 "git version"*)
7 GIT=git ;;
8 *)
9 echo >&2 "No git to bootstrap"
10 exit 1 ;;
11 esac
14 inst_prefix=$(
15 IFS=:
16 for p in $PATH
18 probed=${p%/git-active/bin}
19 if test "$probed" != "$p"
20 then
21 echo "$probed"
22 exit
24 done
25 echo $HOME
28 LANG=C
30 for cv in PYTHON_PATH=python TCL_PATH=tclsh TCLTKPATH=wish
32 cmd=${cv#*=}
33 var=${cv%=*}
34 eval $(
35 if test -f "/usr/bin/$cmd"
36 then
37 break
39 for p in /usr/bin /usr/local/bin
41 if test -f "$p/$cmd"
42 then
43 echo "$var=$p/$cmd; export $var"
44 break
46 found=$(find "$p/$cmd"* -type f 2>/dev/null | head -n 1)
47 if test -f "$found"
48 then
49 echo "$var=$found; export $var"
50 break
52 done
54 done
56 tests= jobs= skip= oldtest= with_dash= testpen=
57 clean=:
59 case `uname` in
60 OpenBSD)
61 # O="-fgnu89-inline"
62 skip="t9402"
64 NetBSD)
65 OLD_ICONV=YesPlease; export OLD_ICONV
66 skip="t5000 t9402"
68 FreeBSD)
69 OLD_ICONV=YesPlease; export OLD_ICONV
70 skip="t5560"
72 SunOS)
73 NEEDS_CRYPTO_WITH_SSL=YesPlease ; export NEEDS_CRYPTO_WITH_SSL
74 NO_PEDANTIC=CannotDo
76 esac
78 determine_branch () {
79 expr "$($GIT symbolic-ref HEAD 2>/dev/null)" : 'refs/heads/\(.*\)' ||
80 echo detached
83 determine_version () {
84 v=`$GIT describe HEAD`
85 expr "$v" : '.*-g[0-9a-f]*$' >/dev/null && {
86 echo >&2 "You are on 'snap' but $v is not an official version."
87 exit 1
89 echo "$v"
92 determine_long_version () {
93 $GIT describe HEAD 2>/dev/null || echo unknown-g00000000 |
94 sed -e 's/-/./g'
97 BUILTIN_CLEAN_FIX=8687f777
98 if ! git merge-base --is-ancestor $BUILTIN_CLEAN_FIX HEAD
99 then
100 NO_PEDANTIC=YesPlease
103 DEVELOPER=
104 case "$NO_PEDANTIC" in
105 ?*) ;;
107 DEVELOPER=1
109 'not-used-anymore')
110 # PEDANT="-Wtypedef-redefinition $PEDANT"
111 PEDANT="-Werror -Wold-style-definition $PEDANT"
112 PEDANT="-Wpointer-arith -Woverflow -Wunused $PEDANT"
113 PEDANT="-Wold-style-declaration -Wstrict-prototypes $PEDANT"
114 PEDANT="-Wstrict-prototypes $PEDANT"
116 esac
118 while case $# in 0) break ;; esac
120 case "$1" in
121 --pedantic)
122 echo >&2 "(no need to say --pedantic)"
124 -j*)
125 case "$NO_JOBS" in
126 ?*) jobs= ;;
127 '') jobs=$1 ;;
128 esac
130 -noprove | --noprove)
131 oldtest=t
133 -loose | --loose)
134 DEVELOPER= PEDANT=
136 --memtrash)
137 testpen=testpen.$$
139 --memtrash=*)
140 testpen=testpen.${1#--memtrash=}
142 --locale=*)
143 LANG=${1#*=}
145 --test=*)
146 tests=$(
147 cd t &&
148 IFS="$IFS,"
149 for t in ${1#*=}
151 eval echo "t$t-*.sh"
152 done | tr '\012' ' '
155 --long)
156 GIT_TEST_LONG=YesPlease
157 export GIT_TEST_LONG
159 --dash)
160 with_dash=y
163 shift
164 break
167 echo >&2 "Eh $1?"
168 exit 1
171 break
173 esac
174 shift
175 done
177 if test -n "$testpen"
178 then
179 for TRASH in /dev/shm /tmp ""
181 if test -n "$TRASH" &&
182 mkdir -p "$TRASH/$testpen" 2>/dev/null &&
183 test -w "$TRASH/$testpen"
184 then
185 testpen=$(cd "$TRASH/$testpen" && /bin/pwd)
186 TRASH="--root=$testpen"
187 clean="$clean; rmdir '$testpen'"
188 break
190 done
191 GIT_TEST_OPTS="$TRASH${GIT_TEST_OPTS+" $GIT_TEST_OPTS"}"
192 export GIT_TEST_OPTS
195 test -f /bin/dash || with_dash=
197 if test -z "$tests" && test -n "$skip"
198 then
199 GIT_SKIP_TESTS="${GIT_SKIP_TESTS:-$skip}"
200 export GIT_SKIP_TESTS
202 if test -z "$oldtest" &&
203 sh -c 'prove --version >/dev/null 2>&1' &&
204 sh -c 'prove --exec : >/dev/null 2>&1'
205 then
206 # --state=slow,save
207 DEFAULT_TEST_TARGET=prove
208 GIT_PROVE_OPTS="${GIT_PROVE_OPTS:+$GIT_PROVE_OPTS }--timer $jobs"
209 export DEFAULT_TEST_TARGET GIT_PROVE_OPTS
212 LC_ALL=$LANG
213 export LANG LC_ALL
215 branch=$(determine_branch)
217 case "$branch" in
218 next | maint | master | pu | jch)
219 prefix="$inst_prefix/git-$branch"
221 snap)
222 v=$(determine_version)
223 prefix="$inst_prefix/git-snap-$v"
226 prefix="$inst_prefix/git-test" ;;
227 esac
229 clean="$clean; rm -f version"
230 determine_long_version >version
232 set "prefix=$prefix" "$@"
233 if test -n "$with_dash" && test -f /bin/dash
234 then
235 set "SHELL_PATH=/bin/dash" "$@"
238 if grep >/dev/null DC_SHA1 Makefile
239 then
240 SHA1IMPLEMENTATION=DC_SHA1=YesPlease
241 elif grep >/dev/null BLK_SHA1 Makefile
242 then
243 SHA1IMPLEMENTATION=BLK_SHA1=YesPlease
244 else
245 SHA1IMPLEMENTATION=
248 set MAN_BASE_URL='"http://www.kernel.org/pub/software/scm/git/docs/"' \
249 MAN_BOLD_LITERAL=YesPlease \
250 $SHA1IMPLEMENTATION \
251 GNU_ROFF=YesPlease \
252 "$@"
254 # Platform hack
255 if test -z "${make:+set}" && {
256 test -x /usr/local/bin/gmake ||
257 test -x /usr/pkg/bin/gmake ||
258 test -x /usr/bin/gmake
260 then
261 make=gmake
263 if test -f /bin/ginstall
264 then
265 set INSTALL=ginstall "$@"
268 unset SSH_AGENT_PID SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION \
269 GPG_AGENT_INFO GNOME_KEYRING_CONTROL GNOME_KEYRING_PID \
270 XDG_SESSION_COOKIE XDG_SESSION_PATH XDG_SEAT_PATH XDG_DATA_DIRS \
271 PGPPATH AUTO_PROXY WINDOWID SESSION_MANAGER XDG_CONFIG_DIRS STY \
272 GDMSESSION KRB5CCNAME GNOME_DESKTOP_SESSION_ID \
273 DBUS_SESSION_BUS_ADDRESS LESSOPEN WINDOW DISPLAY GTK_IM_MODULE \
274 XDG_CURRENT_DESKTOP LESSCLOSE XAUTHORITY
276 # O=-fsanitize=address Meta/Make
278 ${make-make} \
279 $jobs \
280 ETC_GITCONFIG=$prefix/etc/gitconfig \
281 ${DEVELOPER:+"DEVELOPER=YesPlease"} \
282 ${O:+CFLAGS="-g -Wall $O"} \
283 ${tests:+"T=$tests"} \
284 "$@"
285 status=$?
286 eval "$clean"
287 exit $status