(index, rindex): Prototype conditionally.
[emacs.git] / nt / configure.bat
blob4b452810835cfbca37fb1a70f7897094bf575c6f
1 @echo off\r
2 rem   ----------------------------------------------------------------------\r
3 rem   Configuration script for MS Windows 95/98 and NT/2000\r
4 rem   Copyright (C) 1999, 2000 Free Software Foundation, Inc.\r
5 \r
6 rem   This file is part of GNU Emacs.\r
7 \r
8 rem   GNU Emacs is free software; you can redistribute it and/or modify\r
9 rem   it under the terms of the GNU General Public License as published by\r
10 rem   the Free Software Foundation; either version 2, or (at your option)\r
11 rem   any later version.\r
13 rem   GNU Emacs is distributed in the hope that it will be useful,\r
14 rem   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15 rem   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
16 rem   GNU General Public License for more details.\r
18 rem   You should have received a copy of the GNU General Public License\r
19 rem   along with GNU Emacs; see the file COPYING.  If not, write to the\r
20 rem   Free Software Foundation, Inc., 59 Temple Place - Suite 330,\r
21 rem   Boston, MA 02111-1307, USA.\r
22 rem   ----------------------------------------------------------------------\r
23 rem   YOU'LL NEED THE FOLLOWING UTILITIES TO MAKE EMACS:\r
24 rem\r
25 rem   + MS Windows 95/98 or NT/2000\r
26 rem   + either MSVC 2.x or later, or gcc-2.95 or later (with gmake 3.75\r
27 rem     or later) and the Mingw32 and W32 API headers and libraries\r
28 rem\r
29 rem For reference, here is a list of which builds of gmake are known to\r
30 rem work or not, and whether they work in the presence and/or absence of\r
31 rem sh.exe.\r
32 rem  \r
33 rem                                       sh exists     no sh\r
34 rem  cygwin b20.1 make (3.75):            okay[1]       fails[2]\r
35 rem  MSVC compiled gmake 3.77:            okay          okay\r
36 rem  MSVC compiled gmake 3.78.1:          okay          okay\r
37 rem  MSVC compiled gmake 3.79.1:          okay          okay\r
38 rem  mingw32/gcc-2.92.2 make (3.77):      okay          okay\r
39 rem  cygwin compiled gmake 3.77:          okay[1]       fails[2]\r
40 rem  cygwin compiled gmake 3.78.1:        okay          fails[2]\r
41 rem  cygwin compiled gmake 3.79.1:        couldn't build make[3]\r
42 rem\r
43 rem [1] doesn't cope with makefiles with DOS line endings, so must mount\r
44 rem     emacs source with text!=binary.\r
45 rem [2] fails when needs to invoke shell commands; okay invoking gcc etc.\r
46 rem [3] requires LC_MESSAGES support to build; maybe 2.95.x update to\r
47 rem     cygwin provides this?\r
48 rem\r
50 rem ----------------------------------------------------------------------\r
51 rem   See if the environment is large enough.  We need 43 (?) bytes.\r
52 set $foo$=123456789_123456789_123456789_123456789_123\r
53 if not "%$foo$%" == "123456789_123456789_123456789_123456789_123" goto SmallEnv\r
54 set $foo$=\r
56 rem ----------------------------------------------------------------------\r
57 rem   Make sure we are running in the nt subdir\r
58 if exist configure.bat goto start\r
59 echo You must run configure from the nt subdirectory.\r
60 goto end\r
62 :start\r
63 rem ----------------------------------------------------------------------\r
64 rem   Default settings.\r
65 set prefix=\r
66 set nodebug=N\r
67 set noopt=N\r
68 set nocygwin=N\r
69 set COMPILER=\r
70 set usercflags=\r
71 set userldflags=\r
72 set sep1=\r
73 set sep2=\r
75 rem ----------------------------------------------------------------------\r
76 rem   Handle arguments.\r
77 :again\r
78 if "%1" == "-h" goto usage\r
79 if "%1" == "--help" goto usage\r
80 if "%1" == "--prefix" goto setprefix\r
81 if "%1" == "--with-gcc" goto withgcc\r
82 if "%1" == "--with-msvc" goto withmsvc\r
83 if "%1" == "--no-debug" goto nodebug\r
84 if "%1" == "--no-opt" goto noopt\r
85 if "%1" == "--no-cygwin" goto nocygwin\r
86 if "%1" == "--cflags" goto usercflags\r
87 if "%1" == "--ldflags" goto userldflags\r
88 if "%1" == "" goto checkutils\r
89 :usage\r
90 echo Usage: configure [options]\r
91 echo Options:\r
92 echo.   --prefix PREFIX         install Emacs in directory PREFIX\r
93 echo.   --with-gcc              use GCC to compile Emacs\r
94 echo.   --with-msvc             use MSVC to compile Emacs\r
95 echo.   --no-debug              exclude debug info from executables\r
96 echo.   --no-opt                disable optimization\r
97 echo.   --no-cygwin             use -mno-cygwin option with GCC\r
98 echo.   --cflags FLAG           pass FLAG to compiler\r
99 echo.   --ldflags FLAG          pass FLAG to compiler when linking\r
100 goto end\r
101 rem ----------------------------------------------------------------------\r
102 :setprefix\r
103 shift\r
104 set prefix=%1\r
105 shift\r
106 goto again\r
107 rem ----------------------------------------------------------------------\r
108 :withgcc\r
109 set COMPILER=gcc\r
110 shift\r
111 goto again\r
112 rem ----------------------------------------------------------------------\r
113 :withmsvc\r
114 set COMPILER=cl\r
115 shift\r
116 goto again\r
117 rem ----------------------------------------------------------------------\r
118 :nodebug\r
119 set nodebug=Y\r
120 shift\r
121 goto again\r
122 rem ----------------------------------------------------------------------\r
123 :noopt\r
124 set noopt=Y\r
125 shift\r
126 goto again\r
127 rem ----------------------------------------------------------------------\r
128 :nocygwin\r
129 set nocygwin=Y\r
130 shift\r
131 goto again\r
132 rem ----------------------------------------------------------------------\r
133 :usercflags\r
134 shift\r
135 set usercflags=%usercflags%%sep1%%1\r
136 set sep1= %nothing%\r
137 shift\r
138 goto again\r
139 rem ----------------------------------------------------------------------\r
140 :userldflags\r
141 shift\r
142 set userldflags=%userldflags%%sep2%%1\r
143 set sep2= %nothing%\r
144 shift\r
145 goto again\r
147 rem ----------------------------------------------------------------------\r
148 rem    Check that necessary utilities (cp and rm) are present.\r
149 :checkutils\r
150 echo Checking for 'cp'...\r
151 cp configure.bat junk.bat\r
152 if not exist junk.bat goto needcp\r
153 echo Checking for 'rm'...\r
154 rm junk.bat\r
155 if exist junk.bat goto needrm\r
156 goto checkcompiler\r
157 :needcp\r
158 echo You need 'cp' (the Unix file copy program) to build Emacs.\r
159 goto end\r
160 :needrm\r
161 del junk.bat\r
162 echo You need 'rm' (the Unix file delete program) to build Emacs.\r
163 goto end\r
165 rem ----------------------------------------------------------------------\r
166 rem   Auto-detect compiler if not specified, and validate GCC if chosen.\r
167 :checkcompiler\r
168 if (%COMPILER%)==(cl) goto genmakefiles\r
169 if (%COMPILER%)==(gcc) goto checkgcc\r
171 echo Checking whether 'cl' is available...\r
172 echo main(){} >junk.c\r
173 cl -nologo -c junk.c\r
174 if exist junk.obj goto clOK\r
176 echo Checking whether 'gcc' is available...\r
177 gcc -c junk.c\r
178 if not exist junk.o goto nocompiler\r
179 del junk.o\r
181 :checkgcc\r
182 if (%nocygwin%) == (Y) goto checkw32api\r
183 echo Checking whether gcc requires '-mno-cygwin'...\r
184 echo #include "cygwin/version.h" >junk.c\r
185 echo main(){} >>junk.c\r
186 gcc -c junk.c\r
187 if not exist junk.o goto checkw32api\r
188 gcc -mno-cygwin -c junk.c\r
189 if exist junk.o set nocygwin=Y\r
190 del junk.o junk.c\r
192 :checkw32api\r
193 rem ----------------------------------------------------------------------\r
194 rem   Older versions of the Windows API headers either don't have any of\r
195 rem   the IMAGE_xxx definitions (the headers that come with Cygwin b20.1\r
196 rem   are like this), or have a typo in the definition of\r
197 rem   IMAGE_FIRST_SECTION (the headers with gcc/mingw32 2.95 have this\r
198 rem   problem).  The gcc/mingw32 2.95.2 headers are okay, as are distros\r
199 rem   of w32api-xxx.zip from Anders Norlander since 1999-11-18 at least.\r
200 rem\r
201 echo Checking whether W32 API headers are too old...\r
202 echo #include "windows.h" >junk.c\r
203 echo test(PIMAGE_NT_HEADERS pHeader)>>junk.c\r
204 echo {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);}>>junk.c\r
205 gcc -c junk.c\r
206 if exist junk.o goto gccOk\r
208 :nocompiler\r
209 echo.\r
210 echo Configure failed.\r
211 echo To configure Emacs for Windows, you need to have either\r
212 echo gcc-2.95 or later with Mingw32 and the W32 API headers,\r
213 echo or MSVC 2.x or later.\r
214 del junk.c\r
215 goto end\r
217 :gccOk\r
218 set COMPILER=gcc\r
219 del junk.c junk.o\r
220 echo Using 'gcc'\r
221 goto genmakefiles\r
223 :clOk\r
224 set COMPILER=cl\r
225 del junk.c junk.obj\r
226 echo Using 'MSVC'\r
227 goto genmakefiles\r
229 rem ----------------------------------------------------------------------\r
230 :genmakefiles\r
231 echo Generating makefiles\r
232 if %COMPILER% == gcc set MAKECMD=gmake\r
233 if %COMPILER% == cl set MAKECMD=nmake\r
235 rem   Pass on chosen settings to makefiles.\r
236 echo # Start of settings from configure.bat >config.settings\r
237 echo COMPILER=%COMPILER% >>config.settings\r
238 if (%nodebug%) == (Y) echo NODEBUG=1 >>config.settings\r
239 if (%noopt%) == (Y) echo NOOPT=1 >>config.settings\r
240 if (%nocygwin%) == (Y) echo NOCYGWIN=1 >>config.settings\r
241 if not "(%prefix%)" == "()" echo INSTALL_DIR=%prefix% >>config.settings\r
242 if not "(%usercflags%)" == "()" echo USER_CFLAGS=%usercflags% >>config.settings\r
243 if not "(%userldflags%)" == "()" echo USER_LDFLAGS=%userldflags% >>config.settings\r
244 echo # End of settings from configure.bat >>config.settings\r
245 echo. >>config.settings\r
247 copy config.nt ..\src\config.h\r
248 if not "(%usercflags%)" == "()" echo #define USER_CFLAGS " %usercflags%">>..\src\config.h\r
249 if not "(%userldflags%)" == "()" echo #define USER_LDFLAGS " %userldflags%">>..\src\config.h\r
250 copy paths.h ..\src\epaths.h\r
252 rem   gmake doesn't support "cd foo" in commands (except as part of a\r
253 rem   compound statement which command.com doesn't support), but nmake\r
254 rem   doesn't support the -C dir command line switch, so generate the\r
255 rem   necessary makefile fragment for targets that involve changing dir.\r
256 rem \r
257 if %MAKECMD% == nmake goto gen1\r
259 echo. > make-frag\r
260 echo all-other-dirs: >> make-frag\r
261 echo.   $(MAKE) -C ../lib-src all >> make-frag\r
262 echo.   $(MAKE) -C ../src all >> make-frag\r
263 echo.   $(MAKE) -C ../lisp all >> make-frag\r
264 echo.   $(MAKE) -C ../leim all >> make-frag\r
265 echo. >> make-frag\r
266 echo clean-other-dirs: >> make-frag\r
267 echo.   $(MAKE) -C ../lib-src clean >> make-frag\r
268 echo.   $(MAKE) -C ../src clean >> make-frag\r
269 echo.   $(MAKE) -C ../lisp clean >> make-frag\r
270 echo.   $(MAKE) -C ../leim clean >> make-frag\r
271 echo. >> make-frag\r
272 echo install-other-dirs: >> make-frag\r
273 echo.   $(MAKE) -C ../lib-src install >> make-frag\r
274 echo.   $(MAKE) -C ../src install >> make-frag\r
275 echo.   $(MAKE) -C ../lisp install >> make-frag\r
276 echo.   $(MAKE) -C ../leim install >> make-frag\r
277 echo. >> make-frag\r
278 goto gen2\r
280 :gen1\r
281 echo. > make-frag\r
282 echo all-other-dirs: >> make-frag\r
283 echo.   cd ..\lib-src >> make-frag\r
284 echo.   $(MAKE) all >> make-frag\r
285 echo.   cd ..\src >> make-frag\r
286 echo.   $(MAKE) all >> make-frag\r
287 echo.   cd ..\lisp >> make-frag\r
288 echo.   $(MAKE) all >> make-frag\r
289 echo.   cd ..\leim >> make-frag\r
290 echo.   $(MAKE) all >> make-frag\r
291 echo.   cd ..\nt >> make-frag\r
292 echo. >> make-frag\r
293 echo clean-other-dirs: >> make-frag\r
294 echo.   cd ..\lib-src >> make-frag\r
295 echo.   $(MAKE) clean >> make-frag\r
296 echo.   cd ..\src >> make-frag\r
297 echo.   $(MAKE) clean >> make-frag\r
298 echo.   cd ..\lisp >> make-frag\r
299 echo.   $(MAKE) clean >> make-frag\r
300 echo.   cd ..\leim >> make-frag\r
301 echo.   $(MAKE) clean >> make-frag\r
302 echo.   cd ..\nt >> make-frag\r
303 echo. >> make-frag\r
304 echo install-other-dirs: >> make-frag\r
305 echo.   cd ..\lib-src >> make-frag\r
306 echo.   $(MAKE) install >> make-frag\r
307 echo.   cd ..\src >> make-frag\r
308 echo.   $(MAKE) install >> make-frag\r
309 echo.   cd ..\lisp >> make-frag\r
310 echo.   $(MAKE) install >> make-frag\r
311 echo.   cd ..\leim >> make-frag\r
312 echo.   $(MAKE) install >> make-frag\r
313 echo.   cd ..\nt >> make-frag\r
314 echo. >> make-frag\r
316 :gen2\r
317 copy /b config.settings+%MAKECMD%.defs+make-frag+..\nt\makefile.w32-in ..\nt\makefile\r
318 del make-frag\r
319 copy /b config.settings+%MAKECMD%.defs+..\lib-src\makefile.w32-in ..\lib-src\makefile\r
320 copy /b config.settings+%MAKECMD%.defs+..\src\makefile.w32-in ..\src\makefile\r
321 if not exist ..\lisp\Makefile.unix rename ..\lisp\Makefile Makefile.unix\r
322 if exist ..\lisp\makefile del /f ..\lisp\makefile\r
323 copy /b config.settings+%MAKECMD%.defs+..\lisp\makefile.w32-in ..\lisp\makefile\r
324 rem   Use the default (no-op) Makefile.in if the nt version is not present.\r
325 if exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\makefile.w32-in ..\leim\makefile\r
326 if not exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\Makefile.in ..\leim\makefile\r
327 del config.settings\r
329 echo.\r
330 echo Emacs successfully configured.\r
331 echo Run `%MAKECMD%' to build, then run `%MAKECMD% install' to install.\r
332 goto end\r
334 :SmallEnv\r
335 echo Your environment size is too small.  Please enlarge it and rerun configure.\r
336 echo For example, type "command.com /e:2048" to have 2048 bytes available.\r
337 set $foo$=\r
338 :end\r
339 set prefix=\r
340 set nodebug=\r
341 set noopt=\r
342 set nocygwin=\r
343 set COMPILER=\r
344 set MAKECMD=\r
345 set usercflags=\r
346 set userldflags=\r