@echo offrem ----------------------------------------------------------------------rem Configuration script for MS Windows 95/98 and NT/2000rem Copyright (C) 1999-2001 Free Software Foundation, Inc.rem This file is part of GNU Emacs.rem GNU Emacs is free software; you can redistribute it and/or modifyrem it under the terms of the GNU General Public License as published byrem the Free Software Foundation; either version 2, or (at your option)rem any later version.rem GNU Emacs is distributed in the hope that it will be useful,rem but WITHOUT ANY WARRANTY; without even the implied warranty ofrem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See therem GNU General Public License for more details.rem You should have received a copy of the GNU General Public Licenserem along with GNU Emacs; see the file COPYING. If not, write to therem Free Software Foundation, Inc., 59 Temple Place - Suite 330,rem Boston, MA 02111-1307, USA.rem ----------------------------------------------------------------------rem YOU'LL NEED THE FOLLOWING UTILITIES TO MAKE EMACS:remrem + MS Windows 95/98 or NT/2000rem + either MSVC 2.x or later, or gcc-2.95 or later (with gmake 3.75rem or later) and the Mingw32 and W32 API headers and librariesremrem For reference, here is a list of which builds of gmake are known torem work or not, and whether they work in the presence and/or absence ofrem sh.exe.rem rem sh exists no shrem cygwin b20.1 make (3.75): okay[1] fails[2]rem MSVC compiled gmake 3.77: okay okayrem MSVC compiled gmake 3.78.1: okay okayrem MSVC compiled gmake 3.79.1: okay okayrem mingw32/gcc-2.92.2 make (3.77): okay okayrem cygwin compiled gmake 3.77: okay[1] fails[2]rem cygwin compiled gmake 3.78.1: okay fails[2]rem cygwin compiled gmake 3.79.1: couldn't build make[3]remrem [1] doesn't cope with makefiles with DOS line endings, so must mountrem emacs source with text!=binary.rem [2] fails when needs to invoke shell commands; okay invoking gcc etc.rem [3] requires LC_MESSAGES support to build; maybe 2.95.x update torem cygwin provides this?remrem ----------------------------------------------------------------------rem See if the environment is large enough. We need 43 (?) bytes.set $foo$=123456789_123456789_123456789_123456789_123if not "%$foo$%" == "123456789_123456789_123456789_123456789_123" goto SmallEnvset $foo$=rem ----------------------------------------------------------------------rem Make sure we are running in the nt subdirif exist configure.bat goto startecho You must run configure from the nt subdirectory.goto end:startrem ----------------------------------------------------------------------rem Default settings.set prefix=set nodebug=Nset noopt=Nset nocygwin=Nset COMPILER=set usercflags=set userldflags=set sep1=set sep2=rem ----------------------------------------------------------------------rem Handle arguments.:againif "%1" == "-h" goto usageif "%1" == "--help" goto usageif "%1" == "--prefix" goto setprefixif "%1" == "--with-gcc" goto withgccif "%1" == "--with-msvc" goto withmsvcif "%1" == "--no-debug" goto nodebugif "%1" == "--no-opt" goto nooptif "%1" == "--no-cygwin" goto nocygwinif "%1" == "--cflags" goto usercflagsif "%1" == "--ldflags" goto userldflagsif "%1" == "" goto checkutils:usageecho Usage: configure [options]echo Options:echo. --prefix PREFIX install Emacs in directory PREFIXecho. --with-gcc use GCC to compile Emacsecho. --with-msvc use MSVC to compile Emacsecho. --no-debug exclude debug info from executablesecho. --no-opt disable optimizationecho. --no-cygwin use -mno-cygwin option with GCCecho. --cflags FLAG pass FLAG to compilerecho. --ldflags FLAG pass FLAG to compiler when linkinggoto endrem ----------------------------------------------------------------------:setprefixshiftset prefix=%1shiftgoto againrem ----------------------------------------------------------------------:withgccset COMPILER=gccshiftgoto againrem ----------------------------------------------------------------------:withmsvcset COMPILER=clshiftgoto againrem ----------------------------------------------------------------------:nodebugset nodebug=Yshiftgoto againrem ----------------------------------------------------------------------:nooptset noopt=Yshiftgoto againrem ----------------------------------------------------------------------:nocygwinset nocygwin=Yshiftgoto againrem ----------------------------------------------------------------------:usercflagsshiftset usercflags=%usercflags%%sep1%%1set sep1= %nothing%shiftgoto againrem ----------------------------------------------------------------------:userldflagsshiftset userldflags=%userldflags%%sep2%%1set sep2= %nothing%shiftgoto againrem ----------------------------------------------------------------------rem Check that necessary utilities (cp and rm) are present.:checkutilsecho Checking for 'cp'...cp configure.bat junk.batif not exist junk.bat goto needcpecho Checking for 'rm'...rm junk.batif exist junk.bat goto needrmgoto checkcompiler:needcpecho You need 'cp' (the Unix file copy program) to build Emacs.goto end:needrmdel junk.batecho You need 'rm' (the Unix file delete program) to build Emacs.goto endrem ----------------------------------------------------------------------rem Auto-detect compiler if not specified, and validate GCC if chosen.:checkcompilerif (%COMPILER%)==(cl) goto genmakefilesif (%COMPILER%)==(gcc) goto checkgccecho Checking whether 'cl' is available...echo main(){} >junk.ccl -nologo -c junk.cif exist junk.obj goto clOKecho Checking whether 'gcc' is available...gcc -c junk.cif not exist junk.o goto nocompilerdel junk.o:checkgccRem WARNING -- COMMAND.COM on some systems only looks at the firstRem 8 characters of a label. So do NOT be tempted to changeRem chkapi* into something fancier like checkw32apiRem You HAVE been warned!if (%nocygwin%) == (Y) goto chkapiecho Checking whether gcc requires '-mno-cygwin'...echo #include "cygwin/version.h" >junk.cecho main(){} >>junk.cgcc -c junk.cif not exist junk.o goto chkapigcc -mno-cygwin -c junk.cif exist junk.o set nocygwin=Yrm -f junk.c junk.o:chkapirem ----------------------------------------------------------------------rem Older versions of the Windows API headers either don't have any ofrem the IMAGE_xxx definitions (the headers that come with Cygwin b20.1rem are like this), or have a typo in the definition ofrem IMAGE_FIRST_SECTION (the headers with gcc/mingw32 2.95 have thisrem problem). The gcc/mingw32 2.95.2 headers are okay, as are distrosrem of w32api-xxx.zip from Anders Norlander since 1999-11-18 at least.remecho Checking whether W32 API headers are too old...echo #include "windows.h" >junk.cecho test(PIMAGE_NT_HEADERS pHeader) >>junk.cecho {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);} >>junk.cif (%nocygwin%) == (Y) goto chkapi1set cf=%usercflags%goto chkapi2:chkapi1set cf=%usercflags% -mno-cygwin:chkapi2echo ongcc %cf% -c junk.cecho offset cf=if exist junk.o goto gccOk:nocompilerecho.echo Configure failed.echo To configure Emacs for Windows, you need to have eitherecho gcc-2.95 or later with Mingw32 and the W32 API headers,echo or MSVC 2.x or later.del junk.cgoto end:gccOkset COMPILER=gccrm -f junk.c junk.oecho Using 'gcc'goto genmakefiles:clOkset COMPILER=clrm -f junk.c junk.objecho Using 'MSVC'goto genmakefilesrem ----------------------------------------------------------------------:genmakefilesecho Generating makefilesif %COMPILER% == gcc set MAKECMD=gmakeif %COMPILER% == cl set MAKECMD=nmakerem Pass on chosen settings to makefiles.rem NB. Be very careful to not have a space before redirection symbolsrem except when there is a preceding digit, when a space is required.remecho # Start of settings from configure.bat >config.settingsecho COMPILER=%COMPILER%>>config.settingsif (%nodebug%) == (Y) echo NODEBUG=1 >>config.settingsif (%noopt%) == (Y) echo NOOPT=1 >>config.settingsif (%nocygwin%) == (Y) echo NOCYGWIN=1 >>config.settingsif not "(%prefix%)" == "()" echo INSTALL_DIR=%prefix%>>config.settingsif not "(%usercflags%)" == "()" echo USER_CFLAGS=%usercflags%>>config.settingsif not "(%userldflags%)" == "()" echo USER_LDFLAGS=%userldflags%>>config.settingsecho # End of settings from configure.bat>>config.settingsecho. >>config.settingscopy config.nt ..\src\config.hif not "(%usercflags%)" == "()" echo #define USER_CFLAGS " %usercflags%">>..\src\config.hif not "(%userldflags%)" == "()" echo #define USER_LDFLAGS " %userldflags%">>..\src\config.hcopy paths.h ..\src\epaths.hcopy /b config.settings+%MAKECMD%.defs+..\nt\makefile.w32-in ..\nt\makefilecopy /b config.settings+%MAKECMD%.defs+..\lib-src\makefile.w32-in ..\lib-src\makefilecopy /b config.settings+%MAKECMD%.defs+..\src\makefile.w32-in ..\src\makefileif not exist ..\lisp\Makefile.unix rename ..\lisp\Makefile.in Makefile.unixif exist ..\lisp\makefile rm -f ../lisp/[Mm]akefilecopy /b config.settings+%MAKECMD%.defs+..\lisp\makefile.w32-in ..\lisp\makefilerem 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\makefileif not exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\Makefile.in ..\leim\makefiledel config.settingsRem Some people use WinZip which doesn't create empty directories!if not exist ..\site-lisp\nul mkdir ..\site-lisp\if not exist ..\site-lisp\subdirs.el copy subdirs.el ..\site-lisp\subdirs.elecho.echo Emacs successfully configured.echo Run `%MAKECMD%' to build, then run `%MAKECMD% install' to install.goto end:SmallEnvecho 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$=:endset prefix=set nodebug=set noopt=set nocygwin=set COMPILER=set MAKECMD=set usercflags=set userldflags=