configure.bat 28.8 KB
Newer Older
Eli Zaretskii's avatar
Eli Zaretskii committed
1 2
@echo off
rem   ----------------------------------------------------------------------
3
rem   Configuration script for MS Windows operating systems
4
rem   Copyright (C) 1999-2011  Free Software Foundation, Inc.
Eli Zaretskii's avatar
Eli Zaretskii committed
5 6 7

rem   This file is part of GNU Emacs.

8
rem   GNU Emacs is free software: you can redistribute it and/or modify
Eli Zaretskii's avatar
Eli Zaretskii committed
9
rem   it under the terms of the GNU General Public License as published by
10 11
rem   the Free Software Foundation, either version 3 of the License, or
rem   (at your option) any later version.
Eli Zaretskii's avatar
Eli Zaretskii committed
12 13 14 15 16 17 18

rem   GNU Emacs is distributed in the hope that it will be useful,
rem   but WITHOUT ANY WARRANTY; without even the implied warranty of
rem   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
rem   GNU General Public License for more details.

rem   You should have received a copy of the GNU General Public License
19 20
rem   along with GNU Emacs.  If not, see http://www.gnu.org/licenses/.

Eli Zaretskii's avatar
Eli Zaretskii committed
21 22 23
rem   ----------------------------------------------------------------------
rem   YOU'LL NEED THE FOLLOWING UTILITIES TO MAKE EMACS:
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 27
rem     or later) and the Mingw32 and W32 API headers and libraries.
rem   + Visual Studio 2005 is not supported at this time.
Eli Zaretskii's avatar
Eli Zaretskii committed
28
rem
29
rem For reference, here is a list of which builds of GNU make are known to
Eli Zaretskii's avatar
Eli Zaretskii committed
30 31
rem work or not, and whether they work in the presence and/or absence of
rem sh.exe.
Juanma Barranquero's avatar
Juanma Barranquero committed
32
rem
Eli Zaretskii's avatar
Eli Zaretskii committed
33
rem                                       sh exists     no sh
34
rem  cygwin b20.1 make (3.75):            fails[1,5]    fails[2,5]
Eli Zaretskii's avatar
Eli Zaretskii committed
35 36 37
rem  MSVC compiled gmake 3.77:            okay          okay
rem  MSVC compiled gmake 3.78.1:          okay          okay
rem  MSVC compiled gmake 3.79.1:          okay          okay
38 39 40 41
rem  mingw32/gcc-2.92.2 make (3.77):      okay          okay[4]
rem  cygwin compiled gmake 3.77:          fails[1,5]    fails[2,5]
rem  cygwin compiled gmake 3.78.1:        fails[5]      fails[2,5]
rem  cygwin compiled gmake 3.79.1:        fails[3,5]    fails[2?,5]
42 43
rem  cygwin compiled make 3.80:           okay[6]       fails?[7]
rem  cygwin compiled make 3.81:           fails         fails?[7]
44
rem  mingw32 compiled make 3.79.1:        okay          okay
45 46
rem  mingw32 compiled make 3.80:          okay          okay?[7]
rem  mingw32 compiled make 3.81:          okay          okay[8]
Eli Zaretskii's avatar
Eli Zaretskii committed
47 48 49 50
rem
rem [1] doesn't cope with makefiles with DOS line endings, so must mount
rem     emacs source with text!=binary.
rem [2] fails when needs to invoke shell commands; okay invoking gcc etc.
51 52 53 54 55
rem [3] requires LC_MESSAGES support to build; cannot build with early
rem     versions of cygwin.
rem [4] may fail on Windows 9X and Windows ME; if so, install Bash.
rem [5] fails when building leim due to the use of cygwin style paths.
rem     May work if building emacs without leim.
56 57 58 59
rem [6] need to uncomment 3 lines in nt/gmake.defs that invoke `cygpath';
rem    	look for "cygpath" near line 85 of gmake.defs.
rem [7] not recommended; please report if you try this combination.
rem [8] tested only on Windows XP.
Eli Zaretskii's avatar
Eli Zaretskii committed
60 61
rem

Eli Zaretskii's avatar
Eli Zaretskii committed
62 63
if exist config.log del config.log

Eli Zaretskii's avatar
Eli Zaretskii committed
64 65 66 67 68 69 70 71 72 73 74 75 76
rem ----------------------------------------------------------------------
rem   See if the environment is large enough.  We need 43 (?) bytes.
set $foo$=123456789_123456789_123456789_123456789_123
if not "%$foo$%" == "123456789_123456789_123456789_123456789_123" goto SmallEnv
set $foo$=

rem ----------------------------------------------------------------------
rem   Make sure we are running in the nt subdir
if exist configure.bat goto start
echo You must run configure from the nt subdirectory.
goto end

:start
77 78 79 80 81 82 83 84 85 86 87 88 89
rem ----------------------------------------------------------------------
rem   Attempt to enable command extensions.  Set use_extensions to 1 if
rem   they are available and 0 if they are not available.
set use_extensions=1
setlocal ENABLEEXTENSIONS
if "%CMDEXTVERSION%" == "" set use_extensions=0
if "%use_extensions%" == "1" goto afterext

echo. Command extensions are not available.  Using parameters that include the =
echo. character by enclosing them in quotes will not be supported.

:afterext

Eli Zaretskii's avatar
Eli Zaretskii committed
90 91 92 93 94
rem ----------------------------------------------------------------------
rem   Default settings.
set prefix=
set nodebug=N
set noopt=N
95
set enablechecking=N
96
set profile=N
Eli Zaretskii's avatar
Eli Zaretskii committed
97 98 99
set nocygwin=N
set COMPILER=
set usercflags=
100
set escusercflags=
101
set docflags=
Eli Zaretskii's avatar
Eli Zaretskii committed
102
set userldflags=
103
set escuserldflags=
Ted Zlatanov's avatar
Ted Zlatanov committed
104
set extrauserlibs=
105
set doldflags=
Ted Zlatanov's avatar
Ted Zlatanov committed
106
set doextralibs=
Eli Zaretskii's avatar
Eli Zaretskii committed
107 108
set sep1=
set sep2=
109
set sep3=
Ted Zlatanov's avatar
Ted Zlatanov committed
110
set sep4=
111
set distfiles=
Eli Zaretskii's avatar
Eli Zaretskii committed
112 113 114 115 116 117 118 119 120 121 122

rem ----------------------------------------------------------------------
rem   Handle arguments.
:again
if "%1" == "-h" goto usage
if "%1" == "--help" goto usage
if "%1" == "--prefix" goto setprefix
if "%1" == "--with-gcc" goto withgcc
if "%1" == "--with-msvc" goto withmsvc
if "%1" == "--no-debug" goto nodebug
if "%1" == "--no-opt" goto noopt
123
if "%1" == "--enable-checking" goto enablechecking
124
if "%1" == "--profile" goto profile
Eli Zaretskii's avatar
Eli Zaretskii committed
125 126 127
if "%1" == "--no-cygwin" goto nocygwin
if "%1" == "--cflags" goto usercflags
if "%1" == "--ldflags" goto userldflags
Ted Zlatanov's avatar
Ted Zlatanov committed
128
if "%1" == "--lib" goto extrauserlibs
Jason Rumney's avatar
Jason Rumney committed
129
if "%1" == "--without-png" goto withoutpng
Jason Rumney's avatar
Jason Rumney committed
130
if "%1" == "--without-jpeg" goto withoutjpeg
131
if "%1" == "--without-gif" goto withoutgif
132
if "%1" == "--without-tiff" goto withouttiff
Ted Zlatanov's avatar
Ted Zlatanov committed
133
if "%1" == "--without-gnutls" goto withoutgnutls
Jason Rumney's avatar
Jason Rumney committed
134
if "%1" == "--without-xpm" goto withoutxpm
135
if "%1" == "--with-svg" goto withsvg
136
if "%1" == "--distfiles" goto distfiles
Eli Zaretskii's avatar
Eli Zaretskii committed
137
if "%1" == "" goto checkutils
138

Eli Zaretskii's avatar
Eli Zaretskii committed
139 140 141 142 143 144 145 146
:usage
echo Usage: configure [options]
echo Options:
echo.   --prefix PREFIX         install Emacs in directory PREFIX
echo.   --with-gcc              use GCC to compile Emacs
echo.   --with-msvc             use MSVC to compile Emacs
echo.   --no-debug              exclude debug info from executables
echo.   --no-opt                disable optimization
147
echo.   --enable-checking       enable checks and assertions
148
echo.   --profile               enable profiling
Eli Zaretskii's avatar
Eli Zaretskii committed
149 150 151
echo.   --no-cygwin             use -mno-cygwin option with GCC
echo.   --cflags FLAG           pass FLAG to compiler
echo.   --ldflags FLAG          pass FLAG to compiler when linking
Ted Zlatanov's avatar
Ted Zlatanov committed
152
echo.   --lib LIB               link to extra library LIB
153 154 155 156 157
echo.   --without-png           do not use PNG library even if it is installed
echo.   --without-jpeg          do not use JPEG library even if it is installed
echo.   --without-gif           do not use GIF library even if it is installed
echo.   --without-tiff          do not use TIFF library even if it is installed
echo.   --without-xpm           do not use XPM library even if it is installed
Ted Zlatanov's avatar
Ted Zlatanov committed
158
echo.   --without-gnutls        do not use GNUTLS library even if it is installed
159
echo.   --with-svg              use the RSVG library (experimental)
160
echo.   --distfiles             path to files for make dist, e.g. libXpm.dll
161 162 163 164 165 166 167 168 169 170 171 172 173 174
if "%use_extensions%" == "0" goto end
echo.
echo. The cflags and ldflags arguments support parameters that include the =
echo. character.  However, since the = character is normally treated as a
echo. separator character you will need to enclose any parameter that includes
echo. the = character in quotes.  For example, to include
echo. -DSITELOAD_PURESIZE_EXTRA=100000 as one of the cflags you would run
echo. configure.bat as follows:
echo. configure.bat --cflags "-DSITELOAD_PURESIZE_EXTRA=100000"
echo.
echo. Note that this capability of processing parameters that include the =
echo. character depends on command extensions.  This batch file attempts to
echo. enable command extensions.  If command extensions cannot be enabled, a
echo. warning message will be displayed.
Eli Zaretskii's avatar
Eli Zaretskii committed
175
goto end
176

Eli Zaretskii's avatar
Eli Zaretskii committed
177
rem ----------------------------------------------------------------------
178

Eli Zaretskii's avatar
Eli Zaretskii committed
179 180 181 182 183
:setprefix
shift
set prefix=%1
shift
goto again
184

Eli Zaretskii's avatar
Eli Zaretskii committed
185
rem ----------------------------------------------------------------------
186

Eli Zaretskii's avatar
Eli Zaretskii committed
187 188 189 190
:withgcc
set COMPILER=gcc
shift
goto again
191

Eli Zaretskii's avatar
Eli Zaretskii committed
192
rem ----------------------------------------------------------------------
193

Eli Zaretskii's avatar
Eli Zaretskii committed
194 195 196 197
:withmsvc
set COMPILER=cl
shift
goto again
198

Eli Zaretskii's avatar
Eli Zaretskii committed
199
rem ----------------------------------------------------------------------
200

Eli Zaretskii's avatar
Eli Zaretskii committed
201 202 203 204
:nodebug
set nodebug=Y
shift
goto again
205

Eli Zaretskii's avatar
Eli Zaretskii committed
206
rem ----------------------------------------------------------------------
207

Eli Zaretskii's avatar
Eli Zaretskii committed
208 209 210 211
:noopt
set noopt=Y
shift
goto again
212

Eli Zaretskii's avatar
Eli Zaretskii committed
213
rem ----------------------------------------------------------------------
214

215 216 217 218
:enablechecking
set enablechecking=Y
shift
goto again
219

220
rem ----------------------------------------------------------------------
221

222 223 224 225
:profile
set profile=Y
shift
goto again
226

227
rem ----------------------------------------------------------------------
228

Eli Zaretskii's avatar
Eli Zaretskii committed
229 230 231 232
:nocygwin
set nocygwin=Y
shift
goto again
233

Eli Zaretskii's avatar
Eli Zaretskii committed
234
rem ----------------------------------------------------------------------
235

Eli Zaretskii's avatar
Eli Zaretskii committed
236
:usercflags
237 238 239 240 241 242
if "%use_extensions%" == "1" goto ucflagex
goto ucflagne

:ucflagex
shift
set usercflags=%usercflags%%sep1%%~1
243
set escusercflags=%usercflags:"=\"%
244 245 246 247 248
set sep1= %nothing%
shift
goto again

:ucflagne
Eli Zaretskii's avatar
Eli Zaretskii committed
249 250
shift
set usercflags=%usercflags%%sep1%%1
251
set escusercflags=%usercflags%
Eli Zaretskii's avatar
Eli Zaretskii committed
252 253 254
set sep1= %nothing%
shift
goto again
255

Ted Zlatanov's avatar
Ted Zlatanov committed
256 257 258 259 260 261 262 263
:extrauserlibs
shift
echo. extrauserlibs: %extrauserlibs%
set extrauserlibs=%extrauserlibs%%sep4%%1
set sep4= %nothing%
shift
goto again

Eli Zaretskii's avatar
Eli Zaretskii committed
264
rem ----------------------------------------------------------------------
265

Eli Zaretskii's avatar
Eli Zaretskii committed
266
:userldflags
267 268 269 270 271 272
if "%use_extensions%" == "1" goto ulflagex
goto ulflagne

:ulflagex
shift
set userldflags=%userldflags%%sep2%%~1
273
set escuserldflags=%userldflags:"=\"%
274 275 276 277 278
set sep2= %nothing%
shift
goto again

:ulflagne
Eli Zaretskii's avatar
Eli Zaretskii committed
279 280
shift
set userldflags=%userldflags%%sep2%%1
281
set escuserldflags=%userldflags%
Eli Zaretskii's avatar
Eli Zaretskii committed
282 283 284
set sep2= %nothing%
shift
goto again
285

Jason Rumney's avatar
Jason Rumney committed
286 287 288 289 290
rem ----------------------------------------------------------------------

:withoutpng
set pngsupport=N
set HAVE_PNG=
291
shift
Jason Rumney's avatar
Jason Rumney committed
292
goto again
Eli Zaretskii's avatar
Eli Zaretskii committed
293

Jason Rumney's avatar
Jason Rumney committed
294 295 296 297 298
rem ----------------------------------------------------------------------

:withoutjpeg
set jpegsupport=N
set HAVE_JPEG=
299
shift
Jason Rumney's avatar
Jason Rumney committed
300 301
goto again

302 303 304 305 306 307 308 309
rem ----------------------------------------------------------------------

:withoutgif
set gifsupport=N
set HAVE_GIF=
shift
goto again

310 311
rem ----------------------------------------------------------------------

Ted Zlatanov's avatar
Ted Zlatanov committed
312 313 314 315 316 317 318 319
:withoutgnutls
set tlssupport=N
set HAVE_GNUTLS=
shift
goto again

rem ----------------------------------------------------------------------

320 321 322 323 324 325
:withouttiff
set tiffsupport=N
set HAVE_TIFF=
shift
goto again

Jason Rumney's avatar
Jason Rumney committed
326 327 328 329 330 331 332 333
rem ----------------------------------------------------------------------

:withoutxpm
set xpmsupport=N
set HAVE_XPM=
shift
goto again

334 335 336 337 338
:withsvg
shift
set svgsupport=Y
goto again

339 340 341 342 343 344 345 346 347 348
rem ----------------------------------------------------------------------

:distfiles
set HAVE_DISTFILES=1
shift
set distfiles=%distfiles%%sep3%%1
set sep3= %nothing%
shift
goto again

Eli Zaretskii's avatar
Eli Zaretskii committed
349 350
rem ----------------------------------------------------------------------
rem    Check that necessary utilities (cp and rm) are present.
351

Eli Zaretskii's avatar
Eli Zaretskii committed
352 353 354 355 356 357 358 359
:checkutils
echo Checking for 'cp'...
cp configure.bat junk.bat
if not exist junk.bat goto needcp
echo Checking for 'rm'...
rm junk.bat
if exist junk.bat goto needrm
goto checkcompiler
360

Eli Zaretskii's avatar
Eli Zaretskii committed
361 362 363
:needcp
echo You need 'cp' (the Unix file copy program) to build Emacs.
goto end
364

Eli Zaretskii's avatar
Eli Zaretskii committed
365 366 367 368 369 370 371
:needrm
del junk.bat
echo You need 'rm' (the Unix file delete program) to build Emacs.
goto end

rem ----------------------------------------------------------------------
rem   Auto-detect compiler if not specified, and validate GCC if chosen.
372

Eli Zaretskii's avatar
Eli Zaretskii committed
373
:checkcompiler
Jason Rumney's avatar
Jason Rumney committed
374
if (%COMPILER%)==(cl) goto compilercheckdone
Eli Zaretskii's avatar
Eli Zaretskii committed
375 376 377
if (%COMPILER%)==(gcc) goto checkgcc

echo Checking whether 'gcc' is available...
Jason Rumney's avatar
Jason Rumney committed
378
echo main(){} >junk.c
Eli Zaretskii's avatar
Eli Zaretskii committed
379
gcc -c junk.c
Jason Rumney's avatar
Jason Rumney committed
380
if exist junk.o goto checkgcc
Eli Zaretskii's avatar
Eli Zaretskii committed
381

Jason Rumney's avatar
Jason Rumney committed
382 383 384 385 386
echo Checking whether 'cl' is available...
cl -nologo -c junk.c
if exist junk.obj goto clOK
goto nocompiler

Eli Zaretskii's avatar
Eli Zaretskii committed
387
:checkgcc
388
if exist junk.o del junk.o
Eli Zaretskii's avatar
Eli Zaretskii committed
389 390 391 392
Rem WARNING -- COMMAND.COM on some systems only looks at the first
Rem            8 characters of a label.  So do NOT be tempted to change
Rem            chkapi* into something fancier like checkw32api
Rem You HAVE been warned!
393
if (%nocygwin%) == (Y) goto chkapiN
Eli Zaretskii's avatar
Eli Zaretskii committed
394 395 396
echo Checking whether gcc requires '-mno-cygwin'...
echo #include "cygwin/version.h" >junk.c
echo main(){} >>junk.c
Eli Zaretskii's avatar
Eli Zaretskii committed
397 398
echo gcc -c junk.c >>config.log
gcc -c junk.c >>config.log 2>&1
Eli Zaretskii's avatar
Eli Zaretskii committed
399
if not exist junk.o goto chkapi
Eli Zaretskii's avatar
Eli Zaretskii committed
400 401
echo gcc -mno-cygwin -c junk.c >>config.log
gcc -mno-cygwin -c junk.c >>config.log 2>&1
Eli Zaretskii's avatar
Eli Zaretskii committed
402 403 404
if exist junk.o set nocygwin=Y

:chkapi
Eli Zaretskii's avatar
Eli Zaretskii committed
405 406
echo The failed program was: >>config.log
type junk.c >>config.log
407

408 409
:chkapiN
rm -f junk.c junk.o
Eli Zaretskii's avatar
Eli Zaretskii committed
410 411 412 413 414 415 416
rem ----------------------------------------------------------------------
rem   Older versions of the Windows API headers either don't have any of
rem   the IMAGE_xxx definitions (the headers that come with Cygwin b20.1
rem   are like this), or have a typo in the definition of
rem   IMAGE_FIRST_SECTION (the headers with gcc/mingw32 2.95 have this
rem   problem).  The gcc/mingw32 2.95.2 headers are okay, as are distros
rem   of w32api-xxx.zip from Anders Norlander since 1999-11-18 at least.
417
rem   Beginning with Emacs 23, we need usp10.h.
Eli Zaretskii's avatar
Eli Zaretskii committed
418 419 420
rem
echo Checking whether W32 API headers are too old...
echo #include "windows.h" >junk.c
421
echo #include "usp10.h" >>junk.c
Eli Zaretskii's avatar
Eli Zaretskii committed
422 423 424 425 426
echo test(PIMAGE_NT_HEADERS pHeader) >>junk.c
echo {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);} >>junk.c
if (%nocygwin%) == (Y) goto chkapi1
set cf=%usercflags%
goto chkapi2
427

Eli Zaretskii's avatar
Eli Zaretskii committed
428 429
:chkapi1
set cf=%usercflags% -mno-cygwin
430

Eli Zaretskii's avatar
Eli Zaretskii committed
431 432 433
:chkapi2
echo on
gcc %cf% -c junk.c
Eli Zaretskii's avatar
Eli Zaretskii committed
434 435 436
@echo off
@echo gcc %cf% -c junk.c >>config.log
gcc %cf% -c junk.c >>config.log 2>&1
Eli Zaretskii's avatar
Eli Zaretskii committed
437
set cf=
438
if exist junk.o goto chkuser
Eli Zaretskii's avatar
Eli Zaretskii committed
439 440
echo The failed program was: >>config.log
type junk.c >>config.log
441 442 443 444 445
goto nocompiler

:chkuser
rm -f junk.o
echo int main (int argc, char *argv[]) {>junk.c
446
echo char *usercflags = "%escusercflags%";>>junk.c
447 448 449 450 451 452 453 454 455 456
echo }>>junk.c
echo gcc -Werror -c junk.c >>config.log
gcc -Werror -c junk.c >>config.log 2>&1
if exist junk.o goto gccOk
echo.
echo Error in --cflags argument: %usercflags%
echo Backslashes and quotes cannot be used with --cflags.  Please use forward
echo slashes for filenames and paths (e.g. when passing directories to -I).
rm -f junk.c
goto end
Eli Zaretskii's avatar
Eli Zaretskii committed
457 458 459 460 461 462 463 464 465 466 467 468 469

:nocompiler
echo.
echo Configure failed.
echo To configure Emacs for Windows, you need to have either
echo gcc-2.95 or later with Mingw32 and the W32 API headers,
echo or MSVC 2.x or later.
del junk.c
goto end

:gccOk
set COMPILER=gcc
echo Using 'gcc'
Eli Zaretskii's avatar
Eli Zaretskii committed
470 471 472 473 474 475 476 477 478 479 480
rm -f junk.c junk.o
Rem It is not clear what GCC version began supporting -mtune
Rem and pentium4 on x86, so check this explicitly.
echo main(){} >junk.c
echo gcc -c -O2 -mtune=pentium4 junk.c >>config.log
gcc -c -O2 -mtune=pentium4 junk.c >>config.log 2>&1
if not errorlevel 1 goto gccMtuneOk
echo The failed program was: >>config.log
type junk.c >>config.log
set mf=-mcpu=i686
rm -f junk.c junk.o
481
goto gccdebug
482

Eli Zaretskii's avatar
Eli Zaretskii committed
483 484 485 486
:gccMtuneOk
echo GCC supports -mtune=pentium4 >>config.log
set mf=-mtune=pentium4
rm -f junk.c junk.o
487

488 489 490 491 492 493 494 495 496 497 498
:gccdebug
rem Check for DWARF-2 debug info support, else default to stabs
echo main(){} >junk.c
echo gcc -c -gdwarf-2 -g3 junk.c >>config.log
gcc -c -gdwarf-2 -g3 junk.c >>config.log 2>&1
if not errorlevel 1 goto gccdwarf
echo The failed program was: >>config.log
type junk.c >>config.log
set dbginfo=-gstabs+
rm -f junk.c junk.o
goto compilercheckdone
499

500 501 502 503
:gccdwarf
echo GCC supports DWARF-2 >>config.log
set dbginfo=-gdwarf-2 -g3
rm -f junk.c junk.o
Jason Rumney's avatar
Jason Rumney committed
504
goto compilercheckdone
Eli Zaretskii's avatar
Eli Zaretskii committed
505 506 507 508 509

:clOk
set COMPILER=cl
rm -f junk.c junk.obj
echo Using 'MSVC'
Jason Rumney's avatar
Jason Rumney committed
510 511 512 513 514 515 516 517

:compilercheckdone

rem ----------------------------------------------------------------------
rem   Check for external image libraries. Since they are loaded
rem   dynamically, the libraries themselves do not need to be present
rem   at compile time, but the header files are required.

518 519 520 521 522 523 524
set mingwflag=

if (%nocygwin%) == (N) goto flagsOK
set mingwflag=-mno-cygwin

:flagsOK

Jason Rumney's avatar
Jason Rumney committed
525 526 527 528 529 530
if (%pngsupport%) == (N) goto pngDone

echo Checking for libpng...
echo #include "png.h" >junk.c
echo main (){} >>junk.c
rem   -o option is ignored with cl, but allows result to be consistent.
Eli Zaretskii's avatar
Eli Zaretskii committed
531 532
echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log
%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log
Jason Rumney's avatar
Jason Rumney committed
533 534
if exist junk.obj goto havePng

Jason Rumney's avatar
Jason Rumney committed
535
echo ...png.h not found, building without PNG support.
Eli Zaretskii's avatar
Eli Zaretskii committed
536 537
echo The failed program was: >>config.log
type junk.c >>config.log
Jason Rumney's avatar
Jason Rumney committed
538 539 540 541 542 543 544 545 546
set HAVE_PNG=
goto :pngDone

:havePng
echo ...PNG header available, building with PNG support.
set HAVE_PNG=1

:pngDone
rm -f junk.c junk.obj
Eli Zaretskii's avatar
Eli Zaretskii committed
547

Ted Zlatanov's avatar
Ted Zlatanov committed
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
if (%tlssupport%) == (N) goto tlsDone

rem this is a copy of the PNG detection
echo Checking for libgnutls...
echo #include "gnutls/gnutls.h" >junk.c
echo main (){} >>junk.c
rem   -o option is ignored with cl, but allows result to be consistent.
echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log
%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log
if exist junk.obj goto haveTls

echo ...gnutls.h not found, building without TLS support.
echo The failed program was: >>config.log
type junk.c >>config.log
set HAVE_GNUTLS=
goto :tlsDone

:haveTls
echo ...GNUTLS header available, building with GNUTLS support.
set HAVE_GNUTLS=1

:tlsDone
rm -f junk.c junk.obj

Jason Rumney's avatar
Jason Rumney committed
572 573
if (%jpegsupport%) == (N) goto jpegDone

Jason Rumney's avatar
Jason Rumney committed
574
echo Checking for jpeg-6b...
Jason Rumney's avatar
Jason Rumney committed
575 576 577
echo #include "jconfig.h" >junk.c
echo main (){} >>junk.c
rem   -o option is ignored with cl, but allows result to be consistent.
Eli Zaretskii's avatar
Eli Zaretskii committed
578 579
echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log
%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log
Jason Rumney's avatar
Jason Rumney committed
580 581
if exist junk.obj goto haveJpeg

Jason Rumney's avatar
Jason Rumney committed
582
echo ...jconfig.h not found, building without JPEG support.
Eli Zaretskii's avatar
Eli Zaretskii committed
583 584
echo The failed program was: >>config.log
type junk.c >>config.log
Jason Rumney's avatar
Jason Rumney committed
585 586 587 588 589 590 591 592 593 594
set HAVE_JPEG=
goto :jpegDone

:haveJpeg
echo ...JPEG header available, building with JPEG support.
set HAVE_JPEG=1

:jpegDone
rm -f junk.c junk.obj

595 596
if (%gifsupport%) == (N) goto gifDone

Jason Rumney's avatar
Jason Rumney committed
597
echo Checking for libgif...
598 599 600
echo #include "gif_lib.h" >junk.c
echo main (){} >>junk.c
rem   -o option is ignored with cl, but allows result to be consistent.
Eli Zaretskii's avatar
Eli Zaretskii committed
601 602
echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log
%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log
603 604
if exist junk.obj goto haveGif

Jason Rumney's avatar
Jason Rumney committed
605
echo ...gif_lib.h not found, building without GIF support.
Eli Zaretskii's avatar
Eli Zaretskii committed
606 607
echo The failed program was: >>config.log
type junk.c >>config.log
608 609 610 611 612 613 614 615 616 617
set HAVE_GIF=
goto :gifDone

:haveGif
echo ...GIF header available, building with GIF support.
set HAVE_GIF=1

:gifDone
rm -f junk.c junk.obj

618 619 620 621 622 623
if (%tiffsupport%) == (N) goto tiffDone

echo Checking for tiff...
echo #include "tiffio.h" >junk.c
echo main (){} >>junk.c
rem   -o option is ignored with cl, but allows result to be consistent.
Eli Zaretskii's avatar
Eli Zaretskii committed
624 625
echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log
%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log
626 627
if exist junk.obj goto haveTiff

Jason Rumney's avatar
Jason Rumney committed
628
echo ...tiffio.h not found, building without TIFF support.
Eli Zaretskii's avatar
Eli Zaretskii committed
629 630
echo The failed program was: >>config.log
type junk.c >>config.log
631 632 633 634 635 636 637 638 639 640
set HAVE_TIFF=
goto :tiffDone

:haveTiff
echo ...TIFF header available, building with TIFF support.
set HAVE_TIFF=1

:tiffDone
rm -f junk.c junk.obj

Jason Rumney's avatar
Jason Rumney committed
641 642 643 644 645 646 647
if (%xpmsupport%) == (N) goto xpmDone

echo Checking for libXpm...
echo #define FOR_MSW 1 >junk.c
echo #include "X11/xpm.h" >>junk.c
echo main (){} >>junk.c
rem   -o option is ignored with cl, but allows result to be consistent.
Eli Zaretskii's avatar
Eli Zaretskii committed
648 649
echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log
%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log
Jason Rumney's avatar
Jason Rumney committed
650 651 652
if exist junk.obj goto haveXpm

echo ...X11/xpm.h not found, building without XPM support.
Eli Zaretskii's avatar
Eli Zaretskii committed
653 654
echo The failed program was: >>config.log
type junk.c >>config.log
Jason Rumney's avatar
Jason Rumney committed
655 656 657 658 659 660 661 662
set HAVE_XPM=
goto :xpmDone

:haveXpm
echo ...XPM header available, building with XPM support.
set HAVE_XPM=1

:xpmDone
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
rm -f junk.c junk.obj

if not (%svgsupport%) == (Y) goto :svgDone
echo Checking for librsvg...
echo #include "librsvg/rsvg.h" >junk.c
echo main (){} >>junk.c
rem   -o option is ignored with cl, but allows result to be consistent.
echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log
%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log
if exist junk.obj goto haveSvg

echo ...librsvg/rsvg.h or dependencies not found, building without SVG support.
echo The failed program was: >>config.log
type junk.c >>config.log
set HAVE_RSVG=
goto :svgDone

:haveSvg
echo ...librsvg header available, building with SVG support (EXPERIMENTAL).
set HAVE_RSVG=1

:svgDone
Jason Rumney's avatar
Jason Rumney committed
685 686
rm -f junk.c junk.obj junk.err junk.out

687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
rem Any distfiles provided for building distribution? If no, we're done.
if "(%HAVE_DISTFILES%)"=="()" goto :distFilesDone

rem Any arguments to --distfiles specified? If no, we're done.
if not "%distfiles%"=="" goto :checkDistFiles
set distFilesOk=0
echo No arguments specified for option --distfiles!
goto distfilesDone

:checkDistFiles
echo Checking for distfiles...
rem Check if all specified distfiles exist
set fileNotFound=
for %%d in (%distfiles%) do if not exist %%d set fileNotFound=%%d
if not "%fileNotFound%"=="" goto distFilesNotFound

set distFilesOK=1
echo ...all distfiles found.
goto :distFilesDone

:distFilesNotFound
set distFilesOk=0
echo ...%fileNotFound% not found.
set distfiles=
goto :distfilesDone

:distFilesDone
set fileNotFound=

Eli Zaretskii's avatar
Eli Zaretskii committed
716
rem ----------------------------------------------------------------------
717

Eli Zaretskii's avatar
Eli Zaretskii committed
718 719 720 721 722 723 724 725 726 727 728
:genmakefiles
echo Generating makefiles
if %COMPILER% == gcc set MAKECMD=gmake
if %COMPILER% == cl set MAKECMD=nmake

rem   Pass on chosen settings to makefiles.
rem   NB. Be very careful to not have a space before redirection symbols
rem   except when there is a preceding digit, when a space is required.
rem
echo # Start of settings from configure.bat >config.settings
echo COMPILER=%COMPILER%>>config.settings
Eli Zaretskii's avatar
Eli Zaretskii committed
729
if not "(%mf%)" == "()" echo MCPU_FLAG=%mf%>>config.settings
730
if not "(%dbginfo%)" == "()" echo DEBUG_INFO=%dbginfo%>>config.settings
Eli Zaretskii's avatar
Eli Zaretskii committed
731 732
if (%nodebug%) == (Y) echo NODEBUG=1 >>config.settings
if (%noopt%) == (Y) echo NOOPT=1 >>config.settings
733
if (%enablechecking%) == (Y) echo ENABLECHECKS=1 >>config.settings
734
if (%profile%) == (Y) echo PROFILE=1 >>config.settings
Eli Zaretskii's avatar
Eli Zaretskii committed
735 736
if (%nocygwin%) == (Y) echo NOCYGWIN=1 >>config.settings
if not "(%prefix%)" == "()" echo INSTALL_DIR=%prefix%>>config.settings
737
if not "(%distfiles%)" == "()" echo DIST_FILES=%distfiles%>>config.settings
738 739 740 741
rem We go thru docflags because usercflags could be "-DFOO=bar" -something
rem and the if command cannot cope with this
for %%v in (%usercflags%) do if not (%%v)==() set docflags=Y
if (%docflags%)==(Y) echo USER_CFLAGS=%usercflags%>>config.settings
742
if (%docflags%)==(Y) echo ESC_USER_CFLAGS=%escusercflags%>>config.settings
743 744
for %%v in (%userldflags%) do if not (%%v)==() set doldflags=Y
if (%doldflags%)==(Y) echo USER_LDFLAGS=%userldflags%>>config.settings
Ted Zlatanov's avatar
Ted Zlatanov committed
745 746
for %%v in (%extrauserlibs%) do if not (%%v)==() set doextralibs=Y
if (%doextralibs%)==(Y) echo USER_LIBS=%extrauserlibs%>>config.settings
Eli Zaretskii's avatar
Eli Zaretskii committed
747 748 749
echo # End of settings from configure.bat>>config.settings
echo. >>config.settings

750 751 752
copy config.nt config.tmp
echo. >>config.tmp
echo /* Start of settings from configure.bat.  */ >>config.tmp
753 754
rem   We write USER_CFLAGS and USER_LDFLAGS starting with a space to simplify
rem   processing of compiler options in w32.c:get_emacs_configuration_options
755 756
if (%docflags%) == (Y) echo #define USER_CFLAGS " %escusercflags%">>config.tmp
if (%doldflags%) == (Y) echo #define USER_LDFLAGS " %escuserldflags%">>config.tmp
757
if (%profile%) == (Y) echo #define PROFILING 1 >>config.tmp
758
if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>config.tmp
Ted Zlatanov's avatar
Ted Zlatanov committed
759
if not "(%HAVE_GNUTLS%)" == "()" echo #define HAVE_GNUTLS 1 >>config.tmp
760 761 762 763
if not "(%HAVE_JPEG%)" == "()" echo #define HAVE_JPEG 1 >>config.tmp
if not "(%HAVE_GIF%)" == "()" echo #define HAVE_GIF 1 >>config.tmp
if not "(%HAVE_TIFF%)" == "()" echo #define HAVE_TIFF 1 >>config.tmp
if not "(%HAVE_XPM%)" == "()" echo #define HAVE_XPM 1 >>config.tmp
764 765
if "(%HAVE_RSVG%)" == "(1)" echo #define HAVE_RSVG 1 >>config.tmp

766 767 768 769 770 771 772 773 774 775 776
echo /* End of settings from configure.bat.  */ >>config.tmp

Rem See if fc.exe returns a meaningful exit status.  If it does, we
Rem might as well avoid unnecessary overwriting of config.h and epaths.h,
Rem since this forces recompilation of every source file.
if exist foo.bar del foo.bar
fc /b foo.bar foo.bar >nul 2>&1
if not errorlevel 2 goto doCopy
fc /b config.tmp ..\src\config.h >nul 2>&1
if errorlevel 1 goto doCopy
fc /b paths.h ..\src\epaths.h >nul 2>&1
777
if not errorlevel 1 goto dontCopy
778

779 780
:doCopy
copy config.tmp ..\src\config.h
Eli Zaretskii's avatar
Eli Zaretskii committed
781 782
copy paths.h ..\src\epaths.h

783 784
:dontCopy
if exist config.tmp del config.tmp
Eli Zaretskii's avatar
Eli Zaretskii committed
785
copy /b config.settings+%MAKECMD%.defs+..\nt\makefile.w32-in ..\nt\makefile
786
if exist ..\admin\unidata copy /b config.settings+%MAKECMD%.defs+..\admin\unidata\makefile.w32-in ..\admin\unidata\makefile
Eli Zaretskii's avatar
Eli Zaretskii committed
787
copy /b config.settings+%MAKECMD%.defs+..\lib-src\makefile.w32-in ..\lib-src\makefile
788
copy /b config.settings+%MAKECMD%.defs+..\lib\makefile.w32-in ..\lib\makefile
Eli Zaretskii's avatar
Eli Zaretskii committed
789
copy /b config.settings+%MAKECMD%.defs+..\src\makefile.w32-in ..\src\makefile
790 791 792 793
copy /b config.settings+%MAKECMD%.defs+..\doc\emacs\makefile.w32-in ..\doc\emacs\makefile
copy /b config.settings+%MAKECMD%.defs+..\doc\misc\makefile.w32-in ..\doc\misc\makefile
copy /b config.settings+%MAKECMD%.defs+..\doc\lispref\makefile.w32-in ..\doc\lispref\makefile
copy /b config.settings+%MAKECMD%.defs+..\doc\lispintro\makefile.w32-in ..\doc\lispintro\makefile
Eli Zaretskii's avatar
Eli Zaretskii committed
794 795 796 797 798 799 800
if exist ..\lisp\makefile rm -f ../lisp/[Mm]akefile
copy /b config.settings+%MAKECMD%.defs+..\lisp\makefile.w32-in ..\lisp\makefile
rem   Use the default (no-op) Makefile.in if the nt version is not present.
if exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\makefile.w32-in ..\leim\makefile
if not exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\Makefile.in ..\leim\makefile
del config.settings

801 802
Rem Some people use WinZip which doesn't create empty directories!
if not exist ..\site-lisp\nul mkdir ..\site-lisp\
803 804 805 806 807 808
Rem Update subdirs.el only if it is different or fc.exe doesn't work.
if exist foo.bar del foo.bar
fc /b foo.bar foo.bar >nul 2>&1
if not errorlevel 2 goto doUpdateSubdirs
fc /b subdirs.el ..\site-lisp\subdirs.el >nul 2>&1
if not errorlevel 1 goto dontUpdateSubdirs
809

810 811 812 813 814
:doUpdateSubdirs
if exist ..\site-lisp\subdirs.el del ..\site-lisp\subdirs.el
copy subdirs.el ..\site-lisp\subdirs.el

:dontUpdateSubdirs
Eli Zaretskii's avatar
Eli Zaretskii committed
815
echo.
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847

rem check that we have all the libraries we need.
set libsOK=1

if not "(%HAVE_XPM%)" == "()" goto checkpng
if (%xpmsupport%) == (N) goto checkpng
 set libsOK=0
 echo XPM support is missing. It is required for color icons in the toolbar.
 echo   Install libXpm development files or use --without-xpm

:checkpng
if not "(%HAVE_PNG%)" == "()" goto checkjpeg
if (%pngsupport%) == (N) goto checkjpeg
 set libsOK=0
 echo PNG support is missing.
 echo   Install libpng development files or use --without-png

:checkjpeg
if not "(%HAVE_JPEG%)" == "()" goto checktiff
if (%jpegsupport%) == (N) goto checktiff
 set libsOK=0
 echo JPEG support is missing.
 echo   Install jpeg development files or use --without-jpeg

:checktiff
if not "(%HAVE_TIFF%)" == "()" goto checkgif
if (%tiffsupport%) == (N) goto checkgif
 set libsOK=0
 echo TIFF support is missing.
 echo   Install libtiff development files or use --without-tiff

:checkgif
848 849
if not "(%HAVE_GIF%)" == "()" goto checkdistfiles
if (%gifsupport%) == (N) goto checkdistfiles
850 851 852 853
 set libsOK=0
 echo GIF support is missing.
 echo   Install giflib or libungif development files or use --without-gif

854 855 856 857 858 859 860
:checkdistfiles
if "(%HAVE_DISTFILES%)" == "()" goto donelibchecks
if (%distFilesOk%) == (1) goto donelibchecks
echo.
echo Files specified with option --distfiles could not be found.
echo   Fix these issues before running make dist

861 862 863 864 865 866 867
:donelibchecks
if (%libsOK%) == (1) goto success
echo.
echo Important libraries are missing. Fix these issues before running make.
goto end

:success
Eli Zaretskii's avatar
Eli Zaretskii committed
868
echo Emacs successfully configured.
869
echo Emacs successfully configured. >>config.log
870
if (%MAKECMD%) == (gmake) set MAKECMD=make
Eli Zaretskii's avatar
Eli Zaretskii committed
871 872 873 874 875 876 877
echo Run `%MAKECMD%' to build, then run `%MAKECMD% install' to install.
goto end

