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