smtp: use the upload buffer size for scratch buffer malloc
[platform/upstream/curl.git] / buildconf
1 #!/bin/sh
2 #***************************************************************************
3 #                                  _   _ ____  _
4 #  Project                     ___| | | |  _ \| |
5 #                             / __| | | | |_) | |
6 #                            | (__| |_| |  _ <| |___
7 #                             \___|\___/|_| \_\_____|
8 #
9 # Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
10 #
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at https://curl.haxx.se/docs/copyright.html.
14 #
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
18 #
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
21 #
22 ###########################################################################
23
24 #--------------------------------------------------------------------------
25 # die prints argument string to stdout and exits this shell script.
26 #
27 die(){
28   echo "buildconf: $@"
29   exit 1
30 }
31
32 #--------------------------------------------------------------------------
33 # findtool works as 'which' but we use a different name to make it more
34 # obvious we aren't using 'which'! ;-)
35 # Unlike 'which' does, the current directory is ignored.
36 #
37 findtool(){
38   file="$1"
39
40   if { echo "$file" | grep "/" >/dev/null 2>&1; } then
41     # when file is given with a path check it first
42     if test -f "$file"; then
43       echo "$file"
44       return
45     fi
46   fi
47
48   old_IFS=$IFS; IFS=':'
49   for path in $PATH
50   do
51     IFS=$old_IFS
52     # echo "checks for $file in $path" >&2
53     if test "$path" -a "$path" != '.' -a -f "$path/$file"; then
54       echo "$path/$file"
55       return
56     fi
57   done
58   IFS=$old_IFS
59 }
60
61 #--------------------------------------------------------------------------
62 # removethis() removes all files and subdirectories with the given name,
63 # inside and below the current subdirectory at invocation time.
64 #
65 removethis(){
66   if test "$#" = "1"; then
67     find . -depth -name $1 -print > buildconf.tmp.$$
68     while read fdname
69     do
70       if test -f "$fdname"; then
71         rm -f "$fdname"
72       elif test -d "$fdname"; then
73         rm -f -r "$fdname"
74       fi
75     done < buildconf.tmp.$$
76     rm -f buildconf.tmp.$$
77   fi
78 }
79
80 #--------------------------------------------------------------------------
81 # Ensure that buildconf runs from the subdirectory where configure.ac lives
82 #
83 if test ! -f configure.ac ||
84   test ! -f src/tool_main.c ||
85   test ! -f lib/urldata.h ||
86   test ! -f include/curl/curl.h ||
87   test ! -f m4/curl-functions.m4; then
88   echo "Can not run buildconf from outside of curl's source subdirectory!"
89   echo "Change to the subdirectory where buildconf is found, and try again."
90   exit 1
91 fi
92
93 #--------------------------------------------------------------------------
94 # autoconf 2.57 or newer. Unpatched version 2.67 does not generate proper
95 # configure script. Unpatched version 2.68 is simply unusable, we should
96 # disallow 2.68 usage.
97 #
98 need_autoconf="2.57"
99 ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
100 if test -z "$ac_version"; then
101   echo "buildconf: autoconf not found."
102   echo "            You need autoconf version $need_autoconf or newer installed."
103   exit 1
104 fi
105 old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS
106 if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
107   echo "buildconf: autoconf version $ac_version found."
108   echo "            You need autoconf version $need_autoconf or newer installed."
109   echo "            If you have a sufficient autoconf installed, but it"
110   echo "            is not named 'autoconf', then try setting the"
111   echo "            AUTOCONF environment variable."
112   exit 1
113 fi
114
115 if test "$1" = "2" -a "$2" -eq "67"; then
116   echo "buildconf: autoconf version $ac_version (BAD)"
117   echo "            Unpatched version generates broken configure script."
118 elif test "$1" = "2" -a "$2" -eq "68"; then
119   echo "buildconf: autoconf version $ac_version (BAD)"
120   echo "            Unpatched version generates unusable configure script."
121 else
122   echo "buildconf: autoconf version $ac_version (ok)"
123 fi
124
125 am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
126 if test -z "$am4te_version"; then
127   echo "buildconf: autom4te not found. Weird autoconf installation!"
128   exit 1
129 fi
130 if test "$am4te_version" = "$ac_version"; then
131   echo "buildconf: autom4te version $am4te_version (ok)"
132 else
133   echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)"
134   exit 1
135 fi
136
137 #--------------------------------------------------------------------------
138 # autoheader 2.50 or newer
139 #
140 ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
141 if test -z "$ah_version"; then
142   echo "buildconf: autoheader not found."
143   echo "            You need autoheader version 2.50 or newer installed."
144   exit 1
145 fi
146 old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS
147 if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
148   echo "buildconf: autoheader version $ah_version found."
149   echo "            You need autoheader version 2.50 or newer installed."
150   echo "            If you have a sufficient autoheader installed, but it"
151   echo "            is not named 'autoheader', then try setting the"
152   echo "            AUTOHEADER environment variable."
153   exit 1
154 fi
155
156 echo "buildconf: autoheader version $ah_version (ok)"
157
158 #--------------------------------------------------------------------------
159 # automake 1.7 or newer
160 #
161 need_automake="1.7"
162 am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
163 if test -z "$am_version"; then
164   echo "buildconf: automake not found."
165   echo "            You need automake version $need_automake or newer installed."
166   exit 1
167 fi
168 old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS
169 if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
170   echo "buildconf: automake version $am_version found."
171   echo "            You need automake version $need_automake or newer installed."
172   echo "            If you have a sufficient automake installed, but it"
173   echo "            is not named 'automake', then try setting the"
174   echo "            AUTOMAKE environment variable."
175   exit 1
176 fi
177
178 echo "buildconf: automake version $am_version (ok)"
179
180 acloc_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
181 if test -z "$acloc_version"; then
182   echo "buildconf: aclocal not found. Weird automake installation!"
183   exit 1
184 fi
185 if test "$acloc_version" = "$am_version"; then
186   echo "buildconf: aclocal version $acloc_version (ok)"
187 else
188   echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)"
189   exit 1
190 fi
191
192 #--------------------------------------------------------------------------
193 # GNU libtoolize preliminary check
194 #
195 want_lt_major=1
196 want_lt_minor=4
197 want_lt_patch=2
198 want_lt_version=1.4.2
199
200 # This approach that tries 'glibtoolize' first is intended for systems that
201 # have GNU libtool named as 'glibtoolize' and libtoolize not being GNU's.
202
203 libtoolize=`findtool glibtoolize 2>/dev/null`
204 if test ! -x "$libtoolize"; then
205   libtoolize=`findtool ${LIBTOOLIZE:-libtoolize}`
206 fi
207 if test -z "$libtoolize"; then
208   echo "buildconf: libtoolize not found."
209   echo "  You need GNU libtoolize $want_lt_version or newer installed."
210   exit 1
211 fi
212
213 lt_pver=`$libtoolize --version 2>/dev/null|head -n 1`
214 lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
215 lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
216 if test -z "$lt_version"; then
217   echo "buildconf: libtoolize not found."
218   echo "  You need GNU libtoolize $want_lt_version or newer installed."
219   exit 1
220 fi
221 old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
222 lt_major=$1
223 lt_minor=$2
224 lt_patch=$3
225
226 if test -z "$lt_major"; then
227   lt_status="bad"
228 elif test "$lt_major" -gt "$want_lt_major"; then
229   lt_status="good"
230 elif test "$lt_major" -lt "$want_lt_major"; then
231   lt_status="bad"
232 elif test -z "$lt_minor"; then
233   lt_status="bad"
234 elif test "$lt_minor" -gt "$want_lt_minor"; then
235   lt_status="good"
236 elif test "$lt_minor" -lt "$want_lt_minor"; then
237   lt_status="bad"
238 elif test -z "$lt_patch"; then
239   lt_status="bad"
240 elif test "$lt_patch" -gt "$want_lt_patch"; then
241   lt_status="good"
242 elif test "$lt_patch" -lt "$want_lt_patch"; then
243   lt_status="bad"
244 else
245   lt_status="good"
246 fi
247 if test "$lt_status" != "good"; then
248   echo "buildconf: libtoolize version $lt_version found."
249   echo "  You need GNU libtoolize $want_lt_version or newer installed."
250   exit 1
251 fi
252
253 echo "buildconf: libtoolize version $lt_version (ok)"
254
255 #--------------------------------------------------------------------------
256 # m4 check
257 #
258 m4=`(${M4:-m4} --version 0<&- || ${M4:-gm4} --version) 2>/dev/null 0<&- | head -n 1`;
259 m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
260
261 if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
262   echo "buildconf: GNU m4 version $m4_version (ok)"
263 else
264   if test -z "$m4"; then
265     echo "buildconf: m4 version not recognized. You need a GNU m4 installed!"
266   else
267     echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
268   fi
269   exit 1
270 fi
271
272 #--------------------------------------------------------------------------
273 # perl check
274 #
275 PERL=`findtool ${PERL:-perl}`
276 if test -z "$PERL"; then
277   echo "buildconf: perl not found"
278   exit 1
279 fi
280
281 #--------------------------------------------------------------------------
282 # Remove files generated on previous buildconf/configure run.
283 #
284 for fname in .deps \
285     .libs \
286     *.la \
287     *.lo \
288     *.a \
289     *.o \
290     Makefile \
291     Makefile.in \
292     aclocal.m4 \
293     aclocal.m4.bak \
294     ares_build.h \
295     ares_config.h \
296     ares_config.h.in \
297     autom4te.cache \
298     compile \
299     config.guess \
300     curl_config.h \
301     curl_config.h.in \
302     config.log \
303     config.lt \
304     config.status \
305     config.sub \
306     configure \
307     configurehelp.pm \
308     curl-config \
309     depcomp \
310     libcares.pc \
311     libcurl.pc \
312     libtool \
313     libtool.m4 \
314     libtool.m4.tmp \
315     ltmain.sh \
316     ltoptions.m4 \
317     ltsugar.m4 \
318     ltversion.m4 \
319     lt~obsolete.m4 \
320     missing \
321     install-sh \
322     stamp-h1 \
323     stamp-h2 \
324     stamp-h3 ; do
325   removethis "$fname"
326 done
327
328 #--------------------------------------------------------------------------
329 # run the correct scripts now
330 #
331
332 echo "buildconf: running libtoolize"
333 ${libtoolize} --copy --force || die "libtoolize command failed"
334
335 # When using libtool 1.5.X (X < 26) we copy libtool.m4 to our local m4
336 # subdirectory and this local copy is patched to fix some warnings that
337 # are triggered when running aclocal and using autoconf 2.62 or later.
338
339 if test "$lt_major" = "1" && test "$lt_minor" = "5"; then
340   if test -z "$lt_patch" || test "$lt_patch" -lt "26"; then
341     echo "buildconf: copying libtool.m4 to local m4 subdir"
342     ac_dir=`${ACLOCAL:-aclocal} --print-ac-dir`
343     if test -f $ac_dir/libtool.m4; then
344       cp -f $ac_dir/libtool.m4 m4/libtool.m4
345     else
346       echo "buildconf: $ac_dir/libtool.m4 not found"
347     fi
348     if test -f m4/libtool.m4; then
349       echo "buildconf: renaming some variables in local m4/libtool.m4"
350       $PERL -i.tmp -pe \
351         's/lt_prog_compiler_pic_works/lt_cv_prog_compiler_pic_works/g; \
352          s/lt_prog_compiler_static_works/lt_cv_prog_compiler_static_works/g;' \
353         m4/libtool.m4
354       rm -f m4/libtool.m4.tmp
355     fi
356   fi
357 fi
358
359 if test -f m4/libtool.m4; then
360   echo "buildconf: converting all mv to mv -f in local m4/libtool.m4"
361   $PERL -i.tmp -pe 's/\bmv +([^-\s])/mv -f $1/g' m4/libtool.m4
362   rm -f m4/libtool.m4.tmp
363 fi
364
365 echo "buildconf: running aclocal"
366 ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "aclocal command failed"
367
368 echo "buildconf: converting all mv to mv -f in local aclocal.m4"
369 $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
370
371 echo "buildconf: running autoheader"
372 ${AUTOHEADER:-autoheader} || die "autoheader command failed"
373
374 echo "buildconf: running autoconf"
375 ${AUTOCONF:-autoconf} || die "autoconf command failed"
376
377 if test -d ares; then
378   cd ares
379   echo "buildconf: running in ares"
380   ./buildconf
381   cd ..
382 fi
383
384 echo "buildconf: running automake"
385 ${AUTOMAKE:-automake} --add-missing --copy || die "automake command failed"
386
387 #--------------------------------------------------------------------------
388 # GNU libtool complementary check
389 #
390 # Depending on the libtool and automake versions being used, config.guess
391 # might not be installed in the subdirectory until automake has finished.
392 # So we can not attempt to use it until this very last buildconf stage.
393 #
394 if test ! -f ./config.guess; then
395   echo "buildconf: config.guess not found"
396 else
397   buildhost=`./config.guess 2>/dev/null|head -n 1`
398   case $buildhost in
399     *-*-darwin*)
400       need_lt_major=1
401       need_lt_minor=5
402       need_lt_patch=26
403       need_lt_check="yes"
404       ;;
405     *-*-hpux*)
406       need_lt_major=1
407       need_lt_minor=5
408       need_lt_patch=24
409       need_lt_check="yes"
410       ;;
411   esac
412   if test ! -z "$need_lt_check"; then
413     if test -z "$lt_major"; then
414       lt_status="bad"
415     elif test "$lt_major" -gt "$need_lt_major"; then
416       lt_status="good"
417     elif test "$lt_major" -lt "$need_lt_major"; then
418       lt_status="bad"
419     elif test -z "$lt_minor"; then
420       lt_status="bad"
421     elif test "$lt_minor" -gt "$need_lt_minor"; then
422       lt_status="good"
423     elif test "$lt_minor" -lt "$need_lt_minor"; then
424       lt_status="bad"
425     elif test -z "$lt_patch"; then
426       lt_status="bad"
427     elif test "$lt_patch" -gt "$need_lt_patch"; then
428       lt_status="good"
429     elif test "$lt_patch" -lt "$need_lt_patch"; then
430       lt_status="bad"
431     else
432       lt_status="good"
433     fi
434     if test "$lt_status" != "good"; then
435       need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
436       echo "buildconf: libtool version $lt_version found."
437       echo "            $buildhost requires GNU libtool $need_lt_version or newer installed."
438       rm -f configure
439       exit 1
440     fi
441   fi
442 fi
443
444 #--------------------------------------------------------------------------
445 # Finished successfully.
446 #
447 echo "buildconf: OK"
448 exit 0