Fix section detection in cook.sh
[git] / Make
1 #!/bin/sh
2
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
10
11 inst_prefix=$(
12         IFS=:
13         for p in $PATH
14         do
15                 probed=${p%/git-active/bin}
16                 if test "$probed" != "$p"
17                 then
18                         echo "$probed"
19                         exit
20                 fi
21         done
22         echo $HOME
23 )
24
25 LANG=C
26 old_style_def_fix=b79d18c92d9f4841a6a1a29b7b2373a8ff9871e1
27
28 : ${O=-O2}
29 Wall='-Wall -Wdeclaration-after-statement' tests=
30 while case $# in 0) break ;; esac
31 do 
32         case "$1" in
33         -pedantic | --pedantic)
34                 o= &&
35                 rev=$($GIT rev-parse HEAD) &&
36                 case "$($GIT merge-base "$old_style_def_fix" "$rev")" in
37                 $old_style_def_fix)
38                         o=-Wold-style-definition ;;
39                 esac
40                 O="$O -Werror $o -std=c99 -Wno-pointer-to-int-cast"
41                 # O="$O -fwrapv -fno-strict-overflow"
42                 ;;
43         -loose | --loose)
44                 Wall=
45                 ;;
46         --locale=*)
47                 LANG=${1#*=}
48                 ;;
49         --test=*)
50                 tests=$(
51                         cd t &&
52                         for t in ${1#*=}
53                         do
54                                 eval echo "t$t-*.sh"
55                         done | tr '\012' ' '
56                 )
57                 ;;
58         --)
59                 shift
60                 break
61                 ;;
62         -*)
63                 echo >&2 "Eh $1?"
64                 exit 1
65                 ;;
66         *)
67                 break
68                 ;;              
69         esac
70         shift
71 done
72
73 LC_ALL=$LANG
74 export LANG LC_ALL
75
76 head=`$GIT symbolic-ref HEAD 2>/dev/null` &&
77 branch=`expr "$head" : 'refs/heads/\(.*\)'` || branch=detached
78
79 case "$branch" in
80 next | maint | master | pu | jch)
81         prefix="$inst_prefix/git-$branch"
82         ;;
83 snap)
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
88         }
89         prefix="$inst_prefix/git-snap-$v"
90         ;;
91 *)
92         prefix="$inst_prefix/git-test" ;;
93 esac
94 d="prefix=$prefix"
95
96 sh -c 'git describe --abbrev=4 HEAD' >/dev/null 2>&1 || {
97         $GIT describe --abbrev=4 HEAD | sed -e 's/-/./g' >version
98 }
99
100 d="$d ASCIIDOC_NO_ROFF=YesPlease ASCIIDOC8=YesPlease"
101
102 # Platform hack
103 if test -z "${make:+set}" && {
104         test -x /usr/local/bin/gmake ||
105         test -x /usr/bin/gmake
106 }
107 then
108         make=gmake
109 fi
110 if test -f /bin/ginstall
111 then
112         set INSTALL=ginstall "$@"
113 fi
114
115 CFLAGS="$O $Wall -g"
116 OK_TO_USE_CFLAGS=Yes
117 if test -n "${NO_CFLAGS+set}"
118 then
119         unset OK_TO_USE_CFLAGS
120 fi
121
122 ${make-make} $d \
123      ETC_GITCONFIG=$prefix/etc/gitconfig \
124      ${OK_TO_USE_CFLAGS+"CFLAGS=$CFLAGS"} \
125      ${tests:+"T=$tests"} \
126      "$@"
127 status=$?
128 rm -f version
129 exit $status