1@echo off
2echo Configuring GNU libcharset for DJGPP v2.x...
3Rem The SmallEnv tests protect against fixed and too small size
4Rem of the environment in stock DOS shell.
5
6Rem Find out where the sources are
7set XSRC=.
8if not "%XSRC%" == "." goto SmallEnv
9if "%1" == "" goto InPlace
10set XSRC=%1
11if not "%XSRC%" == "%1" goto SmallEnv
12redir -e /dev/null update %XSRC%/configure.orig ./configure
13test -f ./configure
14if errorlevel 1 update %XSRC%/configure ./configure
15
16:InPlace
17Rem Update configuration files
18echo Updating configuration scripts...
19test -f ./configure.orig
20if errorlevel 1 update ./configure ./configure.orig
21sed -f %XSRC%/djgpp/config.sed ./configure.orig > configure
22if errorlevel 1 goto SedError
23
24Rem Make sure they have a config.site file
25set CONFIG_SITE=%XSRC%/djgpp/config.site
26if not "%CONFIG_SITE%" == "%XSRC%/djgpp/config.site" goto SmallEnv
27
28Rem Make sure crucial file names are not munged by unpacking
29test -f %XSRC%/config.h.in
30if not errorlevel 1 mv -f %XSRC%/config.h.in %XSRC%/config.h-in
31test -f %XSRC%/include/libcharset.h.in
32if not errorlevel 1 mv -f %XSRC%/include/libcharset.h.in %XSRC%/include/libcharset.h-in
33
34Rem This is required because DOS/Windows are case-insensitive
35Rem to file names, and "make install" will do nothing if Make
36Rem finds a file called `install'.
37if exist INSTALL mv -f INSTALL INSTALL.txt
38
39Rem install-sh is required by the configure script but clashes with the
40Rem various Makefile install-foo targets, so we MUST have it before the
41Rem script runs and rename it afterwards
42test -f %XSRC%/install-sh
43if not errorlevel 1 goto NoRen0
44test -f %XSRC%/install-sh.sh
45if not errorlevel 1 mv -f %XSRC%/install-sh.sh %XSRC%/install-sh
46:NoRen0
47
48Rem Set HOSTNAME so it shows in config.status
49if not "%HOSTNAME%" == "" goto hostdone
50if "%windir%" == "" goto msdos
51set OS=MS-Windows
52if not "%OS%" == "MS-Windows" goto SmallEnv
53goto haveos
54:msdos
55set OS=MS-DOS
56if not "%OS%" == "MS-DOS" goto SmallEnv
57:haveos
58if not "%USERNAME%" == "" goto haveuname
59if not "%USER%" == "" goto haveuser
60echo No USERNAME and no USER found in the environment, using default values
61set HOSTNAME=Unknown PC
62if not "%HOSTNAME%" == "Unknown PC" goto SmallEnv
63goto userdone
64:haveuser
65set HOSTNAME=%USER%'s PC
66if not "%HOSTNAME%" == "%USER%'s PC" goto SmallEnv
67goto userdone
68:haveuname
69set HOSTNAME=%USERNAME%'s PC
70if not "%HOSTNAME%" == "%USERNAME%'s PC" goto SmallEnv
71:userdone
72set _HOSTNAME=%HOSTNAME%, %OS%
73if not "%_HOSTNAME%" == "%HOSTNAME%, %OS%" goto SmallEnv
74set HOSTNAME=%_HOSTNAME%
75:hostdone
76set _HOSTNAME=
77set OS=
78
79Rem With libtool 1.4 -fPIC is the default. This completely breaks compilations
80Rem with djgpp, so we will always use --disable-shared to inhibit the usage of
81Rem -fPIC and -DPIC flags in libtool.
82echo Running the ./configure script...
83sh ./configure --enable-static --disable-shared --src=%XSRC%
84if errorlevel 1 goto CfgError
85echo Done.
86goto End
87
88:SedError
89echo ./configure script editing failed!
90goto End
91
92:CfgError
93echo ./configure script exited abnormally!
94goto End
95
96:SmallEnv
97echo Your environment size is too small.  Enlarge it and run me again.
98echo Configuration NOT done!
99
100:End
101test -f %XSRC%/install-sh.sh
102if not errorlevel 1 goto NoRen1
103test -f %XSRC%/install-sh
104if not errorlevel 1 mv -f %XSRC%/install-sh %XSRC%/install-sh.sh
105:NoRen1
106set CONFIG_SITE=
107set HOSTNAME=
108set XSRC=
109