Remove directory part from filenames in function declarations.
[bpt/emacs.git] / nt / configure.bat
index ff4fae1..ef0a746 100755 (executable)
@@ -1,13 +1,14 @@
 @echo off\r
 rem   ----------------------------------------------------------------------\r
-rem   Configuration script for MS Windows 95/98 and NT/2000\r
-rem   Copyright (C) 1999-2001 Free Software Foundation, Inc.\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 Free Software Foundation, Inc.\r
 \r
 rem   This file is part of GNU Emacs.\r
 \r
 rem   GNU Emacs is free software; you can redistribute it and/or modify\r
 rem   it under the terms of the GNU General Public License as published by\r
-rem   the Free Software Foundation; either version 2, or (at your option)\r
+rem   the Free Software Foundation; either version 3, or (at your option)\r
 rem   any later version.\r
 \r
 rem   GNU Emacs is distributed in the hope that it will be useful,\r
@@ -17,36 +18,51 @@ rem   GNU General Public License for more details.
 \r
 rem   You should have received a copy of the GNU General Public License\r
 rem   along with GNU Emacs; see the file COPYING.  If not, write to the\r
-rem   Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
-rem   Boston, MA 02111-1307, USA.\r
+rem   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,\r
+rem   Boston, MA 02110-1301, USA.\r
 rem   ----------------------------------------------------------------------\r
 rem   YOU'LL NEED THE FOLLOWING UTILITIES TO MAKE EMACS:\r
 rem\r
-rem   + MS Windows 95/98 or NT/2000\r
+rem   + MS Windows 95/98/Me or NT/2000/XP\r
 rem   + either MSVC 2.x or later, or gcc-2.95 or later (with gmake 3.75\r
-rem     or later) and the Mingw32 and W32 API headers and libraries\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
 rem\r
 rem For reference, here is a list of which builds of gmake are known to\r
 rem work or not, and whether they work in the presence and/or absence of\r
 rem sh.exe.\r
 rem\r
 rem                                       sh exists     no sh\r
-rem  cygwin b20.1 make (3.75):            okay[1]       fails[2]\r
+rem  cygwin b20.1 make (3.75):            fails[1,5]    fails[2,5]\r
 rem  MSVC compiled gmake 3.77:            okay          okay\r
 rem  MSVC compiled gmake 3.78.1:          okay          okay\r
 rem  MSVC compiled gmake 3.79.1:          okay          okay\r
-rem  mingw32/gcc-2.92.2 make (3.77):      okay          okay\r
-rem  cygwin compiled gmake 3.77:          okay[1]       fails[2]\r
-rem  cygwin compiled gmake 3.78.1:        okay          fails[2]\r
-rem  cygwin compiled gmake 3.79.1:        couldn't build make[3]\r
+rem  mingw32/gcc-2.92.2 make (3.77):      okay          okay[4]\r
+rem  cygwin compiled gmake 3.77:          fails[1,5]    fails[2,5]\r
+rem  cygwin compiled gmake 3.78.1:        fails[5]      fails[2,5]\r
+rem  cygwin compiled gmake 3.79.1:        fails[3,5]    fails[2?,5]\r
+rem  cygwin compiled make 3.80:           okay[6]       fails?[7]\r
+rem  cygwin compiled make 3.81:           fails         fails?[7]\r
+rem  mingw32 compiled make 3.79.1:        okay          okay\r
+rem  mingw32 compiled make 3.80:          okay          okay?[7]\r
+rem  mingw32 compiled make 3.81:          okay          okay[8]\r
 rem\r
 rem [1] doesn't cope with makefiles with DOS line endings, so must mount\r
 rem     emacs source with text!=binary.\r
 rem [2] fails when needs to invoke shell commands; okay invoking gcc etc.\r
