Add 2012 to FSF copyright years for Emacs files
[bpt/emacs.git] / nt / configure.bat
index 56b8570..e0362c5 100755 (executable)
@@ -1,8 +1,7 @@
 @echo off\r
 rem   ----------------------------------------------------------------------\r
-rem   Configuration script for MS Windows 95/98/Me and NT/2000/XP\r
-rem   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005,\r
-rem      2006, 2007, 2008, 2009 Free Software Foundation, Inc.\r
+rem   Configuration script for MS Windows operating systems\r
+rem   Copyright (C) 1999-2012  Free Software Foundation, Inc.\r
 \r
 rem   This file is part of GNU Emacs.\r
 \r
@@ -22,7 +21,7 @@ rem   along with GNU Emacs.  If not, see http://www.gnu.org/licenses/.
 rem   ----------------------------------------------------------------------\r
 rem   YOU'LL NEED THE FOLLOWING UTILITIES TO MAKE EMACS:\r
 rem\r
-rem   + MS Windows 95/98/Me or NT/2000/XP\r
+rem   + MS Windows 95, NT or later\r
 rem   + either MSVC 2.x or later, or gcc-2.95 or later (with GNU make 3.75\r
 rem     or later) and the Mingw32 and W32 API headers and libraries.\r
 rem   + Visual Studio 2005 is not supported at this time.\r
@@ -75,20 +74,41 @@ echo You must run configure from the nt subdirectory.
 goto end\r
 \r
 :start\r
+rem ----------------------------------------------------------------------\r
+rem   Attempt to enable command extensions.  Set use_extensions to 1 if\r
+rem   they are available and 0 if they are not available.\r
+set use_extensions=1\r
+setlocal ENABLEEXTENSIONS\r
+if "%CMDEXTVERSION%" == "" set use_extensions=0\r
+if "%use_extensions%" == "1" goto afterext\r
+\r
+echo. Command extensions are not available.  Using parameters that include the =\r
+echo. character by enclosing them in quotes will not be supported.\r
+\r
+:afterext\r
+\r
 rem ----------------------------------------------------------------------\r
 rem   Default settings.\r
 set prefix=\r
 set nodebug=N\r
 set noopt=N\r
+set enablechecking=N\r
 set profile=N\r
 set nocygwin=N\r
 set COMPILER=\r
 set usercflags=\r
+set escusercflags=\r
 set docflags=\r
 set userldflags=\r
+set escuserldflags=\r
+set extrauserlibs=\r
 set doldflags=\r
+set doextralibs=\r
 set sep1=\r
 set sep2=\r
+set sep3=\r
+set sep4=\r
+set distfiles=\r
 \r
 rem ----------------------------------------------------------------------\r
 rem   Handle arguments.\r
@@ -100,17 +120,22 @@ if "%1" == "--with-gcc" goto withgcc
 if "%1" == "--with-msvc" goto withmsvc\r
 if "%1" == "--no-debug" goto nodebug\r
 if "%1" == "--no-opt" goto noopt\r
+if "%1" == "--enable-checking" goto enablechecking\r
 if "%1" == "--profile" goto profile\r
 if "%1" == "--no-cygwin" goto nocygwin\r
 if "%1" == "--cflags" goto usercflags\r
 if "%1" == "--ldflags" goto userldflags\r
+if "%1" == "--lib" goto extrauserlibs\r
 if "%1" == "--without-png" goto withoutpng\r
 if "%1" == "--without-jpeg" goto withoutjpeg\r
 if "%1" == "--without-gif" goto withoutgif\r
 if "%1" == "--without-tiff" goto withouttiff\r
+if "%1" == "--without-gnutls" goto withoutgnutls\r
 if "%1" == "--without-xpm" goto withoutxpm\r
 if "%1" == "--with-svg" goto withsvg\r
+if "%1" == "--distfiles" goto distfiles\r
 if "%1" == "" goto checkutils\r
+\r
 :usage\r
 echo Usage: configure [options]\r
 echo Options:\r
