1#!/bin/sh 2# Copyright (C) 2003-2020 Free Software Foundation, Inc. 3# 4# This program is free software: you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation; either version 3 of the License, or 7# (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program. If not, see <https://www.gnu.org/licenses/>. 16 17# This script populates the build infrastructure in the source tree 18# checked-out from VCS. 19# 20# This script requires: 21# - Autoconf 22# - Automake >= 1.13 23# - Wget 24# - XZ Utils 25# If not used from a released tarball, it also requires either 26# - the GNULIB_SRCDIR environment variable pointing to a gnulib checkout, or 27# - a preceding invocation of './gitsub.sh pull'. 28# 29# In addition, it fetches the archive.dir.tar.gz file, which contains 30# data files used by the autopoint program. If you already have the 31# file, place it under gettext-tools/misc, before running this script. 32# 33# Usage: ./autogen.sh [--skip-gnulib] 34 35# Nuisances. 36(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 37 38skip_gnulib=false 39skip_gnulib_option= 40 41while :; do 42 case "$1" in 43 --skip-gnulib) skip_gnulib=true; skip_gnulib_option='--skip-gnulib'; shift;; 44 *) break ;; 45 esac 46done 47 48# The tests in gettext-tools/tests are not meant to be executable, because 49# they have a TESTS_ENVIRONMENT that specifies the shell explicitly. 50 51if ! $skip_gnulib; then 52 if test -n "$GNULIB_SRCDIR"; then 53 test -d "$GNULIB_SRCDIR" || { 54 echo "*** GNULIB_SRCDIR is set but does not point to an existing directory." 1>&2 55 exit 1 56 } 57 else 58 GNULIB_SRCDIR=`pwd`/gnulib 59 test -d "$GNULIB_SRCDIR" || { 60 echo "*** Subdirectory 'gnulib' does not yet exist. Use './gitsub.sh pull' to create it, or set the environment variable GNULIB_SRCDIR." 1>&2 61 exit 1 62 } 63 fi 64 # Now it should contain a gnulib-tool. 65 GNULIB_TOOL="$GNULIB_SRCDIR/gnulib-tool" 66 test -f "$GNULIB_TOOL" || { 67 echo "*** gnulib-tool not found." 1>&2 68 exit 1 69 } 70 # In gettext-runtime: 71 GNULIB_MODULES_RUNTIME_FOR_SRC=' 72 atexit 73 basename-lgpl 74 binary-io 75 closeout 76 error 77 getopt-gnu 78 gettext-h 79 havelib 80 memmove 81 noreturn 82 progname 83 propername 84 relocatable-prog 85 setlocale 86 sigpipe 87 stdbool 88 stdio 89 stdlib 90 strtoul 91 unistd 92 unlocked-io 93 xalloc 94 ' 95 GNULIB_MODULES_RUNTIME_OTHER=' 96 gettext-runtime-misc 97 ansi-c++-opt 98 bison 99 csharpcomp-script 100 java 101 javacomp-script 102 ' 103 $GNULIB_TOOL --dir=gettext-runtime --lib=libgrt --source-base=gnulib-lib --m4-base=gnulib-m4 --no-libtool --local-dir=gnulib-local --local-symlink \ 104 --import $GNULIB_MODULES_RUNTIME_FOR_SRC $GNULIB_MODULES_RUNTIME_OTHER || exit $? 105 $GNULIB_TOOL --copy-file lib/attribute.h gettext-runtime/intl/attribute.h 106 # In gettext-runtime/libasprintf: 107 GNULIB_MODULES_LIBASPRINTF=' 108 alloca 109 attribute 110 errno 111 verify 112 xsize 113 ' 114 GNULIB_MODULES_LIBASPRINTF_OTHER=' 115 ' 116 $GNULIB_TOOL --dir=gettext-runtime/libasprintf --source-base=. --m4-base=gnulib-m4 --lgpl=2 --makefile-name=Makefile.gnulib --libtool --local-dir=gnulib-local --local-symlink \ 117 --import $GNULIB_MODULES_LIBASPRINTF $GNULIB_MODULES_LIBASPRINTF_OTHER || exit $? 118 $GNULIB_TOOL --copy-file m4/intmax_t.m4 gettext-runtime/libasprintf/gnulib-m4/intmax_t.m4 || exit $? 119 $GNULIB_TOOL --copy-file m4/wchar_t.m4 gettext-runtime/libasprintf/gnulib-m4/wchar_t.m4 || exit $? 120 $GNULIB_TOOL --copy-file m4/wint_t.m4 gettext-runtime/libasprintf/gnulib-m4/wint_t.m4 || exit $? 121 # In gettext-tools: 122 GNULIB_MODULES_TOOLS_FOR_SRC=' 123 alloca-opt 124 atexit 125 backupfile 126 basename-lgpl 127 binary-io 128 bison 129 bison-i18n 130 byteswap 131 c-ctype 132 c-strcase 133 c-strcasestr 134 c-strstr 135 clean-temp 136 closedir 137 closeout 138 configmake 139 copy-file 140 csharpcomp 141 csharpexec 142 error 143 error-progname 144 execute 145 filename 146 findprog 147 fnmatch 148 fopen 149 fstrcmp 150 full-write 151 fwriteerror 152 gcd 153 getline 154 getopt-gnu 155 gettext 156 gettext-h 157 iconv 158 javacomp 159 javaexec 160 libunistring-optional 161 libxml 162 localcharset 163 locale 164 localename 165 localtime 166 lock 167 mem-hash-map 168 memchr 169 memmove 170 memset 171 minmax 172 mkdir 173 noreturn 174 obstack 175 open 176 opendir 177 openmp-init 178 pipe-filter-ii 179 progname 180 propername 181 read-file 182 readdir 183 relocatable-prog 184 relocatable-script 185 setlocale 186 sh-filename 187 sh-quote 188 sigpipe 189 sigprocmask 190 spawn-pipe 191 stdbool 192 stdio 193 stdlib 194 stpcpy 195 stpncpy 196 strchrnul 197 strcspn 198 strerror 199 strpbrk 200 strtol 201 strtoul 202 supersede 203 sys_select 204 sys_stat 205 sys_time 206 trim 207 unictype/ctype-space 208 unictype/syntax-java-whitespace 209 unilbrk/ulc-width-linebreaks 210 uniname/uniname 211 unistd 212 unistr/u8-check 213 unistr/u8-mbtouc 214 unistr/u8-mbtoucr 215 unistr/u8-uctomb 216 unistr/u16-mbtouc 217 uniwidth/width 218 unlocked-io 219 unsetenv 220 vasprintf 221 wait-process 222 write 223 xalloc 224 xconcat-filename 225 xerror 226 xmalloca 227 xmemdup0 228 xsetenv 229 xstriconv 230 xstriconveh 231 xvasprintf 232 ' 233 # Common dependencies of GNULIB_MODULES_TOOLS_FOR_SRC and GNULIB_MODULES_TOOLS_FOR_LIBGREP. 234 GNULIB_MODULES_TOOLS_FOR_SRC_COMMON_DEPENDENCIES=' 235 alloca-opt 236 extensions 237 gettext-h 238 include_next 239 locale 240 localcharset 241 malloc-posix 242 mbrtowc 243 mbsinit 244 multiarch 245 setlocale-null 246 snippet/arg-nonnull 247 snippet/c++defs 248 snippet/warn-on-use 249 ssize_t 250 stdbool 251 stddef 252 stdint 253 stdlib 254 streq 255 unistd 256 verify 257 wchar 258 wctype-h 259 windows-mutex 260 windows-once 261 windows-recmutex 262 windows-rwlock 263 ' 264 GNULIB_MODULES_TOOLS_OTHER=' 265 gettext-tools-misc 266 ansi-c++-opt 267 csharpcomp-script 268 csharpexec-script 269 java 270 javacomp-script 271 javaexec-script 272 stdint 273 ' 274 GNULIB_MODULES_TOOLS_LIBUNISTRING_TESTS=' 275 unilbrk/u8-possible-linebreaks-tests 276 unilbrk/ulc-width-linebreaks-tests 277 unistr/u8-mbtouc-tests 278 unistr/u8-mbtouc-unsafe-tests 279 uniwidth/width-tests 280 ' 281 $GNULIB_TOOL --dir=gettext-tools --lib=libgettextlib --source-base=gnulib-lib --m4-base=gnulib-m4 --tests-base=gnulib-tests --makefile-name=Makefile.gnulib --libtool --with-tests --local-dir=gnulib-local --local-symlink \ 282 --import --avoid=fdutimensat-tests --avoid=futimens-tests --avoid=utime-tests --avoid=utimens-tests --avoid=utimensat-tests \ 283 `for m in $GNULIB_MODULES_TOOLS_LIBUNISTRING_TESTS; do echo --avoid=$m; done` $GNULIB_MODULES_TOOLS_FOR_SRC $GNULIB_MODULES_TOOLS_FOR_SRC_COMMON_DEPENDENCIES $GNULIB_MODULES_TOOLS_OTHER || exit $? 284 $GNULIB_TOOL --copy-file m4/libtextstyle.m4 gettext-tools/gnulib-m4/libtextstyle.m4 || exit $? 285 # In gettext-tools/libgrep: 286 GNULIB_MODULES_TOOLS_FOR_LIBGREP=' 287 mbrlen 288 regex 289 ' 290 $GNULIB_TOOL --dir=gettext-tools --macro-prefix=grgl --lib=libgrep --source-base=libgrep --m4-base=libgrep/gnulib-m4 --witness-c-macro=IN_GETTEXT_TOOLS_LIBGREP --makefile-name=Makefile.gnulib --local-dir=gnulib-local --local-symlink \ 291 --import `for m in $GNULIB_MODULES_TOOLS_FOR_SRC_COMMON_DEPENDENCIES; do if test \`$GNULIB_TOOL --extract-applicability $m\` != all; then echo --avoid=$m; fi; done` $GNULIB_MODULES_TOOLS_FOR_LIBGREP || exit $? 292 # In gettext-tools/libgettextpo: 293 # This is a subset of the GNULIB_MODULES_FOR_SRC. 294 GNULIB_MODULES_LIBGETTEXTPO=' 295 basename-lgpl 296 close 297 c-ctype 298 c-strcase 299 c-strstr 300 error 301 error-progname 302 filename 303 fopen 304 fstrcmp 305 fwriteerror 306 gcd 307 getline 308 gettext-h 309 iconv 310 libtextstyle-dummy 311 libunistring-optional 312 markup 313 mem-hash-map 314 minmax 315 open 316 relocatable-lib 317 sigpipe 318 stdbool 319 stdio 320 stdlib 321 stpcpy 322 stpncpy 323 strchrnul 324 strerror 325 unictype/ctype-space 326 unilbrk/ulc-width-linebreaks 327 unistr/u8-mbtouc 328 unistr/u8-mbtoucr 329 unistr/u8-uctomb 330 unistr/u16-mbtouc 331 uniwidth/width 332 unlocked-io 333 vasprintf 334 xalloc 335 xconcat-filename 336 xmalloca 337 xerror 338 xstriconv 339 xvasprintf 340 ' 341 # Module 'fdopen' is enabled in gettext-tools/config.status, because 342 # it occurs as dependency of some module ('supersede') in 343 # GNULIB_MODULES_TOOLS_FOR_SRC. Therefore on mingw, libgettextpo/stdio.h 344 # contains '#define fdopen rpl_fdopen'. Therefore we need to include 345 # fdopen.lo in libgettextpo.la. 346 # Module 'realloc-posix' is enabled in gettext-tools/config.status, because 347 # it occurs as dependency of some module ('read-file') in 348 # GNULIB_MODULES_TOOLS_FOR_SRC. Therefore on mingw, libgettextpo/stdlib.h 349 # contains '#define realloc rpl_realloc'. Therefore we need to include 350 # realloc.lo in libgettextpo.la. 351 GNULIB_MODULES_LIBGETTEXTPO_OTHER=' 352 fdopen 353 realloc-posix 354 ' 355 $GNULIB_TOOL --dir=gettext-tools --source-base=libgettextpo --m4-base=libgettextpo/gnulib-m4 --macro-prefix=gtpo --makefile-name=Makefile.gnulib --libtool --local-dir=gnulib-local --local-symlink \ 356 --import --avoid=progname $GNULIB_MODULES_LIBGETTEXTPO $GNULIB_MODULES_LIBGETTEXTPO_OTHER || exit $? 357 # Overwrite older versions of .m4 files with the up-to-date version. 358 cp gettext-runtime/m4/gettext.m4 gettext-tools/gnulib-m4/gettext.m4 359 # Import build tools. We use --copy-file to avoid directory creation. 360 $GNULIB_TOOL --copy-file tests/init.sh gettext-tools || exit $? 361 $GNULIB_TOOL --copy-file build-aux/x-to-1.in gettext-runtime/man/x-to-1.in || exit $? 362 $GNULIB_TOOL --copy-file build-aux/x-to-1.in gettext-tools/man/x-to-1.in || exit $? 363 $GNULIB_TOOL --copy-file build-aux/git-version-gen || exit $? 364 $GNULIB_TOOL --copy-file build-aux/gitlog-to-changelog || exit $? 365 $GNULIB_TOOL --copy-file build-aux/update-copyright || exit $? 366 $GNULIB_TOOL --copy-file build-aux/useless-if-before-free || exit $? 367 $GNULIB_TOOL --copy-file build-aux/vc-list-files || exit $? 368 $GNULIB_TOOL --copy-file top/GNUmakefile . || exit $? 369 $GNULIB_TOOL --copy-file top/maint.mk . || exit $? 370fi 371 372# Fetch config.guess, config.sub. 373if test -n "$GNULIB_TOOL"; then 374 for file in config.guess config.sub; do 375 $GNULIB_TOOL --copy-file build-aux/$file && chmod a+x build-aux/$file || exit $? 376 done 377else 378 for file in config.guess config.sub; do 379 echo "$0: getting $file..." 380 wget -q --timeout=5 -O build-aux/$file.tmp "https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/${file};hb=HEAD" \ 381 && mv build-aux/$file.tmp build-aux/$file \ 382 && chmod a+x build-aux/$file 383 retval=$? 384 rm -f build-aux/$file.tmp 385 test $retval -eq 0 || exit $retval 386 done 387fi 388 389# Fetch gettext-tools/misc/archive.dir.tar. 390if ! test -f gettext-tools/misc/archive.dir.tar; then 391 if ! test -f gettext-tools/misc/archive.dir.tar.xz; then 392 echo "$0: getting gettext-tools/misc/archive.dir.tar..." 393 wget -q --timeout=5 -O gettext-tools/misc/archive.dir.tar.xz-t "https://alpha.gnu.org/gnu/gettext/archive.dir-latest.tar.xz" \ 394 && mv gettext-tools/misc/archive.dir.tar.xz-t gettext-tools/misc/archive.dir.tar.xz 395 retval=$? 396 rm -f gettext-tools/misc/archive.dir.tar.xz-t 397 test $retval -eq 0 || exit $retval 398 fi 399 xz -d -c < gettext-tools/misc/archive.dir.tar.xz > gettext-tools/misc/archive.dir.tar-t \ 400 && mv gettext-tools/misc/archive.dir.tar-t gettext-tools/misc/archive.dir.tar 401 retval=$? 402 rm -f gettext-tools/misc/archive.dir.tar-t 403 test $retval -eq 0 || exit $retval 404fi 405 406# Make sure we get new versions of files brought in by automake. 407(cd build-aux && rm -f ar-lib compile depcomp install-sh mdate-sh missing test-driver ylwrap) 408 409# Generate configure script in each subdirectories. 410dir0=`pwd` 411 412echo "$0: generating configure in gettext-runtime/libasprintf..." 413cd gettext-runtime/libasprintf 414aclocal -I ../../m4 -I ../m4 -I gnulib-m4 \ 415 && autoconf \ 416 && autoheader && touch config.h.in \ 417 && touch ChangeLog \ 418 && automake --add-missing --copy \ 419 && rm -rf autom4te.cache \ 420 || exit $? 421cd "$dir0" 422 423echo "$0: generating configure in gettext-runtime..." 424cd gettext-runtime 425aclocal -I m4 -I ../m4 -I gnulib-m4 \ 426 && autoconf \ 427 && autoheader && touch config.h.in \ 428 && touch ChangeLog intl/ChangeLog \ 429 && automake --add-missing --copy \ 430 && rm -rf autom4te.cache \ 431 || exit $? 432cd "$dir0" 433 434echo "$0: generating files in libtextstyle..." 435cd libtextstyle 436(if ! $skip_gnulib; then export GNULIB_SRCDIR; fi 437 ./autogen.sh $skip_gnulib_option 438) || exit $? 439cd "$dir0" 440 441echo "$0: generating configure in gettext-tools/examples..." 442cd gettext-tools/examples 443aclocal -I ../../gettext-runtime/m4 -I ../../m4 \ 444 && autoconf \ 445 && touch ChangeLog \ 446 && automake --add-missing --copy \ 447 && rm -rf autom4te.cache \ 448 || exit $? 449cd "$dir0" 450 451echo "$0: copying common files from gettext-runtime to gettext-tools..." 452cp -p gettext-runtime/ABOUT-NLS gettext-tools/ABOUT-NLS 453cp -p gettext-runtime/po/Makefile.in.in gettext-tools/po/Makefile.in.in 454cp -p gettext-runtime/po/Rules-quot gettext-tools/po/Rules-quot 455cp -p gettext-runtime/po/boldquot.sed gettext-tools/po/boldquot.sed 456cp -p gettext-runtime/po/quot.sed gettext-tools/po/quot.sed 457cp -p gettext-runtime/po/en@quot.header gettext-tools/po/en@quot.header 458cp -p gettext-runtime/po/en@boldquot.header gettext-tools/po/en@boldquot.header 459cp -p gettext-runtime/po/insert-header.sin gettext-tools/po/insert-header.sin 460cp -p gettext-runtime/po/remove-potcdate.sin gettext-tools/po/remove-potcdate.sin 461# This file might be newer than Gnulib's. 462sed_extract_serial='s/^#.* serial \([^ ]*\).*/\1/p 4631q' 464for file in po.m4; do 465 existing_serial=`sed -n -e "$sed_extract_serial" < "gettext-tools/gnulib-m4/$file"` 466 gettext_serial=`sed -n -e "$sed_extract_serial" < "gettext-runtime/m4/$file"` 467 if test -n "$existing_serial" && test -n "$gettext_serial" \ 468 && test "$existing_serial" -ge "$gettext_serial" 2> /dev/null; then 469 : 470 else 471 cp -p "gettext-runtime/m4/$file" "gettext-tools/gnulib-m4/$file" 472 fi 473done 474 475echo "$0: generating configure in gettext-tools..." 476mkdir -p gettext-tools/intl 477cp -p gettext-runtime/intl/Makefile.am gettext-tools/intl/Makefile.am 478cd gettext-tools 479aclocal -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4 \ 480 && autoconf \ 481 && autoheader && touch config.h.in \ 482 && touch ChangeLog \ 483 && { test -d intl || mkdir intl; } \ 484 && automake --add-missing --copy \ 485 && rm -rf autom4te.cache \ 486 || exit $? 487cd "$dir0" 488 489aclocal -I m4 \ 490 && autoconf \ 491 && touch ChangeLog \ 492 && automake --add-missing --copy \ 493 && rm -rf autom4te.cache gettext-runtime/autom4te.cache gettext-tools/autom4te.cache \ 494 || exit $? 495 496echo "$0: done. Now you can run './configure'." 497