Fix too-often retry bug after 4xx with more hosts than hosts_max_retry.
[exim.git] / src / scripts / Configure-Makefile
CommitLineData
61ec970d 1#! /bin/sh
76ea0716 2# $Cambridge: exim/src/scripts/Configure-Makefile,v 1.2 2005/09/19 14:42:31 ph10 Exp $
61ec970d
PH
3
4# Shell script to build Makefile in a build directory. It must be called
5# from inside the directory. It does its own checking of when to rebuild; it
6# just got too horrendous to get it right in "make", because of the optionally
7# existing configuration files.
8
9
10# First off, get the OS type, and check that there is a make file for it.
11
12ostype=`../scripts/os-type -generic` || exit 1
13
14if [ ! -r ../OS/Makefile-$ostype ] ; then
15 echo ""
16 echo "*** Sorry - operating system $ostype is not supported"
17 echo "*** See OS/Makefile-* for supported systems" 1>&2
18 echo ""
19 exit 1
20fi
21
22# We also need the architecture type, in order to test for any architecture-
23# specific configuration files.
24
25archtype=`../scripts/arch-type` || exit 1
26
27# Now test for either the non-existence of Makefile, or for any of its
28# components being newer. Note that the "newer" script gives the right
29# answer (for our purposes) when the first file is non-existent.
30
31editme=../Local/Makefile
32rebuild=yes
33
34if [ -f Makefile ] ; then
35 rebuild=no
36 if ../scripts/newer $editme Makefile || \
37 ../scripts/newer $editme-$ostype Makefile || \
38 ../scripts/newer $editme-$archtype Makefile || \
39 ../scripts/newer $editme-$ostype-$archtype Makefile || \
40 ../scripts/newer ../scripts/Configure-Makefile Makefile || \
41 ../scripts/newer ../OS/Makefile-Base Makefile || \
42 ../scripts/newer ../OS/Makefile-Default Makefile
43 then
44 rebuild=yes
45 fi
46fi
47
48# If the "build" variable is set it means that a build name was explicitly
49# given. Arrange to pick up a build-specific configuration file.
50
51if [ "X$build" != "X" ] ; then
52 mfb=Local/Makefile-$build
53 if ../scripts/newer $editme-$build Makefile ; then
54 rebuild=yes
55 fi
56else
57 mfb=
58fi
59
60
61# If Makefile is up-to-date, no need to rebuild it.
62
63if [ $rebuild = no ] ; then
64 echo "\`Makefile' is up to date."
65 echo " "
66 exit
67fi
68
69# Makefile needs to be rebuilt in the current directory by joining
70# the generic default makefile, the OS base makefile, and then local
71# generic, OS-specific, architecture-specific, and OS+architecture-specific
72# makefiles, if they exist. These files all contain macro definitions, with
73# later definitions overriding earlier ones. Make a temporary file first, in
74# case things go wrong. A second temporary is needed for sorting out the
75# default Perl stuff. Use short macro names to save typing.
76
77mf=Makefile
78mft=$mf-t
79mftt=$mf-tt
80
81# Ensure the temporary does not exist and start the new one by setting
82# the OSTYPE and ARCHTYPE variables.
83
84rm -f $mft $mftt
85(echo "OSTYPE=$ostype"; echo "ARCHTYPE=$archtype"; echo "") > $mft || exit 1
86
87# Now concatenate the files to the temporary file. Copy the files using sed to
88# remove comments, blank lines, and trailing white space.
89
90# BEWARE: a tab character is needed in the sed command below. It has had
91# a nasty tendency to get lost in the past, causing a problem if a tab has
92# actually been present in one of the files. Use a variable to hold a space
93# and a tab to keep the tab in one place.
94
95st=' '
96
97for f in OS/Makefile-Default \
98 OS/Makefile-$ostype \
99 Local/Makefile \
100 Local/Makefile-$ostype \
101 Local/Makefile-$archtype \
102 Local/Makefile-$ostype-$archtype \
103 $mfb
104do if test -r ../$f
105 then echo "# From $f"
106 sed "/^#/d;/^[$st]*\$/d;s/[$st]*\$//" ../$f || exit 1
107 echo "# End of $f"
108 echo ""
109 fi
110done >> $mft || exit 1
111
112# See if there is a definition of EXIM_PERL in what we have built so far.
113# If so, run Perl to find the default values for PERL_CC, PERL_CCOPTS,
114# and PERL_LIBS. These need to be put at the top of the Makefile, so we rename
115# what we have so far and then copy it afterwards. Use the value of PERL_COMMAND
116# if it has been defined.
117
118EXIM_PERL=`grep EXIM_PERL $mft`
119
120PERL_COMMAND=`grep PERL_COMMAND $mft | sed -e "\\$!d;s/^[$st]*PERL_COMMAND[$st]*=[$st]*//"`
121if [ "${PERL_COMMAND}" = "" ] ; then
122 PERL_COMMAND='perl'
123fi
124
125if [ "${EXIM_PERL}" != "" ] ; then
126 testperl=`$PERL_COMMAND --version`
127 if [ "$testperl" = "" ] ; then
128 echo "*** EXIM_PERL is set, but '$PERL_COMMAND --version' failed"
129 exit 1
130 fi
131
132 mv $mft $mftt
133 echo "PERL_CC=`$PERL_COMMAND -MConfig -e 'print $Config{cc}'`" >>$mft
134 echo "PERL_CCOPTS=`$PERL_COMMAND -MExtUtils::Embed -e ccopts`" >>$mft
135 echo "PERL_LIBS=`$PERL_COMMAND -MExtUtils::Embed -e ldopts`" >>$mft
136 echo "" >>$mft
137 cat $mftt >> $mft
138 rm -f $mftt
139fi
140
141# Record the build variable in the Makefile.
142
143echo "build=$build" >>$mft
144echo "" >>$mft
145
146# Finally, join on the generic base make file, which contains the actual
147# rules and stuff.
148
76ea0716 149echo "# From ../OS/Makefile-Base" >> $mft
61ec970d
PH
150cat ../OS/Makefile-Base >> $mft || exit 1
151
152# If the new makefile is the same as the existing one, say so, and just
153# update the timestamp. Otherwise remove the old and install the new.
154
155if [ -s $mf ] && cmp -s $mft $mf
156then echo ">>> rebuilt $mf unchanged"
157 echo " "
158 touch $mf || exit
159 rm -f $mft
160elif rm -f $mf
161 mv $mft $mf
162then echo ">>> New $mf installed"
163 echo '>>> Use "make makefile" if you need to force rebuilding of the makefile'
164 echo " "
165else echo " "
166 echo "*** Failed to install $mf - see $mft"
167 echo " "
168 exit 1;
169fi
170
171# End of Configure-Makefile