What's cooking (2015/05 #03)
[git.git] / Make
blob0272b9787b3711720a7c50ac19732dab0b750c81
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=
61 case `uname` in
62 OpenBSD)
63 O="-fgnu89-inline"
64 skip="t9402"
66 NetBSD)
67 OLD_ICONV=YesPlease; export OLD_ICONV
68 skip="t5000 t9402"
70 FreeBSD)
71 OLD_ICONV=YesPlease; export OLD_ICONV
72 skip="t5560"
74 SunOS)
75 NEEDS_CRYPTO_WITH_SSL=YesPlease ; export NEEDS_CRYPTO_WITH_SSL
76 NO_PEDANTIC=CannotDo Wall=
78 esac
80 determine_branch () {
81 expr "$($GIT symbolic-ref HEAD 2>/dev/null)" : 'refs/heads/\(.*\)' ||
82 echo detached
85 determine_version () {
86 v=`$GIT describe HEAD`
87 expr "$v" : '.*-g[0-9a-f]*$' >/dev/null && {
88 echo >&2 "You are on 'snap' but $v is not an official version."
89 exit 1
91 echo "$v"
94 determine_long_version () {
95 $GIT describe HEAD 2>/dev/null || echo unknown-g00000000 |
96 sed -e 's/-/./g'
99 BUILTIN_CLEAN_FIX=8687f777
100 if ! git merge-base --is-ancestor $BUILTIN_CLEAN_FIX HEAD
101 then
102 NO_PEDANTIC=YesPlease
105 case "$NO_PEDANTIC" in
106 ?*) ;;
108 PEDANT="-Werror -Wold-style-definition -std=c99 $PEDANT"
109 PEDANT="-Wpointer-arith -Woverflow -Wunused $PEDANT"
110 PEDANT="-Wold-style-declaration -Wstrict-prototypes $PEDANT"
112 esac
114 while case $# in 0) break ;; esac
116 case "$1" in
117 --pedantic)
118 echo >&2 "(no need to say --pedantic)"
120 -j*)
121 case "$NO_JOBS" in
122 ?*) jobs= ;;
123 '') jobs=$1 ;;
124 esac
126 -noprove | --noprove)
127 oldtest=t
129 -loose | --loose)
130 PEDANT= Wall=
132 --locale=*)
133 LANG=${1#*=}
135 --test=*)
136 tests=$(
137 cd t &&
138 for t in ${1#*=}
140 eval echo "t$t-*.sh"
141 done | tr '\012' ' '
144 --dash)
145 with_dash=y
148 shift
149 break
152 echo >&2 "Eh $1?"
153 exit 1
156 break
158 esac
159 shift
160 done
161 O="${PEDANT}${PEDANT:+ }$O"
163 test -f /bin/dash || with_dash=
165 if test -z "$tests" && test -n "$skip"
166 then
167 GIT_SKIP_TESTS="${GIT_SKIP_TESTS:-$skip}"
168 export GIT_SKIP_TESTS
170 if test -z "$oldtest" &&
171 sh -c 'prove --version >/dev/null 2>&1' &&
172 sh -c 'prove --exec : >/dev/null 2>&1'
173 then
174 DEFAULT_TEST_TARGET=prove GIT_PROVE_OPTS="$jobs"
175 export DEFAULT_TEST_TARGET GIT_PROVE_OPTS
178 LC_ALL=$LANG
179 export LANG LC_ALL
181 branch=$(determine_branch)
183 case "$branch" in
184 next | maint | master | pu | jch)
185 prefix="$inst_prefix/git-$branch"
187 snap)
188 v=$(determine_version)
189 prefix="$inst_prefix/git-snap-$v"
192 prefix="$inst_prefix/git-test" ;;
193 esac
195 determine_long_version >version
197 set "prefix=$prefix" "$@"
198 if test -n "$with_dash" && test -f /bin/dash
199 then
200 set "SHELL_PATH=/bin/dash" "$@"
203 set MAN_BASE_URL='"http://www.kernel.org/pub/software/scm/git/docs/"' \
204 ASCIIDOC_NO_ROFF=YesPlease \
205 ASCIIDOC8=YesPlease \
206 BLK_SHA1=YesPlease \
207 GNU_ROFF=YesPlease \
208 "$@"
210 # Platform hack
211 if test -z "${make:+set}" && {
212 test -x /usr/local/bin/gmake ||
213 test -x /usr/pkg/bin/gmake ||
214 test -x /usr/bin/gmake
216 then
217 make=gmake
219 if test -f /bin/ginstall
220 then
221 set INSTALL=ginstall "$@"
224 CFLAGS="$O $Wall -g"
225 OK_TO_USE_CFLAGS=Yes
226 if test -n "${NO_CFLAGS+set}"
227 then
228 unset OK_TO_USE_CFLAGS
231 unset SSH_AGENT_PID SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION \
232 GPG_AGENT_INFO GNOME_KEYRING_CONTROL GNOME_KEYRING_PID \
233 XDG_SESSION_COOKIE XDG_SESSION_PATH XDG_SEAT_PATH XDG_DATA_DIRS \
234 PGPPATH AUTO_PROXY WINDOWID SESSION_MANAGER XDG_CONFIG_DIRS STY \
235 GDMSESSION KRB5CCNAME GNOME_DESKTOP_SESSION_ID \
236 DBUS_SESSION_BUS_ADDRESS LESSOPEN WINDOW DISPLAY GTK_IM_MODULE \
237 XDG_CURRENT_DESKTOP LESSCLOSE XAUTHORITY
239 ${make-make} \
240 $jobs \
241 ETC_GITCONFIG=$prefix/etc/gitconfig \
242 ${OK_TO_USE_CFLAGS+"CFLAGS=$CFLAGS"} \
243 ${tests:+"T=$tests"} \
244 "$@"
245 status=$?
246 rm -f version
247 exit $status