Merge from trunk.
[bpt/emacs.git] / config.bat
1 @echo off
2 rem ----------------------------------------------------------------------
3 rem Configuration script for MSDOS
4 rem Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003
5 rem 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
6 rem Inc.
7
8 rem This file is part of GNU Emacs.
9
10 rem GNU Emacs is free software: you can redistribute it and/or modify
11 rem it under the terms of the GNU General Public License as published by
12 rem the Free Software Foundation, either version 3 of the License, or
13 rem (at your option) any later version.
14
15 rem GNU Emacs is distributed in the hope that it will be useful,
16 rem but WITHOUT ANY WARRANTY; without even the implied warranty of
17 rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 rem GNU General Public License for more details.
19
20 rem You should have received a copy of the GNU General Public License
21 rem along with GNU Emacs. If not, see http://www.gnu.org/licenses/.
22
23 rem ----------------------------------------------------------------------
24 rem YOU'LL NEED THE FOLLOWING UTILITIES TO MAKE EMACS:
25 rem
26 rem + msdos version 3 or better.
27 rem + DJGPP version 2.0 or later (version 2.03 or later recommended).
28 rem + make utility that allows breaking of the 128 chars limit on
29 rem command lines. ndmake (as of version 4.5) won't work due to a
30 rem line length limit. The make that comes with DJGPP does work (and is
31 rem recommended).
32 rem + rm, mv, and cp (from GNU file utilities).
33 rem + sed (you can use the port that comes with DJGPP).
34 rem
35 rem You should be able to get all the above utilities from the DJGPP FTP
36 rem site, ftp.delorie.com, in the directory "pub/djgpp/current/v2gnu".
37 rem ----------------------------------------------------------------------
38 set X11=
39 set nodebug=
40 set djgpp_ver=
41 set sys_malloc=
42 set libxml=
43 if "%1" == "" goto usage
44 rem ----------------------------------------------------------------------
45 rem See if their environment is large enough. We need 28 bytes.
46 set $foo$=789012345678901234567
47 if not "%$foo$%" == "789012345678901234567" goto SmallEnv
48 set $foo$=
49 :again
50 if "%1" == "" goto usage
51 if "%1" == "--with-x" goto withx
52 if "%1" == "--no-debug" goto nodebug
53 if "%1" == "msdos" goto msdos
54 if "%1" == "--with-system-malloc" goto sysmalloc
55 :usage
56 echo Usage: config [--no-debug] [--with-system-malloc] [--with-x] msdos
57 echo [Read the script before you run it.]
58 goto end
59 rem ----------------------------------------------------------------------
60 :withx
61 set X11=Y
62 shift
63 goto again
64 rem ----------------------------------------------------------------------
65 :nodebug
66 set nodebug=Y
67 shift
68 goto again
69 rem ----------------------------------------------------------------------
70 :sysmalloc
71 set sys_malloc=Y
72 shift
73 goto again
74 rem ----------------------------------------------------------------------
75 :msdos
76 Echo Checking whether 'sed' is available...
77 sed -e "w junk.$$$" <Nul
78 If Exist junk.$$$ Goto sedOk
79 Echo To configure 'Emacs' you need to have 'sed'!
80 Goto End
81 :sedOk
82 Echo Checking whether 'rm' is available...
83 rm -f junk.$$$
84 If Not Exist junk.$$$ Goto rmOk
85 Echo To configure 'Emacs' you need to have 'rm'!
86 Goto End
87 :rmOk
88 Echo Checking whether 'mv' is available...
89 rm -f junk.1 junk.2
90 echo foo >junk.1
91 mv junk.1 ./junk.2
92 If Exist junk.2 Goto mvOk
93 Echo To configure 'Emacs' you need to have 'mv'!
94 rm -f junk.1
95 Goto End
96 :mvOk
97 rm -f junk.2
98 Echo Checking whether 'gcc' is available...
99 echo main(){} >junk.c
100 gcc -c junk.c
101 if exist junk.o goto gccOk
102 Echo To configure 'Emacs' you need to have 'gcc'!
103 rm -f junk.c
104 Goto End
105 :gccOk
106 rm -f junk.c junk.o junk junk.exe
107 Echo Checking what version of DJGPP is installed...
108 If Not "%DJGPP%" == "" goto djgppOk
109 Echo To compile 'Emacs' under MS-DOS you MUST have DJGPP installed!
110 Goto End
111 :djgppOk
112 echo int main() >junk.c
113 echo #ifdef __DJGPP__ >>junk.c
114 echo {return (__DJGPP__)*10;} >>junk.c
115 echo #else >>junk.c
116 echo #ifdef __GO32__ >>junk.c
117 echo {return 10;} >>junk.c
118 echo #else >>junk.c
119 echo {return 0;} >>junk.c
120 echo #endif >>junk.c
121 echo #endif >>junk.c
122 gcc -o junk junk.c
123 if not exist junk.exe coff2exe junk
124 junk
125 If ErrorLevel 10 Goto go32Ok
126 rm -f junk.c junk junk.exe
127 Echo To compile 'Emacs' under MS-DOS you MUST have DJGPP installed!
128 Goto End
129 :go32Ok
130 set djgpp_ver=2
131 If Not ErrorLevel 20 Echo To build 'Emacs' you need DJGPP v2.0 or later!
132 If Not ErrorLevel 20 Goto End
133 rm -f junk.c junk junk.exe
134 rem DJECHO is used by the top-level Makefile in the v2.x build
135 Echo Checking whether 'djecho' is available...
136 redir -o Nul -eo djecho -o junk.$$$ foo
137 If Exist junk.$$$ Goto djechoOk
138 Echo To build 'Emacs' you need the 'djecho.exe' program!
139 Echo 'djecho.exe' is part of 'djdevNNN.zip' basic DJGPP development kit.
140 Echo Versions of DJGPP before 2.02 called this program 'echo.exe'.
141 Echo Either unpack 'djecho.exe' from the 'djdevNNN.zip' archive,
142 Echo or, if you have 'echo.exe', copy it to 'djecho.exe'.
143 Echo Then run CONFIG.BAT again with the same arguments you did now.
144 Goto End
145 :djechoOk
146 rm -f junk.$$$
147 Echo Configuring for DJGPP Version %DJGPP_VER% ...
148 Rem ----------------------------------------------------------------------
149 Echo Configuring the source directory...
150 cd src
151
152 rem Create "epaths.h"
153 sed -f ../msdos/sed4.inp <epaths.in >epaths.tmp
154 update epaths.tmp epaths.h >nul
155 rm -f epaths.tmp
156
157 rem Create "config.h"
158 rm -f config.h2 config.tmp
159 if exist config.in sed -e '' config.in > config.tmp
160 if exist ..\autogen\config.in sed -e '' ../autogen/config.in > config.tmp
161 if "%X11%" == "" goto src4
162 if exist config.in sed -f ../msdos/sed2x.inp < config.in > config.tmp
163 if exist ..\autogen\config.in sed -f ../msdos/sed2x.inp < ..\autogen\config.in > config.tmp
164 :src4
165 sed -f ../msdos/sed2v2.inp <config.tmp >config.h2
166 Rem See if DECL_ALIGN can be supported with this GCC
167 rm -f junk.c junk.o junk junk.exe
168 echo struct { int i; char *p; } __attribute__((__aligned__(8))) foo; >junk.c
169 rem Two percent signs because it is a special character for COMMAND.COM/CMD
170 rem Filter thru Sed because "&" is special for CMD.EXE
171 echo int main(void) { return (unsigned long)"&"foo %% 8; } | sed "s/.&./\&/" >>junk.c
172 gcc -o junk junk.c
173 if not exist junk.exe coff2exe junk
174 junk
175 If Not ErrorLevel 1 Goto alignOk
176 Echo WARNING: Your GCC does not support 8-byte aligned variables.
177 Echo WARNING: Therefore Emacs cannot support buffers larger than 128MB.
178 rem The following line disables DECL_ALIGN which in turn disables USE_LSB_TAG
179 rem For details see lisp.h where it defines USE_LSB_TAG
180 echo #define NO_DECL_ALIGN >>config.h2
181 :alignOk
182 Rem See if they have libxml2 later than v2.2.0 installed
183 Echo Checking whether libxml2 v2.2.1 or later is installed ...
184 rm -f junk.c junk.o junk junk.exe
185 rem Use djecho here because we need to quote brackets
186 djecho "#include <libxml/xmlversion.h>" >junk.c
187 djecho "int main()" >>junk.c
188 djecho "{return (LIBXML_VERSION > 20200 ? 0 : 1);}" >>junk.c
189 redir -o Nul -eo gcc -I/dev/env/DJDIR/include/libxml2 -o junk junk.c
190 if not exist junk Goto xmlDone
191 if not exist junk.exe coff2exe junk
192 junk
193 If ErrorLevel 1 Goto xmlDone
194 Echo Configuring with libxml2 ...
195 sed -e "/#undef HAVE_LIBXML2/s/^.*$/#define HAVE_LIBXML2 1/" <config.h2 >config.h3
196 mv config.h3 config.h2
197 set libxml=1
198 :xmlDone
199 rm -f junk.c junk junk.exe
200 Rem See if they requested a SYSTEM_MALLOC build
201 if "%sys_malloc%" == "" Goto cfgDone
202 rm -f config.tmp
203 ren config.h2 config.tmp
204 sed -f ../msdos/sedalloc.inp <config.tmp >config.h2
205
206 :cfgDone
207 rm -f junk.c junk junk.exe
208 update config.h2 config.h >nul
209 rm -f config.tmp config.h2
210
211 rem On my system dir.h gets in the way. It's a VMS file so who cares.
212 if exist dir.h ren dir.h vmsdir.h
213
214 rem Create "makefile" from "makefile.in".
215 rm -f Makefile makefile.tmp
216 copy Makefile.in+lisp.mk+deps.mk makefile.tmp
217 sed -f ../msdos/sed1v2.inp <makefile.tmp >Makefile
218 rm -f makefile.tmp
219
220 if "%X11%" == "" goto src5
221 mv Makefile makefile.tmp
222 sed -f ../msdos/sed1x.inp <makefile.tmp >Makefile
223 rm -f makefile.tmp
224 :src5
225
226 if "%sys_malloc%" == "" goto src5a
227 sed -e "/^GMALLOC_OBJ *=/s/gmalloc.o//" <Makefile >makefile.tmp
228 sed -e "/^VMLIMIT_OBJ *=/s/vm-limit.o//" <makefile.tmp >makefile.tmp2
229 sed -e "/^RALLOC_OBJ *=/s/ralloc.o//" <makefile.tmp2 >Makefile
230 rm -f makefile.tmp makefile.tmp2
231 :src5a
232
233 if "%nodebug%" == "" goto src6
234 sed -e "/^CFLAGS *=/s/ *-gcoff//" <Makefile >makefile.tmp
235 sed -e "/^LDFLAGS *=/s/=/=-s/" <makefile.tmp >Makefile
236 rm -f makefile.tmp
237 :src6
238
239 if "%libxml%" == "" goto src7
240 sed -e "/^LIBXML2_LIBS *=/s/=/= -lxml2 -lz -liconv/" <Makefile >makefile.tmp
241 sed -e "/^LIBXML2_CFLAGS *=/s|=|= -I/dev/env/DJDIR/include/libxml2|" <makefile.tmp >Makefile
242 rm -f makefile.tmp
243 :src7
244 cd ..
245 rem ----------------------------------------------------------------------
246 Echo Configuring the library source directory...
247 cd lib-src
248 sed -f ../msdos/sed3v2.inp <Makefile.in >Makefile
249 if "%X11%" == "" goto libsrc2a
250 mv Makefile makefile.tmp
251 sed -f ../msdos/sed3x.inp <makefile.tmp >Makefile
252 rm -f makefile.tmp
253 :libsrc2a
254 if "%nodebug%" == "" goto libsrc3
255 sed -e "/^CFLAGS *=/s/ *-gcoff//" <Makefile >makefile.tmp
256 sed -e "/^ALL_CFLAGS *=/s/=/= -s/" <makefile.tmp >Makefile
257 rm -f makefile.tmp
258 :libsrc3
259 cd ..
260 rem ----------------------------------------------------------------------
261 if "%X11%" == "" goto oldx1
262 Echo Configuring the oldxmenu directory...
263 cd oldxmenu
264 sed -f ../msdos/sed5x.inp <Makefile.in >Makefile
265 if "%nodebug%" == "" goto oldx2
266 sed -e "/^CFLAGS *=/s/ *-gcoff//" <Makefile >makefile.tmp
267 mv -f makefile.tmp Makefile
268 :oldx2
269 cd ..
270 :oldx1
271 rem ----------------------------------------------------------------------
272 Echo Configuring the doc directory, expect one "File not found" message...
273 cd doc
274 Rem The two variants for lispintro below is for when the shell
275 Rem supports long file names but DJGPP does not
276 for %%d in (emacs lispref lispintro lispintr misc) do sed -f ../msdos/sed6.inp < %%d\Makefile.in > %%d\Makefile
277 cd ..
278 rem ----------------------------------------------------------------------
279 Echo Configuring the lib directory...
280 If Exist build-aux\snippet\c++defs.h update build-aux/snippet/c++defs.h build-aux/snippet/cxxdefs.h
281 cd lib
282 Rem Rename files like djtar on plain DOS filesystem would.
283 If Exist build-aux\snippet\c++defs.h update build-aux/snippet/c++defs.h build-aux/snippet/cxxdefs.h
284 If Exist alloca.in.h update alloca.in.h alloca.in-h
285 If Exist getopt.in.h update getopt.in.h getopt.in-h
286 If Exist stdbool.in.h update stdbool.in.h stdbool.in-h
287 If Exist signal.in.h update signal.in.h signal.in-h
288 If Exist stddef.in.h update stddef.in.h stddef.in-h
289 If Exist stdint.in.h update stdint.in.h stdint.in-h
290 If Exist stdio.in.h update stdio.in.h stdio.in-h
291 If Exist stdlib.in.h update stdlib.in.h stdlib.in-h
292 If Exist sys_stat.in.h update sys_stat.in.h sys_stat.in-h
293 If Exist time.in.h update time.in.h time.in-h
294 If Exist unistd.in.h update unistd.in.h unistd.in-h
295 If Exist Makefile.in sed -f ../msdos/sedlibcf.inp < Makefile.in > makefile.tmp
296 If Exist ..\autogen\Makefile.in sed -f ../msdos/sedlibcf.inp < ..\autogen\Makefile.in > makefile.tmp
297 sed -f ../msdos/sedlibmk.inp < makefile.tmp > Makefile
298 rm -f makefile.tmp
299 Rem Create .Po files for new files in lib/
300 If Not Exist deps\stamp mkdir deps
301 for %%f in (*.c) do @call ..\msdos\depfiles.bat %%f
302 echo deps-stamp > deps\stamp
303 cd ..
304 rem ----------------------------------------------------------------------
305 Echo Configuring the lisp directory...
306 cd lisp
307 If Exist gnus\.dir-locals.el update gnus/.dir-locals.el gnus/_dir-locals.el
308 sed -f ../msdos/sedlisp.inp < Makefile.in > Makefile
309 cd ..
310 rem ----------------------------------------------------------------------
311 If not Exist leim\quail\latin-pre.el goto maindir
312 Echo Configuring the leim directory...
313 cd leim
314 sed -f ../msdos/sedleim.inp < Makefile.in > Makefile
315 cd ..
316 rem ----------------------------------------------------------------------
317 :maindir
318 Echo Configuring the main directory...
319 If Exist .dir-locals.el update .dir-locals.el _dir-locals.el
320 If Exist src\.dbxinit update src/.dbxinit src/_dbxinit
321 Echo Looking for the GDB init file...
322 If Exist src\.gdbinit update src/.gdbinit src/_gdbinit
323 If Exist src\_gdbinit goto gdbinitOk
324 Echo ERROR:
325 Echo I cannot find the GDB init file. It was called ".gdbinit" in
326 Echo the Emacs distribution, but was probably renamed to some other
327 Echo name without the leading dot when you untarred the archive.
328 Echo It should be in the "src/" subdirectory. Please make sure this
329 Echo file exists and is called "_gdbinit" with a leading underscore.
330 Echo Then run CONFIG.BAT again with the same arguments you did now.
331 goto End
332 :gdbinitOk
333 Echo Looking for the GDB init file...found
334 rem GNUMakefile is not appropriate for MS-DOS so move it out of the way
335 If Exist GNUmakefile mv -f GNUmakefile GNUmakefile.unix
336 copy msdos\mainmake.v2 Makefile >nul
337 rem ----------------------------------------------------------------------
338 goto End
339 :SmallEnv
340 echo Your environment size is too small. Please enlarge it and run me again.
341 echo For example, type "command.com /e:2048" to have 2048 bytes available.
342 set $foo$=
343 :end
344 set X11=
345 set nodebug=
346 set djgpp_ver=
347 set sys_malloc=
348 set libxml=
349