:SmallEnv
echo Your environment size is too small.  Please enlarge it and rerun configure.
echo For example, type "command.com /e:2048" to have 2048 bytes available.
set $foo$=
878

Eli Zaretskii's avatar
Eli Zaretskii committed
879 880 881 882
:end
set prefix=
set nodebug=
set noopt=
883
set enablechecking=
884
set profile=
Eli Zaretskii's avatar
Eli Zaretskii committed
885 886 887 888
set nocygwin=
set COMPILER=
set MAKECMD=
set usercflags=
889
set docflags=
Eli Zaretskii's avatar
Eli Zaretskii committed
890
set userldflags=
891
set doldflags=
892
set mingwflag=
Eli Zaretskii's avatar
Eli Zaretskii committed
893
set mf=
894 895 896
set distfiles=
set HAVE_DISTFILES=
set distFilesOk=
897
set pngsupport=
Ted Zlatanov's avatar
Ted Zlatanov committed
898
set tlssupport=
899 900 901 902 903 904 905 906 907 908 909 910
set jpegsupport=
set gifsupport=
set tiffsupport=
set xpmsupport=
set svgsupport=
set libsOK=
set HAVE_GIF=
set HAVE_JPEG=
set HAVE_PNG=
set HAVE_TIFF=
set HAVE_XPM=
set dbginfo=
911