Restructure Makefiles to accomodate multiple archs
[dragonfly.git] / crypto / heimdal-0.6.3 / tools / build.sh
1 #!/bin/sh
2 #
3 # Build many combinations of kth-krb/heimdal/openssl
4 #
5 # $Id: build.sh,v 1.8 2003/04/17 12:55:02 lha Exp $
6
7 opt_n= #:
8 make_f= #-j
9
10 heimdal_versions="0.5.2 0.6pre4"
11 krb4_versions="1.2.2"
12 openssl_versions="0.9.6i 0.9.7a 0.9.7b"
13
14 make_check_version=".*heimdal-0.6.*"
15
16 # 0.5 dont eat 0.9.7
17 dont_build="openssl-0.9.7.*heimdal-0.5.*"
18 # 1.2 dont eat 0.9.7
19 dont_build="openssl-0.9.7.*krb4-1.2.* ${dont_build}"
20 #yacc problems
21 dont_build="openssl-0.9.6.*heimdal-0.5.*osf4.* ${dont_build}"
22 #local openssl 09.7 and broken kuser/Makefile.am
23 dont_build="openssl-0.9.6.*heimdal-0.5.*freebsd4.8.* ${dont_build}" 
24 failed=
25
26 # Allow override
27 for a in $HOME . /etc ; do 
28     [ -f $a/.heimdal-build ] && . $a/.heimdal-build
29 done
30
31 targetdir=${targetdir:-/scratch/heimdal-test}
32 logfile="${targetdir}/buildlog"
33
34 distdirs="${distdirs} /afs/su.se/home/l/h/lha/Public/openssl"
35 distdirs="${distdirs} /afs/pdc.kth.se/public/ftp/pub/heimdal/src"
36 distdirs="${distdirs} /afs/pdc.kth.se/public/ftp/pub/heimdal/src/snapshots"
37 distdirs="${distdirs} /afs/pdc.kth.se/public/ftp/pub/krb/src"
38
39
40 logprint () {
41     d=`date '+%Y-%m-%d %H:%M:%S'`
42     echo "${d}: $*"
43     echo "${d}: --- $*" >> ${logfile}
44 }
45
46 logerror () {
47     echo "$*"
48     exit 1
49 }
50
51 find_unzip_prog () {
52     unzip_prog=
53     oldIFS="$IFS"
54     IFS=:
55     set -- $PATH
56     IFS="$oldIFS"
57     for a in $* ; do
58         if [ -x $a/gzip ] ; then
59             unzip_prog="$a/gzip -dc"
60             break
61         elif [ -x $a/gunzip ] ; then
62             unzip_prog="$a/gunzip -c"
63             break
64         fi
65     done
66     [ "$unzip_prog" = "" ] && logerror failed to find unzip program
67 }
68
69 find_canon_name () {
70     canon_name=
71     for a in ${distdirs} ; do
72         if [ -f $a/config.guess ] ; then
73             canon_name=`$a/config.guess`
74         fi
75         if [ "${canon_name}" != "" ] ; then
76             break
77         fi
78     done
79     [ "${canon_name}" = "" ] && logerror "cant find config.guess"
80 }
81
82 do_check_p () {
83     eval check_var=\$"$1"
84     for a in ${check_var} ; do
85         expr "$2${canon_name}" : "${a}" > /dev/null 2>&1 && return 1
86     done
87     return 0
88 }
89
90 unpack_tar () {
91     for a in ${distdirs} ; do
92         if [ -f $a/$1 ] ; then
93             ${opt_n} ${unzip_prog} ${a}/$1 | ${opt_n} tar xf -
94             return 0
95         fi
96     done
97     logerror "did not find $1"
98 }
99
100 build () {
101     real_ver=$1
102     prog=$2
103     ver=$3
104     confprog=$4
105     checks=$5
106     pv=${prog}-${ver}
107     mkdir tmp || logerror "failed to build tmpdir"
108     cd tmp || logerror "failed to change dir to tmpdir"
109     do_check_p dont_build ${real_ver} || \
110         { cd .. ; rmdir tmp ; logprint "not building $1" && return 0 ; }
111     cd .. || logerror "failed to change back from tmpdir"
112     rmdir tmp || logerror "failed to remove tmpdir"
113     logprint "preparing for ${pv}"
114     ${opt_n} rm -rf ${targetdir}/${prog}-${ver}
115     ${opt_n} rm -rf ${prog}-${ver}
116     unpack_tar ${pv}.tar.gz
117     ${opt_n} cd ${pv} || logerror directory ${pv} not there
118     logprint "configure ${prog} ${ver} (${confprog})"
119     ${opt_n} ./${confprog} \
120         --prefix=${targetdir}/${pv} >> ${logfile} 2>&1 || \
121             { logprint failed to configure ${pv} ; return 1 ; }
122     logprint "make ${prog} ${ver}"
123     ${opt_n} make ${make_f} >> ${logfile} 2>&1 || \
124         { logprint failed to make ${pv} ; return 1 ; }
125     ${opt_n} make install >> ${logfile} 2>&1 || \
126         { logprint failed to install ${pv} ; return 1 ; }
127     do_check_p make_check_version ${real_ver} || \
128         { ${opt_n} make check >> ${logfile} 2>&1 || return 1 ; }
129     ${opt_n} cd ..
130     [ "${checks}" != "" ] && ${opt_n} ${checks} >> ${logfile} 2>&1
131     return 0
132 }
133
134 find_canon_name
135
136 logprint using host `hostname`
137 logprint `uname -a`
138 logprint canonical name ${canon_name}
139
140 logprint clearing logfile
141 > ${logfile}
142
143 find_unzip_prog
144
145 logprint using target dir ${targetdir}
146 mkdir -p ${targetdir}/src
147 cd ${targetdir}/src || exit 1
148 rm -rf heimdal* openssl* krb4*
149
150 logprint === building openssl versions
151 for vo in ${openssl_versions} ; do
152     build openssl-${vo} openssl $vo config
153 done
154
155 wssl="--with-openssl=${targetdir}/openssl"
156 wssli="--with-openssl-include=${targetdir}/openssl"     #this is a hack for broken heimdal 0.5.x autoconf test
157 wossl="--without-openssl"
158 wk4c="--with-krb4-config=${targetdir}/krb4"
159 bk4c="/bin/krb4-config"
160 wok4="--without-krb4"
161
162 logprint === building heimdal w/o krb4 versions
163 for vo in ${openssl_versions} ; do
164     for vh in ${heimdal_versions} ; do
165         v="openssl-${vo}-heimdal-${vh}"
166         build "${v}" \
167             heimdal ${vh} \
168             "configure ${wok4} ${wssl}-${vo} ${wssli}-${vo}/include" \
169             "${targetdir}/heimdal-${vh}/bin/krb5-config --libs | grep lcrypto" \ || \
170             { failed="${failed} ${v}" ; logprint ${v} failed ; }
171     done
172 done
173
174 logprint === building krb4
175 for vo in ${openssl_versions} ; do
176     for vk in ${krb4_versions} ; do
177         v="openssl-${vo}-krb4-${vk}"
178         build "${v}" \
179             krb4 ${vk} \
180             "configure ${wssl}-${vo}" \
181             "${targetdir}/krb4-${vk}/bin/krb4-config --libs | grep lcrypto"|| \
182             { failed="${failed} ${v}" ; logprint ${v} failed ; }
183     done
184 done
185
186 logprint === building heimdal with krb4 versions
187 for vo in ${openssl_versions} ; do
188     for vk in ${krb4_versions} ; do
189         for vh in ${heimdal_versions} ; do
190             v="openssl-${vo}-krb4-${vk}-heimdal-${vh}"
191             build "${v}" \
192                 heimdal ${vh} \
193                 "configure ${wk4c}-${vk}${bk4c} ${wssl}-${vo} ${wssli}-${vo}/include" \
194                 "${targetdir}/heimdal-${vh}/bin/krb5-config --libs | grep lcrypto && ${targetdir}/heimdal-${vh}/bin/krb5-config --libs | grep krb4" \
195                  || \
196             { failed="${failed} ${v}" ; logprint ${v} failed ; }
197         done
198     done
199 done
200
201 logprint === building heimdal without krb4 and openssl versions
202 for vh in ${heimdal_versions} ; do
203     v="des-heimdal-${vh}"
204     build "${v}" \
205         heimdal ${vh} \
206         "configure ${wok4} ${wossl}" || \
207         { failed="${failed} ${v}" ; logprint ${v} failed ; }
208 done
209
210 logprint all done
211 [ "${failed}" != "" ] && logprint "failed: ${failed}"
212 exit 0