@@ -119,67 +144,145 @@ echo.   --with-gcc              use GCC to compile Emacs
 echo.   --with-msvc             use MSVC to compile Emacs\r
 echo.   --no-debug              exclude debug info from executables\r
 echo.   --no-opt                disable optimization\r
+echo.   --enable-checking       enable checks and assertions\r
 echo.   --profile               enable profiling\r
 echo.   --no-cygwin             use -mno-cygwin option with GCC\r
 echo.   --cflags FLAG           pass FLAG to compiler\r
 echo.   --ldflags FLAG          pass FLAG to compiler when linking\r
+echo.   --lib LIB               link to extra library LIB\r
 echo.   --without-png           do not use PNG library even if it is installed\r
 echo.   --without-jpeg          do not use JPEG library even if it is installed\r
 echo.   --without-gif           do not use GIF library even if it is installed\r
 echo.   --without-tiff          do not use TIFF library even if it is installed\r
 echo.   --without-xpm           do not use XPM library even if it is installed\r
+echo.   --without-gnutls        do not use GnuTLS library even if it is installed\r
 echo.   --with-svg              use the RSVG library (experimental)\r
+echo.   --distfiles             path to files for make dist, e.g. libXpm.dll\r
+if "%use_extensions%" == "0" goto end\r
+echo.\r
+echo. The cflags and ldflags arguments support parameters that include the =\r
+echo. character.  However, since the = character is normally treated as a\r
+echo. separator character you will need to enclose any parameter that includes\r
+echo. the = character in quotes.  For example, to include\r
+echo. -DSITELOAD_PURESIZE_EXTRA=100000 as one of the cflags you would run\r
+echo. configure.bat as follows:\r
+echo. configure.bat --cflags "-DSITELOAD_PURESIZE_EXTRA=100000"\r
+echo.\r
+echo. Note that this capability of processing parameters that include the =\r
+echo. character depends on command extensions.  This batch file attempts to\r
+echo. enable command extensions.  If command extensions cannot be enabled, a\r
+echo. warning message will be displayed.\r
 goto end\r
+\r
 rem ----------------------------------------------------------------------\r
+\r
 :setprefix\r
 shift\r
 set prefix=%1\r
 shift\r
 goto again\r
+\r
 rem ----------------------------------------------------------------------\r
+\r
 :withgcc\r
 set COMPILER=gcc\r
 shift\r
 goto again\r
+\r
 rem ----------------------------------------------------------------------\r
+\r
 :withmsvc\r
 set COMPILER=cl\r
 shift\r
 goto again\r
+\r
 rem ----------------------------------------------------------------------\r
+\r
 :nodebug\r
 set nodebug=Y\r
 shift\r
 goto again\r
+\r
 rem ----------------------------------------------------------------------\r
+\r
 :noopt\r
 set noopt=Y\r
 shift\r
 goto again\r
+\r
 rem ----------------------------------------------------------------------\r
+\r
+:enablechecking\r
+set enablechecking=Y\r
+shift\r
+goto again\r
+\r
+rem ----------------------------------------------------------------------\r
+\r
 :profile\r
 set profile=Y\r
 shift\r
 goto again\r
+\r
 rem ----------------------------------------------------------------------\r
+\r
 :nocygwin\r
 set nocygwin=Y\r
 shift\r
 goto again\r
+\r
 rem ----------------------------------------------------------------------\r
+\r
 :usercflags\r
+if "%use_extensions%" == "1" goto ucflagex\r
+goto ucflagne\r
+\r
+:ucflagex\r
+shift\r
+set usercflags=%usercflags%%sep1%%~1\r
+set escusercflags=%usercflags:"=\"%\r
+set sep1= %nothing%\r
+shift\r
+goto again\r
+\r
+:ucflagne\r
 shift\r
 set usercflags=%usercflags%%sep1%%1\r
+set escusercflags=%usercflags%\r
 set sep1= %nothing%\r
 shift\r
 goto again\r
