Tweak for OBSD and SunOS
[git/dscho.git] / Make
blob3e0c515440028488a521680ea25b175d7f046a19
1 #!/bin/sh
3 case "$(git version 2>/dev/null)" in
4 "git version"*)
5 GIT=git ;;
6 *)
7 echo >&2 "No git to bootstrap"
8 exit 1 ;;
9 esac
11 inst_prefix=$(
12 IFS=:
13 for p in $PATH
15 probed=${p%/git-active/bin}
16 if test "$probed" != "$p"
17 then
18 echo "$probed"
19 exit
21 done
22 echo $HOME
25 LANG=C
26 old_style_def_fix=b79d18c92d9f4841a6a1a29b7b2373a8ff9871e1
28 : ${O=-O2}
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 Wall='-Wall -Wdeclaration-after-statement' tests= jobs=
57 case `uname` in
58 OpenBSD)
59 NEEDS_CRYPTO_WITH_SSL=YesPlease ; export NEEDS_CRYPTO_WITH_SSL
60 GIT_SKIP_TESTS="t9200 t9502 $GIT_SKIP_TESTS"; export GIT_SKIP_TESTS
61 NO_PEDANTIC=CannotDo Wall=
63 FreeBSD)
64 OLD_ICONV=YesPlease; export OLD_ICONV
66 SunOS)
67 NEEDS_CRYPTO_WITH_SSL=YesPlease ; export NEEDS_CRYPTO_WITH_SSL
68 GIT_SKIP_TESTS="$GIT_SKIP_TESTS"; export GIT_SKIP_TESTS
69 NO_PEDANTIC=CannotDo Wall=
71 esac
73 while case $# in 0) break ;; esac
74 do
75 case "$1" in
76 -pedantic | --pedantic)
77 o= &&
78 rev=$($GIT rev-parse HEAD) &&
79 case "$($GIT merge-base "$old_style_def_fix" "$rev")" in
80 $old_style_def_fix)
81 o=-Wold-style-definition ;;
82 esac
83 case "$NO_PEDANTIC" in
84 ?*) ;;
85 '')
86 O="$O -Werror $o -std=c99 -Wno-pointer-to-int-cast" ;;
87 esac
88 # -Wvla
89 # O="$O -fwrapv -fno-strict-overflow"
91 -j*)
92 jobs=$1
94 -loose | --loose)
95 Wall=
97 --locale=*)
98 LANG=${1#*=}
100 --test=*)
101 tests=$(
102 cd t &&
103 for t in ${1#*=}
105 eval echo "t$t-*.sh"
106 done | tr '\012' ' '
110 shift
111 break
114 echo >&2 "Eh $1?"
115 exit 1
118 break
120 esac
121 shift
122 done
124 LC_ALL=$LANG
125 export LANG LC_ALL
127 head=`$GIT symbolic-ref HEAD 2>/dev/null` &&
128 branch=`expr "$head" : 'refs/heads/\(.*\)'` || branch=detached
130 case "$branch" in
131 next | maint | master | pu | jch)
132 prefix="$inst_prefix/git-$branch"
134 snap)
135 v=`$GIT describe HEAD`
136 expr "$v" : '.*-g[0-9a-f]*$' >/dev/null && {
137 echo >&2 "You are on 'snap' but $v is not an official version."
138 exit 1
140 prefix="$inst_prefix/git-snap-$v"
143 prefix="$inst_prefix/git-test" ;;
144 esac
145 d="prefix=$prefix"
147 sh -c 'git describe --abbrev=4 HEAD' >/dev/null 2>&1 || {
148 $GIT describe --abbrev=4 HEAD | sed -e 's/-/./g' >version
151 d="$d "'
152 MAN_BASE_URL="http://www.kernel.org/pub/software/scm/git/docs/"
153 ASCIIDOC_NO_ROFF=YesPlease
154 ASCIIDOC8=YesPlease
155 BLK_SHA1=YesPlease
156 GNU_ROFF=YesPlease'
158 # Platform hack
159 if test -z "${make:+set}" && {
160 test -x /usr/local/bin/gmake ||
161 test -x /usr/bin/gmake
163 then
164 make=gmake
166 if test -f /bin/ginstall
167 then
168 set INSTALL=ginstall "$@"
171 CFLAGS="$O $Wall -g"
172 OK_TO_USE_CFLAGS=Yes
173 if test -n "${NO_CFLAGS+set}"
174 then
175 unset OK_TO_USE_CFLAGS
178 ${make-make} $d \
179 ETC_GITCONFIG=$prefix/etc/gitconfig \
180 ${OK_TO_USE_CFLAGS+"CFLAGS=$CFLAGS"} \
181 ${tests:+"T=$tests"} \
182 $jobs \
183 "$@"
184 status=$?
185 rm -f version
186 exit $status