(Fforward_comment): Use type int for `from' and `from_byte'.
[emacs.git] / nt / configure.bat
blobffc11542ce0c042010776a1f7ede2896593a4198
1 @echo off\r
2 rem   ----------------------------------------------------------------------\r
3 rem   Configuration script for MS Windows 95/98/Me and NT/2000/XP\r
4 rem   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005,\r
5 rem      2006 Free Software Foundation, Inc.\r
6 \r
7 rem   This file is part of GNU Emacs.\r
8 \r
9 rem   GNU Emacs is free software; you can redistribute it and/or modify\r
10 rem   it under the terms of the GNU General Public License as published by\r
11 rem   the Free Software Foundation; either version 2, or (at your option)\r
12 rem   any later version.\r
14 rem   GNU Emacs is distributed in the hope that it will be useful,\r
15 rem   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16 rem   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17 rem   GNU General Public License for more details.\r
19 rem   You should have received a copy of the GNU General Public License\r
20 rem   along with GNU Emacs; see the file COPYING.  If not, write to the\r
21 rem   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,\r
22 rem   Boston, MA 02110-1301, USA.\r
23 rem   ----------------------------------------------------------------------\r
24 rem   YOU'LL NEED THE FOLLOWING UTILITIES TO MAKE EMACS:\r
25 rem\r
26 rem   + MS Windows 95/98/Me or NT/2000/XP\r
27 rem   + either MSVC 2.x or later, or gcc-2.95 or later (with gmake 3.75\r
28 rem     or later) and the Mingw32 and W32 API headers and libraries\r
29 rem\r
30 rem For reference, here is a list of which builds of gmake are known to\r
31 rem work or not, and whether they work in the presence and/or absence of\r
32 rem sh.exe.\r
33 rem\r
34 rem                                       sh exists     no sh\r
35 rem  cygwin b20.1 make (3.75):            okay[1]       fails[2]\r
36 rem  MSVC compiled gmake 3.77:            okay          okay\r
37 rem  MSVC compiled gmake 3.78.1:          okay          okay\r
38 rem  MSVC compiled gmake 3.79.1:          okay          okay\r
39 rem  mingw32/gcc-2.92.2 make (3.77):      okay          okay\r
40 rem  cygwin compiled gmake 3.77:          okay[1]       fails[2]\r
41 rem  cygwin compiled gmake 3.78.1:        okay          fails[2]\r
42 rem  cygwin compiled gmake 3.79.1:        couldn't build make[3]\r
43 rem\r
44 rem [1] doesn't cope with makefiles with DOS line endings, so must mount\r
45 rem     emacs source with text!=binary.\r
46 rem [2] fails when needs to invoke shell commands; okay invoking gcc etc.\r
47 rem [3] requires LC_MESSAGES support to build; maybe 2.95.x update to\r
48 rem     cygwin provides this?\r
49 rem\r
51 if exist config.log del config.log\r
53 rem ----------------------------------------------------------------------\r
54 rem   See if the environment is large enough.  We need 43 (?) bytes.\r
55 set $foo$=123456789_123456789_123456789_123456789_123\r
56 if not "%$foo$%" == "123456789_123456789_123456789_123456789_123" goto SmallEnv\r
57 set $foo$=\r
59 rem ----------------------------------------------------------------------\r
60 rem   Make sure we are running in the nt subdir\r
61 if exist configure.bat goto start\r
62 echo You must run configure from the nt subdirectory.\r
63 goto end\r
65 :start\r
66 rem ----------------------------------------------------------------------\r
67 rem   Default settings.\r
68 set prefix=\r
69 set nodebug=N\r
70 set noopt=N\r
71 set nocygwin=N\r
72 set COMPILER=\r
73 set usercflags=\r
74 set userldflags=\r
75 set sep1=\r
76 set sep2=\r
78 rem ----------------------------------------------------------------------\r
79 rem   Handle arguments.\r
80 :again\r
81 if "%1" == "-h" goto usage\r
82 if "%1" == "--help" goto usage\r
83 if "%1" == "--prefix" goto setprefix\r
84 if "%1" == "--with-gcc" goto withgcc\r
85 if "%1" == "--with-msvc" goto withmsvc\r
86 if "%1" == "--no-debug" goto nodebug\r
87 if "%1" == "--no-opt" goto noopt\r
88 if "%1" == "--no-cygwin" goto nocygwin\r
89 if "%1" == "--cflags" goto usercflags\r
90 if "%1" == "--ldflags" goto userldflags\r
91 if "%1" == "--without-png" goto withoutpng\r
92 if "%1" == "--without-jpeg" goto withoutjpeg\r
93 if "%1" == "--without-gif" goto withoutgif\r
94 if "%1" == "--without-tiff" goto withouttiff\r
95 if "%1" == "--without-xpm" goto withoutxpm\r
96 if "%1" == "" goto checkutils\r
97 :usage\r
98 echo Usage: configure [options]\r
99 echo Options:\r
100 echo.   --prefix PREFIX         install Emacs in directory PREFIX\r
101 echo.   --with-gcc              use GCC to compile Emacs\r
102 echo.   --with-msvc             use MSVC to compile Emacs\r
103 echo.   --no-debug              exclude debug info from executables\r
104 echo.   --no-opt                disable optimization\r
105 echo.   --no-cygwin             use -mno-cygwin option with GCC\r
106 echo.   --cflags FLAG           pass FLAG to compiler\r
107 echo.   --ldflags FLAG          pass FLAG to compiler when linking\r
108 echo.   --without-png           do not use libpng even if it is installed\r
109 echo.   --without-jpeg          do not use jpeg-6b even if it is installed\r
110 echo.   --without-gif           do not use libungif even if it is installed\r
111 echo.   --without-tiff          do not use libtiff even if it is installed\r
112 echo.   --without-xpm           do not use libXpm even if it is installed\r
113 goto end\r
114 rem ----------------------------------------------------------------------\r
115 :setprefix\r
116 shift\r
117 set prefix=%1\r
118 shift\r
119 goto again\r
120 rem ----------------------------------------------------------------------\r
121 :withgcc\r
122 set COMPILER=gcc\r
123 shift\r
124 goto again\r
125 rem ----------------------------------------------------------------------\r
126 :withmsvc\r
127 set COMPILER=cl\r
128 shift\r
129 goto again\r
130 rem ----------------------------------------------------------------------\r
131 :nodebug\r
132 set nodebug=Y\r
133 shift\r
134 goto again\r
135 rem ----------------------------------------------------------------------\r
136 :noopt\r
137 set noopt=Y\r
138 shift\r
139 goto again\r
140 rem ----------------------------------------------------------------------\r
141 :nocygwin\r
142 set nocygwin=Y\r
143 shift\r
144 goto again\r
145 rem ----------------------------------------------------------------------\r
146 :usercflags\r
147 shift\r
148 set usercflags=%usercflags%%sep1%%1\r
149 set sep1= %nothing%\r
150 shift\r
151 goto again\r
152 rem ----------------------------------------------------------------------\r
153 :userldflags\r
154 shift\r
155 set userldflags=%userldflags%%sep2%%1\r
156 set sep2= %nothing%\r
157 shift\r
158 goto again\r
159 rem ----------------------------------------------------------------------\r
161 :withoutpng\r
162 set pngsupport=N\r
163 set HAVE_PNG=\r
164 shift\r
165 goto again\r
167 rem ----------------------------------------------------------------------\r
169 :withoutjpeg\r
170 set jpegsupport=N\r
171 set HAVE_JPEG=\r
172 shift\r
173 goto again\r
175 rem ----------------------------------------------------------------------\r
177 :withoutgif\r
178 set gifsupport=N\r
179 set HAVE_GIF=\r
180 shift\r
181 goto again\r
183 rem ----------------------------------------------------------------------\r
185 :withouttiff\r
186 set tiffsupport=N\r
187 set HAVE_TIFF=\r
188 shift\r
189 goto again\r
191 rem ----------------------------------------------------------------------\r
193 :withoutxpm\r
194 set xpmsupport=N\r
195 set HAVE_XPM=\r
196 shift\r
197 goto again\r
199 rem ----------------------------------------------------------------------\r
200 rem    Check that necessary utilities (cp and rm) are present.\r
201 :checkutils\r
202 echo Checking for 'cp'...\r
203 cp configure.bat junk.bat\r
204 if not exist junk.bat goto needcp\r
205 echo Checking for 'rm'...\r
206 rm junk.bat\r
207 if exist junk.bat goto needrm\r
208 goto checkcompiler\r
209 :needcp\r
210 echo You need 'cp' (the Unix file copy program) to build Emacs.\r
211 goto end\r
212 :needrm\r
213 del junk.bat\r
214 echo You need 'rm' (the Unix file delete program) to build Emacs.\r
215 goto end\r
217 rem ----------------------------------------------------------------------\r
218 rem   Auto-detect compiler if not specified, and validate GCC if chosen.\r
219 :checkcompiler\r
220 if (%COMPILER%)==(cl) goto compilercheckdone\r
221 if (%COMPILER%)==(gcc) goto checkgcc\r
223 echo Checking whether 'cl' is available...\r
224 echo main(){} >junk.c\r
225 cl -nologo -c junk.c\r
226 if exist junk.obj goto clOK\r
228 echo Checking whether 'gcc' is available...\r
229 gcc -c junk.c\r
230 if not exist junk.o goto nocompiler\r
231 del junk.o\r
233 :checkgcc\r
234 Rem WARNING -- COMMAND.COM on some systems only looks at the first\r
235 Rem            8 characters of a label.  So do NOT be tempted to change\r
236 Rem            chkapi* into something fancier like checkw32api\r
237 Rem You HAVE been warned!\r
238 if (%nocygwin%) == (Y) goto chkapi\r
239 echo Checking whether gcc requires '-mno-cygwin'...\r
240 echo #include "cygwin/version.h" >junk.c\r
241 echo main(){} >>junk.c\r
242 echo gcc -c junk.c >>config.log\r
243 gcc -c junk.c >>config.log 2>&1\r
244 if not exist junk.o goto chkapi\r
245 echo gcc -mno-cygwin -c junk.c >>config.log\r
246 gcc -mno-cygwin -c junk.c >>config.log 2>&1\r
247 if exist junk.o set nocygwin=Y\r
248 rm -f junk.c junk.o\r
250 :chkapi\r
251 echo The failed program was: >>config.log\r
252 type junk.c >>config.log\r
253 rem ----------------------------------------------------------------------\r
254 rem   Older versions of the Windows API headers either don't have any of\r
255 rem   the IMAGE_xxx definitions (the headers that come with Cygwin b20.1\r
256 rem   are like this), or have a typo in the definition of\r
257 rem   IMAGE_FIRST_SECTION (the headers with gcc/mingw32 2.95 have this\r
258 rem   problem).  The gcc/mingw32 2.95.2 headers are okay, as are distros\r
259 rem   of w32api-xxx.zip from Anders Norlander since 1999-11-18 at least.\r
260 rem\r
261 echo Checking whether W32 API headers are too old...\r
262 echo #include "windows.h" >junk.c\r
263 echo test(PIMAGE_NT_HEADERS pHeader) >>junk.c\r
264 echo {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);} >>junk.c\r
265 if (%nocygwin%) == (Y) goto chkapi1\r
266 set cf=%usercflags%\r
267 goto chkapi2\r
268 :chkapi1\r
269 set cf=%usercflags% -mno-cygwin\r
270 :chkapi2\r
271 echo on\r
272 gcc %cf% -c junk.c\r
273 @echo off\r
274 @echo gcc %cf% -c junk.c >>config.log\r
275 gcc %cf% -c junk.c >>config.log 2>&1\r
276 set cf=\r
277 if exist junk.o goto gccOk\r
278 echo The failed program was: >>config.log\r
279 type junk.c >>config.log\r
281 :nocompiler\r
282 echo.\r
283 echo Configure failed.\r
284 echo To configure Emacs for Windows, you need to have either\r
285 echo gcc-2.95 or later with Mingw32 and the W32 API headers,\r
286 echo or MSVC 2.x or later.\r
287 del junk.c\r
288 goto end\r
290 :gccOk\r
291 set COMPILER=gcc\r
292 echo Using 'gcc'\r
293 rm -f junk.c junk.o\r
294 Rem It is not clear what GCC version began supporting -mtune\r
295 Rem and pentium4 on x86, so check this explicitly.\r
296 echo main(){} >junk.c\r
297 echo gcc -c -O2 -mtune=pentium4 junk.c >>config.log\r
298 gcc -c -O2 -mtune=pentium4 junk.c >>config.log 2>&1\r
299 if not errorlevel 1 goto gccMtuneOk\r
300 echo The failed program was: >>config.log\r
301 type junk.c >>config.log\r
302 set mf=-mcpu=i686\r
303 rm -f junk.c junk.o\r
304 goto compilercheckdone\r
305 :gccMtuneOk\r
306 echo GCC supports -mtune=pentium4 >>config.log\r
307 set mf=-mtune=pentium4\r
308 rm -f junk.c junk.o\r
309 goto compilercheckdone\r
311 :clOk\r
312 set COMPILER=cl\r
313 rm -f junk.c junk.obj\r
314 echo Using 'MSVC'\r
316 :compilercheckdone\r
318 rem ----------------------------------------------------------------------\r
319 rem   Check for external image libraries. Since they are loaded\r
320 rem   dynamically, the libraries themselves do not need to be present\r
321 rem   at compile time, but the header files are required.\r
323 set mingwflag=\r
325 if (%nocygwin%) == (N) goto flagsOK\r
326 set mingwflag=-mno-cygwin\r
328 :flagsOK\r
330 if (%pngsupport%) == (N) goto pngDone\r
332 echo Checking for libpng...\r
333 echo #include "png.h" >junk.c\r
334 echo main (){} >>junk.c\r
335 rem   -o option is ignored with cl, but allows result to be consistent.\r
336 echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
337 %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
338 if exist junk.obj goto havePng\r
340 echo ...png.h not found, building without PNG support.\r
341 echo The failed program was: >>config.log\r
342 type junk.c >>config.log\r
343 set HAVE_PNG=\r
344 goto :pngDone\r
346 :havePng\r
347 echo ...PNG header available, building with PNG support.\r
348 set HAVE_PNG=1\r
350 :pngDone\r
351 rm -f junk.c junk.obj\r
353 if (%jpegsupport%) == (N) goto jpegDone\r
355 echo Checking for jpeg-6b...\r
356 echo #include "jconfig.h" >junk.c\r
357 echo main (){} >>junk.c\r
358 rem   -o option is ignored with cl, but allows result to be consistent.\r
359 echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
360 %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
361 if exist junk.obj goto haveJpeg\r
363 echo ...jconfig.h not found, building without JPEG support.\r
364 echo The failed program was: >>config.log\r
365 type junk.c >>config.log\r
366 set HAVE_JPEG=\r
367 goto :jpegDone\r
369 :haveJpeg\r
370 echo ...JPEG header available, building with JPEG support.\r
371 set HAVE_JPEG=1\r
373 :jpegDone\r
374 rm -f junk.c junk.obj\r
376 if (%gifsupport%) == (N) goto gifDone\r
378 echo Checking for libgif...\r
379 echo #include "gif_lib.h" >junk.c\r
380 echo main (){} >>junk.c\r
381 rem   -o option is ignored with cl, but allows result to be consistent.\r
382 echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
383 %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
384 if exist junk.obj goto haveGif\r
386 echo ...gif_lib.h not found, building without GIF support.\r
387 echo The failed program was: >>config.log\r
388 type junk.c >>config.log\r
389 set HAVE_GIF=\r
390 goto :gifDone\r
392 :haveGif\r
393 echo ...GIF header available, building with GIF support.\r
394 set HAVE_GIF=1\r
396 :gifDone\r
397 rm -f junk.c junk.obj\r
399 if (%tiffsupport%) == (N) goto tiffDone\r
401 echo Checking for tiff...\r
402 echo #include "tiffio.h" >junk.c\r
403 echo main (){} >>junk.c\r
404 rem   -o option is ignored with cl, but allows result to be consistent.\r
405 echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
406 %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
407 if exist junk.obj goto haveTiff\r
409 echo ...tiffio.h not found, building without TIFF support.\r
410 echo The failed program was: >>config.log\r
411 type junk.c >>config.log\r
412 set HAVE_TIFF=\r
413 goto :tiffDone\r
415 :haveTiff\r
416 echo ...TIFF header available, building with TIFF support.\r
417 set HAVE_TIFF=1\r
419 :tiffDone\r
420 rm -f junk.c junk.obj\r
422 if (%xpmsupport%) == (N) goto xpmDone\r
424 echo Checking for libXpm...\r
425 echo #define FOR_MSW 1 >junk.c\r
426 echo #include "X11/xpm.h" >>junk.c\r
427 echo main (){} >>junk.c\r
428 rem   -o option is ignored with cl, but allows result to be consistent.\r
429 echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
430 %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
431 if exist junk.obj goto haveXpm\r
433 echo ...X11/xpm.h not found, building without XPM support.\r
434 echo The failed program was: >>config.log\r
435 type junk.c >>config.log\r
436 set HAVE_XPM=\r
437 goto :xpmDone\r
439 :haveXpm\r
440 echo ...XPM header available, building with XPM support.\r
441 set HAVE_XPM=1\r
443 :xpmDone\r
444 rm -f junk.c junk.obj junk.err junk.out\r
446 rem ----------------------------------------------------------------------\r
447 :genmakefiles\r
448 echo Generating makefiles\r
449 if %COMPILER% == gcc set MAKECMD=gmake\r
450 if %COMPILER% == cl set MAKECMD=nmake\r
452 rem   Pass on chosen settings to makefiles.\r
453 rem   NB. Be very careful to not have a space before redirection symbols\r
454 rem   except when there is a preceding digit, when a space is required.\r
455 rem\r
456 echo # Start of settings from configure.bat >config.settings\r
457 echo COMPILER=%COMPILER%>>config.settings\r
458 if not "(%mf%)" == "()" echo MCPU_FLAG=%mf%>>config.settings\r
459 if (%nodebug%) == (Y) echo NODEBUG=1 >>config.settings\r
460 if (%noopt%) == (Y) echo NOOPT=1 >>config.settings\r
461 if (%nocygwin%) == (Y) echo NOCYGWIN=1 >>config.settings\r
462 if not "(%prefix%)" == "()" echo INSTALL_DIR=%prefix%>>config.settings\r
463 if not "(%usercflags%)" == "()" echo USER_CFLAGS=%usercflags%>>config.settings\r
464 if not "(%userldflags%)" == "()" echo USER_LDFLAGS=%userldflags%>>config.settings\r
465 echo # End of settings from configure.bat>>config.settings\r
466 echo. >>config.settings\r
468 copy config.nt config.tmp\r
469 echo. >>config.tmp\r
470 echo /* Start of settings from configure.bat.  */ >>config.tmp\r
471 if not "(%usercflags%)" == "()" echo #define USER_CFLAGS " %usercflags%">>config.tmp\r
472 if not "(%userldflags%)" == "()" echo #define USER_LDFLAGS " %userldflags%">>config.tmp\r
473 if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>config.tmp\r
474 if not "(%HAVE_JPEG%)" == "()" echo #define HAVE_JPEG 1 >>config.tmp\r
475 if not "(%HAVE_GIF%)" == "()" echo #define HAVE_GIF 1 >>config.tmp\r
476 if not "(%HAVE_TIFF%)" == "()" echo #define HAVE_TIFF 1 >>config.tmp\r
477 if not "(%HAVE_XPM%)" == "()" echo #define HAVE_XPM 1 >>config.tmp\r
478 echo /* End of settings from configure.bat.  */ >>config.tmp\r
480 Rem See if fc.exe returns a meaningful exit status.  If it does, we\r
481 Rem might as well avoid unnecessary overwriting of config.h and epaths.h,\r
482 Rem since this forces recompilation of every source file.\r
483 if exist foo.bar del foo.bar\r
484 fc /b foo.bar foo.bar >nul 2>&1\r
485 if not errorlevel 2 goto doCopy\r
486 fc /b config.tmp ..\src\config.h >nul 2>&1\r
487 if errorlevel 1 goto doCopy\r
488 fc /b paths.h ..\src\epaths.h >nul 2>&1\r
489 if errorlevel 0 goto dontCopy\r
490 :doCopy\r
491 copy config.tmp ..\src\config.h\r
492 copy paths.h ..\src\epaths.h\r
494 :dontCopy\r
495 if exist config.tmp del config.tmp\r
496 copy /b config.settings+%MAKECMD%.defs+..\nt\makefile.w32-in ..\nt\makefile\r
497 copy /b config.settings+%MAKECMD%.defs+..\lib-src\makefile.w32-in ..\lib-src\makefile\r
498 copy /b config.settings+%MAKECMD%.defs+..\src\makefile.w32-in ..\src\makefile\r
499 copy /b config.settings+%MAKECMD%.defs+..\man\makefile.w32-in ..\man\makefile\r
500 copy /b config.settings+%MAKECMD%.defs+..\lispref\makefile.w32-in ..\lispref\makefile\r
501 copy /b config.settings+%MAKECMD%.defs+..\lispintro\makefile.w32-in ..\lispintro\makefile\r
502 if exist ..\lisp\makefile rm -f ../lisp/[Mm]akefile\r
503 copy /b config.settings+%MAKECMD%.defs+..\lisp\makefile.w32-in ..\lisp\makefile\r
504 rem   Use the default (no-op) Makefile.in if the nt version is not present.\r
505 if exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\makefile.w32-in ..\leim\makefile\r
506 if not exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\Makefile.in ..\leim\makefile\r
507 del config.settings\r
509 Rem Some people use WinZip which doesn't create empty directories!\r
510 if not exist ..\site-lisp\nul mkdir ..\site-lisp\\r
511 if not exist ..\site-lisp\subdirs.el copy subdirs.el ..\site-lisp\subdirs.el\r
513 echo.\r
514 echo Emacs successfully configured.\r
515 echo Emacs successfully configured. >>config.log\r
516 echo Run `%MAKECMD%' to build, then run `%MAKECMD% install' to install.\r
517 goto end\r
519 :SmallEnv\r
520 echo Your environment size is too small.  Please enlarge it and rerun configure.\r
521 echo For example, type "command.com /e:2048" to have 2048 bytes available.\r
522 set $foo$=\r
523 :end\r
524 set prefix=\r
525 set nodebug=\r
526 set noopt=\r
527 set nocygwin=\r
528 set COMPILER=\r
529 set MAKECMD=\r
530 set usercflags=\r
531 set userldflags=\r
532 set mingwflag=\r
533 set mf=\r
535 goto skipArchTag\r
536    arch-tag: 300d20a4-1675-4e75-b615-7ce1a8c5376c\r
537 :skipArchTag\r