(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
[emacs.git] / nt / configure.bat
blob216420873c73700662ced311a597a0786d75b4f0
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-2003 Free Software Foundation, Inc.\r
5 \r
6 rem   This file is part of GNU Emacs.\r
7 \r
8 rem   GNU Emacs is free software; you can redistribute it and/or modify\r
9 rem   it under the terms of the GNU General Public License as published by\r
10 rem   the Free Software Foundation; either version 2, or (at your option)\r
11 rem   any later version.\r
13 rem   GNU Emacs is distributed in the hope that it will be useful,\r
14 rem   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15 rem   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
16 rem   GNU General Public License for more details.\r
18 rem   You should have received a copy of the GNU General Public License\r
19 rem   along with GNU Emacs; see the file COPYING.  If not, write to the\r
20 rem   Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
21 rem   Boston, MA 02111-1307, USA.\r
22 rem   ----------------------------------------------------------------------\r
23 rem   YOU'LL NEED THE FOLLOWING UTILITIES TO MAKE EMACS:\r
24 rem\r
25 rem   + MS Windows 95/98/Me or NT/2000/XP\r
26 rem   + either MSVC 2.x or later, or gcc-2.95 or later (with gmake 3.75\r
27 rem     or later) and the Mingw32 and W32 API headers and libraries\r
28 rem\r
29 rem For reference, here is a list of which builds of gmake are known to\r
30 rem work or not, and whether they work in the presence and/or absence of\r
31 rem sh.exe.\r
32 rem\r
33 rem                                       sh exists     no sh\r
34 rem  cygwin b20.1 make (3.75):            okay[1]       fails[2]\r
35 rem  MSVC compiled gmake 3.77:            okay          okay\r
36 rem  MSVC compiled gmake 3.78.1:          okay          okay\r
37 rem  MSVC compiled gmake 3.79.1:          okay          okay\r
38 rem  mingw32/gcc-2.92.2 make (3.77):      okay          okay\r
39 rem  cygwin compiled gmake 3.77:          okay[1]       fails[2]\r
40 rem  cygwin compiled gmake 3.78.1:        okay          fails[2]\r
41 rem  cygwin compiled gmake 3.79.1:        couldn't build make[3]\r
42 rem\r
43 rem [1] doesn't cope with makefiles with DOS line endings, so must mount\r
44 rem     emacs source with text!=binary.\r
45 rem [2] fails when needs to invoke shell commands; okay invoking gcc etc.\r
46 rem [3] requires LC_MESSAGES support to build; maybe 2.95.x update to\r
47 rem     cygwin provides this?\r
48 rem\r
50 rem ----------------------------------------------------------------------\r
51 rem   See if the environment is large enough.  We need 43 (?) bytes.\r
52 set $foo$=123456789_123456789_123456789_123456789_123\r
53 if not "%$foo$%" == "123456789_123456789_123456789_123456789_123" goto SmallEnv\r
54 set $foo$=\r
56 rem ----------------------------------------------------------------------\r
57 rem   Make sure we are running in the nt subdir\r
58 if exist configure.bat goto start\r
59 echo You must run configure from the nt subdirectory.\r
60 goto end\r
62 :start\r
63 rem ----------------------------------------------------------------------\r
64 rem   Default settings.\r
65 set prefix=\r
66 set nodebug=N\r
67 set noopt=N\r
68 set nocygwin=N\r
69 set COMPILER=\r
70 set usercflags=\r
71 set userldflags=\r
72 set sep1=\r
73 set sep2=\r
75 rem ----------------------------------------------------------------------\r
76 rem   Handle arguments.\r
77 :again\r
78 if "%1" == "-h" goto usage\r
79 if "%1" == "--help" goto usage\r
80 if "%1" == "--prefix" goto setprefix\r
81 if "%1" == "--with-gcc" goto withgcc\r
82 if "%1" == "--with-msvc" goto withmsvc\r
83 if "%1" == "--no-debug" goto nodebug\r
84 if "%1" == "--no-opt" goto noopt\r
85 if "%1" == "--no-cygwin" goto nocygwin\r
86 if "%1" == "--cflags" goto usercflags\r
87 if "%1" == "--ldflags" goto userldflags\r
88 if "%1" == "--without-png" goto withoutpng\r
89 if "%1" == "--without-jpeg" goto withoutjpeg\r
90 if "%1" == "--without-gif" goto withoutgif\r
91 if "%1" == "--without-tiff" goto withouttiff\r
92 if "%1" == "--without-xpm" goto withoutxpm\r
93 if "%1" == "" goto checkutils\r
94 :usage\r
95 echo Usage: configure [options]\r
96 echo Options:\r
97 echo.   --prefix PREFIX         install Emacs in directory PREFIX\r
98 echo.   --with-gcc              use GCC to compile Emacs\r
99 echo.   --with-msvc             use MSVC to compile Emacs\r
100 echo.   --no-debug              exclude debug info from executables\r
101 echo.   --no-opt                disable optimization\r
102 echo.   --no-cygwin             use -mno-cygwin option with GCC\r
103 echo.   --cflags FLAG           pass FLAG to compiler\r
104 echo.   --ldflags FLAG          pass FLAG to compiler when linking\r
105 echo.   --without-png           do not use libpng even if it is installed\r
106 echo.   --without-jpeg          do not use jpeg-6b even if it is installed\r
107 echo.   --without-gif           do not use libungif even if it is installed\r
108 echo.   --without-tiff          do not use libtiff even if it is installed\r
109 echo.   --without-xpm           do not use libXpm even if it is installed\r
110 goto end\r
111 rem ----------------------------------------------------------------------\r
112 :setprefix\r
113 shift\r
114 set prefix=%1\r
115 shift\r
116 goto again\r
117 rem ----------------------------------------------------------------------\r
118 :withgcc\r
119 set COMPILER=gcc\r
120 shift\r
121 goto again\r
122 rem ----------------------------------------------------------------------\r
123 :withmsvc\r
124 set COMPILER=cl\r
125 shift\r
126 goto again\r
127 rem ----------------------------------------------------------------------\r
128 :nodebug\r
129 set nodebug=Y\r
130 shift\r
131 goto again\r
132 rem ----------------------------------------------------------------------\r
133 :noopt\r
134 set noopt=Y\r
135 shift\r
136 goto again\r
137 rem ----------------------------------------------------------------------\r
138 :nocygwin\r
139 set nocygwin=Y\r
140 shift\r
141 goto again\r
142 rem ----------------------------------------------------------------------\r
143 :usercflags\r
144 shift\r
145 set usercflags=%usercflags%%sep1%%1\r
146 set sep1= %nothing%\r
147 shift\r
148 goto again\r
149 rem ----------------------------------------------------------------------\r
150 :userldflags\r
151 shift\r
152 set userldflags=%userldflags%%sep2%%1\r
153 set sep2= %nothing%\r
154 shift\r
155 goto again\r
156 rem ----------------------------------------------------------------------\r
158 :withoutpng\r
159 set pngsupport=N\r
160 set HAVE_PNG=\r
161 shift\r
162 goto again\r
164 rem ----------------------------------------------------------------------\r
166 :withoutjpeg\r
167 set jpegsupport=N\r
168 set HAVE_JPEG=\r
169 shift\r
170 goto again\r
172 rem ----------------------------------------------------------------------\r
174 :withoutgif\r
175 set gifsupport=N\r
176 set HAVE_GIF=\r
177 shift\r
178 goto again\r
180 rem ----------------------------------------------------------------------\r
182 :withouttiff\r
183 set tiffsupport=N\r
184 set HAVE_TIFF=\r
185 shift\r
186 goto again\r
188 rem ----------------------------------------------------------------------\r
190 :withoutxpm\r
191 set xpmsupport=N\r
192 set HAVE_XPM=\r
193 shift\r
194 goto again\r
196 rem ----------------------------------------------------------------------\r
197 rem    Check that necessary utilities (cp and rm) are present.\r
198 :checkutils\r
199 echo Checking for 'cp'...\r
200 cp configure.bat junk.bat\r
201 if not exist junk.bat goto needcp\r
202 echo Checking for 'rm'...\r
203 rm junk.bat\r
204 if exist junk.bat goto needrm\r
205 goto checkcompiler\r
206 :needcp\r
207 echo You need 'cp' (the Unix file copy program) to build Emacs.\r
208 goto end\r
209 :needrm\r
210 del junk.bat\r
211 echo You need 'rm' (the Unix file delete program) to build Emacs.\r
212 goto end\r
214 rem ----------------------------------------------------------------------\r
215 rem   Auto-detect compiler if not specified, and validate GCC if chosen.\r
216 :checkcompiler\r
217 if (%COMPILER%)==(cl) goto compilercheckdone\r
218 if (%COMPILER%)==(gcc) goto checkgcc\r
220 echo Checking whether 'cl' is available...\r
221 echo main(){} >junk.c\r
222 cl -nologo -c junk.c\r
223 if exist junk.obj goto clOK\r
225 echo Checking whether 'gcc' is available...\r
226 gcc -c junk.c\r
227 if not exist junk.o goto nocompiler\r
228 del junk.o\r
230 :checkgcc\r
231 Rem WARNING -- COMMAND.COM on some systems only looks at the first\r
232 Rem            8 characters of a label.  So do NOT be tempted to change\r
233 Rem            chkapi* into something fancier like checkw32api\r
234 Rem You HAVE been warned!\r
235 if (%nocygwin%) == (Y) goto chkapi\r
236 echo Checking whether gcc requires '-mno-cygwin'...\r
237 echo #include "cygwin/version.h" >junk.c\r
238 echo main(){} >>junk.c\r
239 gcc -c junk.c\r
240 if not exist junk.o goto chkapi\r
241 gcc -mno-cygwin -c junk.c\r
242 if exist junk.o set nocygwin=Y\r
243 rm -f junk.c junk.o\r
245 :chkapi\r
246 rem ----------------------------------------------------------------------\r
247 rem   Older versions of the Windows API headers either don't have any of\r
248 rem   the IMAGE_xxx definitions (the headers that come with Cygwin b20.1\r
249 rem   are like this), or have a typo in the definition of\r
250 rem   IMAGE_FIRST_SECTION (the headers with gcc/mingw32 2.95 have this\r
251 rem   problem).  The gcc/mingw32 2.95.2 headers are okay, as are distros\r
252 rem   of w32api-xxx.zip from Anders Norlander since 1999-11-18 at least.\r
253 rem\r
254 echo Checking whether W32 API headers are too old...\r
255 echo #include "windows.h" >junk.c\r
256 echo test(PIMAGE_NT_HEADERS pHeader) >>junk.c\r
257 echo {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);} >>junk.c\r
258 if (%nocygwin%) == (Y) goto chkapi1\r
259 set cf=%usercflags%\r
260 goto chkapi2\r
261 :chkapi1\r
262 set cf=%usercflags% -mno-cygwin\r
263 :chkapi2\r
264 echo on\r
265 gcc %cf% -c junk.c\r
266 echo off\r
267 set cf=\r
268 if exist junk.o goto gccOk\r
270 :nocompiler\r
271 echo.\r
272 echo Configure failed.\r
273 echo To configure Emacs for Windows, you need to have either\r
274 echo gcc-2.95 or later with Mingw32 and the W32 API headers,\r
275 echo or MSVC 2.x or later.\r
276 del junk.c\r
277 goto end\r
279 :gccOk\r
280 set COMPILER=gcc\r
281 rm -f junk.c junk.o\r
282 echo Using 'gcc'\r
283 goto compilercheckdone\r
285 :clOk\r
286 set COMPILER=cl\r
287 rm -f junk.c junk.obj\r
288 echo Using 'MSVC'\r
290 :compilercheckdone\r
292 rem ----------------------------------------------------------------------\r
293 rem   Check for external image libraries. Since they are loaded\r
294 rem   dynamically, the libraries themselves do not need to be present\r
295 rem   at compile time, but the header files are required.\r
297 set mingwflag=\r
299 if (%nocygwin%) == (N) goto flagsOK\r
300 set mingwflag=-mno-cygwin\r
302 :flagsOK\r
304 if (%pngsupport%) == (N) goto pngDone\r
306 echo Checking for libpng...\r
307 echo #include "png.h" >junk.c\r
308 echo main (){} >>junk.c\r
309 rem   -o option is ignored with cl, but allows result to be consistent.\r
310 %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>junk.err\r
311 if exist junk.obj goto havePng\r
313 echo ...png.h not found, building without PNG support.\r
314 set HAVE_PNG=\r
315 goto :pngDone\r
317 :havePng\r
318 echo ...PNG header available, building with PNG support.\r
319 set HAVE_PNG=1\r
321 :pngDone\r
322 rm -f junk.c junk.obj\r
324 if (%jpegsupport%) == (N) goto jpegDone\r
326 echo Checking for jpeg-6b...\r
327 echo #include "jconfig.h" >junk.c\r
328 echo main (){} >>junk.c\r
329 rem   -o option is ignored with cl, but allows result to be consistent.\r
330 %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>junk.err\r
331 if exist junk.obj goto haveJpeg\r
333 echo ...jconfig.h not found, building without JPEG support.\r
334 set HAVE_JPEG=\r
335 goto :jpegDone\r
337 :haveJpeg\r
338 echo ...JPEG header available, building with JPEG support.\r
339 set HAVE_JPEG=1\r
341 :jpegDone\r
342 rm -f junk.c junk.obj\r
344 if (%gifsupport%) == (N) goto gifDone\r
346 echo Checking for libgif...\r
347 echo #include "gif_lib.h" >junk.c\r
348 echo main (){} >>junk.c\r
349 rem   -o option is ignored with cl, but allows result to be consistent.\r
350 %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>junk.err\r
351 if exist junk.obj goto haveGif\r
353 echo ...gif_lib.h not found, building without GIF support.\r
354 set HAVE_GIF=\r
355 goto :gifDone\r
357 :haveGif\r
358 echo ...GIF header available, building with GIF support.\r
359 set HAVE_GIF=1\r
361 :gifDone\r
362 rm -f junk.c junk.obj\r
364 if (%tiffsupport%) == (N) goto tiffDone\r
366 echo Checking for tiff...\r
367 echo #include "tiffio.h" >junk.c\r
368 echo main (){} >>junk.c\r
369 rem   -o option is ignored with cl, but allows result to be consistent.\r
370 %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>junk.err\r
371 if exist junk.obj goto haveTiff\r
373 echo ...tiffio.h not found, building without TIFF support.\r
374 set HAVE_TIFF=\r
375 goto :tiffDone\r
377 :haveTiff\r
378 echo ...TIFF header available, building with TIFF support.\r
379 set HAVE_TIFF=1\r
381 :tiffDone\r
382 rm -f junk.c junk.obj\r
384 if (%xpmsupport%) == (N) goto xpmDone\r
386 echo Checking for libXpm...\r
387 echo #define FOR_MSW 1 >junk.c\r
388 echo #include "X11/xpm.h" >>junk.c\r
389 echo main (){} >>junk.c\r
390 rem   -o option is ignored with cl, but allows result to be consistent.\r
391 %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>junk.err\r
392 if exist junk.obj goto haveXpm\r
394 echo ...X11/xpm.h not found, building without XPM support.\r
395 set HAVE_XPM=\r
396 goto :xpmDone\r
398 :haveXpm\r
399 echo ...XPM header available, building with XPM support.\r
400 set HAVE_XPM=1\r
402 :xpmDone\r
403 rm -f junk.c junk.obj junk.err junk.out\r
405 rem ----------------------------------------------------------------------\r
406 :genmakefiles\r
407 echo Generating makefiles\r
408 if %COMPILER% == gcc set MAKECMD=gmake\r
409 if %COMPILER% == cl set MAKECMD=nmake\r
411 rem   Pass on chosen settings to makefiles.\r
412 rem   NB. Be very careful to not have a space before redirection symbols\r
413 rem   except when there is a preceding digit, when a space is required.\r
414 rem\r
415 echo # Start of settings from configure.bat >config.settings\r
416 echo COMPILER=%COMPILER%>>config.settings\r
417 if (%nodebug%) == (Y) echo NODEBUG=1 >>config.settings\r
418 if (%noopt%) == (Y) echo NOOPT=1 >>config.settings\r
419 if (%nocygwin%) == (Y) echo NOCYGWIN=1 >>config.settings\r
420 if not "(%prefix%)" == "()" echo INSTALL_DIR=%prefix%>>config.settings\r
421 if not "(%usercflags%)" == "()" echo USER_CFLAGS=%usercflags%>>config.settings\r
422 if not "(%userldflags%)" == "()" echo USER_LDFLAGS=%userldflags%>>config.settings\r
423 echo # End of settings from configure.bat>>config.settings\r
424 echo. >>config.settings\r
426 copy config.nt ..\src\config.h\r
427 echo. >>..\src\config.h\r
428 echo /* Start of settings from configure.bat.  */ >>..\src\config.h\r
429 if not "(%usercflags%)" == "()" echo #define USER_CFLAGS " %usercflags%">>..\src\config.h\r
430 if not "(%userldflags%)" == "()" echo #define USER_LDFLAGS " %userldflags%">>..\src\config.h\r
431 if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>..\src\config.h\r
432 if not "(%HAVE_JPEG%)" == "()" echo #define HAVE_JPEG 1 >>..\src\config.h\r
433 if not "(%HAVE_GIF%)" == "()" echo #define HAVE_GIF 1 >>..\src\config.h\r
434 if not "(%HAVE_TIFF%)" == "()" echo #define HAVE_TIFF 1 >>..\src\config.h\r
435 if not "(%HAVE_XPM%)" == "()" echo #define HAVE_XPM 1 >>..\src\config.h\r
436 echo /* End of settings from configure.bat.  */ >>..\src\config.h\r
438 copy paths.h ..\src\epaths.h\r
440 copy /b config.settings+%MAKECMD%.defs+..\nt\makefile.w32-in ..\nt\makefile\r
441 copy /b config.settings+%MAKECMD%.defs+..\lib-src\makefile.w32-in ..\lib-src\makefile\r
442 copy /b config.settings+%MAKECMD%.defs+..\src\makefile.w32-in ..\src\makefile\r
443 copy /b config.settings+%MAKECMD%.defs+..\man\makefile.w32-in ..\man\makefile\r
444 copy /b config.settings+%MAKECMD%.defs+..\lispref\makefile.w32-in ..\lispref\makefile\r
445 copy /b config.settings+%MAKECMD%.defs+..\lispintro\makefile.w32-in ..\lispintro\makefile\r
446 if not exist ..\lisp\Makefile.unix rename ..\lisp\Makefile.in Makefile.unix\r
447 if exist ..\lisp\makefile rm -f ../lisp/[Mm]akefile\r
448 copy /b config.settings+%MAKECMD%.defs+..\lisp\makefile.w32-in ..\lisp\makefile\r
449 rem   Use the default (no-op) Makefile.in if the nt version is not present.\r
450 if exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\makefile.w32-in ..\leim\makefile\r
451 if not exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\Makefile.in ..\leim\makefile\r
452 del config.settings\r
454 Rem Some people use WinZip which doesn't create empty directories!\r
455 if not exist ..\site-lisp\nul mkdir ..\site-lisp\\r
456 if not exist ..\site-lisp\subdirs.el copy subdirs.el ..\site-lisp\subdirs.el\r
458 echo.\r
459 echo Emacs successfully configured.\r
460 echo Run `%MAKECMD%' to build, then run `%MAKECMD% install' to install.\r
461 goto end\r
463 :SmallEnv\r
464 echo Your environment size is too small.  Please enlarge it and rerun configure.\r
465 echo For example, type "command.com /e:2048" to have 2048 bytes available.\r
466 set $foo$=\r
467 :end\r
468 set prefix=\r
469 set nodebug=\r
470 set noopt=\r
471 set nocygwin=\r
472 set COMPILER=\r
473 set MAKECMD=\r
474 set usercflags=\r
475 set userldflags=\r
476 set mingwflag=\r
478 goto skipArchTag\r
479    arch-tag: 300d20a4-1675-4e75-b615-7ce1a8c5376c\r
480 :skipArchTag\r