+\r
+:extrauserlibs\r
+shift\r
+echo. extrauserlibs: %extrauserlibs%\r
+set extrauserlibs=%extrauserlibs%%sep4%%1\r
+set sep4= %nothing%\r
+shift\r
+goto again\r
+\r
 rem ----------------------------------------------------------------------\r
+\r
 :userldflags\r
+if "%use_extensions%" == "1" goto ulflagex\r
+goto ulflagne\r
+\r
+:ulflagex\r
+shift\r
+set userldflags=%userldflags%%sep2%%~1\r
+set escuserldflags=%userldflags:"=\"%\r
+set sep2= %nothing%\r
+shift\r
+goto again\r
+\r
+:ulflagne\r
 shift\r
 set userldflags=%userldflags%%sep2%%1\r
+set escuserldflags=%userldflags%\r
 set sep2= %nothing%\r
 shift\r
 goto again\r
+\r
 rem ----------------------------------------------------------------------\r
 \r
 :withoutpng\r
@@ -206,6 +309,14 @@ goto again
 \r
 rem ----------------------------------------------------------------------\r
 \r
+:withoutgnutls\r
+set tlssupport=N\r
+set HAVE_GNUTLS=\r
+shift\r
+goto again\r
+\r
+rem ----------------------------------------------------------------------\r
+\r
 :withouttiff\r
 set tiffsupport=N\r
 set HAVE_TIFF=\r
@@ -225,8 +336,19 @@ shift
 set svgsupport=Y\r
 goto again\r
 \r
+rem ----------------------------------------------------------------------\r
+\r
+:distfiles\r
+set HAVE_DISTFILES=1\r
+shift\r
+set distfiles=%distfiles%%sep3%%1\r
+set sep3= %nothing%\r
+shift\r
+goto again\r
+\r
 rem ----------------------------------------------------------------------\r
 rem    Check that necessary utilities (cp and rm) are present.\r
+\r
 :checkutils\r
 echo Checking for 'cp'...\r
 cp configure.bat junk.bat\r
@@ -235,9 +357,11 @@ echo Checking for 'rm'...
 rm junk.bat\r
 if exist junk.bat goto needrm\r
 goto checkcompiler\r
+\r
 :needcp\r
 echo You need 'cp' (the Unix file copy program) to build Emacs.\r
 goto end\r
+\r
 :needrm\r
 del junk.bat\r
 echo You need 'rm' (the Unix file delete program) to build Emacs.\r
@@ -245,6 +369,7 @@ goto end
 \r
 rem ----------------------------------------------------------------------\r
 rem   Auto-detect compiler if not specified, and validate GCC if chosen.\r
+\r
 :checkcompiler\r
 if (%COMPILER%)==(cl) goto compilercheckdone\r
 if (%COMPILER%)==(gcc) goto checkgcc\r
@@ -279,6 +404,7 @@ if exist junk.o set nocygwin=Y
 :chkapi\r
 echo The failed program was: >>config.log\r
 type junk.c >>config.log\r
+\r
 :chkapiN\r
 rm -f junk.c junk.o\r
 rem ----------------------------------------------------------------------\r
@@ -298,8 +424,10 @@ echo {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);} >>junk.c
 if (%nocygwin%) == (Y) goto chkapi1\r
 set cf=%usercflags%\r
 goto chkapi2\r
+\r
 :chkapi1\r
 set cf=%usercflags% -mno-cygwin\r
+\r
 :chkapi2\r
 echo on\r
 gcc %cf% -c junk.c\r
@@ -307,9 +435,25 @@ gcc %cf% -c junk.c
 @echo gcc %cf% -c junk.c >>config.log\r
 gcc %cf% -c junk.c >>config.log 2>&1\r
 set cf=\r
-if exist junk.o goto gccOk\r
+if exist junk.o goto chkuser\r
 echo The failed program was: >>config.log\r
 type junk.c >>config.log\r
