[CVE-2018-17942] libunistring security patch
[platform/upstream/libunistring.git] / autogen.sh
1 #!/bin/sh
2 # Convenience script for regenerating all autogeneratable files that are
3 # omitted from the version control repository. In particular, this script
4 # also regenerates all aclocal.m4, config.h.in, Makefile.in, configure files
5 # with new versions of autoconf or automake.
6 #
7 # This script requires autoconf-2.63..2.69 and automake-1.11..1.16 in the PATH.
8 # It also requires either
9 #   - the GNULIB_TOOL environment variable pointing to the gnulib-tool script
10 #     in a gnulib checkout, or
11 #   - the git program in the PATH and an internet connection.
12 # It also requires
13 #   - the gperf program.
14
15 # Copyright (C) 2003-2018 Free Software Foundation, Inc.
16 #
17 # This program is free software: you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 3 of the License, or
20 # (at your option) any later version.
21 #
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 #
27 # You should have received a copy of the GNU General Public License
28 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
29
30 # Usage: ./autogen.sh [--skip-gnulib]
31 #
32 # Usage from a git checkout:                 ./autogen.sh
33 # This uses an up-to-date gnulib checkout.
34 #
35 # Usage from a released tarball:             ./autogen.sh --skip-gnulib
36 # This does not use a gnulib checkout.
37
38 skip_gnulib=false
39 while :; do
40   case "$1" in
41     --skip-gnulib) skip_gnulib=true; shift;;
42     *) break ;;
43   esac
44 done
45
46 TEXINFO_VERSION=4.13
47
48 if test $skip_gnulib = false; then
49   # texinfo.tex
50   # The most recent snapshot of it is available in the gnulib repository.
51   # But this is a snapshot, with all possible dangers.
52   # A stable release of it is available through "automake --add-missing --copy",
53   # but that is too old (does not support @arrow{}). So take the version which
54   # matches the latest stable texinfo release.
55   if test ! -f build-aux/texinfo.tex; then
56     { wget -q --timeout=5 -O build-aux/texinfo.tex.tmp 'http://cvs.savannah.gnu.org/viewvc/*checkout*/texinfo/doc/texinfo.tex?root=texinfo&pathrev=texinfo_'`echo $TEXINFO_VERSION | sed -e 's/[.]/_/g'` \
57         && mv build-aux/texinfo.tex.tmp build-aux/texinfo.tex; \
58     } || rm -f build-aux/texinfo.tex.tmp
59   fi
60   if test -z "$GNULIB_TOOL"; then
61     # Check out gnulib in a subdirectory 'gnulib'.
62     if test -d gnulib; then
63       (cd gnulib && git pull)
64     else
65       git clone git://git.savannah.gnu.org/gnulib.git
66     fi
67     # Now it should contain a gnulib-tool.
68     if test -f gnulib/gnulib-tool; then
69       GNULIB_TOOL=`pwd`/gnulib/gnulib-tool
70     else
71       echo "** warning: gnulib-tool not found" 1>&2
72     fi
73   fi
74   # Skip the gnulib-tool step if gnulib-tool was not found.
75   if test -n "$GNULIB_TOOL"; then
76     GNULIB_MODULES='
77       unitypes
78       unistr/base
79       unistr/u8-check
80       unistr/u8-chr
81       unistr/u8-cmp
82       unistr/u8-cmp2
83       unistr/u8-cpy
84       unistr/u8-cpy-alloc
85       unistr/u8-endswith
86       unistr/u8-mblen
87       unistr/u8-mbsnlen
88       unistr/u8-mbtouc
89       unistr/u8-mbtoucr
90       unistr/u8-mbtouc-unsafe
91       unistr/u8-move
92       unistr/u8-next
93       unistr/u8-prev
94       unistr/u8-set
95       unistr/u8-startswith
96       unistr/u8-stpcpy
97       unistr/u8-stpncpy
98       unistr/u8-strcat
99       unistr/u8-strchr
100       unistr/u8-strcmp
101       unistr/u8-strcoll
102       unistr/u8-strcpy
103       unistr/u8-strcspn
104       unistr/u8-strdup
105       unistr/u8-strlen
106       unistr/u8-strmblen
107       unistr/u8-strmbtouc
108       unistr/u8-strncat
109       unistr/u8-strncmp
110       unistr/u8-strncpy
111       unistr/u8-strnlen
112       unistr/u8-strpbrk
113       unistr/u8-strrchr
114       unistr/u8-strspn
115       unistr/u8-strstr
116       unistr/u8-strtok
117       unistr/u8-to-u16
118       unistr/u8-to-u32
119       unistr/u8-uctomb
120       unistr/u16-check
121       unistr/u16-chr
122       unistr/u16-cmp
123       unistr/u16-cmp2
124       unistr/u16-cpy
125       unistr/u16-cpy-alloc
126       unistr/u16-endswith
127       unistr/u16-mblen
128       unistr/u16-mbsnlen
129       unistr/u16-mbtouc
130       unistr/u16-mbtoucr
131       unistr/u16-mbtouc-unsafe
132       unistr/u16-move
133       unistr/u16-next
134       unistr/u16-prev
135       unistr/u16-set
136       unistr/u16-startswith
137       unistr/u16-stpcpy
138       unistr/u16-stpncpy
139       unistr/u16-strcat
140       unistr/u16-strchr
141       unistr/u16-strcmp
142       unistr/u16-strcoll
143       unistr/u16-strcpy
144       unistr/u16-strcspn
145       unistr/u16-strdup
146       unistr/u16-strlen
147       unistr/u16-strmblen
148       unistr/u16-strmbtouc
149       unistr/u16-strncat
150       unistr/u16-strncmp
151       unistr/u16-strncpy
152       unistr/u16-strnlen
153       unistr/u16-strpbrk
154       unistr/u16-strrchr
155       unistr/u16-strspn
156       unistr/u16-strstr
157       unistr/u16-strtok
158       unistr/u16-to-u32
159       unistr/u16-to-u8
160       unistr/u16-uctomb
161       unistr/u32-check
162       unistr/u32-chr
163       unistr/u32-cmp
164       unistr/u32-cmp2
165       unistr/u32-cpy
166       unistr/u32-cpy-alloc
167       unistr/u32-endswith
168       unistr/u32-mblen
169       unistr/u32-mbsnlen
170       unistr/u32-mbtouc
171       unistr/u32-mbtoucr
172       unistr/u32-mbtouc-unsafe
173       unistr/u32-move
174       unistr/u32-next
175       unistr/u32-prev
176       unistr/u32-set
177       unistr/u32-startswith
178       unistr/u32-stpcpy
179       unistr/u32-stpncpy
180       unistr/u32-strcat
181       unistr/u32-strchr
182       unistr/u32-strcmp
183       unistr/u32-strcoll
184       unistr/u32-strcpy
185       unistr/u32-strcspn
186       unistr/u32-strdup
187       unistr/u32-strlen
188       unistr/u32-strmblen
189       unistr/u32-strmbtouc
190       unistr/u32-strncat
191       unistr/u32-strncmp
192       unistr/u32-strncpy
193       unistr/u32-strnlen
194       unistr/u32-strpbrk
195       unistr/u32-strrchr
196       unistr/u32-strspn
197       unistr/u32-strstr
198       unistr/u32-strtok
199       unistr/u32-to-u16
200       unistr/u32-to-u8
201       unistr/u32-uctomb
202       uniconv/base
203       uniconv/u8-conv-from-enc
204       uniconv/u8-conv-to-enc
205       uniconv/u8-strconv-from-enc
206       uniconv/u8-strconv-from-locale
207       uniconv/u8-strconv-to-enc
208       uniconv/u8-strconv-to-locale
209       uniconv/u16-conv-from-enc
210       uniconv/u16-conv-to-enc
211       uniconv/u16-strconv-from-enc
212       uniconv/u16-strconv-from-locale
213       uniconv/u16-strconv-to-enc
214       uniconv/u16-strconv-to-locale
215       uniconv/u32-conv-from-enc
216       uniconv/u32-conv-to-enc
217       uniconv/u32-strconv-from-enc
218       uniconv/u32-strconv-from-locale
219       uniconv/u32-strconv-to-enc
220       uniconv/u32-strconv-to-locale
221       unistdio/base
222       unistdio/u8-asnprintf
223       unistdio/u8-asprintf
224       unistdio/u8-snprintf
225       unistdio/u8-sprintf
226       unistdio/u8-u8-asnprintf
227       unistdio/u8-u8-asprintf
228       unistdio/u8-u8-snprintf
229       unistdio/u8-u8-sprintf
230       unistdio/u8-u8-vasnprintf
231       unistdio/u8-u8-vasprintf
232       unistdio/u8-u8-vsnprintf
233       unistdio/u8-u8-vsprintf
234       unistdio/u8-vasnprintf
235       unistdio/u8-vasprintf
236       unistdio/u8-vsnprintf
237       unistdio/u8-vsprintf
238       unistdio/u16-asnprintf
239       unistdio/u16-asprintf
240       unistdio/u16-snprintf
241       unistdio/u16-sprintf
242       unistdio/u16-u16-asnprintf
243       unistdio/u16-u16-asprintf
244       unistdio/u16-u16-snprintf
245       unistdio/u16-u16-sprintf
246       unistdio/u16-u16-vasnprintf
247       unistdio/u16-u16-vasprintf
248       unistdio/u16-u16-vsnprintf
249       unistdio/u16-u16-vsprintf
250       unistdio/u16-vasnprintf
251       unistdio/u16-vasprintf
252       unistdio/u16-vsnprintf
253       unistdio/u16-vsprintf
254       unistdio/u32-asnprintf
255       unistdio/u32-asprintf
256       unistdio/u32-snprintf
257       unistdio/u32-sprintf
258       unistdio/u32-u32-asnprintf
259       unistdio/u32-u32-asprintf
260       unistdio/u32-u32-snprintf
261       unistdio/u32-u32-sprintf
262       unistdio/u32-u32-vasnprintf
263       unistdio/u32-u32-vasprintf
264       unistdio/u32-u32-vsnprintf
265       unistdio/u32-u32-vsprintf
266       unistdio/u32-vasnprintf
267       unistdio/u32-vasprintf
268       unistdio/u32-vsnprintf
269       unistdio/u32-vsprintf
270       unistdio/ulc-asnprintf
271       unistdio/ulc-asprintf
272       unistdio/ulc-fprintf
273       unistdio/ulc-snprintf
274       unistdio/ulc-sprintf
275       unistdio/ulc-vasnprintf
276       unistdio/ulc-vasprintf
277       unistdio/ulc-vfprintf
278       unistdio/ulc-vsnprintf
279       unistdio/ulc-vsprintf
280       uniname/base
281       uniname/uniname
282       unictype/base
283       unictype/bidiclass-all
284       unictype/block-all
285       unictype/category-all
286       unictype/combining-class-all
287       unictype/ctype-alnum
288       unictype/ctype-alpha
289       unictype/ctype-blank
290       unictype/ctype-cntrl
291       unictype/ctype-digit
292       unictype/ctype-graph
293       unictype/ctype-lower
294       unictype/ctype-print
295       unictype/ctype-punct
296       unictype/ctype-space
297       unictype/ctype-upper
298       unictype/ctype-xdigit
299       unictype/decimal-digit
300       unictype/digit
301       unictype/joininggroup-all
302       unictype/joiningtype-all
303       unictype/mirror
304       unictype/numeric
305       unictype/property-all
306       unictype/scripts-all
307       unictype/syntax-c-ident
308       unictype/syntax-c-whitespace
309       unictype/syntax-java-ident
310       unictype/syntax-java-whitespace
311       uniwidth/base
312       uniwidth/u8-strwidth
313       uniwidth/u8-width
314       uniwidth/u16-strwidth
315       uniwidth/u16-width
316       uniwidth/u32-strwidth
317       uniwidth/u32-width
318       uniwidth/width
319       unigbrk/base
320       unigbrk/u8-grapheme-breaks
321       unigbrk/u8-grapheme-next
322       unigbrk/u8-grapheme-prev
323       unigbrk/u16-grapheme-breaks
324       unigbrk/u16-grapheme-next
325       unigbrk/u16-grapheme-prev
326       unigbrk/u32-grapheme-breaks
327       unigbrk/u32-grapheme-next
328       unigbrk/u32-grapheme-prev
329       unigbrk/uc-gbrk-prop
330       unigbrk/uc-is-grapheme-break
331       unigbrk/ulc-grapheme-breaks
332       unigbrk/uc-grapheme-breaks
333       uniwbrk/base
334       uniwbrk/u8-wordbreaks
335       uniwbrk/u16-wordbreaks
336       uniwbrk/u32-wordbreaks
337       uniwbrk/ulc-wordbreaks
338       uniwbrk/wordbreak-property
339       unilbrk/base
340       unilbrk/u8-possible-linebreaks
341       unilbrk/u8-width-linebreaks
342       unilbrk/u16-possible-linebreaks
343       unilbrk/u16-width-linebreaks
344       unilbrk/u32-possible-linebreaks
345       unilbrk/u32-width-linebreaks
346       unilbrk/ulc-possible-linebreaks
347       unilbrk/ulc-width-linebreaks
348       uninorm/base
349       uninorm/canonical-decomposition
350       uninorm/composition
351       uninorm/decomposition
352       uninorm/filter
353       uninorm/nfc
354       uninorm/nfd
355       uninorm/nfkc
356       uninorm/nfkd
357       uninorm/u8-normalize
358       uninorm/u8-normcmp
359       uninorm/u8-normcoll
360       uninorm/u8-normxfrm
361       uninorm/u16-normalize
362       uninorm/u16-normcmp
363       uninorm/u16-normcoll
364       uninorm/u16-normxfrm
365       uninorm/u32-normalize
366       uninorm/u32-normcmp
367       uninorm/u32-normcoll
368       uninorm/u32-normxfrm
369       unicase/base
370       unicase/empty-prefix-context
371       unicase/empty-suffix-context
372       unicase/locale-language
373       unicase/tolower
374       unicase/totitle
375       unicase/toupper
376       unicase/u8-casecmp
377       unicase/u8-casecoll
378       unicase/u8-casefold
379       unicase/u8-casexfrm
380       unicase/u8-ct-casefold
381       unicase/u8-ct-tolower
382       unicase/u8-ct-totitle
383       unicase/u8-ct-toupper
384       unicase/u8-is-cased
385       unicase/u8-is-casefolded
386       unicase/u8-is-lowercase
387       unicase/u8-is-titlecase
388       unicase/u8-is-uppercase
389       unicase/u8-prefix-context
390       unicase/u8-suffix-context
391       unicase/u8-tolower
392       unicase/u8-totitle
393       unicase/u8-toupper
394       unicase/u16-casecmp
395       unicase/u16-casecoll
396       unicase/u16-casefold
397       unicase/u16-casexfrm
398       unicase/u16-ct-casefold
399       unicase/u16-ct-tolower
400       unicase/u16-ct-totitle
401       unicase/u16-ct-toupper
402       unicase/u16-is-cased
403       unicase/u16-is-casefolded
404       unicase/u16-is-lowercase
405       unicase/u16-is-titlecase
406       unicase/u16-is-uppercase
407       unicase/u16-prefix-context
408       unicase/u16-suffix-context
409       unicase/u16-tolower
410       unicase/u16-totitle
411       unicase/u16-toupper
412       unicase/u32-casecmp
413       unicase/u32-casecoll
414       unicase/u32-casefold
415       unicase/u32-casexfrm
416       unicase/u32-ct-casefold
417       unicase/u32-ct-tolower
418       unicase/u32-ct-totitle
419       unicase/u32-ct-toupper
420       unicase/u32-is-cased
421       unicase/u32-is-casefolded
422       unicase/u32-is-lowercase
423       unicase/u32-is-titlecase
424       unicase/u32-is-uppercase
425       unicase/u32-prefix-context
426       unicase/u32-suffix-context
427       unicase/u32-tolower
428       unicase/u32-totitle
429       unicase/u32-toupper
430       unicase/ulc-casecmp
431       unicase/ulc-casecoll
432       unicase/ulc-casexfrm
433       relocatable-lib-lgpl
434     '
435     $GNULIB_TOOL --lib=libunistring --source-base=lib --m4-base=gnulib-m4 --tests-base=tests \
436       --with-tests --lgpl=3orGPLv2 --makefile-name=Makefile.gnulib --libtool --local-dir=gnulib-local \
437       --import $GNULIB_MODULES
438     # Change lib/unistr.h to be usable standalone.
439     sed -e 's/if GNULIB_[A-Za-z0-9_]* || .*/if 1/g' \
440         -e 's/if GNULIB_[A-Za-z0-9_]*/if 1/g' \
441         -e 's/HAVE_INLINE/UNISTRING_HAVE_INLINE/g' \
442         < lib/unistr.in.h \
443         > lib/unistr.in.h.tmp \
444     && mv lib/unistr.in.h.tmp lib/unistr.in.h
445     # Change lib/unictype.h and lib/uninorm.h for shared libraries on Woe32 systems.
446     sed -e 's/extern const uc_general_category_t UC_/extern LIBUNISTRING_DLL_VARIABLE const uc_general_category_t UC_/' \
447         -e 's/extern const uc_property_t UC_/extern LIBUNISTRING_DLL_VARIABLE const uc_property_t UC_/' \
448         < lib/unictype.in.h \
449         > lib/unictype.in.h.tmp \
450     && mv lib/unictype.in.h.tmp lib/unictype.in.h
451     sed -e 's/extern const struct unicode_normalization_form /extern LIBUNISTRING_DLL_VARIABLE const struct unicode_normalization_form /' \
452         < lib/uninorm.in.h \
453         > lib/uninorm.in.h.tmp \
454     && mv lib/uninorm.in.h.tmp lib/uninorm.in.h
455     sed -e 's/extern const casing_/extern LIBUNISTRING_DLL_VARIABLE const casing_/' \
456         < lib/unicase.in.h \
457         > lib/unicase.in.h.tmp \
458     && mv lib/unicase.in.h.tmp lib/unicase.in.h
459     $GNULIB_TOOL --copy-file build-aux/config.guess; chmod a+x build-aux/config.guess
460     $GNULIB_TOOL --copy-file build-aux/config.sub;   chmod a+x build-aux/config.sub
461     # If we got no texinfo.tex so far, take the snapshot from gnulib.
462     if test ! -f build-aux/texinfo.tex; then
463       $GNULIB_TOOL --copy-file build-aux/texinfo.tex build-aux/texinfo.tex
464     fi
465   fi
466 fi
467
468 build-aux/fixaclocal aclocal -I m4 -I gnulib-m4
469 autoconf
470 autoheader && touch config.h.in
471 # Make sure we get new versions of files brought in by automake.
472 (cd build-aux && rm -f ar-lib compile depcomp install-sh mdate-sh missing test-driver)
473 automake --add-missing --copy
474 # Get rid of autom4te.cache directory.
475 rm -rf autom4te.cache