1@echo off 2Rem Configure libiconv for DJGPP. 3 4Rem WARNING WARNING WARNING: This file needs to have DOS CRLF end-of-line 5Rem format, or else stock DOS/Windows shells will refuse to run it. 6 7echo Configuring GNU libiconv for DJGPP v2.x... 8Rem The SmallEnv tests protect against fixed and too small size 9Rem of the environment in stock DOS shell. 10 11Rem Find out if NLS is wanted or not, 12Rem if dependency-tracking is wanted or not, 13Rem if caching is wanted or not 14Rem and where the sources are. 15Rem We always default to NLS support, 16Rem no dependency tracking 17Rem and to in place configuration. 18set ARGS= 19set NLS=disabled 20if not "%NLS%" == "disabled" goto SmallEnv 21set CACHING=enabled 22if not "%CACHING%" == "enabled" goto SmallEnv 23set DEPENDENCY_TRACKING=disabled 24if not "%DEPENDENCY_TRACKING%" == "disabled" goto SmallEnv 25set LIBICONV_PREFIX=disabled 26if not "%LIBICONV_PREFIX%" == "disabled" goto SmallEnv 27set LIBINTL_PREFIX=disabled 28if not "%LIBINTL_PREFIX%" == "disabled" goto SmallEnv 29set HTML=enabled 30if not "%HTML%" == "enabled" goto SmallEnv 31set XSRC=. 32if not "%XSRC%" == "." goto SmallEnv 33 34Rem Loop over all arguments. 35Rem Special arguments are: NLS, XSRC, CACHE, STATIC_LIBS, LIBICONV_PREFIX, LIBINTL_PREFIX and DEPS. 36Rem All other arguments are stored into ARGS. 37:ArgLoop 38if "%1" == "nls" goto NextArgument 39if "%1" == "NLS" goto NextArgument 40if "%1" == "no-nls" goto NoNLS 41if "%1" == "no-NLS" goto NoNLS 42if "%1" == "NO-NLS" goto NoNLS 43goto CachingOption 44:NoNLS 45if "%1" == "no-nls" set NLS=disabled 46if "%1" == "no-NLS" set NLS=disabled 47if "%1" == "NO-NLS" set NLS=disabled 48if not "%NLS%" == "disabled" goto SmallEnv 49goto NextArgument 50:CachingOption 51if "%1" == "cache" goto NextArgument 52if "%1" == "CACHE" goto NextArgument 53if "%1" == "no-cache" goto NoCaching 54if "%1" == "no-CACHE" goto NoCaching 55if "%1" == "NO-CACHE" goto NoCaching 56goto DependencyOption 57:NoCaching 58if "%1" == "no-cache" set CACHING=disabled 59if "%1" == "no-CACHE" set CACHING=disabled 60if "%1" == "NO-CACHE" set CACHING=disabled 61if not "%CACHING%" == "disabled" goto SmallEnv 62goto NextArgument 63:DependencyOption 64if "%1" == "no-dep" goto NextArgument 65if "%1" == "no-DEP" goto NextArgument 66if "%1" == "NO-DEP" goto NextArgument 67if "%1" == "dep" goto DependecyTraking 68if "%1" == "DEP" goto DependecyTraking 69goto LibiconvPrefixOption 70:DependecyTraking 71if "%1" == "dep" set DEPENDENCY_TRACKING=enabled 72if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled 73if not "%DEPENDENCY_TRACKING%" == "enabled" goto SmallEnv 74goto NextArgument 75:LibiconvPrefixOption 76if "%1" == "no-libiconvprefix" goto NextArgument 77if "%1" == "no-LIBICONVPREFIX" goto NextArgument 78if "%1" == "NO-LIBICONVPREFIX" goto NextArgument 79if "%1" == "libiconvprefix" goto WithLibiconvPrefix 80if "%1" == "LIBICONVPREFIX" goto WithLibiconvPrefix 81goto LibintlPrefixOption 82:WithLibiconvPrefix 83if "%1" == "libiconvprefix" set LIBICONV_PREFIX=enabled 84if "%1" == "LIBICONVPREFIX" set LIBICONV_PREFIX=enabled 85if not "%LIBICONV_PREFIX%" == "enabled" goto SmallEnv 86goto NextArgument 87:LibintlPrefixOption 88if "%1" == "no-libiconvprefix" goto NextArgument 89if "%1" == "no-LIBICONVPREFIX" goto NextArgument 90if "%1" == "NO-LIBICONVPREFIX" goto NextArgument 91if "%1" == "libintlprefix" goto _WithLibintlPrefix 92if "%1" == "LIBINTLPREFIX" goto _WithLibintlPrefix 93goto HTMLOption 94:_WithLibintlPrefix 95if "%1" == "libintlprefix" set LIBINTL_PREFIX=enabled 96if "%1" == "LIBINTLPREFIX" set LIBINTL_PREFIX=enabled 97if not "%LIBINTL_PREFIX%" == "enabled" goto SmallEnv 98:HTMLOption 99if "%1" == "withhtml" goto NextArgument 100if "%1" == "withHTML" goto NextArgument 101if "%1" == "WITHHTML" goto NextArgument 102if "%1" == "withouthtml" goto _WithoutHTML 103if "%1" == "withoutHTML" goto _WithoutHTML 104if "%1" == "WITHOUTHTML" goto _WithoutHTML 105goto SrcDirOption 106:_WithoutHTML 107if "%1" == "withouthtml" set HTML=disabled 108if "%1" == "withoutHTML" set HTML=disabled 109if "%1" == "WITHOUTHTML" set HTML=disabled 110if not "%HTML%" == "disabled" goto SmallEnv 111goto NextArgument 112:SrcDirOption 113echo %1 | grep -q "/" 114if errorlevel 1 goto CollectArgument 115set XSRC=%1 116if not "%XSRC%" == "%1" goto SmallEnv 117goto NextArgument 118:CollectArgument 119set _ARGS=%ARGS% %1 120if not "%_ARGS%" == "%ARGS% %1" if not "%_ARGS%" == "%ARGS%%1" goto SmallEnv 121echo %_ARGS% | grep -q "[^ ]" 122if not errorlevel 0 set ARGS=%_ARGS% 123set _ARGS= 124:NextArgument 125shift 126if not "%1" == "" goto ArgLoop 127 128Rem Create an arguments file for the configure script. 129echo --srcdir=%XSRC% > arguments 130if "%CACHING%" == "enabled" echo --cache-file=%XSRC%/djgpp/config.cache >> arguments 131if "%DEPENDENCY_TRACKING%" == "enabled" echo --enable-dependency-tracking >> arguments 132if "%DEPENDENCY_TRACKING%" == "disabled" echo --disable-dependency-tracking >> arguments 133if "%LIBICONV_PREFIX%" == "enabled" echo --with-libiconv-prefix >> arguments 134if "%LIBICONV_PREFIX%" == "disabled" echo --without-libiconv-prefix >> arguments 135if "%LIBINTL_PREFIX%" == "enabled" echo --with-libintl-prefix >> arguments 136if "%LIBINTL_PREFIX%" == "disabled" echo --without-libintl-prefix >> arguments 137if "%HTML%" == "enabled" echo --enable-html >> arguments 138if "%HTML%" == "disabled" echo --disable-html >> arguments 139if not "%ARGS%" == "" echo %ARGS% >> arguments 140set ARGS= 141set CACHING= 142set DEPENDENCY_TRACKING= 143set LIBICONV_PREFIX= 144set LIBINTL_PREFIX= 145set HTML= 146 147Rem Find out where the sources are 148if "%XSRC%" == "." goto InPlace 149 150:NotInPlace 151redir -e /dev/null update %XSRC%/configure.orig ./configure 152test -f ./configure 153if errorlevel 1 update %XSRC%/configure ./configure 154test -d ./libcharset 155if errorlevel 1 md libcharset 156redir -e /dev/null update %XSRC%/libcharset/configure.orig ./libcharset/configure 157test -f ./libcharset/configure 158if errorlevel 1 update %XSRC%/libcharset/configure ./libcharset/configure 159 160:InPlace 161Rem Update configuration files 162echo Updating configuration scripts... 163test -f ./configure.orig 164if errorlevel 1 update ./configure ./configure.orig 165sed -f %XSRC%/djgpp/config.sed ./configure.orig > configure 166if errorlevel 1 goto SedError 167test -f ./libcharset/configure.orig 168if errorlevel 1 update ./libcharset/configure ./libcharset/configure.orig 169sed -f %XSRC%/djgpp/config.sed ./libcharset/configure.orig > configure.tmp 170if errorlevel 1 goto SedError 171Rem The following is needed because the toplevel configure script calls the 172Rem %XSRC%/libcharset/configure script instead of ./libcharset/configure. 173test -f %XSRC%/libcharset/configure.orig 174if errorlevel 1 update %XSRC%/libcharset/configure %XSRC%/libcharset/configure.orig 175update configure.tmp %XSRC%/libcharset/configure 176rm ./configure.tmp 177 178Rem Make sure they have a config.site file 179set CONFIG_SITE=%XSRC%/djgpp/config.site 180if not "%CONFIG_SITE%" == "%XSRC%/djgpp/config.site" goto SmallEnv 181 182Rem Make sure crucial file names are not munged by unpacking 183test -f %XSRC%/config.h.in 184if not errorlevel 1 redir -e /dev/null mv -f %XSRC%/config.h.in %XSRC%/config.h-in 185test -f %XSRC%/config.h-in 186if errorlevel 1 redir -e /dev/null mv -f %XSRC%/config.h %XSRC%/config.h-in 187test -f %XSRC%/config.h-in 188if errorlevel 1 redir -e /dev/null mv -f %XSRC%/configh.in %XSRC%/config.h-in 189test -f %XSRC%/config.h-in 190if errorlevel 1 redir -e /dev/null mv -f %XSRC%/config_h.in %XSRC%/config.h-in 191test -f %XSRC%/include/iconv.h.in 192if not errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/iconv.h.in %XSRC%/include/iconv.h-in 193test -f %XSRC%/include/iconv.h-in 194if errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/iconv.h %XSRC%/include/iconv.h-in 195test -f %XSRC%/include/iconv.h-in 196if errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/iconvh.in %XSRC%/include/iconv.h-in 197test -f %XSRC%/include/iconv.h-in 198if errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/iconv_h.in %XSRC%/include/iconv.h-in 199test -f %XSRC%/libcharset/config.h.in 200if not errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/config.h.in %XSRC%/libcharset/config.h-in 201test -f %XSRC%/libcharset/config.h-in 202if errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/config.h %XSRC%/libcharset/config.h-in 203test -f %XSRC%/libcharset/config.h-in 204if errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/configh.in %XSRC%/libcharset/config.h-in 205test -f %XSRC%/libcharset/config.h-in 206if errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/config_h.in %XSRC%/libcharset/config.h-in 207test -f %XSRC%/libcharset/include/libcharset.h.in 208if not errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/include/libcharset.h.in %XSRC%/libcharset/include/libcharset.h-in 209test -f %XSRC%/libcharset/include/libcharset.h-in 210if errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/include/libcharset.h %XSRC%/libcharset/include/libcharset.h-in 211test -f %XSRC%/libcharset/include/libcharset.h-in 212if errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/include/libcharseth.in %XSRC%/libcharset/include/libcharset.h-in 213test -f %XSRC%/libcharset/include/libcharset.h-in 214if errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/include/libcharset_h.in %XSRC%/libcharset/include/libcharset.h-in 215test -f %XSRC%/libcharset/include/localcharset.h.in 216if not errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/include/localcharset.h.in %XSRC%/libcharset/include/localcharset.h-in 217test -f %XSRC%/libcharset/include/localcharset.h-in 218if errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/include/localcharset.h %XSRC%/libcharset/include/localcharset.h-in 219test -f %XSRC%/libcharset/include/localcharset.h-in 220if errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/include/localcharseth.in %XSRC%/libcharset/include/localcharset.h-in 221test -f %XSRC%/libcharset/include/localcharset.h-in 222if errorlevel 1 redir -e /dev/null mv -f %XSRC%/libcharset/include/localcharset_h.in %XSRC%/libcharset/include/localcharset.h-in 223 224Rem DJGPP needs ICONV_CONST set to const. 225sed "s/^#undef ICONV_CONST/#define ICONV_CONST const/" %XSRC%/config.h-in > config.tmp 226mv -f config.tmp %XSRC%/config.h-in 227 228Rem All fixes needed to get the package configured, compiled and tested. 229Rem 1: Change the stateless-check script so it knowns about the 230Rem new filenames. 231Rem 2: Ditto for Makefile.in 232Rem 3: Ditto for source files. 233 234test -f %XSRC%/stamp-djgppfixes 235if not errorlevel 1 goto TestsuitFixed 236Rem Fix the Makefile.ins. 237test -f %XSRC%/lib/Makefile.orig 238if errorlevel 1 update %XSRC%/lib/Makefile.in %XSRC%/lib/Makefile.orig 239sed -f %XSRC%/djgpp/makefile.sed %XSRC%/lib/Makefile.in > Makefile.tmp 240if errorlevel 1 goto SedError 241update Makefile.tmp %XSRC%/lib/Makefile.in 242rm Makefile.tmp 243test -f %XSRC%/tests/Makefile.orig 244if errorlevel 1 update %XSRC%/tests/Makefile.in %XSRC%/tests/Makefile.orig 245sed -f %XSRC%/djgpp/makefile.sed %XSRC%/tests/Makefile.in > Makefile.tmp 246if errorlevel 1 goto SedError 247update Makefile.tmp %XSRC%/tests/Makefile.in 248rm Makefile.tmp 249 250Rem Fix the source files. 251test -f %XSRC%/lib/aliases/aliases2.orig 252if errorlevel 1 update %XSRC%/lib/aliases/aliases2.h %XSRC%/lib/aliases/aliases2.orig 253sed -f %XSRC%/djgpp/sources.sed %XSRC%/lib/aliases/aliases2.h > aliases2.tmp 254if errorlevel 1 goto SedError 255update aliases2.tmp %XSRC%/lib/aliases/aliases2.h 256rm aliases2.tmp 257test -f %XSRC%/lib/iconv.orig 258if errorlevel 1 update %XSRC%/lib/iconv.c %XSRC%/lib/iconv.orig 259sed -f %XSRC%/djgpp/sources.sed %XSRC%/lib/iconv.c > iconv.tmp 260if errorlevel 1 goto SedError 261update iconv.tmp %XSRC%/lib/iconv.c 262rm iconv.tmp 263test -f %XSRC%/lib/converters.orig 264if errorlevel 1 update %XSRC%/lib/converters.h %XSRC%/lib/converters.orig 265sed -f %XSRC%/djgpp/sources.sed %XSRC%/lib/converters.h > converters.tmp 266if errorlevel 1 goto SedError 267update converters.tmp %XSRC%/lib/converters.h 268rm converters.tmp 269test -f %XSRC%/lib/cns/11643.orig 270if errorlevel 1 update %XSRC%/lib/cns/11643.h %XSRC%/lib/cns/11643.orig 271sed -f %XSRC%/djgpp/sources.sed %XSRC%/lib/cns/11643.h > 11643.tmp 272if errorlevel 1 goto SedError 273update 11643.tmp %XSRC%/lib/cns/11643.h 274rm 11643.tmp 275test -f %XSRC%/lib/cns/11643_4.orig 276if errorlevel 1 update %XSRC%/lib/cns/11643_4.h %XSRC%/lib/cns/11643_4.orig 277sed -f %XSRC%/djgpp/sources.sed %XSRC%/lib/cns/11643_4.h > 11643_4.tmp 278if errorlevel 1 goto SedError 279update 11643_4.tmp %XSRC%/lib/cns/11643_4.h 280rm 11643_4.tmp 281test -f %XSRC%/lib/iso/ir165.orig 282if errorlevel 1 update %XSRC%/lib/iso/ir165.h %XSRC%/lib/iso/ir165.orig 283sed -f %XSRC%/djgpp/sources.sed %XSRC%/lib/iso/ir165.h > ir165.tmp 284if errorlevel 1 goto SedError 285update ir165.tmp %XSRC%/lib/iso/ir165.h 286rm ir165.tmp 287 288Rem Fix the test scripts. 289if "%XSRC%" == "." goto NoDirChange 290cd | sed "s|:.*$|:|" > cd_BuildDir.bat 291cd | sed "s|^.:|cd |" >> cd_BuildDir.bat 292mv -f cd_BuildDir.bat %XSRC%/cd_BuildDir.bat 293echo %XSRC% | sed -e "s|^/dev/||" -e "s|/|:|" -e "s|:.*$|:|g" > cd_SrcDir.bat 294echo %XSRC% | sed -e "s|^/dev/||" -e "s|/|:/|" -e "s|^.*:|cd |" -e "s|^\.\.|cd &|" -e "s|/|\\|g" >> cd_SrcDir.bat 295call cd_SrcDir.bat 296call djgpp\edtest.bat 297call cd_BuildDir.bat 298rm -f cd_SrcDir.bat cd_BuildDir.bat %XSRC%/cd_BuildDir.bat 299goto TestsuitFixed 300:NoDirChange 301call djgpp\edtest.bat 302:TestsuitFixed 303touch %XSRC%/stamp-djgppfixes 304 305Rem This is required because DOS/Windows are case-insensitive 306Rem to file names, and "make install" will do nothing if Make 307Rem finds a file called `install'. 308if exist INSTALL mv -f INSTALL INSTALL.txt 309 310Rem Set SHELL to a sane default or some configure tests stop working 311Rem if the package is configured across partitions. 312if not "%SHELL%" == "" goto HomeName 313set SHELL=/bin/sh 314if not "%SHELL%" == "/bin/sh" goto SmallEnv 315echo No SHELL found in the environment, using default value 316 317:HomeName 318Rem Set HOME to a sane default so configure stops complaining. 319if not "%HOME%" == "" goto HostName 320set HOME=%XSRC%/djgpp 321if not "%HOME%" == "%XSRC%/djgpp" goto SmallEnv 322echo No HOME found in the environment, using default value 323 324:HostName 325Rem Set HOSTNAME so it shows in config.status 326if not "%HOSTNAME%" == "" goto hostdone 327if "%windir%" == "" goto msdos 328set OS=MS-Windows 329if not "%OS%" == "MS-Windows" goto SmallEnv 330goto haveos 331:msdos 332set OS=MS-DOS 333if not "%OS%" == "MS-DOS" goto SmallEnv 334:haveos 335if not "%USERNAME%" == "" goto haveuname 336if not "%USER%" == "" goto haveuser 337echo No USERNAME and no USER found in the environment, using default values 338set HOSTNAME=Unknown PC 339if not "%HOSTNAME%" == "Unknown PC" goto SmallEnv 340goto userdone 341:haveuser 342set HOSTNAME=%USER%'s PC 343if not "%HOSTNAME%" == "%USER%'s PC" goto SmallEnv 344goto userdone 345:haveuname 346set HOSTNAME=%USERNAME%'s PC 347if not "%HOSTNAME%" == "%USERNAME%'s PC" goto SmallEnv 348:userdone 349set _HOSTNAME=%HOSTNAME%, %OS% 350if not "%_HOSTNAME%" == "%HOSTNAME%, %OS%" goto SmallEnv 351set HOSTNAME=%_HOSTNAME% 352:hostdone 353set _HOSTNAME= 354set OS= 355 356Rem install-sh is required by the configure script but clashes with the 357Rem various Makefile install-foo targets, so we MUST have it before the 358Rem script runs and rename it afterwards 359test -f %XSRC%/install-sh 360if not errorlevel 1 goto NoRen0 361test -f %XSRC%/install-sh.sh 362if not errorlevel 1 mv -f %XSRC%/install-sh.sh %XSRC%/install-sh 363:NoRen0 364 365if "%NLS%" == "disabled" goto WithoutNLS 366 367:WithNLS 368test -d %XSRC%/po 369if errorlevel 1 goto WithoutNLS 370 371Rem Check for the needed libraries and binaries. 372test -x /dev/env/DJDIR/bin/msgfmt.exe 373if not errorlevel 0 goto MissingNLSTools 374test -x /dev/env/DJDIR/bin/xgettext.exe 375if not errorlevel 0 goto MissingNLSTools 376test -f /dev/env/DJDIR/include/libcharset.h 377if not errorlevel 0 goto MissingNLSTools 378test -f /dev/env/DJDIR/lib/libcharset.a 379if not errorlevel 0 goto MissingNLSTools 380test -f /dev/env/DJDIR/include/iconv.h 381if not errorlevel 0 goto MissingNLSTools 382test -f /dev/env/DJDIR/lib/libiconv.a 383if not errorlevel 0 goto MissingNLSTools 384test -f /dev/env/DJDIR/include/libintl.h 385if not errorlevel 0 goto MissingNLSTools 386test -f /dev/env/DJDIR/lib/libintl.a 387if not errorlevel 0 goto MissingNLSTools 388 389Rem Recreate the files in the %XSRC%/po subdir with our ported tools. 390redir -e /dev/null rm %XSRC%/po/*.gmo 391redir -e /dev/null rm %XSRC%/po/libiconv.pot 392redir -e /dev/null rm %XSRC%/po/cat-id-tbl.c 393redir -e /dev/null rm %XSRC%/po/stamp-cat-id 394 395Rem Update the arguments file for the configure script. 396Rem We prefer without-included-gettext because libintl.a from gettext package 397Rem is the only one that is garanteed to have been ported to DJGPP. 398echo --enable-nls --without-included-gettext >> arguments 399goto ConfigurePackage 400 401:MissingNLSTools 402echo Needed libs/tools for NLS not found. Configuring without NLS. 403:WithoutNLS 404Rem Update the arguments file for the configure script. 405echo --disable-nls >> arguments 406 407:ConfigurePackage 408echo Running the ./configure script... 409sh ./configure @arguments 410if errorlevel 1 goto CfgError 411rm arguments 412echo Done. 413goto End 414 415:SedError 416echo ./configure script editing failed! 417goto End 418 419:CfgError 420echo ./configure script exited abnormally! 421goto End 422 423:SmallEnv 424echo Your environment size is too small. Enlarge it and run me again. 425echo Configuration NOT done! 426 427:End 428test -f %XSRC%/install-sh.sh 429if not errorlevel 1 goto NoRen1 430test -f %XSRC%/install-sh 431if not errorlevel 1 mv -f %XSRC%/install-sh %XSRC%/install-sh.sh 432:NoRen1 433set CONFIG_SITE= 434set HOSTNAME= 435set XSRC= 436