What's cooking (2015/07 #04)
[alt-git.git] / Make
blob1ba20fe4c61063b9835b5a5ee5497450cf41c7ad
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 : ${O=-O2}
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 Wall="-Wall -Wvla -Wdeclaration-after-statement -Wno-format-zero-length${Wall+ $Wall}"
59 tests= jobs= skip= oldtest= with_dash= testpen=
60 clean=:
62 case `uname` in
63 OpenBSD)
64 O="-fgnu89-inline"
65 skip="t9402"
67 NetBSD)
68 OLD_ICONV=YesPlease; export OLD_ICONV
69 skip="t5000 t9402"
71 FreeBSD)
72 OLD_ICONV=YesPlease; export OLD_ICONV
73 skip="t5560"
75 SunOS)
76 NEEDS_CRYPTO_WITH_SSL=YesPlease ; export NEEDS_CRYPTO_WITH_SSL
77 NO_PEDANTIC=CannotDo Wall=
79 esac
81 determine_branch () {
82 expr "$($GIT symbolic-ref HEAD 2>/dev/null)" : 'refs/heads/\(.*\)' ||
83 echo detached
86 determine_version () {
87 v=`$GIT describe HEAD`
88 expr "$v" : '.*-g[0-9a-f]*$' >/dev/null && {
89 echo >&2 "You are on 'snap' but $v is not an official version."
90 exit 1
92 echo "$v"
95 determine_long_version () {
96 $GIT describe HEAD 2>/dev/null || echo unknown-g00000000 |
97 sed -e 's/-/./g'
100 BUILTIN_CLEAN_FIX=8687f777
101 if ! git merge-base --is-ancestor $BUILTIN_CLEAN_FIX HEAD
102 then
103 NO_PEDANTIC=YesPlease
106 case "$NO_PEDANTIC" in
107 ?*) ;;
109 PEDANT="-Werror -Wold-style-definition -std=c99 $PEDANT"
110 PEDANT="-Wpointer-arith -Woverflow -Wunused $PEDANT"
111 PEDANT="-Wold-style-declaration -Wstrict-prototypes $PEDANT"
113 esac
115 while case $# in 0) break ;; esac
117 case "$1" in
118 --pedantic)
119 echo >&2 "(no need to say --pedantic)"
121 -j*)
122 case "$NO_JOBS" in
123 ?*) jobs= ;;
124 '') jobs=$1 ;;
125 esac
127 -noprove | --noprove)
128 oldtest=t
130 -loose | --loose)
131 PEDANT= Wall=
133 --memtrash)
134 testpen=testpen.$$
136 --memtrash=*)
137 testpen=testpen.${1#--memtrash=}
139 --locale=*)
140 LANG=${1#*=}
142 --test=*)
143 tests=$(
144 cd t &&
145 for t in ${1#*=}
147 eval echo "t$t-*.sh"
148 done | tr '\012' ' '
151 --dash)
152 with_dash=y
155 shift
156 break
159 echo >&2 "Eh $1?"
160 exit 1
163 break
165 esac
166 shift
167 done
169 if test -n "$testpen"
170 then
171 for TRASH in /dev/shm /tmp ""
173 if test -n "$TRASH" &&
174 mkdir -p "$TRASH/$testpen" 2>/dev/null &&
175 test -w "$TRASH/$testpen"
176 then
177 testpen=$(cd "$TRASH/$testpen" && /bin/pwd)
178 TRASH="--root=$testpen"
179 clean="$clean; rmdir '$testpen'"
180 break
182 done
183 GIT_TEST_OPTS="$TRASH${GIT_TEST_OPTS+" $GIT_TEST_OPTS"}"
184 export GIT_TEST_OPTS
187 O="${PEDANT}${PEDANT:+ }$O"
189 test -f /bin/dash || with_dash=
191 if test -z "$tests" && test -n "$skip"
192 then
193 GIT_SKIP_TESTS="${GIT_SKIP_TESTS:-$skip}"
194 export GIT_SKIP_TESTS
196 if test -z "$oldtest" &&
197 sh -c 'prove --version >/dev/null 2>&1' &&
198 sh -c 'prove --exec : >/dev/null 2>&1'
199 then
200 DEFAULT_TEST_TARGET=prove GIT_PROVE_OPTS="$jobs"
201 export DEFAULT_TEST_TARGET GIT_PROVE_OPTS
204 LC_ALL=$LANG
205 export LANG LC_ALL
207 branch=$(determine_branch)
209 case "$branch" in
210 next | maint | master | pu | jch)
211 prefix="$inst_prefix/git-$branch"
213 snap)
214 v=$(determine_version)
215 prefix="$inst_prefix/git-snap-$v"
218 prefix="$inst_prefix/git-test" ;;
219 esac
221 clean="$clean; rm -f version"
222 determine_long_version >version
224 set "prefix=$prefix" "$@"
225 if test -n "$with_dash" && test -f /bin/dash
226 then
227 set "SHELL_PATH=/bin/dash" "$@"
230 set MAN_BASE_URL='"http://www.kernel.org/pub/software/scm/git/docs/"' \
231 ASCIIDOC_NO_ROFF=YesPlease \
232 ASCIIDOC8=YesPlease \
233 BLK_SHA1=YesPlease \
234 GNU_ROFF=YesPlease \
235 "$@"
237 # Platform hack
238 if test -z "${make:+set}" && {
239 test -x /usr/local/bin/gmake ||
240 test -x /usr/pkg/bin/gmake ||
241 test -x /usr/bin/gmake
243 then
244 make=gmake
246 if test -f /bin/ginstall
247 then
248 set INSTALL=ginstall "$@"
251 CFLAGS="$O $Wall -g"
252 OK_TO_USE_CFLAGS=Yes
253 if test -n "${NO_CFLAGS+set}"
254 then
255 unset OK_TO_USE_CFLAGS
258 unset SSH_AGENT_PID SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION \
259 GPG_AGENT_INFO GNOME_KEYRING_CONTROL GNOME_KEYRING_PID \
260 XDG_SESSION_COOKIE XDG_SESSION_PATH XDG_SEAT_PATH XDG_DATA_DIRS \
261 PGPPATH AUTO_PROXY WINDOWID SESSION_MANAGER XDG_CONFIG_DIRS STY \
262 GDMSESSION KRB5CCNAME GNOME_DESKTOP_SESSION_ID \
263 DBUS_SESSION_BUS_ADDRESS LESSOPEN WINDOW DISPLAY GTK_IM_MODULE \
264 XDG_CURRENT_DESKTOP LESSCLOSE XAUTHORITY
266 ${make-make} \
267 $jobs \
268 ETC_GITCONFIG=$prefix/etc/gitconfig \
269 ${OK_TO_USE_CFLAGS+"CFLAGS=$CFLAGS"} \
270 ${tests:+"T=$tests"} \
271 "$@"
272 status=$?
273 eval "$clean"
274 exit $status