Commit | Line | Data |
---|---|---|
f466241d EZ |
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-2001 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 | |
12 | \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 | |
17 | \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 | |
49 | \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 | |
55 | \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 | |
61 | \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 | |
74 | \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 | |
e0006538 | 88 | if "%1" == "--without-png" goto withoutpng\r |
aad0eae4 | 89 | if "%1" == "--without-jpeg" goto withoutjpeg\r |
f466241d EZ |
90 | if "%1" == "" goto checkutils\r |
91 | :usage\r | |
92 | echo Usage: configure [options]\r | |
93 | echo Options:\r | |
94 | echo. --prefix PREFIX install Emacs in directory PREFIX\r | |
95 | echo. --with-gcc use GCC to compile Emacs\r | |
96 | echo. --with-msvc use MSVC to compile Emacs\r | |
97 | echo. --no-debug exclude debug info from executables\r | |
98 | echo. --no-opt disable optimization\r | |
99 | echo. --no-cygwin use -mno-cygwin option with GCC\r | |
100 | echo. --cflags FLAG pass FLAG to compiler\r | |
101 | echo. --ldflags FLAG pass FLAG to compiler when linking\r | |
e0006538 | 102 | echo. --without-png do not use libpng even if it is installed \r |
aad0eae4 | 103 | echo. --without-jpeg do not use jpeglib even if it is installed \r |
f466241d EZ |
104 | goto end\r |
105 | rem ----------------------------------------------------------------------\r | |
106 | :setprefix\r | |
107 | shift\r | |
108 | set prefix=%1\r | |
109 | shift\r | |
110 | goto again\r | |
111 | rem ----------------------------------------------------------------------\r | |
112 | :withgcc\r | |
113 | set COMPILER=gcc\r | |
114 | shift\r | |
115 | goto again\r | |
116 | rem ----------------------------------------------------------------------\r | |
117 | :withmsvc\r | |
118 | set COMPILER=cl\r | |
119 | shift\r | |
120 | goto again\r | |
121 | rem ----------------------------------------------------------------------\r | |
122 | :nodebug\r | |
123 | set nodebug=Y\r | |
124 | shift\r | |
125 | goto again\r | |
126 | rem ----------------------------------------------------------------------\r | |
127 | :noopt\r | |
128 | set noopt=Y\r | |
129 | shift\r | |
130 | goto again\r | |
131 | rem ----------------------------------------------------------------------\r | |
132 | :nocygwin\r | |
133 | set nocygwin=Y\r | |
134 | shift\r | |
135 | goto again\r | |
136 | rem ----------------------------------------------------------------------\r | |
137 | :usercflags\r | |
138 | shift\r | |
139 | set usercflags=%usercflags%%sep1%%1\r | |
140 | set sep1= %nothing%\r | |
141 | shift\r | |
142 | goto again\r | |
143 | rem ----------------------------------------------------------------------\r | |
144 | :userldflags\r | |
145 | shift\r | |
146 | set userldflags=%userldflags%%sep2%%1\r | |
147 | set sep2= %nothing%\r | |
148 | shift\r | |
149 | goto again\r | |
e0006538 JR |
150 | rem ----------------------------------------------------------------------\r |
151 | \r | |
152 | :withoutpng\r | |
153 | set pngsupport=N\r | |
154 | set HAVE_PNG=\r | |
155 | goto again\r | |
f466241d | 156 | \r |
aad0eae4 JR |
157 | rem ----------------------------------------------------------------------\r |
158 | \r | |
159 | :withoutjpeg\r | |
160 | set jpegsupport=N\r | |
161 | set HAVE_JPEG=\r | |
162 | goto again\r | |
163 | \r | |
f466241d EZ |
164 | rem ----------------------------------------------------------------------\r |
165 | rem Check that necessary utilities (cp and rm) are present.\r | |
166 | :checkutils\r | |
167 | echo Checking for 'cp'...\r | |
168 | cp configure.bat junk.bat\r | |
169 | if not exist junk.bat goto needcp\r | |
170 | echo Checking for 'rm'...\r | |
171 | rm junk.bat\r | |
172 | if exist junk.bat goto needrm\r | |
173 | goto checkcompiler\r | |
174 | :needcp\r | |
175 | echo You need 'cp' (the Unix file copy program) to build Emacs.\r | |
176 | goto end\r | |
177 | :needrm\r | |
178 | del junk.bat\r | |
179 | echo You need 'rm' (the Unix file delete program) to build Emacs.\r | |
180 | goto end\r | |
181 | \r | |
182 | rem ----------------------------------------------------------------------\r | |
183 | rem Auto-detect compiler if not specified, and validate GCC if chosen.\r | |
184 | :checkcompiler\r | |
e0006538 | 185 | if (%COMPILER%)==(cl) goto compilercheckdone\r |
f466241d EZ |
186 | if (%COMPILER%)==(gcc) goto checkgcc\r |
187 | \r | |
188 | echo Checking whether 'cl' is available...\r | |
189 | echo main(){} >junk.c\r | |
190 | cl -nologo -c junk.c\r | |
191 | if exist junk.obj goto clOK\r | |
192 | \r | |
193 | echo Checking whether 'gcc' is available...\r | |
194 | gcc -c junk.c\r | |
195 | if not exist junk.o goto nocompiler\r | |
196 | del junk.o\r | |
197 | \r | |
198 | :checkgcc\r | |
199 | Rem WARNING -- COMMAND.COM on some systems only looks at the first\r | |
200 | Rem 8 characters of a label. So do NOT be tempted to change\r | |
201 | Rem chkapi* into something fancier like checkw32api\r | |
202 | Rem You HAVE been warned!\r | |
203 | if (%nocygwin%) == (Y) goto chkapi\r | |
204 | echo Checking whether gcc requires '-mno-cygwin'...\r | |
205 | echo #include "cygwin/version.h" >junk.c\r | |
206 | echo main(){} >>junk.c\r | |
207 | gcc -c junk.c\r | |
208 | if not exist junk.o goto chkapi\r | |
209 | gcc -mno-cygwin -c junk.c\r | |
210 | if exist junk.o set nocygwin=Y\r | |
211 | rm -f junk.c junk.o\r | |
212 | \r | |
213 | :chkapi\r | |
214 | rem ----------------------------------------------------------------------\r | |
215 | rem Older versions of the Windows API headers either don't have any of\r | |
216 | rem the IMAGE_xxx definitions (the headers that come with Cygwin b20.1\r | |
217 | rem are like this), or have a typo in the definition of\r | |
218 | rem IMAGE_FIRST_SECTION (the headers with gcc/mingw32 2.95 have this\r | |
219 | rem problem). The gcc/mingw32 2.95.2 headers are okay, as are distros\r | |
220 | rem of w32api-xxx.zip from Anders Norlander since 1999-11-18 at least.\r | |
221 | rem\r | |
222 | echo Checking whether W32 API headers are too old...\r | |
223 | echo #include "windows.h" >junk.c\r | |
224 | echo test(PIMAGE_NT_HEADERS pHeader) >>junk.c\r | |
225 | echo {PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION(pHeader);} >>junk.c\r | |
226 | if (%nocygwin%) == (Y) goto chkapi1\r | |
227 | set cf=%usercflags%\r | |
228 | goto chkapi2\r | |
229 | :chkapi1\r | |
230 | set cf=%usercflags% -mno-cygwin\r | |
231 | :chkapi2\r | |
232 | echo on\r | |
233 | gcc %cf% -c junk.c\r | |
234 | echo off\r | |
235 | set cf=\r | |
236 | if exist junk.o goto gccOk\r | |
237 | \r | |
238 | :nocompiler\r | |
239 | echo.\r | |
240 | echo Configure failed.\r | |
241 | echo To configure Emacs for Windows, you need to have either\r | |
242 | echo gcc-2.95 or later with Mingw32 and the W32 API headers,\r | |
243 | echo or MSVC 2.x or later.\r | |
244 | del junk.c\r | |
245 | goto end\r | |
246 | \r | |
247 | :gccOk\r | |
248 | set COMPILER=gcc\r | |
249 | rm -f junk.c junk.o\r | |
250 | echo Using 'gcc'\r | |
e0006538 | 251 | goto compilercheckdone\r |
f466241d EZ |
252 | \r |
253 | :clOk\r | |
254 | set COMPILER=cl\r | |
255 | rm -f junk.c junk.obj\r | |
256 | echo Using 'MSVC'\r | |
e0006538 JR |
257 | \r |
258 | :compilercheckdone\r | |
259 | \r | |
260 | rem ----------------------------------------------------------------------\r | |
261 | rem Check for external image libraries. Since they are loaded\r | |
262 | rem dynamically, the libraries themselves do not need to be present\r | |
263 | rem at compile time, but the header files are required.\r | |
264 | \r | |
265 | if (%pngsupport%) == (N) goto pngDone\r | |
266 | \r | |
267 | echo Checking for libpng...\r | |
268 | echo #include "png.h" >junk.c\r | |
269 | echo main (){} >>junk.c\r | |
270 | rem -o option is ignored with cl, but allows result to be consistent.\r | |
271 | %COMPILER% %usercflags% -c junk.c -o junk.obj\r | |
272 | if exist junk.obj goto havePng\r | |
273 | \r | |
274 | echo ...building without PNG support.\r | |
275 | set HAVE_PNG=\r | |
276 | goto :pngDone\r | |
277 | \r | |
278 | :havePng\r | |
279 | echo ...PNG header available, building with PNG support.\r | |
280 | set HAVE_PNG=1\r | |
281 | \r | |
282 | :pngDone\r | |
283 | rm -f junk.c junk.obj\r | |
f466241d | 284 | \r |
aad0eae4 JR |
285 | if (%jpegsupport%) == (N) goto jpegDone\r |
286 | \r | |
287 | echo Checking for jpeg ...\r | |
288 | echo #include "jconfig.h" >junk.c\r | |
289 | echo main (){} >>junk.c\r | |
290 | rem -o option is ignored with cl, but allows result to be consistent.\r | |
291 | %COMPILER% %usercflags% -c junk.c -o junk.obj\r | |
292 | if exist junk.obj goto haveJpeg\r | |
293 | \r | |
294 | echo ...building without JPEG support.\r | |
295 | set HAVE_JPEG=\r | |
296 | goto :jpegDone\r | |
297 | \r | |
298 | :haveJpeg\r | |
299 | echo ...JPEG header available, building with JPEG support.\r | |
300 | set HAVE_JPEG=1\r | |
301 | \r | |
302 | :jpegDone\r | |
303 | rm -f junk.c junk.obj\r | |
304 | \r | |
f466241d EZ |
305 | rem ----------------------------------------------------------------------\r |
306 | :genmakefiles\r | |
307 | echo Generating makefiles\r | |
308 | if %COMPILER% == gcc set MAKECMD=gmake\r | |
309 | if %COMPILER% == cl set MAKECMD=nmake\r | |
310 | \r | |
311 | rem Pass on chosen settings to makefiles.\r | |
312 | rem NB. Be very careful to not have a space before redirection symbols\r | |
313 | rem except when there is a preceding digit, when a space is required.\r | |
314 | rem\r | |
315 | echo # Start of settings from configure.bat >config.settings\r | |
316 | echo COMPILER=%COMPILER%>>config.settings\r | |
317 | if (%nodebug%) == (Y) echo NODEBUG=1 >>config.settings\r | |
318 | if (%noopt%) == (Y) echo NOOPT=1 >>config.settings\r | |
319 | if (%nocygwin%) == (Y) echo NOCYGWIN=1 >>config.settings\r | |
320 | if not "(%prefix%)" == "()" echo INSTALL_DIR=%prefix%>>config.settings\r | |
321 | if not "(%usercflags%)" == "()" echo USER_CFLAGS=%usercflags%>>config.settings\r | |
322 | if not "(%userldflags%)" == "()" echo USER_LDFLAGS=%userldflags%>>config.settings\r | |
323 | echo # End of settings from configure.bat>>config.settings\r | |
324 | echo. >>config.settings\r | |
325 | \r | |
326 | copy config.nt ..\src\config.h\r | |
e0006538 JR |
327 | echo. >>..\src\config.h\r |
328 | echo /* Start of settings from configure.bat. */ >>..\src\config.h\r | |
f466241d EZ |
329 | if not "(%usercflags%)" == "()" echo #define USER_CFLAGS " %usercflags%">>..\src\config.h\r |
330 | if not "(%userldflags%)" == "()" echo #define USER_LDFLAGS " %userldflags%">>..\src\config.h\r | |
e0006538 | 331 | if not "(%HAVE_PNG%)" == "()" echo #define HAVE_PNG 1 >>..\src\config.h\r |
aad0eae4 | 332 | if not "(%HAVE_JPEG%)" == "()" echo #define HAVE_JPEG 1 >>..\src\config.h\r |
e0006538 JR |
333 | echo /* End of settings from configure.bat. */ >>..\src\config.h\r |
334 | \r | |
f466241d EZ |
335 | copy paths.h ..\src\epaths.h\r |
336 | \r | |
337 | copy /b config.settings+%MAKECMD%.defs+..\nt\makefile.w32-in ..\nt\makefile\r | |
338 | copy /b config.settings+%MAKECMD%.defs+..\lib-src\makefile.w32-in ..\lib-src\makefile\r | |
339 | copy /b config.settings+%MAKECMD%.defs+..\src\makefile.w32-in ..\src\makefile\r | |
340 | if not exist ..\lisp\Makefile.unix rename ..\lisp\Makefile.in Makefile.unix\r | |
341 | if exist ..\lisp\makefile rm -f ../lisp/[Mm]akefile\r | |
342 | copy /b config.settings+%MAKECMD%.defs+..\lisp\makefile.w32-in ..\lisp\makefile\r | |
343 | rem Use the default (no-op) Makefile.in if the nt version is not present.\r | |
344 | if exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\makefile.w32-in ..\leim\makefile\r | |
345 | if not exist ..\leim\makefile.w32-in copy /b config.settings+%MAKECMD%.defs+..\leim\Makefile.in ..\leim\makefile\r | |
346 | del config.settings\r | |
347 | \r | |
e44f8099 EZ |
348 | Rem Some people use WinZip which doesn't create empty directories!\r |
349 | if not exist ..\site-lisp\nul mkdir ..\site-lisp\\r | |
f466241d EZ |
350 | if not exist ..\site-lisp\subdirs.el copy subdirs.el ..\site-lisp\subdirs.el\r |
351 | \r | |
352 | echo.\r | |
353 | echo Emacs successfully configured.\r | |
354 | echo Run `%MAKECMD%' to build, then run `%MAKECMD% install' to install.\r | |
355 | goto end\r | |
356 | \r | |
357 | :SmallEnv\r | |
358 | echo Your environment size is too small. Please enlarge it and rerun configure.\r | |
359 | echo For example, type "command.com /e:2048" to have 2048 bytes available.\r | |
360 | set $foo$=\r | |
361 | :end\r | |
362 | set prefix=\r | |
363 | set nodebug=\r | |
364 | set noopt=\r | |
365 | set nocygwin=\r | |
366 | set COMPILER=\r | |
367 | set MAKECMD=\r | |
368 | set usercflags=\r | |
369 | set userldflags=\r |