+goto nocompiler\r
+\r
+:chkuser\r
+rm -f junk.o\r
+echo int main (int argc, char *argv[]) {>junk.c\r
+echo char *usercflags = "%escusercflags%";>>junk.c\r
+echo }>>junk.c\r
+echo gcc -Werror -c junk.c >>config.log\r
+gcc -Werror -c junk.c >>config.log 2>&1\r
+if exist junk.o goto gccOk\r
+echo.\r
+echo Error in --cflags argument: %usercflags%\r
+echo Backslashes and quotes cannot be used with --cflags.  Please use forward\r
+echo slashes for filenames and paths (e.g. when passing directories to -I).\r
+rm -f junk.c\r
+goto end\r
 \r
 :nocompiler\r
 echo.\r
@@ -335,10 +479,12 @@ type junk.c >>config.log
 set mf=-mcpu=i686\r
 rm -f junk.c junk.o\r
 goto gccdebug\r
+\r
 :gccMtuneOk\r
 echo GCC supports -mtune=pentium4 >>config.log\r
 set mf=-mtune=pentium4\r
 rm -f junk.c junk.o\r
+\r
 :gccdebug\r
 rem Check for DWARF-2 debug info support, else default to stabs\r
 echo main(){} >junk.c\r
@@ -350,6 +496,7 @@ type junk.c >>config.log
 set dbginfo=-gstabs+\r
 rm -f junk.c junk.o\r
 goto compilercheckdone\r
+\r
 :gccdwarf\r
 echo GCC supports DWARF-2 >>config.log\r
 set dbginfo=-gdwarf-2 -g3\r
@@ -398,6 +545,30 @@ set HAVE_PNG=1
 :pngDone\r
 rm -f junk.c junk.obj\r
 \r
+if (%tlssupport%) == (N) goto tlsDone\r
+\r
+rem this is a copy of the PNG detection\r
+echo Checking for libgnutls...\r
+echo #include "gnutls/gnutls.h" >junk.c\r
+echo main (){} >>junk.c\r
+rem   -o option is ignored with cl, but allows result to be consistent.\r
+echo %COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >>config.log\r
+%COMPILER% %usercflags% %mingwflag% -c junk.c -o junk.obj >junk.out 2>>config.log\r
+if exist junk.obj goto haveTls\r
+\r
+echo ...gnutls.h not found, building without TLS support.\r
+echo The failed program was: >>config.log\r
+type junk.c >>config.log\r
+set HAVE_GNUTLS=\r
+goto :tlsDone\r
+\r
+:haveTls\r
+echo ...GnuTLS header available, building with GnuTLS support.\r
+set HAVE_GNUTLS=1\r
+\r
+:tlsDone\r
+rm -f junk.c junk.obj\r
+\r
 if (%jpegsupport%) == (N) goto jpegDone\r
 \r
 echo Checking for jpeg-6b...\r
@@ -513,7 +684,37 @@ set HAVE_RSVG=1
 :svgDone\r
 rm -f junk.c junk.obj junk.err junk.out\r
 \r
+rem Any distfiles provided for building distribution? If no, we're done.\r
+if "(%HAVE_DISTFILES%)"=="()" goto :distFilesDone\r
+\r
+rem Any arguments to --distfiles specified? If no, we're done.\r
+if not "%distfiles%"=="" goto :checkDistFiles\r
+set distFilesOk=0\r
+echo No arguments specified for option --distfiles!\r
+goto distfilesDone\r
+\r
+:checkDistFiles\r
+echo Checking for distfiles...\r
+rem Check if all specified distfiles exist\r
+set fileNotFound=\r
+for %%d in (%distfiles%) do if not exist %%d set fileNotFound=%%d\r
+if not "%fileNotFound%"=="" goto distFilesNotFound\r
+\r
+set distFilesOK=1\r
+echo ...all distfiles found.\r
+goto :distFilesDone\r
+\r
+:distFilesNotFound\r
+set distFilesOk=0\r
+echo ...%fileNotFound% not found.\r
+set distfiles=\r
+goto :distfilesDone\r
+\r
+:distFilesDone\r
+set fileNotFound=\r
+\r
 rem ----------------------------------------------------------------------\r
