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