1@echo off
2
3echo Configuring GNU Diffutils for DJGPP v2.x...
4
5Rem Copyright (C) 2001 Free Software Foundation, Inc.
6
7Rem This program is free software; you can redistribute it and/or modify
8Rem it under the terms of the GNU General Public License as published by
9Rem the Free Software Foundation; either version 2, or (at your option)
10Rem any later version.
11
12Rem This program is distributed in the hope that it will be useful,
13Rem but WITHOUT ANY WARRANTY; without even the implied warranty of
14Rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15Rem GNU General Public License for more details.
16
17Rem You should have received a copy of the GNU General Public License
18Rem along with this program; if not, write to the Free Software
19Rem Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20Rem 02111-1307, USA.
21
22Rem Written by Eli Zaretskii.
23
24
25Rem The small_env tests protect against fixed and too small size
26Rem of the environment in stock DOS shell.
27
28Rem Find out if NLS is wanted or not,
29Rem if dependency-tracking is wanted or not,
30Rem if cache is wanted or not
31Rem and where the sources are.
32set ARGS=
33set NLS=disabled
34if not "%NLS%" == "disabled" goto small_env
35set CACHE=enabled
36if not "%CACHE%" == "enabled" goto small_env
37set DEPENDENCY_TRACKING=disabled
38if not "%DEPENDENCY_TRACKING%" == "disabled" goto small_env
39set XSRC=.
40if not "%XSRC%" == "." goto small_env
41
42Rem Loop over all arguments.
43Rem Special arguments are: NLS, XSRC CACHE and DEPS.
44Rem All other arguments are stored into ARGS.
45:arg_loop
46set SPECIAL_ARG_SEEN=0
47if not "%SPECIAL_ARG_SEEN%" == "0" goto small_env
48if "%1" == "NLS" goto nls_on
49if not "%1" == "nls" goto CacheOpt
50:nls_on
51if "%1" == "nls" set NLS=enabled
52if "%1" == "NLS" set NLS=enabled
53if not "%NLS%" == "enabled" goto small_env
54set SPECIAL_ARG_SEEN=1
55if not "%SPECIAL_ARG_SEEN%" == "1" goto small_env
56shift
57:CacheOpt
58set SPECIAL_ARG_SEEN=0
59if not "%SPECIAL_ARG_SEEN%" == "0" goto small_env
60if "%1" == "no-cache" goto cache_off
61if "%1" == "no-CACHE" goto cache_off
62if not "%1" == "NO-CACHE" goto dependency_opt
63:cache_off
64if "%1" == "no-cache" set CACHE=disabled
65if "%1" == "no-CACHE" set CACHE=disabled
66if "%1" == "NO-CACHE" set CACHE=disabled
67if not "%CACHE%" == "disabled" goto small_env
68set SPECIAL_ARG_SEEN=1
69if not "%SPECIAL_ARG_SEEN%" == "1" goto small_env
70shift
71:dependency_opt
72set SPECIAL_ARG_SEEN=0
73if not "%SPECIAL_ARG_SEEN%" == "0" goto small_env
74if "%1" == "dep" goto dep_off
75if not "%1" == "DEP" goto src_dir_opt
76:dep_off
77if "%1" == "dep" set DEPENDENCY_TRACKING=enabled
78if "%1" == "DEP" set DEPENDENCY_TRACKING=enabled
79if not "%DEPENDENCY_TRACKING%" == "enabled" goto small_env
80set SPECIAL_ARG_SEEN=1
81if not "%SPECIAL_ARG_SEEN%" == "1" goto small_env
82shift
83:src_dir_opt
84set SPECIAL_ARG_SEEN=0
85if not "%SPECIAL_ARG_SEEN%" == "0" goto small_env
86echo %1 | grep -q "/"
87if errorlevel 1 goto collect_arg
88set XSRC=%1
89if not "%XSRC%" == "%1" goto small_env
90set SPECIAL_ARG_SEEN=1
91if not "%SPECIAL_ARG_SEEN%" == "1" goto small_env
92:collect_arg
93if "%SPECIAL_ARG_SEEN%" == "0" set _ARGS=%ARGS% %1
94if "%SPECIAL_ARG_SEEN%" == "0" if not "%_ARGS%" == "%ARGS% %1" goto small_env
95echo %_ARGS% | grep -q "[^ ]"
96if not errorlevel 0 set ARGS=%_ARGS%
97set _ARGS=
98shift
99if not "%1" == "" goto arg_loop
100set SPECIAL_ARG_SEEN=
101
102Rem Create a response file for the configure script.
103echo --srcdir=%XSRC% > arguments
104if "%CACHE%" == "enabled"                echo --config-cache >> arguments
105if "%DEPENDENCY_TRACKING%" == "enabled"  echo --enable-dependency-tracking >> arguments
106if "%DEPENDENCY_TRACKING%" == "disabled" echo --disable-dependency-tracking >> arguments
107if not "%ARGS%" == ""                    echo %ARGS% >> arguments
108set ARGS=
109set CACHE=
110set DEPENDENCY_TRACKING=
111
112if "%XSRC%" == "." goto in_place
113
114:not_in_place
115redir -e /dev/null update %XSRC%/configure.orig ./configure
116test -f ./configure
117if errorlevel 1 update %XSRC%/configure ./configure
118
119:in_place
120Rem Update configuration files
121echo Updating configuration scripts...
122test -f ./configure.orig
123if errorlevel 1 update configure configure.orig
124sed -f %XSRC%/ms/config.sed configure.orig > configure
125if errorlevel 1 goto sed_error
126
127Rem Make sure they have a config.site file
128set CONFIG_SITE=%XSRC%/ms/config.site
129if not "%CONFIG_SITE%" == "%XSRC%/ms/config.site" goto small_env
130
131Rem Make sure crucial file names are not munged by unpacking
132test -f %XSRC%/po/Makefile.in.in
133if not errorlevel 1 mv -f %XSRC%/po/Makefile.in.in %XSRC%/po/Makefile.in-in
134test -f %XSRC%/m4/Makefile.am.in
135if not errorlevel 1 mv -f %XSRC%/m4/Makefile.am.in %XSRC%/m4/Makefile.am-in
136
137Rem This is required because DOS/Windows are case-insensitive
138Rem to file names, and "make install" will do nothing if Make
139Rem finds a file called `install'.
140if exist INSTALL ren INSTALL INSTALL.txt
141
142Rem Set HOME to a sane default so configure stops complaining.
143if not "%HOME%" == "" goto HostName
144set HOME=%XSRC%/ms
145if not "%HOME%" == "%XSRC%/ms" goto small_env
146echo No HOME found in the environment, using default value
147
148:HostName
149Rem Set HOSTNAME so it shows in config.status
150if not "%HOSTNAME%" == "" goto hostdone
151if "%windir%" == "" goto msdos
152set OS=MS-Windows
153if not "%OS%" == "MS-Windows" goto small_env
154goto haveos
155:msdos
156set OS=MS-DOS
157if not "%OS%" == "MS-DOS" goto small_env
158:haveos
159if not "%USERNAME%" == "" goto haveuname
160if not "%USER%" == "" goto haveuser
161echo No USERNAME and no USER found in the environment, using default values
162set HOSTNAME=Unknown PC
163if not "%HOSTNAME%" == "Unknown PC" goto small_env
164goto userdone
165:haveuser
166set HOSTNAME=%USER%'s PC
167if not "%HOSTNAME%" == "%USER%'s PC" goto small_env
168goto userdone
169:haveuname
170set HOSTNAME=%USERNAME%'s PC
171if not "%HOSTNAME%" == "%USERNAME%'s PC" goto small_env
172:userdone
173set _HOSTNAME=%HOSTNAME%, %OS%
174if not "%_HOSTNAME%" == "%HOSTNAME%, %OS%" goto small_env
175set HOSTNAME=%_HOSTNAME%
176:hostdone
177set _HOSTNAME=
178set OS=
179
180Rem install-sh is required by the configure script but clashes with the
181Rem various Makefile install-foo targets, so we MUST have it before the
182Rem script runs and rename it afterwards
183test -f %XSRC%/install-sh
184if not errorlevel 1 goto no_ren0
185test -f %XSRC%/install-sh.sh
186if not errorlevel 1 mv -f %XSRC%/install-sh.sh %XSRC%/install-sh
187:no_ren0
188
189if "%NLS%" == "disabled" goto without_NLS
190
191:with_NLS
192Rem Check for the needed libraries and binaries.
193test -x /dev/env/DJDIR/bin/msgfmt.exe
194if not errorlevel 0 goto missing_NLS_tools
195test -x /dev/env/DJDIR/bin/xgettext.exe
196if not errorlevel 0 goto missing_NLS_tools
197test -f /dev/env/DJDIR/include/libcharset.h
198if not errorlevel 0 goto missing_NLS_tools
199test -f /dev/env/DJDIR/lib/libcharset.a
200if not errorlevel 0 goto missing_NLS_tools
201test -f /dev/env/DJDIR/include/iconv.h
202if not errorlevel 0 goto missing_NLS_tools
203test -f /dev/env/DJDIR/lib/libiconv.a
204if not errorlevel 0 goto missing_NLS_tools
205test -f /dev/env/DJDIR/include/libintl.h
206if not errorlevel 0 goto missing_NLS_tools
207test -f /dev/env/DJDIR/lib/libintl.a
208if not errorlevel 0 goto missing_NLS_tools
209
210Rem Recreate the files in the %XSRC%/po subdir with our ported tools.
211redir -e /dev/null rm %XSRC%/po/*.gmo
212redir -e /dev/null rm %XSRC%/po/diffutil*.pot
213redir -e /dev/null rm %XSRC%/po/cat-id-tbl.c
214redir -e /dev/null rm %XSRC%/po/stamp-cat-id
215
216Rem Update the arguments file for the configure script.
217Rem We prefer without-included-gettext because libintl.a from gettext package
218Rem is the only one that is guaranteed to have been ported to DJGPP.
219echo --enable-nls --without-included-gettext >> arguments
220goto configure_package
221
222:missing_NLS_tools
223echo Needed libs/tools for NLS not found. Configuring without NLS.
224:without_NLS
225Rem Update the arguments file for the configure script.
226echo --disable-nls >> arguments
227
228:configure_package
229echo Running the ./configure script...
230sh ./configure @arguments
231if errorlevel 1 goto cfg_error
232rm arguments
233echo Done.
234goto End
235
236:sed_error
237echo ./configure script editing failed!
238goto End
239
240:cfg_error
241echo ./configure script exited abnormally!
242goto End
243
244:small_env
245echo Your environment size is too small.  Enlarge it and run me again.
246echo Configuration NOT done!
247
248:End
249test -f %XSRC%/install-sh.sh
250if not errorlevel 1 goto no_ren1
251test -f %XSRC%/install-sh
252if not errorlevel 1 mv -f %XSRC%/install-sh %XSRC%/install-sh.sh
253:no_ren1
254if "%HOME%" == "%XSRC%/ms" set HOME=
255set ARGS=
256set CONFIG_SITE=
257set HOSTNAME=
258set NLS=
259set CACHE=
260set DEPENDENCY_TRACKING=
261set XSRC=
262