+\r
 :genmakefiles\r
 echo Generating makefiles\r
 if %COMPILER% == gcc set MAKECMD=gmake\r
@@ -529,24 +730,33 @@ if not "(%mf%)" == "()" echo MCPU_FLAG=%mf%>>config.settings
 if not "(%dbginfo%)" == "()" echo DEBUG_INFO=%dbginfo%>>config.settings\r
 if (%nodebug%) == (Y) echo NODEBUG=1 >>config.settings\r
 if (%noopt%) == (Y) echo NOOPT=1 >>config.settings\r
+if (%enablechecking%) == (Y) echo ENABLECHECKS=1 >>config.settings\r
 if (%profile%) == (Y) echo PROFILE=1 >>config.settings\r
 if (%nocygwin%) == (Y) echo NOCYGWIN=1 >>config.settings\r
 if not "(%prefix%)" == "()" echo INSTALL_DIR=%prefix%>>config.settings\r
+if not "(%distfiles%)" == "()" echo DIST_FILES=%distfiles%>>config.settings\r
 rem We go thru docflags because usercflags could be "-DFOO=bar" -something\r
 rem and the if command cannot cope with this\r
 for %%v in (%usercflags%) do if not (%%v)==() set docflags=Y\r
 if (%docflags%)==(Y) echo USER_CFLAGS=%usercflags%>>config.settings\r
+if (%docflags%)==(Y) echo ESC_USER_CFLAGS=%escusercflags%>>config.settings\r
 for %%v in (%userldflags%) do if not (%%v)==() set doldflags=Y\r
 if (%doldflags%)==(Y) echo USER_LDFLAGS=%userldflags%>>config.settings\r
+for %%v in (%extrauserlibs%) do if not (%%v)==() set doextralibs=Y\r
+if (%doextralibs%)==(Y) echo USER_LIBS=%extrauserlibs%>>config.settings\r
 echo # End of settings from configure.bat>>config.settings\r
 echo. >>config.settings\r
 \r
 copy config.nt config.tmp\r
 echo. >>config.tmp\r
 echo /* Start of settings from configure.bat.  */ >>config.tmp\r
-if (%docflags%) == (Y) echo #define USER_CFLAGS " %usercflags%">>config.tmp\r
-if (%doldflags%) == (Y) echo #define USER_LDFLAGS " %userldflags%">>config.tmp\r
+rem   We write USER_CFLAGS and USER_LDFLAGS starting with a space to simplify\r
+rem   processing of compiler options in w32.c:get_emacs_configuration_options\r
+if (%docflags%) == (Y) echo #define USER_CFLAGS " %escusercflags%">>config.tmp\r
+if (%doldflags%) == (Y) echo #define USER_LDFLAGS " %escuserldflags%">>config.tmp\r
+if (%profile%) == (Y) echo #define PROFILING 1 >>config.tmp\r
 if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>config.tmp\r
+if not "(%HAVE_GNUTLS%)" == "()" echo #define HAVE_GNUTLS 1 >>config.tmp\r
 if not "(%HAVE_JPEG%)" == "()" echo #define HAVE_JPEG 1 >>config.tmp\r
 if not "(%HAVE_GIF%)" == "()" echo #define HAVE_GIF 1 >>config.tmp\r
 if not "(%HAVE_TIFF%)" == "()" echo #define HAVE_TIFF 1 >>config.tmp\r
@@ -564,7 +774,8 @@ if not errorlevel 2 goto doCopy
 fc /b config.tmp ..\src\config.h >nul 2>&1\r
 if errorlevel 1 goto doCopy\r
 fc /b paths.h ..\src\epaths.h >nul 2>&1\r
