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