-rem [3] requires LC_MESSAGES support to build; maybe 2.95.x update to\r
-rem     cygwin provides this?\r
+rem [3] requires LC_MESSAGES support to build; cannot build with early\r
+rem     versions of cygwin.\r
+rem [4] may fail on Windows 9X and Windows ME; if so, install Bash.\r
+rem [5] fails when building leim due to the use of cygwin style paths.\r
+rem     May work if building emacs without leim.\r
+rem [6] need to uncomment 3 lines in nt/gmake.defs that invoke `cygpath';\r
+rem            look for "cygpath" near line 85 of gmake.defs.\r
+rem [7] not recommended; please report if you try this combination.\r
+rem [8] tested only on Windows XP.\r
 rem\r
 \r
+if exist config.log del config.log\r
+\r
 rem ----------------------------------------------------------------------\r
 rem   See if the environment is large enough.  We need 43 (?) bytes.\r
 set $foo$=123456789_123456789_123456789_123456789_123\r
@@ -68,7 +84,9 @@ set noopt=N
 set nocygwin=N\r
 set COMPILER=\r
 set usercflags=\r
+set docflags=\r
 set userldflags=\r
+set doldflags=\r
 set sep1=\r
 set sep2=\r
 \r
@@ -87,6 +105,9 @@ if "%1" == "--cflags" goto usercflags
 if "%1" == "--ldflags" goto userldflags\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-xpm" goto withoutxpm\r
 if "%1" == "" goto checkutils\r
 :usage\r
 echo Usage: configure [options]\r
@@ -99,8 +120,11 @@ echo.   --no-opt                disable optimization
 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.   --without-png           do not use libpng even if it is installed\r
-echo.   --without-jpeg          do not use jpeglib even if it is installed\r
+echo.   --without-png           do not use libpng\r
+echo.   --without-jpeg          do not use jpeg-6b\r
+echo.   --without-gif           do not use giflib or libungif\r
+echo.   --without-tiff          do not use libtiff\r
+echo.   --without-xpm           do not use libXpm\r
 goto end\r
 rem ----------------------------------------------------------------------\r
 :setprefix\r
@@ -152,6 +176,7 @@ rem ----------------------------------------------------------------------
 :withoutpng\r
 set pngsupport=N\r
 set HAVE_PNG=\r
+shift\r
 goto again\r
 \r
 rem ----------------------------------------------------------------------\r
@@ -159,6 +184,31 @@ rem ----------------------------------------------------------------------
 :withoutjpeg\r
 set jpegsupport=N\r
 set HAVE_JPEG=\r
+shift\r
+goto again\r
+\r
+rem ----------------------------------------------------------------------\r
+\r
+:withoutgif\r
+set gifsupport=N\r
+set HAVE_GIF=\r
+shift\r
+goto again\r
+\r
+rem ----------------------------------------------------------------------\r
+\r
+:withouttiff\r
+set tiffsupport=N\r
+set HAVE_TIFF=\r
+shift\r
+goto again\r
+\r
+rem ----------------------------------------------------------------------\r
+\r
+:withoutxpm\r
+set xpmsupport=N\r
+set HAVE_XPM=\r
+shift\r
 goto again\r
 \r
 rem ----------------------------------------------------------------------\r
@@ -204,13 +254,17 @@ if (%nocygwin%) == (Y) goto chkapi
 echo Checking whether gcc requires '-mno-cygwin'...\r
 echo #include "cygwin/version.h" >junk.c\r
 echo main(){} >>junk.c\r
-gcc -c junk.c\r
+echo gcc -c junk.c >>config.log\r
+gcc -c junk.c >>config.log 2>&1\r
 if not exist junk.o goto chkapi\r
-gcc -mno-cygwin -c junk.c\r
+echo gcc -mno-cygwin -c junk.c >>config.log\r
+gcc -mno-cygwin -c junk.c >>config.log 2>&1\r
 if exist junk.o set nocygwin=Y\r
 rm -f junk.c junk.o\r
 \r
 :chkapi\r
+echo The failed program was: >>config.log\r
+type junk.c >>config.log\r
 rem ----------------------------------------------------------------------\r
 rem   Older versions of the Windows API headers either don't have any of\r
 rem   the IMAGE_xxx definitions (the headers that come with Cygwin b20.1\r
@@ -231,9 +285,13 @@ set cf=%usercflags% -mno-cygwin
 :chkapi2\r
 echo on\r
 gcc %cf% -c junk.c\r
-echo off\r
+@echo off\r
+@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
+echo The failed program was: >>config.log\r
+type junk.c >>config.log\r
 \r
 :nocompiler\r
 echo.\r
@@ -246,8 +304,23 @@ goto end
 \r
 :gccOk\r
 set COMPILER=gcc\r
-rm -f junk.c junk.o\r
 echo Using 'gcc'\r
+rm -f junk.c junk.o\r
+Rem It is not clear what GCC version began supporting -mtune\r
+Rem and pentium4 on x86, so check this explicitly.\r
+echo main(){} >junk.c\r
+echo gcc -c -O2 -mtune=pentium4 junk.c >>config.log\r
+gcc -c -O2 -mtune=pentium4 junk.c >>config.log 2>&1\r
+if not errorlevel 1 goto gccMtuneOk\r
+echo The failed program was: >>config.log\r
+type junk.c >>config.log\r
+set mf=-mcpu=i686\r
+rm -f junk.c junk.o\r
+goto compilercheckdone\r
+:gccMtuneOk\r
+echo GCC supports -mtune=pentium4 >>config.log\r
+set mf=-mtune=pentium4\r
+rm -f junk.c junk.o\r
 goto compilercheckdone\r
 \r
 :clOk\r
@@ -262,16 +335,26 @@ rem   Check for external image libraries. Since they are loaded
 rem   dynamically, the libraries themselves do not need to be present\r
 rem   at compile time, but the header files are required.\r
 \r
+set mingwflag=\r
+\r
+if (%nocygwin%) == (N) goto flagsOK\r
+set mingwflag=-mno-cygwin\r
+\r
+:flagsOK\r
+\r
 if (%pngsupport%) == (N) goto pngDone\r
 \r
 echo Checking for libpng...\r
 echo #include "png.h" >junk.c\r
 echo main (){} >>junk.c\r
 rem   -o option is ignored with cl, but allows result to be consistent.\r
-%COMPILER% %usercflags% -c junk.c -o junk.obj\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 havePng\r
 \r
-echo ...building without PNG support.\r
+echo ...png.h not found, building without PNG support.\r
+echo The failed program was: >>config.log\r
+type junk.c >>config.log\r
 set HAVE_PNG=\r
 goto :pngDone\r
 \r
@@ -284,14 +367,17 @@ rm -f junk.c junk.obj
 \r
 if (%jpegsupport%) == (N) goto jpegDone\r
 \r
-echo Checking for jpeg ...\r
+echo Checking for jpeg-6b...\r
 echo #include "jconfig.h" >junk.c\r
 echo main (){} >>junk.c\r
 rem   -o option is ignored with cl, but allows result to be consistent.\r
-%COMPILER% %usercflags% -c junk.c -o junk.obj\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 haveJpeg\r
 \r
-echo ...building without JPEG support.\r
+echo ...jconfig.h not found, building without JPEG support.\r
+echo The failed program was: >>config.log\r
+type junk.c >>config.log\r
 set HAVE_JPEG=\r
 goto :jpegDone\r
 \r
@@ -302,6 +388,76 @@ set HAVE_JPEG=1
 :jpegDone\r
 rm -f junk.c junk.obj\r
 \r
+if (%gifsupport%) == (N) goto gifDone\r
+\r
+echo Checking for libgif...\r
+echo #include "gif_lib.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 haveGif\r
+\r
+echo ...gif_lib.h not found, building without GIF support.\r
+echo The failed program was: >>config.log\r
+type junk.c >>config.log\r
+set HAVE_GIF=\r
+goto :gifDone\r
+\r
+:haveGif\r
+echo ...GIF header available, building with GIF support.\r
+set HAVE_GIF=1\r
+\r
+:gifDone\r
+rm -f junk.c junk.obj\r
+\r
+if (%tiffsupport%) == (N) goto tiffDone\r
+\r
+echo Checking for tiff...\r
+echo #include "tiffio.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 haveTiff\r
+\r
+echo ...tiffio.h not found, building without TIFF support.\r
+echo The failed program was: >>config.log\r
+type junk.c >>config.log\r
+set HAVE_TIFF=\r
+goto :tiffDone\r
+\r
+:haveTiff\r
+echo ...TIFF header available, building with TIFF support.\r
+set HAVE_TIFF=1\r
+\r
+:tiffDone\r
+rm -f junk.c junk.obj\r
+\r
+if (%xpmsupport%) == (N) goto xpmDone\r
+\r
+echo Checking for libXpm...\r
+echo #define FOR_MSW 1 >junk.c\r
+echo #include "X11/xpm.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 haveXpm\r
+\r
+echo ...X11/xpm.h not found, building without XPM support.\r
+echo The failed program was: >>config.log\r
+type junk.c >>config.log\r
+set HAVE_XPM=\r
+goto :xpmDone\r
+\r
+:haveXpm\r
+echo ...XPM header available, building with XPM support.\r
+set HAVE_XPM=1\r
+\r
+:xpmDone\r
+rm -f junk.c junk.obj junk.err junk.out\r
+\r
 rem ----------------------------------------------------------------------\r
 :genmakefiles\r
 echo Generating makefiles\r
@@ -314,30 +470,55 @@ rem   except when there is a preceding digit, when a space is required.
 rem\r
 echo # Start of settings from configure.bat >config.settings\r
 echo COMPILER=%COMPILER%>>config.settings\r
+if not "(%mf%)" == "()" echo MCPU_FLAG=%mf%>>config.settings\r
 if (%nodebug%) == (Y) echo NODEBUG=1 >>config.settings\r
 if (%noopt%) == (Y) echo NOOPT=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 "(%usercflags%)" == "()" echo USER_CFLAGS=%usercflags%>>config.settings\r
-if not "(%userldflags%)" == "()" echo USER_LDFLAGS=%userldflags%>>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
+for %%v in (%userldflags%) do if not (%%v)==() set doldflags=Y\r
+if (%doldflags%)==(Y) echo USER_LDFLAGS=%userldflags%>>config.settings\r
 echo # End of settings from configure.bat>>config.settings\r
 echo. >>config.settings\r
 \r
-copy config.nt ..\src\config.h\r
-echo. >>..\src\config.h\r
-echo /* Start of settings from configure.bat.  */ >>..\src\config.h\r
-if not "(%usercflags%)" == "()" echo #define USER_CFLAGS " %usercflags%">>..\src\config.h\r
-if not "(%userldflags%)" == "()" echo #define USER_LDFLAGS " %userldflags%">>..\src\config.h\r
-if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>..\src\config.h\r
-if not "(%HAVE_JPEG%)" == "()" echo #define HAVE_JPEG 1 >>..\src\config.h\r
-echo /* End of settings from configure.bat.  */ >>..\src\config.h\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
+if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 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
+if not "(%HAVE_XPM%)" == "()" echo #define HAVE_XPM 1 >>config.tmp\r
+echo /* End of settings from configure.bat.  */ >>config.tmp\r
+\r
+Rem See if fc.exe returns a meaningful exit status.  If it does, we\r
+Rem might as well avoid unnecessary overwriting of config.h and epaths.h,\r
+Rem since this forces recompilation of every source file.\r
+if exist foo.bar del foo.bar\r
+fc /b foo.bar foo.bar >nul 2>&1\r
+if not errorlevel 2 goto doCopy\r
+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
+:doCopy\r
+copy config.tmp ..\src\config.h\r
 copy paths.h ..\src\epaths.h\r
 \r
+:dontCopy\r
+if exist config.tmp del config.tmp\r
 copy /b config.settings+%MAKECMD%.defs+..\nt\makefile.w32-in ..\nt\makefile\r
 copy /b config.settings+%MAKECMD%.defs+..\lib-src\makefile.w32-in ..\lib-src\makefile\r
 copy /b config.settings+%MAKECMD%.defs+..\src\makefile.w32-in ..\src\makefile\r
-if not exist ..\lisp\Makefile.unix rename ..\lisp\Makefile.in Makefile.unix\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
+copy /b config.settings+%MAKECMD%.defs+..\doc\lispref\makefile.w32-in ..\doc\lispref\makefile\r
+copy /b config.settings+%MAKECMD%.defs+..\doc\lispintro\makefile.w32-in ..\doc\lispintro\makefile\r
 if exist ..\lisp\makefile rm -f ../lisp/[Mm]akefile\r
 copy /b config.settings+%MAKECMD%.defs+..\lisp\makefile.w32-in ..\lisp\makefile\r
 rem   Use the default (no-op) Makefile.in if the nt version is not present.\r
@@ -347,10 +528,65 @@ del config.settings
 \r
 Rem Some people use WinZip which doesn't create empty directories!\r
 if not exist ..\site-lisp\nul mkdir ..\site-lisp\\r
-if not exist ..\site-lisp\subdirs.el copy subdirs.el ..\site-lisp\subdirs.el\r
+Rem Update subdirs.el only if it is different or fc.exe doesn't work.\r
+if exist foo.bar del foo.bar\r
+fc /b foo.bar foo.bar >nul 2>&1\r
+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
+:doUpdateSubdirs\r
+if exist ..\site-lisp\subdirs.el del ..\site-lisp\subdirs.el\r
+copy subdirs.el ..\site-lisp\subdirs.el\r
+\r
+:dontUpdateSubdirs\r
+echo.\r
 \r
+rem check that we have all the libraries we need.\r
+set libsOK=1\r
+\r
+if not "(%HAVE_XPM%)" == "()" goto checkpng\r
+if (%xpmsupport%) == (N) goto checkpng\r
+ set libsOK=0\r
+ echo XPM support is missing. It is required for color icons in the toolbar.\r
+ echo   Install libXpm development files or use --without-xpm\r
+\r
+:checkpng\r
+if not "(%HAVE_PNG%)" == "()" goto checkjpeg\r
+if (%pngsupport%) == (N) goto checkjpeg\r
+ set libsOK=0\r
+ echo PNG support is missing.\r
+ echo   Install libpng development files or use --without-png\r
+\r
+:checkjpeg\r
+if not "(%HAVE_JPEG%)" == "()" goto checktiff\r
+if (%jpegsupport%) == (N) goto checktiff\r
+ set libsOK=0\r
+ echo JPEG support is missing.\r
+ echo   Install jpeg development files or use --without-jpeg\r
+\r
+:checktiff\r
+if not "(%HAVE_TIFF%)" == "()" goto checkgif\r
+if (%tiffsupport%) == (N) goto checkgif\r
+ set libsOK=0\r
+ echo TIFF support is missing.\r
+ 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
+ set libsOK=0\r
+ echo GIF support is missing.\r
+ echo   Install giflib or libungif development files or use --without-gif\r
+\r
+:donelibchecks\r
+if (%libsOK%) == (1) goto success\r
 echo.\r
+echo Important libraries are missing. Fix these issues before running make.\r
+goto end\r
+\r
+:success\r
 echo Emacs successfully configured.\r
+echo Emacs successfully configured. >>config.log\r
 echo Run `%MAKECMD%' to build, then run `%MAKECMD% install' to install.\r
 goto end\r
 \r
@@ -366,4 +602,12 @@ set nocygwin=
 set COMPILER=\r
 set MAKECMD=\r
 set usercflags=\r
+set docflags=\r
 set userldflags=\r
+set doldflags=\r
+set mingwflag=\r
+set mf=\r
+\r
+goto skipArchTag\r
+   arch-tag: 300d20a4-1675-4e75-b615-7ce1a8c5376c\r
+:skipArchTag\r