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