* doc/emacs/mini.texi (Repetition): Further copyedit.
[bpt/emacs.git] / nt / configure.bat
CommitLineData
f466241d
EZ
1@echo off\r
2rem ----------------------------------------------------------------------\r
ee705a5c 3rem Configuration script for MS Windows operating systems\r
acaf905b 4rem Copyright (C) 1999-2012 Free Software Foundation, Inc.\r
f466241d
EZ
5\r
6rem This file is part of GNU Emacs.\r
7\r
eef0be9e 8rem GNU Emacs is free software: you can redistribute it and/or modify\r
f466241d 9rem it under the terms of the GNU General Public License as published by\r
eef0be9e
GM
10rem the Free Software Foundation, either version 3 of the License, or\r
11rem (at your option) any later version.\r
f466241d
EZ
12\r
13rem GNU Emacs is distributed in the hope that it will be useful,\r
14rem but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
16rem GNU General Public License for more details.\r
17\r
18rem You should have received a copy of the GNU General Public License\r
eef0be9e
GM
19rem along with GNU Emacs. If not, see http://www.gnu.org/licenses/.\r
20\r
f466241d
EZ
21rem ----------------------------------------------------------------------\r
22rem YOU'LL NEED THE FOLLOWING UTILITIES TO MAKE EMACS:\r
23rem\r
ee705a5c 24rem + MS Windows 95, NT or later\r
361823f4 25rem + either MSVC 2.x or later, or gcc-2.95 or later (with GNU make 3.75\r
b46a6a83 26rem or later) and the Mingw32 and Windows API headers and libraries.\r
56a469c3 27rem + Visual Studio 2005 is not supported at this time.\r
f466241d 28rem\r
361823f4 29rem For reference, here is a list of which builds of GNU make are known to\r
f466241d
EZ
30rem work or not, and whether they work in the presence and/or absence of\r
31rem sh.exe.\r
7019fb66 32rem\r
f466241d 33rem sh exists no sh\r
56a469c3 34rem cygwin b20.1 make (3.75): fails[1,5] fails[2,5]\r
f466241d
EZ
35rem MSVC compiled gmake 3.77: okay okay\r
36rem MSVC compiled gmake 3.78.1: okay okay\r
37rem MSVC compiled gmake 3.79.1: okay okay\r
56a469c3
EZ
38rem mingw32/gcc-2.92.2 make (3.77): okay okay[4]\r
39rem cygwin compiled gmake 3.77: fails[1,5] fails[2,5]\r
40rem cygwin compiled gmake 3.78.1: fails[5] fails[2,5]\r
41rem cygwin compiled gmake 3.79.1: fails[3,5] fails[2?,5]\r
17f55fae
EZ
42rem cygwin compiled make 3.80: okay[6] fails?[7]\r
43rem cygwin compiled make 3.81: fails fails?[7]\r
56a469c3 44rem mingw32 compiled make 3.79.1: okay okay\r
17f55fae
EZ
45rem mingw32 compiled make 3.80: okay okay?[7]\r
46rem mingw32 compiled make 3.81: okay okay[8]\r
f466241d
EZ
47rem\r
48rem [1] doesn't cope with makefiles with DOS line endings, so must mount\r
49rem emacs source with text!=binary.\r
50rem [2] fails when needs to invoke shell commands; okay invoking gcc etc.\r
56a469c3
EZ
51rem [3] requires LC_MESSAGES support to build; cannot build with early\r
52rem versions of cygwin.\r
53rem [4] may fail on Windows 9X and Windows ME; if so, install Bash.\r
54rem [5] fails when building leim due to the use of cygwin style paths.\r
55rem May work if building emacs without leim.\r
17f55fae
EZ
56rem [6] need to uncomment 3 lines in nt/gmake.defs that invoke `cygpath';\r
57rem look for "cygpath" near line 85 of gmake.defs.\r
58rem [7] not recommended; please report if you try this combination.\r
59rem [8] tested only on Windows XP.\r
f466241d
EZ
60rem\r
61\r
dbbdb507
EZ
62if exist config.log del config.log\r
63\r
f466241d
EZ
64rem ----------------------------------------------------------------------\r
65rem See if the environment is large enough. We need 43 (?) bytes.\r
66set $foo$=123456789_123456789_123456789_123456789_123\r
67if not "%$foo$%" == "123456789_123456789_123456789_123456789_123" goto SmallEnv\r
68set $foo$=\r
69\r
70rem ----------------------------------------------------------------------\r
71rem Make sure we are running in the nt subdir\r
72if exist configure.bat goto start\r
73echo You must run configure from the nt subdirectory.\r
74goto end\r
75\r
76:start\r
4a1a6b5b
BK
77rem ----------------------------------------------------------------------\r
78rem Attempt to enable command extensions. Set use_extensions to 1 if\r
79rem they are available and 0 if they are not available.\r
80set use_extensions=1\r
81setlocal ENABLEEXTENSIONS\r
82if "%CMDEXTVERSION%" == "" set use_extensions=0\r
83if "%use_extensions%" == "1" goto afterext\r
84\r
85echo. Command extensions are not available. Using parameters that include the =\r
86echo. character by enclosing them in quotes will not be supported.\r
87\r
88:afterext\r
89\r
f466241d
EZ
90rem ----------------------------------------------------------------------\r
91rem Default settings.\r
92set prefix=\r
93set nodebug=N\r
94set noopt=N\r
7d0170c8 95set enablechecking=N\r
75663c75 96set profile=N\r
f466241d
EZ
97set nocygwin=N\r
98set COMPILER=\r
99set usercflags=\r
4d3fcc8e 100set escusercflags=\r
3a1ebd63 101set docflags=\r
f466241d 102set userldflags=\r
4d3fcc8e 103set escuserldflags=\r
fd4af8d9 104set extrauserlibs=\r
3a1ebd63 105set doldflags=\r
fd4af8d9 106set doextralibs=\r
f466241d
EZ
107set sep1=\r
108set sep2=\r
e3aef5c6 109set sep3=\r
fd4af8d9 110set sep4=\r
e3aef5c6 111set distfiles=\r
f466241d
EZ
112\r
113rem ----------------------------------------------------------------------\r
114rem Handle arguments.\r
115:again\r
116if "%1" == "-h" goto usage\r
117if "%1" == "--help" goto usage\r
118if "%1" == "--prefix" goto setprefix\r
119if "%1" == "--with-gcc" goto withgcc\r
120if "%1" == "--with-msvc" goto withmsvc\r
121if "%1" == "--no-debug" goto nodebug\r
122if "%1" == "--no-opt" goto noopt\r
7d0170c8 123if "%1" == "--enable-checking" goto enablechecking\r
75663c75 124if "%1" == "--profile" goto profile\r
f466241d
EZ
125if "%1" == "--no-cygwin" goto nocygwin\r
126if "%1" == "--cflags" goto usercflags\r
127if "%1" == "--ldflags" goto userldflags\r
fd4af8d9 128if "%1" == "--lib" goto extrauserlibs\r
e0006538 129if "%1" == "--without-png" goto withoutpng\r
aad0eae4 130if "%1" == "--without-jpeg" goto withoutjpeg\r
12ff2dc5 131if "%1" == "--without-gif" goto withoutgif\r
47c01e80 132if "%1" == "--without-tiff" goto withouttiff\r
fd4af8d9 133if "%1" == "--without-gnutls" goto withoutgnutls\r
9078ead6 134if "%1" == "--without-libxml2" goto withoutlibxml2\r
507f5dce 135if "%1" == "--without-xpm" goto withoutxpm\r
8bc63b1a 136if "%1" == "--with-svg" goto withsvg\r
e3aef5c6 137if "%1" == "--distfiles" goto distfiles\r
f466241d 138if "%1" == "" goto checkutils\r
ee705a5c 139\r
f466241d
EZ
140:usage\r
141echo Usage: configure [options]\r
142echo Options:\r
143echo. --prefix PREFIX install Emacs in directory PREFIX\r
144echo. --with-gcc use GCC to compile Emacs\r
145echo. --with-msvc use MSVC to compile Emacs\r
146echo. --no-debug exclude debug info from executables\r
147echo. --no-opt disable optimization\r
0566bc95 148echo. --enable-checking enable additional run-time checks\r
75663c75 149echo. --profile enable profiling\r
f466241d
EZ
150echo. --no-cygwin use -mno-cygwin option with GCC\r
151echo. --cflags FLAG pass FLAG to compiler\r
152echo. --ldflags FLAG pass FLAG to compiler when linking\r
fd4af8d9 153echo. --lib LIB link to extra library LIB\r
f01e03d3
JB
154echo. --without-png do not use PNG library even if it is installed\r
155echo. --without-jpeg do not use JPEG library even if it is installed\r
156echo. --without-gif do not use GIF library even if it is installed\r
157echo. --without-tiff do not use TIFF library even if it is installed\r
158echo. --without-xpm do not use XPM library even if it is installed\r
e9fce1ac 159echo. --without-gnutls do not use GnuTLS library even if it is installed\r
9078ead6 160echo. --without-libxml2 do not use libxml2 library even if it is installed\r
8d67bc8e 161echo. --with-svg use the RSVG library (experimental)\r
e3aef5c6 162echo. --distfiles path to files for make dist, e.g. libXpm.dll\r
4a1a6b5b
BK
163if "%use_extensions%" == "0" goto end\r
164echo.\r
165echo. The cflags and ldflags arguments support parameters that include the =\r
166echo. character. However, since the = character is normally treated as a\r
167echo. separator character you will need to enclose any parameter that includes\r
168echo. the = character in quotes. For example, to include\r
169echo. -DSITELOAD_PURESIZE_EXTRA=100000 as one of the cflags you would run\r
170echo. configure.bat as follows:\r
171echo. configure.bat --cflags "-DSITELOAD_PURESIZE_EXTRA=100000"\r
172echo.\r
173echo. Note that this capability of processing parameters that include the =\r
174echo. character depends on command extensions. This batch file attempts to\r
175echo. enable command extensions. If command extensions cannot be enabled, a\r
176echo. warning message will be displayed.\r
f466241d 177goto end\r
ee705a5c 178\r
f466241d 179rem ----------------------------------------------------------------------\r
ee705a5c 180\r
f466241d
EZ
181:setprefix\r
182shift\r
183set prefix=%1\r
184shift\r
185goto again\r
ee705a5c 186\r
f466241d 187rem ----------------------------------------------------------------------\r
ee705a5c 188\r
f466241d
EZ
189:withgcc\r
190set COMPILER=gcc\r
191shift\r
192goto again\r
ee705a5c 193\r
f466241d 194rem ----------------------------------------------------------------------\r
ee705a5c 195\r
f466241d
EZ
196:withmsvc\r
197set COMPILER=cl\r
198shift\r
199goto again\r
ee705a5c 200\r
f466241d 201rem ----------------------------------------------------------------------\r
ee705a5c 202\r
f466241d
EZ
203:nodebug\r
204set nodebug=Y\r
205shift\r
206goto again\r
ee705a5c 207\r
f466241d 208rem ----------------------------------------------------------------------\r
ee705a5c 209\r
f466241d
EZ
210:noopt\r
211set noopt=Y\r
212shift\r
213goto again\r
ee705a5c 214\r
f466241d 215rem ----------------------------------------------------------------------\r
ee705a5c 216\r
7d0170c8
JB
217:enablechecking\r
218set enablechecking=Y\r
219shift\r
220goto again\r
ee705a5c 221\r
7d0170c8 222rem ----------------------------------------------------------------------\r
ee705a5c 223\r
75663c75
JR
224:profile\r
225set profile=Y\r
226shift\r
227goto again\r
ee705a5c 228\r
75663c75 229rem ----------------------------------------------------------------------\r
ee705a5c 230\r
f466241d
EZ
231:nocygwin\r
232set nocygwin=Y\r
233shift\r
234goto again\r
ee705a5c 235\r
f466241d 236rem ----------------------------------------------------------------------\r
ee705a5c 237\r
f466241d 238:usercflags\r
4a1a6b5b
BK
239if "%use_extensions%" == "1" goto ucflagex\r
240goto ucflagne\r
241\r
242:ucflagex\r
243shift\r
244set usercflags=%usercflags%%sep1%%~1\r
4d3fcc8e 245set escusercflags=%usercflags:"=\"%\r
4a1a6b5b
BK
246set sep1= %nothing%\r
247shift\r
248goto again\r
249\r
250:ucflagne\r
f466241d
EZ
251shift\r
252set usercflags=%usercflags%%sep1%%1\r
4d3fcc8e 253set escusercflags=%usercflags%\r
f466241d
EZ
254set sep1= %nothing%\r
255shift\r
256goto again\r
ee705a5c 257\r
fd4af8d9
TZ
258:extrauserlibs\r
259shift\r
260echo. extrauserlibs: %extrauserlibs%\r
261set extrauserlibs=%extrauserlibs%%sep4%%1\r
262set sep4= %nothing%\r
263shift\r
264goto again\r
265\r
f466241d 266rem ----------------------------------------------------------------------\r
ee705a5c 267\r
f466241d 268:userldflags\r
4a1a6b5b
BK
269if "%use_extensions%" == "1" goto ulflagex\r
270goto ulflagne\r
271\r
272:ulflagex\r
273shift\r
274set userldflags=%userldflags%%sep2%%~1\r
4d3fcc8e 275set escuserldflags=%userldflags:"=\"%\r
4a1a6b5b
BK
276set sep2= %nothing%\r
277shift\r
278goto again\r
279\r
280:ulflagne\r
f466241d
EZ
281shift\r
282set userldflags=%userldflags%%sep2%%1\r
4d3fcc8e 283set escuserldflags=%userldflags%\r
f466241d
EZ
284set sep2= %nothing%\r
285shift\r
286goto again\r
ee705a5c 287\r
e0006538
JR
288rem ----------------------------------------------------------------------\r
289\r
290:withoutpng\r
291set pngsupport=N\r
292set HAVE_PNG=\r
39bd0e03 293shift\r
e0006538 294goto again\r
f466241d 295\r
aad0eae4
JR
296rem ----------------------------------------------------------------------\r
297\r
298:withoutjpeg\r
299set jpegsupport=N\r
300set HAVE_JPEG=\r
39bd0e03 301shift\r
aad0eae4
JR
302goto again\r
303\r
12ff2dc5
JB
304rem ----------------------------------------------------------------------\r
305\r
306:withoutgif\r
307set gifsupport=N\r
308set HAVE_GIF=\r
309shift\r
310goto again\r
311\r
47c01e80
JB
312rem ----------------------------------------------------------------------\r
313\r
fd4af8d9
TZ
314:withoutgnutls\r
315set tlssupport=N\r
316set HAVE_GNUTLS=\r
317shift\r
318goto again\r
319\r
320rem ----------------------------------------------------------------------\r
321\r
9078ead6
EZ
322:withoutlibxml2\r
323set libxml2support=N\r
324set HAVE_LIBXML2=\r
325shift\r
326goto again\r
327\r
328rem ----------------------------------------------------------------------\r
329\r
47c01e80
JB
330:withouttiff\r
331set tiffsupport=N\r
332set HAVE_TIFF=\r
333shift\r
334goto again\r
335\r
507f5dce
JR
336rem ----------------------------------------------------------------------\r
337\r
338:withoutxpm\r
339set xpmsupport=N\r
340set HAVE_XPM=\r
341shift\r
342goto again\r
343\r
8bc63b1a
JR
344:withsvg\r
345shift\r
346set svgsupport=Y\r
347goto again\r
348\r
e3aef5c6
CS
349rem ----------------------------------------------------------------------\r
350\r
351:distfiles\r
352set HAVE_DISTFILES=1\r
353shift\r
354set distfiles=%distfiles%%sep3%%1\r
355set sep3= %nothing%\r
356shift\r
357goto again\r
358\r
f466241d
EZ
359rem ----------------------------------------------------------------------\r
360rem Check that necessary utilities (cp and rm) are present.\r
ee705a5c 361\r
f466241d
EZ
362:checkutils\r
363echo Checking for 'cp'...\r
364cp configure.bat junk.bat\r
365if not exist junk.bat goto needcp\r
366echo Checking for 'rm'...\r
367rm junk.bat\r
368if exist junk.bat goto needrm\r
369goto checkcompiler\r
ee705a5c 370\r
f466241d
EZ
371:needcp\r
372echo You need 'cp' (the Unix file copy program) to build Emacs.\r
373goto end\r
ee705a5c 374\r
f466241d
EZ
375:needrm\r
376del junk.bat\r
377echo You need 'rm' (the Unix file delete program) to build Emacs.\r
378goto end\r
379\r
380rem ----------------------------------------------------------------------\r
381rem Auto-detect compiler if not specified, and validate GCC if chosen.\r
ee705a5c 382\r
f466241d 383:checkcompiler\r
e0006538 384if (%COMPILER%)==(cl) goto compilercheckdone\r
f466241d
EZ
385if (%COMPILER%)==(gcc) goto checkgcc\r
386\r
f466241d 387echo Checking whether 'gcc' is available...\r
680d641f 388echo main(){} >junk.c\r
f466241d 389gcc -c junk.c\r
680d641f 390if exist junk.o goto checkgcc\r
f466241d 391\r
680d641f
JR
392echo Checking whether 'cl' is available...\r
393cl -nologo -c junk.c\r
394if exist junk.obj goto clOK\r
395goto nocompiler\r
396\r
f466241d 397:checkgcc\r
1046da1c 398if exist junk.o del junk.o\r
f466241d
EZ
399Rem WARNING -- COMMAND.COM on some systems only looks at the first\r
400Rem 8 characters of a label. So do NOT be tempted to change\r
401Rem chkapi* into something fancier like checkw32api\r
402Rem You HAVE been warned!\r
1046da1c 403if (%nocygwin%) == (Y) goto chkapiN\r
f466241d
EZ
404echo Checking whether gcc requires '-mno-cygwin'...\r
405echo #include "cygwin/version.h" >junk.c\r
406echo main(){} >>junk.c\r
dbbdb507
EZ
407echo gcc -c junk.c >>config.log\r
408gcc -c junk.c >>config.log 2>&1\r
f466241d 409if not exist junk.o goto chkapi\r
dbbdb507
EZ
410echo gcc -mno-cygwin -c junk.c >>config.log\r
411gcc -mno-cygwin -c junk.c >>config.log 2>&1\r
f466241d 412if exist junk.o set nocygwin=Y\r
f466241d
EZ
413\r
414:chkapi\r
dbbdb507
EZ
415echo The failed program was: >>config.log\r
416type junk.c >>config.log\r
ee705a5c 417\r
1046da1c
EZ
418:chkapiN\r
419rm -f junk.c junk.o\r
f466241d
EZ
420rem ----------------------------------------------------------------------\r
421rem Older versions of the Windows API headers either don't have any of\r
422rem the IMAGE_xxx definitions (the headers that come with Cygwin b20.1\r
423rem are like this), or have a typo in the definition of\r
424rem IMAGE_FIRST_SECTION (the headers with gcc/mingw32 2.95 have this\r
425rem problem). The gcc/mingw32 2.95.2 headers are okay, as are distros\r
426rem of w32api-xxx.zip from Anders Norlander since 1999-11-18 at least.\r
892508a4 427rem Beginning with Emacs 23, we need usp10.h.\r
f466241d 428rem\r
b46a6a83 429echo Checking whether Windows API headers are too old...\r
f466241d 430echo #include "windows.h" >junk.c\r
892508a4 431echo #include "usp10.h" >>junk.c\r
f466241d
EZ
432echo test(PIMAGE_NT_HEADERS pHeader) >>junk.c\r
433echo {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);} >>junk.c\r
434if (%nocygwin%) == (Y) goto chkapi1\r
435set cf=%usercflags%\r
436goto chkapi2\r
ee705a5c 437\r
f466241d
EZ
438:chkapi1\r
439set cf=%usercflags% -mno-cygwin\r
ee705a5c 440\r
f466241d
EZ
441:chkapi2\r
442echo on\r
443gcc %cf% -c junk.c\r
dbbdb507
EZ
444@echo off\r
445@echo gcc %cf% -c junk.c >>config.log\r
446gcc %cf% -c junk.c >>config.log 2>&1\r
f466241d 447set cf=\r
05212154 448if exist junk.o goto chkuser\r
dbbdb507
EZ
449echo The failed program was: >>config.log\r
450type junk.c >>config.log\r
05212154
JB
451goto nocompiler\r
452\r
453:chkuser\r
454rm -f junk.o\r
455echo int main (int argc, char *argv[]) {>junk.c\r
4d3fcc8e 456echo char *usercflags = "%escusercflags%";>>junk.c\r
05212154
JB
457echo }>>junk.c\r
458echo gcc -Werror -c junk.c >>config.log\r
459gcc -Werror -c junk.c >>config.log 2>&1\r
460if exist junk.o goto gccOk\r
461echo.\r
462echo Error in --cflags argument: %usercflags%\r
463echo Backslashes and quotes cannot be used with --cflags. Please use forward\r
464echo slashes for filenames and paths (e.g. when passing directories to -I).\r
465rm -f junk.c\r
466goto end\r
f466241d
EZ
467\r
468:nocompiler\r
469echo.\r
470echo Configure failed.\r
471echo To configure Emacs for Windows, you need to have either\r
b46a6a83 472echo gcc-2.95 or later with Mingw32 and the Windows API headers,\r
f466241d
EZ
473echo or MSVC 2.x or later.\r
474del junk.c\r
475goto end\r
476\r
477:gccOk\r
478set COMPILER=gcc\r
f466241d 479echo Using 'gcc'\r
dbbdb507
EZ
480rm -f junk.c junk.o\r
481Rem It is not clear what GCC version began supporting -mtune\r
482Rem and pentium4 on x86, so check this explicitly.\r
483echo main(){} >junk.c\r
484echo gcc -c -O2 -mtune=pentium4 junk.c >>config.log\r
485gcc -c -O2 -mtune=pentium4 junk.c >>config.log 2>&1\r
486if not errorlevel 1 goto gccMtuneOk\r
487echo The failed program was: >>config.log\r
488type junk.c >>config.log\r
489set mf=-mcpu=i686\r
490rm -f junk.c junk.o\r
540c2a33 491goto gccdebug\r
ee705a5c 492\r
dbbdb507
EZ
493:gccMtuneOk\r
494echo GCC supports -mtune=pentium4 >>config.log\r
495set mf=-mtune=pentium4\r
496rm -f junk.c junk.o\r
ee705a5c 497\r
540c2a33
JB
498:gccdebug\r
499rem Check for DWARF-2 debug info support, else default to stabs\r
500echo main(){} >junk.c\r
501echo gcc -c -gdwarf-2 -g3 junk.c >>config.log\r
502gcc -c -gdwarf-2 -g3 junk.c >>config.log 2>&1\r
503if not errorlevel 1 goto gccdwarf\r
504echo The failed program was: >>config.log\r
505type junk.c >>config.log\r
506set dbginfo=-gstabs+\r
507rm -f junk.c junk.o\r
508goto compilercheckdone\r
ee705a5c 509\r
540c2a33
JB
510:gccdwarf\r
511echo GCC supports DWARF-2 >>config.log\r
512set dbginfo=-gdwarf-2 -g3\r
513rm -f junk.c junk.o\r
e0006538 514goto compilercheckdone\r
f466241d
EZ
515\r
516:clOk\r
517set COMPILER=cl\r
518rm -f junk.c junk.obj\r
519echo Using 'MSVC'\r
e0006538
JR
520\r
521:compilercheckdone\r
522\r
523rem ----------------------------------------------------------------------\r
524rem Check for external image libraries. Since they are loaded\r
525rem dynamically, the libraries themselves do not need to be present\r
526rem at compile time, but the header files are required.\r
527\r
112dc8e1
JR
528set mingwflag=\r
529\r
530if (%nocygwin%) == (N) goto flagsOK\r
531set mingwflag=-mno-cygwin\r
532\r
533:flagsOK\r
534\r
e0006538
JR
535if (%pngsupport%) == (N) goto pngDone\r
536\r
537echo Checking for libpng...\r
538echo #include "png.h" >junk.c\r
539echo main (){} >>junk.c\r
540rem -o option is ignored with cl, but allows result to be consistent.\r
dbbdb507
EZ
541echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
542%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
e0006538
JR
543if exist junk.obj goto havePng\r
544\r
507f5dce 545echo ...png.h not found, building without PNG support.\r
dbbdb507
EZ
546echo The failed program was: >>config.log\r
547type junk.c >>config.log\r
e0006538
JR
548set HAVE_PNG=\r
549goto :pngDone\r
550\r
551:havePng\r
552echo ...PNG header available, building with PNG support.\r
553set HAVE_PNG=1\r
554\r
555:pngDone\r
556rm -f junk.c junk.obj\r
f466241d 557\r
fd4af8d9
TZ
558if (%tlssupport%) == (N) goto tlsDone\r
559\r
560rem this is a copy of the PNG detection\r
561echo Checking for libgnutls...\r
562echo #include "gnutls/gnutls.h" >junk.c\r
563echo main (){} >>junk.c\r
564rem -o option is ignored with cl, but allows result to be consistent.\r
565echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
566%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
567if exist junk.obj goto haveTls\r
568\r
569echo ...gnutls.h not found, building without TLS support.\r
570echo The failed program was: >>config.log\r
571type junk.c >>config.log\r
572set HAVE_GNUTLS=\r
573goto :tlsDone\r
574\r
575:haveTls\r
e9fce1ac 576echo ...GnuTLS header available, building with GnuTLS support.\r
fd4af8d9
TZ
577set HAVE_GNUTLS=1\r
578\r
579:tlsDone\r
580rm -f junk.c junk.obj\r
581\r
9078ead6
EZ
582if (%libxml2support%) == (N) goto xml2Done\r
583\r
584echo Checking for libxml2....\r
585echo #include "libxml/HTMLparser.h" >junk.c\r
586echo main(){} >>junk.c\r
587echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
588%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
589if exist junk.obj goto havelibxml2\r
590\r
591echo ...libxml/HTMLparser.h not found, building without libxml2 support\r
592echo The failed program was: >>config.log\r
593type junk.c >>config.log\r
594set HAVE_LIBXML2=\r
595goto xml2Done\r
596\r
597:havelibxml2\r
598echo ...libxml2 header available, building with libxml2 support\r
599set HAVE_LIBXML2=1\r
600\r
601:xml2Done\r
602rm -f junk.c junk.obj\r
603\r
aad0eae4
JR
604if (%jpegsupport%) == (N) goto jpegDone\r
605\r
507f5dce 606echo Checking for jpeg-6b...\r
aad0eae4
JR
607echo #include "jconfig.h" >junk.c\r
608echo main (){} >>junk.c\r
609rem -o option is ignored with cl, but allows result to be consistent.\r
dbbdb507
EZ
610echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
611%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
aad0eae4
JR
612if exist junk.obj goto haveJpeg\r
613\r
507f5dce 614echo ...jconfig.h not found, building without JPEG support.\r
dbbdb507
EZ
615echo The failed program was: >>config.log\r
616type junk.c >>config.log\r
aad0eae4
JR
617set HAVE_JPEG=\r
618goto :jpegDone\r
619\r
620:haveJpeg\r
621echo ...JPEG header available, building with JPEG support.\r
622set HAVE_JPEG=1\r
623\r
624:jpegDone\r
625rm -f junk.c junk.obj\r
626\r
12ff2dc5
JB
627if (%gifsupport%) == (N) goto gifDone\r
628\r
507f5dce 629echo Checking for libgif...\r
ae97707f
EZ
630rem giflib-5.0.0 needs size_t defined before gif_lib.h is included\r
631rem redirection characters need to be protected from the shell\r
632echo #include ^<stddef.h^> >junk.c\r
633echo #include "gif_lib.h" >>junk.c\r
12ff2dc5
JB
634echo main (){} >>junk.c\r
635rem -o option is ignored with cl, but allows result to be consistent.\r
dbbdb507
EZ
636echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
637%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
12ff2dc5
JB
638if exist junk.obj goto haveGif\r
639\r
507f5dce 640echo ...gif_lib.h not found, building without GIF support.\r
dbbdb507
EZ
641echo The failed program was: >>config.log\r
642type junk.c >>config.log\r
12ff2dc5
JB
643set HAVE_GIF=\r
644goto :gifDone\r
645\r
646:haveGif\r
647echo ...GIF header available, building with GIF support.\r
648set HAVE_GIF=1\r
649\r
650:gifDone\r
651rm -f junk.c junk.obj\r
652\r
47c01e80
JB
653if (%tiffsupport%) == (N) goto tiffDone\r
654\r
655echo Checking for tiff...\r
656echo #include "tiffio.h" >junk.c\r
657echo main (){} >>junk.c\r
658rem -o option is ignored with cl, but allows result to be consistent.\r
dbbdb507
EZ
659echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
660%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
47c01e80
JB
661if exist junk.obj goto haveTiff\r
662\r
507f5dce 663echo ...tiffio.h not found, building without TIFF support.\r
dbbdb507
EZ
664echo The failed program was: >>config.log\r
665type junk.c >>config.log\r
47c01e80
JB
666set HAVE_TIFF=\r
667goto :tiffDone\r
668\r
669:haveTiff\r
670echo ...TIFF header available, building with TIFF support.\r
671set HAVE_TIFF=1\r
672\r
673:tiffDone\r
674rm -f junk.c junk.obj\r
675\r
507f5dce
JR
676if (%xpmsupport%) == (N) goto xpmDone\r
677\r
678echo Checking for libXpm...\r
679echo #define FOR_MSW 1 >junk.c\r
680echo #include "X11/xpm.h" >>junk.c\r
681echo main (){} >>junk.c\r
682rem -o option is ignored with cl, but allows result to be consistent.\r
dbbdb507
EZ
683echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
684%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
507f5dce
JR
685if exist junk.obj goto haveXpm\r
686\r
687echo ...X11/xpm.h not found, building without XPM support.\r
dbbdb507
EZ
688echo The failed program was: >>config.log\r
689type junk.c >>config.log\r
507f5dce
JR
690set HAVE_XPM=\r
691goto :xpmDone\r
692\r
693:haveXpm\r
694echo ...XPM header available, building with XPM support.\r
695set HAVE_XPM=1\r
696\r
697:xpmDone\r
8bc63b1a
JR
698rm -f junk.c junk.obj\r
699\r
700if not (%svgsupport%) == (Y) goto :svgDone\r
701echo Checking for librsvg...\r
702echo #include "librsvg/rsvg.h" >junk.c\r
703echo main (){} >>junk.c\r
704rem -o option is ignored with cl, but allows result to be consistent.\r
705echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
706%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
707if exist junk.obj goto haveSvg\r
708\r
709echo ...librsvg/rsvg.h or dependencies not found, building without SVG support.\r
710echo The failed program was: >>config.log\r
711type junk.c >>config.log\r
712set HAVE_RSVG=\r
713goto :svgDone\r
714\r
715:haveSvg\r
716echo ...librsvg header available, building with SVG support (EXPERIMENTAL).\r
717set HAVE_RSVG=1\r
718\r
719:svgDone\r
507f5dce
JR
720rm -f junk.c junk.obj junk.err junk.out\r
721\r
e3aef5c6
CS
722rem Any distfiles provided for building distribution? If no, we're done.\r
723if "(%HAVE_DISTFILES%)"=="()" goto :distFilesDone\r
724\r
725rem Any arguments to --distfiles specified? If no, we're done.\r
726if not "%distfiles%"=="" goto :checkDistFiles\r
727set distFilesOk=0\r
728echo No arguments specified for option --distfiles!\r
729goto distfilesDone\r
730\r
731:checkDistFiles\r
732echo Checking for distfiles...\r
733rem Check if all specified distfiles exist\r
734set fileNotFound=\r
735for %%d in (%distfiles%) do if not exist %%d set fileNotFound=%%d\r
736if not "%fileNotFound%"=="" goto distFilesNotFound\r
737\r
738set distFilesOK=1\r
739echo ...all distfiles found.\r
740goto :distFilesDone\r
741\r
742:distFilesNotFound\r
743set distFilesOk=0\r
744echo ...%fileNotFound% not found.\r
745set distfiles=\r
746goto :distfilesDone\r
747\r
748:distFilesDone\r
749set fileNotFound=\r
750\r
f466241d 751rem ----------------------------------------------------------------------\r
ee705a5c 752\r
f466241d
EZ
753:genmakefiles\r
754echo Generating makefiles\r
755if %COMPILER% == gcc set MAKECMD=gmake\r
756if %COMPILER% == cl set MAKECMD=nmake\r
757\r
758rem Pass on chosen settings to makefiles.\r
f466241d 759rem\r
e383e32d
EZ
760rem The weird place we put the redirection is to make sure no extra\r
761rem whitespace winds up at the end of the Make variables, since some\r
762rem variables, e.g. INSTALL_DIR, cannot stand that. Yes, echo will\r
763rem write the blanks between the end of command arguments and the\r
764rem redirection symbol to the file. OTOH, we cannot put the\r
765rem redirection immediately after the last character of the command,\r
766rem because environment variable expansion can yield a digit there,\r
767rem which will then be misinterpreted as the file descriptor to\r
768rem redirect...\r
f466241d 769echo # Start of settings from configure.bat >config.settings\r
e383e32d
EZ
770>>config.settings echo COMPILER=%COMPILER%\r
771if not "(%mf%)" == "()" >>config.settings echo MCPU_FLAG=%mf%\r
772if not "(%dbginfo%)" == "()" >>config.settings echo DEBUG_INFO=%dbginfo%\r
773if (%nodebug%) == (Y) >>config.settings echo NODEBUG=1\r
774if (%noopt%) == (Y) >>config.settings echo NOOPT=1\r
e383e32d
EZ
775if (%profile%) == (Y) >>config.settings echo PROFILE=1\r
776if (%nocygwin%) == (Y) >>config.settings echo NOCYGWIN=1\r
777if not "(%prefix%)" == "()" >>config.settings echo INSTALL_DIR=%prefix%\r
778if not "(%distfiles%)" == "()" >>config.settings echo DIST_FILES=%distfiles%\r
3a1ebd63
EZ
779rem We go thru docflags because usercflags could be "-DFOO=bar" -something\r
780rem and the if command cannot cope with this\r
781for %%v in (%usercflags%) do if not (%%v)==() set docflags=Y\r
e383e32d
EZ
782if (%docflags%)==(Y) >>config.settings echo USER_CFLAGS=%usercflags%\r
783if (%docflags%)==(Y) >>config.settings echo ESC_USER_CFLAGS=%escusercflags%\r
3a1ebd63 784for %%v in (%userldflags%) do if not (%%v)==() set doldflags=Y\r
e383e32d 785if (%doldflags%)==(Y) >>config.settings echo USER_LDFLAGS=%userldflags%\r
fd4af8d9 786for %%v in (%extrauserlibs%) do if not (%%v)==() set doextralibs=Y\r
e383e32d 787if (%doextralibs%)==(Y) >>config.settings echo USER_LIBS=%extrauserlibs%\r
f466241d
EZ
788echo # End of settings from configure.bat>>config.settings\r
789echo. >>config.settings\r
790\r
c262c68c
EZ
791copy config.nt config.tmp\r
792echo. >>config.tmp\r
793echo /* Start of settings from configure.bat. */ >>config.tmp\r
8f978ca0
JB
794rem We write USER_CFLAGS and USER_LDFLAGS starting with a space to simplify\r
795rem processing of compiler options in w32.c:get_emacs_configuration_options\r
ce128722
EZ
796if (%docflags%) == (Y) echo #define USER_CFLAGS " %escusercflags%" >>config.tmp\r
797if (%doldflags%) == (Y) echo #define USER_LDFLAGS " %escuserldflags%" >>config.tmp\r
f179addc 798if (%profile%) == (Y) echo #define PROFILING 1 >>config.tmp\r
0566bc95 799if (%enablechecking%) == (Y) echo #define ENABLE_CHECKING 1 >>config.tmp\r
c262c68c 800if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>config.tmp\r
fd4af8d9 801if not "(%HAVE_GNUTLS%)" == "()" echo #define HAVE_GNUTLS 1 >>config.tmp\r
9078ead6 802if not "(%HAVE_LIBXML2%)" == "()" echo #define HAVE_LIBXML2 1 >>config.tmp\r
c262c68c
EZ
803if not "(%HAVE_JPEG%)" == "()" echo #define HAVE_JPEG 1 >>config.tmp\r
804if not "(%HAVE_GIF%)" == "()" echo #define HAVE_GIF 1 >>config.tmp\r
805if not "(%HAVE_TIFF%)" == "()" echo #define HAVE_TIFF 1 >>config.tmp\r
806if not "(%HAVE_XPM%)" == "()" echo #define HAVE_XPM 1 >>config.tmp\r
8bc63b1a
JR
807if "(%HAVE_RSVG%)" == "(1)" echo #define HAVE_RSVG 1 >>config.tmp\r
808\r
c262c68c
EZ
809echo /* End of settings from configure.bat. */ >>config.tmp\r
810\r
811Rem See if fc.exe returns a meaningful exit status. If it does, we\r
812Rem might as well avoid unnecessary overwriting of config.h and epaths.h,\r
813Rem since this forces recompilation of every source file.\r
814if exist foo.bar del foo.bar\r
815fc /b foo.bar foo.bar >nul 2>&1\r
816if not errorlevel 2 goto doCopy\r
817fc /b config.tmp ..\src\config.h >nul 2>&1\r
818if errorlevel 1 goto doCopy\r
819fc /b paths.h ..\src\epaths.h >nul 2>&1\r
252b4f5c 820if not errorlevel 1 goto dontCopy\r
ee705a5c 821\r
c262c68c
EZ
822:doCopy\r
823copy config.tmp ..\src\config.h\r
f466241d
EZ
824copy paths.h ..\src\epaths.h\r
825\r
c262c68c
EZ
826:dontCopy\r
827if exist config.tmp del config.tmp\r
f466241d 828copy /b config.settings+%MAKECMD%.defs+..\nt\makefile.w32-in ..\nt\makefile\r
a392138f 829if exist ..\admin\unidata copy /b config.settings+%MAKECMD%.defs+..\admin\unidata\makefile.w32-in ..\admin\unidata\makefile\r
f466241d 830copy /b config.settings+%MAKECMD%.defs+..\lib-src\makefile.w32-in ..\lib-src\makefile\r
f915f0f7 831copy /b config.settings+%MAKECMD%.defs+..\lib\makefile.w32-in ..\lib\makefile\r
f466241d 832copy /b config.settings+%MAKECMD%.defs+..\src\makefile.w32-in ..\src\makefile\r
8aee12d0
GM
833copy /b config.settings+%MAKECMD%.defs+..\doc\emacs\makefile.w32-in ..\doc\emacs\makefile\r
834copy /b config.settings+%MAKECMD%.defs+..\doc\misc\makefile.w32-in ..\doc\misc\makefile\r
835copy /b config.settings+%MAKECMD%.defs+..\doc\lispref\makefile.w32-in ..\doc\lispref\makefile\r
836copy /b config.settings+%MAKECMD%.defs+..\doc\lispintro\makefile.w32-in ..\doc\lispintro\makefile\r
f466241d
EZ
837if exist ..\lisp\makefile rm -f ../lisp/[Mm]akefile\r
838copy /b config.settings+%MAKECMD%.defs+..\lisp\makefile.w32-in ..\lisp\makefile\r
839rem Use the default (no-op) Makefile.in if the nt version is not present.\r
840if exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\makefile.w32-in ..\leim\makefile\r
841if not exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\Makefile.in ..\leim\makefile\r
842del config.settings\r
843\r
e44f8099
EZ
844Rem Some people use WinZip which doesn't create empty directories!\r
845if not exist ..\site-lisp\nul mkdir ..\site-lisp\\r
57a64408
JB
846Rem Update subdirs.el only if it is different or fc.exe doesn't work.\r
847if exist foo.bar del foo.bar\r
848fc /b foo.bar foo.bar >nul 2>&1\r
849if not errorlevel 2 goto doUpdateSubdirs\r
850fc /b subdirs.el ..\site-lisp\subdirs.el >nul 2>&1\r
851if not errorlevel 1 goto dontUpdateSubdirs\r
ee705a5c 852\r
57a64408
JB
853:doUpdateSubdirs\r
854if exist ..\site-lisp\subdirs.el del ..\site-lisp\subdirs.el\r
855copy subdirs.el ..\site-lisp\subdirs.el\r
856\r
857:dontUpdateSubdirs\r
f466241d 858echo.\r
32154d10
JR
859\r
860rem check that we have all the libraries we need.\r
861set libsOK=1\r
862\r
863if not "(%HAVE_XPM%)" == "()" goto checkpng\r
864if (%xpmsupport%) == (N) goto checkpng\r
865 set libsOK=0\r
866 echo XPM support is missing. It is required for color icons in the toolbar.\r
867 echo Install libXpm development files or use --without-xpm\r
868\r
869:checkpng\r
870if not "(%HAVE_PNG%)" == "()" goto checkjpeg\r
871if (%pngsupport%) == (N) goto checkjpeg\r
872 set libsOK=0\r
873 echo PNG support is missing.\r
874 echo Install libpng development files or use --without-png\r
875\r
876:checkjpeg\r
877if not "(%HAVE_JPEG%)" == "()" goto checktiff\r
878if (%jpegsupport%) == (N) goto checktiff\r
879 set libsOK=0\r
880 echo JPEG support is missing.\r
881 echo Install jpeg development files or use --without-jpeg\r
882\r
883:checktiff\r
884if not "(%HAVE_TIFF%)" == "()" goto checkgif\r
885if (%tiffsupport%) == (N) goto checkgif\r
886 set libsOK=0\r
887 echo TIFF support is missing.\r
888 echo Install libtiff development files or use --without-tiff\r
889\r
890:checkgif\r
e3aef5c6
CS
891if not "(%HAVE_GIF%)" == "()" goto checkdistfiles\r
892if (%gifsupport%) == (N) goto checkdistfiles\r
32154d10
JR
893 set libsOK=0\r
894 echo GIF support is missing.\r
895 echo Install giflib or libungif development files or use --without-gif\r
896\r
e3aef5c6
CS
897:checkdistfiles\r
898if "(%HAVE_DISTFILES%)" == "()" goto donelibchecks\r
899if (%distFilesOk%) == (1) goto donelibchecks\r
900echo.\r
901echo Files specified with option --distfiles could not be found.\r
902echo Fix these issues before running make dist\r
903\r
32154d10
JR
904:donelibchecks\r
905if (%libsOK%) == (1) goto success\r
906echo.\r
907echo Important libraries are missing. Fix these issues before running make.\r
908goto end\r
909\r
910:success\r
f466241d 911echo Emacs successfully configured.\r
a27014fc 912echo Emacs successfully configured. >>config.log\r
361823f4 913if (%MAKECMD%) == (gmake) set MAKECMD=make\r
f466241d
EZ
914echo Run `%MAKECMD%' to build, then run `%MAKECMD% install' to install.\r
915goto end\r
916\r
917:SmallEnv\r
918echo Your environment size is too small. Please enlarge it and rerun configure.\r
919echo For example, type "command.com /e:2048" to have 2048 bytes available.\r
920set $foo$=\r
ee705a5c 921\r
f466241d
EZ
922:end\r
923set prefix=\r
924set nodebug=\r
925set noopt=\r
7d0170c8 926set enablechecking=\r
75663c75 927set profile=\r
f466241d
EZ
928set nocygwin=\r
929set COMPILER=\r
930set MAKECMD=\r
931set usercflags=\r
3a1ebd63 932set docflags=\r
f466241d 933set userldflags=\r
3a1ebd63 934set doldflags=\r
112dc8e1 935set mingwflag=\r
dbbdb507 936set mf=\r
e3aef5c6
CS
937set distfiles=\r
938set HAVE_DISTFILES=\r
939set distFilesOk=\r
ca6e909c 940set pngsupport=\r
fd4af8d9 941set tlssupport=\r
9078ead6 942set libxml2support=\r
ca6e909c
EZ
943set jpegsupport=\r
944set gifsupport=\r
945set tiffsupport=\r
946set xpmsupport=\r
947set svgsupport=\r
948set libsOK=\r
949set HAVE_GIF=\r
950set HAVE_JPEG=\r
951set HAVE_PNG=\r
952set HAVE_TIFF=\r
953set HAVE_XPM=\r
954set dbginfo=\r
a30cb5dd
EZ
955endlocal\r
956set use_extensions=\r
a2fcf029 957\r