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 if NLS is wanted or not,
7Rem if dependency-tracking is wanted or not,
8Rem if caching is wanted or not
9Rem and where the sources are.
10Rem We always default to NLS support,
11Rem no dependency tracking
12Rem and to in place configuration.
13set ARGS=
14set NLS=disabled
15if not "%NLS%" == "disabled" goto SmallEnv
16set CACHING=enabled
17if not "%CACHING%" == "enabled" goto SmallEnv
18set DEPENDENCY_TRACKING=disabled
19if not "%DEPENDENCY_TRACKING%" == "disabled" goto SmallEnv
20set LIBICONV_PREFIX=disabled
21if not "%LIBICONV_PREFIX%" == "disabled" goto SmallEnv
22set LIBINTL_PREFIX=disabled
23if not "%LIBINTL_PREFIX%" == "disabled" goto SmallEnv
24set HTML=enabled
25if not "%HTML%" == "enabled" goto SmallEnv
26set XSRC=.
27if not "%XSRC%" == "." goto SmallEnv
28
29Rem Loop over all arguments.
30Rem Special arguments are: NLS, XSRC, CACHE, STATIC_LIBS, LIBICONV_PREFIX, LIBINTL_PREFIX and DEPS.
31Rem All other arguments are stored into ARGS.
32:ArgLoop
33if "%1" == "nls" goto NextArgument
34if "%1" == "NLS" goto NextArgument
35if "%1" == "no-nls" goto NoNLS
36if "%1" == "no-NLS" goto NoNLS
37if "%1" == "NO-NLS" goto NoNLS
38goto CachingOption
39:NoNLS
40if "%1" == "no-nls" set NLS=disabled
41if "%1" == "no-NLS" set NLS=disabled
42if "%1" == "NO-NLS" set NLS=disabled
43if not "%NLS%" == "disabled" goto SmallEnv
44goto NextArgument
45:CachingOption
46if "%1" == "cache" goto NextArgument
47if "%1" == "CACHE" goto NextArgument
48if "%1" == "no-cache" goto NoCaching
49if "%1" == "no-CACHE" goto NoCaching
50if "%1" == "NO-CACHE" goto NoCaching
51goto DependencyOption
52:NoCaching
53if "%1" == "no-cache" set CACHING=disabled
54if "%1" == "no-CACHE" set CACHING=disabled
55if "%1" == "NO-CACHE" set CACHING=disabled
56if not "%CACHING%" == "disabled" goto SmallEnv
57goto NextArgument
58:DependencyOption
59if "%1" == "no-dep" goto NextArgument
60if "%1" == "no-DEP" goto NextArgument
61if "%1" == "NO-DEP" goto NextArgument
62if "%1" == "dep" goto DependecyTraking
63if "%1" == "DEP" goto DependecyTraking
64goto LibiconvPrefixOption
65:DependecyTraking
66if "%1" == "dep" set DEPENDENCY_TRACKING=enabled
67if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled
68if not "%DEPENDENCY_TRACKING%" == "enabled" goto SmallEnv
69goto NextArgument
70:LibiconvPrefixOption
71if "%1" == "no-libiconvprefix" goto NextArgument
72if "%1" == "no-LIBICONVPREFIX" goto NextArgument
73if "%1" == "NO-LIBICONVPREFIX" goto NextArgument
74if "%1" == "libiconvprefix" goto WithLibiconvPrefix
75if "%1" == "LIBICONVPREFIX" goto WithLibiconvPrefix
76goto LibintlPrefixOption
77:WithLibiconvPrefix
78if "%1" == "libiconvprefix" set LIBICONV_PREFIX=enabled
79if "%1" == "LIBICONVPREFIX" set LIBICONV_PREFIX=enabled
80if not "%LIBICONV_PREFIX%" == "enabled" goto SmallEnv
81goto NextArgument
82:LibintlPrefixOption
83if "%1" == "no-libiconvprefix" goto NextArgument
84if "%1" == "no-LIBICONVPREFIX" goto NextArgument
85if "%1" == "NO-LIBICONVPREFIX" goto NextArgument
86if "%1" == "libintlprefix" goto _WithLibintlPrefix
87if "%1" == "LIBINTLPREFIX" goto _WithLibintlPrefix
88goto HTMLOption
89:_WithLibintlPrefix
90if "%1" == "libintlprefix" set LIBINTL_PREFIX=enabled
91if "%1" == "LIBINTLPREFIX" set LIBINTL_PREFIX=enabled
92if not "%LIBINTL_PREFIX%" == "enabled" goto SmallEnv
93:HTMLOption
94if "%1" == "withhtml" goto NextArgument
95if "%1" == "withHTML" goto NextArgument
96if "%1" == "WITHHTML" goto NextArgument
97if "%1" == "withouthtml" goto _WithoutHTML
98if "%1" == "withoutHTML" goto _WithoutHTML
99if "%1" == "WITHOUTHTML" goto _WithoutHTML
100goto SrcDirOption
101:_WithoutHTML
102if "%1" == "withouthtml" set HTML=disabled
103if "%1" == "withoutHTML" set HTML=disabled
104if "%1" == "WITHOUTHTML" set HTML=disabled
105if not "%HTML%" == "disabled" goto SmallEnv
106goto NextArgument
107:SrcDirOption
108echo %1 | grep -q "/"
109if errorlevel 1 goto CollectArgument
110set XSRC=%1
111if not "%XSRC%" == "%1" goto SmallEnv
112goto NextArgument
113:CollectArgument
114set _ARGS=#%ARGS%#%1#
115if not "%_ARGS%" == "#%ARGS%#%1#" goto SmallEnv
116echo %_ARGS% | grep -q "###"
117if errorlevel 1 set ARGS=%ARGS% %1
118set _ARGS=
119:NextArgument
120shift
121if not "%1" == "" goto ArgLoop
122
123Rem Create an arguments file for the configure script.
124echo --srcdir=%XSRC% > arguments
125if "%CACHING%" == "enabled"              echo --cache-file=%XSRC%/djgpp/config.cache >> arguments
126if "%DEPENDENCY_TRACKING%" == "enabled"  echo --enable-dependency-tracking >> arguments
127if "%DEPENDENCY_TRACKING%" == "disabled" echo --disable-dependency-tracking >> arguments
128if "%LIBICONV_PREFIX%" == "enabled"      echo --with-libiconv-prefix >> arguments
129if "%LIBICONV_PREFIX%" == "disabled"     echo --without-libiconv-prefix >> arguments
130if "%LIBINTL_PREFIX%" == "enabled"       echo --with-libintl-prefix >> arguments
131if "%LIBINTL_PREFIX%" == "disabled"      echo --without-libintl-prefix >> arguments
132if "%HTML%" == "enabled"                 echo --enable-html >> arguments
133if "%HTML%" == "disabled"                echo --disable-html >> arguments
134if not "%ARGS%" == ""                    echo %ARGS% >> arguments
135set ARGS=
136set CACHING=
137set DEPENDENCY_TRACKING=
138set LIBICONV_PREFIX=
139set LIBINTL_PREFIX=
140set HTML=
141
142Rem Find out where the sources are
143if "%XSRC%" == "." goto InPlace
144
145:NotInPlace
146redir -e /dev/null update %XSRC%/configure.orig ./configure
147test -f ./configure
148if errorlevel 1 update %XSRC%/configure ./configure
149
150:InPlace
151Rem Update configuration files
152echo Updating configuration scripts...
153test -f ./configure.orig
154if errorlevel 1 update ./configure ./configure.orig
155sed -f %XSRC%/djgpp/config.sed ./configure.orig > configure
156if errorlevel 1 goto SedError
157
158Rem Make sure they have a config.site file
159set CONFIG_SITE=%XSRC%/djgpp/config.site
160if not "%CONFIG_SITE%" == "%XSRC%/djgpp/config.site" goto SmallEnv
161
162Rem Make sure crucial file names are not munged by unpacking
163test -f %XSRC%/config.h.in
164if not errorlevel 1 redir -e /dev/null mv -f %XSRC%/config.h.in %XSRC%/config.h-in
165test -f %XSRC%/config.h-in
166if errorlevel 1 redir -e /dev/null mv -f %XSRC%/config.h %XSRC%/config.h-in
167test -f %XSRC%/config.h-in
168if errorlevel 1 redir -e /dev/null mv -f %XSRC%/configh.in %XSRC%/config.h-in
169test -f %XSRC%/config.h-in
170if errorlevel 1 redir -e /dev/null mv -f %XSRC%/config_h.in %XSRC%/config.h-in
171test -f %XSRC%/include/libcharset.h-in
172if not errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/libcharset.h-in %XSRC%/include/libcharset.h-in
173test -f %XSRC%/include/libcharset.h-in
174if errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/libcharset.h %XSRC%/include/libcharset.h-in
175test -f %XSRC%/include/libcharset.h-in
176if errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/libcharseth.in %XSRC%/include/libcharset.h-in
177test -f %XSRC%/include/libcharset.h-in
178if errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/libcharset_h.in %XSRC%/include/libcharset.h-in
179test -f %XSRC%/include/localcharset.h-in
180if not errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/localcharset.h-in %XSRC%/include/localcharset.h-in
181test -f %XSRC%/include/localcharset.h-in
182if errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/localcharset.h %XSRC%/include/localcharset.h-in
183test -f %XSRC%/include/localcharset.h-in
184if errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/localcharseth.in %XSRC%/include/localcharset.h-in
185test -f %XSRC%/include/localcharset.h-in
186if errorlevel 1 redir -e /dev/null mv -f %XSRC%/include/localcharset_h.in %XSRC%/include/localcharset.h-in
187
188Rem This is required because DOS/Windows are case-insensitive
189Rem to file names, and "make install" will do nothing if Make
190Rem finds a file called `install'.
191if exist INSTALL mv -f INSTALL INSTALL.txt
192
193Rem Set SHELL to a sane default or some configure tests stop working
194Rem if the package is configured across partitions.
195if not "%SHELL%" == "" goto HomeName
196set SHELL=/bin/sh
197if not "%SHELL%" == "/bin/sh" goto SmallEnv
198echo No SHELL found in the environment, using default value
199
200:HomeName
201Rem Set HOME to a sane default so configure stops complaining.
202if not "%HOME%" == "" goto HostName
203set HOME=%XSRC%/djgpp
204if not "%HOME%" == "%XSRC%/djgpp" goto SmallEnv
205echo No HOME found in the environment, using default value
206
207:HostName
208Rem Set HOSTNAME so it shows in config.status
209if not "%HOSTNAME%" == "" goto hostdone
210if "%windir%" == "" goto msdos
211set OS=MS-Windows
212if not "%OS%" == "MS-Windows" goto SmallEnv
213goto haveos
214:msdos
215set OS=MS-DOS
216if not "%OS%" == "MS-DOS" goto SmallEnv
217:haveos
218if not "%USERNAME%" == "" goto haveuname
219if not "%USER%" == "" goto haveuser
220echo No USERNAME and no USER found in the environment, using default values
221set HOSTNAME=Unknown PC
222if not "%HOSTNAME%" == "Unknown PC" goto SmallEnv
223goto userdone
224:haveuser
225set HOSTNAME=%USER%'s PC
226if not "%HOSTNAME%" == "%USER%'s PC" goto SmallEnv
227goto userdone
228:haveuname
229set HOSTNAME=%USERNAME%'s PC
230if not "%HOSTNAME%" == "%USERNAME%'s PC" goto SmallEnv
231:userdone
232set _HOSTNAME=%HOSTNAME%, %OS%
233if not "%_HOSTNAME%" == "%HOSTNAME%, %OS%" goto SmallEnv
234set HOSTNAME=%_HOSTNAME%
235:hostdone
236set _HOSTNAME=
237set OS=
238
239Rem install-sh is required by the configure script but clashes with the
240Rem various Makefile install-foo targets, so we MUST have it before the
241Rem script runs and rename it afterwards
242test -f %XSRC%/install-sh
243if not errorlevel 1 goto NoRen0
244test -f %XSRC%/install-sh.sh
245if not errorlevel 1 mv -f %XSRC%/install-sh.sh %XSRC%/install-sh
246:NoRen0
247
248if "%NLS%" == "disabled" goto WithoutNLS
249
250:WithNLS
251test -d %XSRC%/po
252if errorlevel 1 goto WithoutNLS
253
254Rem Check for the needed libraries and binaries.
255test -x /dev/env/DJDIR/bin/msgfmt.exe
256if not errorlevel 0 goto MissingNLSTools
257test -x /dev/env/DJDIR/bin/xgettext.exe
258if not errorlevel 0 goto MissingNLSTools
259test -f /dev/env/DJDIR/include/libcharset.h
260if not errorlevel 0 goto MissingNLSTools
261test -f /dev/env/DJDIR/lib/libcharset.a
262if not errorlevel 0 goto MissingNLSTools
263test -f /dev/env/DJDIR/include/iconv.h
264if not errorlevel 0 goto MissingNLSTools
265test -f /dev/env/DJDIR/lib/libiconv.a
266if not errorlevel 0 goto MissingNLSTools
267test -f /dev/env/DJDIR/include/libintl.h
268if not errorlevel 0 goto MissingNLSTools
269test -f /dev/env/DJDIR/lib/libintl.a
270if not errorlevel 0 goto MissingNLSTools
271
272Rem Recreate the files in the %XSRC%/po subdir with our ported tools.
273redir -e /dev/null rm %XSRC%/po/*.gmo
274redir -e /dev/null rm %XSRC%/po/sed.pot
275redir -e /dev/null rm %XSRC%/po/cat-id-tbl.c
276redir -e /dev/null rm %XSRC%/po/stamp-cat-id
277
278Rem Update the arguments file for the configure script.
279Rem We prefer without-included-gettext because libintl.a from gettext package
280Rem is the only one that is garanteed to have been ported to DJGPP.
281echo --enable-nls --without-included-gettext >> arguments
282goto ConfigurePackage
283
284:MissingNLSTools
285echo Needed libs/tools for NLS not found. Configuring without NLS.
286:WithoutNLS
287Rem Update the arguments file for the configure script.
288echo --disable-nls >> arguments
289
290:ConfigurePackage
291echo Running the ./configure script...
292sh ./configure @arguments
293if errorlevel 1 goto CfgError
294rm arguments
295echo Done.
296goto End
297
298:SedError
299echo ./configure script editing failed!
300goto End
301
302:CfgError
303echo ./configure script exited abnormally!
304goto End
305
306:SmallEnv
307echo Your environment size is too small.  Enlarge it and run me again.
308echo Configuration NOT done!
309
310:End
311test -f %XSRC%/install-sh.sh
312if not errorlevel 1 goto NoRen1
313test -f %XSRC%/install-sh
314if not errorlevel 1 mv -f %XSRC%/install-sh %XSRC%/install-sh.sh
315:NoRen1
316set CONFIG_SITE=
317set HOSTNAME=
318set XSRC=
319