-if errorlevel 0 goto dontCopy\r
+if not errorlevel 1 goto dontCopy\r
+\r
 :doCopy\r
 copy config.tmp ..\src\config.h\r
 copy paths.h ..\src\epaths.h\r
@@ -574,6 +785,7 @@ if exist config.tmp del config.tmp
 copy /b config.settings+%MAKECMD%.defs+..\nt\makefile.w32-in ..\nt\makefile\r
 if exist ..\admin\unidata copy /b config.settings+%MAKECMD%.defs+..\admin\unidata\makefile.w32-in ..\admin\unidata\makefile\r
 copy /b config.settings+%MAKECMD%.defs+..\lib-src\makefile.w32-in ..\lib-src\makefile\r
+copy /b config.settings+%MAKECMD%.defs+..\lib\makefile.w32-in ..\lib\makefile\r
 copy /b config.settings+%MAKECMD%.defs+..\src\makefile.w32-in ..\src\makefile\r
 copy /b config.settings+%MAKECMD%.defs+..\doc\emacs\makefile.w32-in ..\doc\emacs\makefile\r
 copy /b config.settings+%MAKECMD%.defs+..\doc\misc\makefile.w32-in ..\doc\misc\makefile\r
@@ -594,6 +806,7 @@ fc /b foo.bar foo.bar >nul 2>&1
 if not errorlevel 2 goto doUpdateSubdirs\r
 fc /b subdirs.el ..\site-lisp\subdirs.el >nul 2>&1\r
 if not errorlevel 1 goto dontUpdateSubdirs\r
+\r
 :doUpdateSubdirs\r
 if exist ..\site-lisp\subdirs.el del ..\site-lisp\subdirs.el\r
 copy subdirs.el ..\site-lisp\subdirs.el\r
@@ -632,12 +845,19 @@ if (%tiffsupport%) == (N) goto checkgif
  echo   Install libtiff development files or use --without-tiff\r
 \r
 :checkgif\r
-if not "(%HAVE_GIF%)" == "()" goto donelibchecks\r
-if (%gifsupport%) == (N) goto donelibchecks\r
+if not "(%HAVE_GIF%)" == "()" goto checkdistfiles\r
+if (%gifsupport%) == (N) goto checkdistfiles\r
  set libsOK=0\r
  echo GIF support is missing.\r
  echo   Install giflib or libungif development files or use --without-gif\r
 \r
+:checkdistfiles\r
+if "(%HAVE_DISTFILES%)" == "()" goto donelibchecks\r
+if (%distFilesOk%) == (1) goto donelibchecks\r
+echo.\r
+echo Files specified with option --distfiles could not be found.\r
+echo   Fix these issues before running make dist\r
+\r
 :donelibchecks\r
 if (%libsOK%) == (1) goto success\r
 echo.\r
@@ -655,10 +875,12 @@ goto end
 echo Your environment size is too small.  Please enlarge it and rerun configure.\r
 echo For example, type "command.com /e:2048" to have 2048 bytes available.\r
 set $foo$=\r
+\r
 :end\r
 set prefix=\r
 set nodebug=\r
 set noopt=\r
+set enablechecking=\r
 set profile=\r
 set nocygwin=\r
 set COMPILER=\r
@@ -669,7 +891,21 @@ set userldflags=
 set doldflags=\r
 set mingwflag=\r
 set mf=\r
+set distfiles=\r
+set HAVE_DISTFILES=\r
+set distFilesOk=\r
+set pngsupport=\r
+set tlssupport=\r
+set jpegsupport=\r
+set gifsupport=\r
+set tiffsupport=\r
+set xpmsupport=\r
+set svgsupport=\r
+set libsOK=\r
+set HAVE_GIF=\r
+set HAVE_JPEG=\r
+set HAVE_PNG=\r
+set HAVE_TIFF=\r
+set HAVE_XPM=\r
+set dbginfo=\r
 \r
-goto skipArchTag\r
-   arch-tag: 300d20a4-1675-4e75-b615-7ce1a8c5376c\r
-:skipArchTag\r