What's cooking (2015/03 #08)
[alt-git.git] / Make
blob21771a669e6b4f632ecd7ddec30dd131aafc8701
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 case "$NO_PEDANTIC" in
100 ?*) ;;
102 PEDANT="-Werror -Wold-style-definition -std=c99 $PEDANT"
103 PEDANT="-Wpointer-arith -Woverflow -Wunused $PEDANT"
104 PEDANT="-Wold-style-declaration -Wstrict-prototypes $PEDANT"
106 esac
108 while case $# in 0) break ;; esac
110 case "$1" in
111 --pedantic)
112 echo >&2 "(no need to say --pedantic)"
114 -j*)
115 case "$NO_JOBS" in
116 ?*) jobs= ;;
117 '') jobs=$1 ;;
118 esac
120 -noprove | --noprove)
121 oldtest=t
123 -loose | --loose)
124 PEDANT= Wall=
126 --locale=*)
127 LANG=${1#*=}
129 --test=*)
130 tests=$(
131 cd t &&
132 for t in ${1#*=}
134 eval echo "t$t-*.sh"
135 done | tr '\012' ' '
138 --dash)
139 with_dash=y
142 shift
143 break
146 echo >&2 "Eh $1?"
147 exit 1
150 break
152 esac
153 shift
154 done
155 O="${PEDANT}${PEDANT:+ }$O"
157 test -f /bin/dash || with_dash=
159 if test -z "$tests" && test -n "$skip"
160 then
161 GIT_SKIP_TESTS="${GIT_SKIP_TESTS:-$skip}"
162 export GIT_SKIP_TESTS
164 if test -z "$oldtest" &&
165 sh -c 'prove --version >/dev/null 2>&1' &&
166 sh -c 'prove --exec : >/dev/null 2>&1'
167 then
168 DEFAULT_TEST_TARGET=prove GIT_PROVE_OPTS="$jobs"
169 export DEFAULT_TEST_TARGET GIT_PROVE_OPTS
172 LC_ALL=$LANG
173 export LANG LC_ALL
175 branch=$(determine_branch)
177 case "$branch" in
178 next | maint | master | pu | jch)
179 prefix="$inst_prefix/git-$branch"
181 snap)
182 v=$(determine_version)
183 prefix="$inst_prefix/git-snap-$v"
186 prefix="$inst_prefix/git-test" ;;
187 esac
189 determine_long_version >version
191 set "prefix=$prefix" "$@"
192 if test -n "$with_dash" && test -f /bin/dash
193 then
194 set "SHELL_PATH=/bin/dash" "$@"
197 set MAN_BASE_URL='"http://www.kernel.org/pub/software/scm/git/docs/"' \
198 ASCIIDOC_NO_ROFF=YesPlease \
199 ASCIIDOC8=YesPlease \
200 BLK_SHA1=YesPlease \
201 GNU_ROFF=YesPlease \
202 "$@"
204 # Platform hack
205 if test -z "${make:+set}" && {
206 test -x /usr/local/bin/gmake ||
207 test -x /usr/pkg/bin/gmake ||
208 test -x /usr/bin/gmake
210 then
211 make=gmake
213 if test -f /bin/ginstall
214 then
215 set INSTALL=ginstall "$@"
218 CFLAGS="$O $Wall -g"
219 OK_TO_USE_CFLAGS=Yes
220 if test -n "${NO_CFLAGS+set}"
221 then
222 unset OK_TO_USE_CFLAGS
225 unset SSH_AGENT_PID SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION \
226 GPG_AGENT_INFO GNOME_KEYRING_CONTROL GNOME_KEYRING_PID \
227 XDG_SESSION_COOKIE XDG_SESSION_PATH XDG_SEAT_PATH XDG_DATA_DIRS \
228 PGPPATH AUTO_PROXY WINDOWID SESSION_MANAGER XDG_CONFIG_DIRS STY \
229 GDMSESSION KRB5CCNAME GNOME_DESKTOP_SESSION_ID \
230 DBUS_SESSION_BUS_ADDRESS LESSOPEN WINDOW DISPLAY GTK_IM_MODULE \
231 XDG_CURRENT_DESKTOP LESSCLOSE XAUTHORITY
233 ${make-make} \
234 $jobs \
235 ETC_GITCONFIG=$prefix/etc/gitconfig \
236 ${OK_TO_USE_CFLAGS+"CFLAGS=$CFLAGS"} \
237 ${tests:+"T=$tests"} \
238 "$@"
239 status=$?
240 rm -f version
241 exit $status