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