1@echo off
2rem   ----------------------------------------------------------------------
3rem   Configuration script for MSDOS
4rem   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003
5rem   2004, 2005, 2006, 2007  Free Software Foundation, Inc.
6
7rem   This file is part of GNU Emacs.
8
9rem   GNU Emacs is free software; you can redistribute it and/or modify
10rem   it under the terms of the GNU General Public License as published by
11rem   the Free Software Foundation; either version 2, or (at your option)
12rem   any later version.
13
14rem   GNU Emacs is distributed in the hope that it will be useful,
15rem   but WITHOUT ANY WARRANTY; without even the implied warranty of
16rem   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17rem   GNU General Public License for more details.
18
19rem   You should have received a copy of the GNU General Public License
20rem   along with GNU Emacs; see the file COPYING.  If not, write to the
21rem   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22rem   Boston, MA 02110-1301, USA.
23rem   ----------------------------------------------------------------------
24rem   YOU'LL NEED THE FOLLOWING UTILITIES TO MAKE EMACS:
25rem
26rem   + msdos version 3 or better.
27rem   + DJGPP version 1.12maint1 or later (version 2.03 or later recommended).
28rem   + make utility that allows breaking of the 128 chars limit on
29rem     command lines.  ndmake (as of version 4.5) won't work due to a
30rem     line length limit.  The make that comes with DJGPP does work.
31rem   + rm and mv (from GNU file utilities).
32rem   + sed (you can use the port that comes with DJGPP).
33rem
34rem   You should be able to get all the above utilities from the DJGPP FTP
35rem   site, ftp.delorie.com, in the directory "pub/djgpp/current/v2gnu".
36rem   ----------------------------------------------------------------------
37set X11=
38set nodebug=
39set djgpp_ver=
40if "%1" == "" goto usage
41rem   ----------------------------------------------------------------------
42rem   See if their environment is large enough.  We need 28 bytes.
43set $foo$=789012345678901234567
44if not "%$foo$%" == "789012345678901234567" goto SmallEnv
45set $foo$=
46:again
47if "%1" == "" goto usage
48if "%1" == "--with-x" goto withx
49if "%1" == "--no-debug" goto nodebug
50if "%1" == "msdos" goto msdos
51:usage
52echo Usage: config [--with-x] [--no-debug] msdos
53echo [Read the script before you run it.]
54goto end
55rem   ----------------------------------------------------------------------
56:withx
57set X11=Y
58shift
59goto again
60rem   ----------------------------------------------------------------------
61:nodebug
62set nodebug=Y
63shift
64goto again
65rem   ----------------------------------------------------------------------
66:msdos
67Echo Checking whether 'sed' is available...
68sed -e "w junk.$$$" <Nul
69If Exist junk.$$$ Goto sedOk
70Echo To configure 'Emacs' you need to have 'sed'!
71Goto End
72:sedOk
73Echo Checking whether 'rm' is available...
74rm -f junk.$$$
75If Not Exist junk.$$$ Goto rmOk
76Echo To configure 'Emacs' you need to have 'rm'!
77Goto End
78:rmOk
79Echo Checking whether 'mv' is available...
80rm -f junk.1 junk.2
81echo foo >junk.1
82mv junk.1 ./junk.2
83If Exist junk.2 Goto mvOk
84Echo To configure 'Emacs' you need to have 'mv'!
85rm -f junk.1
86Goto End
87:mvOk
88rm -f junk.2
89Echo Checking whether 'gcc' is available...
90echo main(){} >junk.c
91gcc -c junk.c
92if exist junk.o goto gccOk
93Echo To configure 'Emacs' you need to have 'gcc'!
94rm -f junk.c
95Goto End
96:gccOk
97rm -f junk.c junk.o junk junk.exe
98Echo Checking what version of DJGPP is installed...
99If Not "%DJGPP%" == "" goto djgppOk
100Echo To compile 'Emacs' under MS-DOS you MUST have DJGPP installed!
101Goto End
102:djgppOk
103echo int main()           >junk.c
104echo #ifdef __DJGPP__    >>junk.c
105echo {return (__DJGPP__)*10;} >>junk.c
106echo #else               >>junk.c
107echo #ifdef __GO32__     >>junk.c
108echo {return 10;}         >>junk.c
109echo #else               >>junk.c
110echo {return 0;}         >>junk.c
111echo #endif              >>junk.c
112echo #endif              >>junk.c
113gcc -o junk junk.c
114if not exist junk.exe coff2exe junk
115junk
116If ErrorLevel 10 Goto go32Ok
117rm -f junk.c junk junk.exe
118Echo To compile 'Emacs' under MS-DOS you MUST have DJGPP installed!
119Goto End
120:go32Ok
121set djgpp_ver=1
122If ErrorLevel 20 set djgpp_ver=2
123rm -f junk.c junk junk.exe
124rem The v1.x build does not need djecho
125if "%DJGPP_VER%" == "1" Goto djechoOk
126rem DJECHO is used by the top-level Makefile in the v2.x build
127Echo Checking whether 'djecho' is available...
128redir -o Nul -eo djecho -o junk.$$$ foo
129If Exist junk.$$$ Goto djechoOk
130Echo To build 'Emacs' you need the 'djecho.exe' program!
131Echo 'djecho.exe' is part of 'djdevNNN.zip' basic DJGPP development kit.
132Echo Versions of DJGPP before 2.02 called this program 'echo.exe'.
133Echo Either unpack 'djecho.exe' from the 'djdevNNN.zip' archive,
134Echo or, if you have 'echo.exe', copy it to 'djecho.exe'.
135Echo Then run CONFIG.BAT again with the same arguments you did now.
136Goto End
137:djechoOk
138rm -f junk.$$$
139Echo Configuring for DJGPP Version %DJGPP_VER% ...
140Rem   ----------------------------------------------------------------------
141Echo Configuring the source directory...
142cd src
143
144rem   Create "epaths.h"
145sed -f ../msdos/sed4.inp <epaths.in >epaths.tmp
146update epaths.tmp epaths.h >nul
147rm -f epaths.tmp
148
149rem   Create "config.h"
150rm -f config.h2 config.tmp
151sed -e '' config.in > config.tmp
152if "%X11%" == "" goto src4
153sed -f ../msdos/sed2x.inp <config.in >config.tmp
154:src4
155if "%DJGPP_VER%" == "2" Goto src41
156sed -f ../msdos/sed2.inp <config.tmp >config.h2
157goto src42
158:src41
159sed -f ../msdos/sed2v2.inp <config.tmp >config.h2
160:src42
161Rem See if DECL_ALIGN can be supported with this GCC
162rm -f junk.c junk.o junk junk.exe
163echo struct { int i; char *p; } __attribute__((__aligned__(8))) foo;  >junk.c
164rem Two percent signs because it is a special character for COMMAND.COM/CMD
165rem Filter thru Sed because "&" is special for CMD.EXE
166echo int main(void) { return (unsigned long)"&"foo %% 8; } | sed "s/.&./\&/"         >>junk.c
167gcc -o junk junk.c
168if not exist junk.exe coff2exe junk
169junk
170If Not ErrorLevel 1 Goto alignOk
171Echo WARNING: Your GCC does not support 8-byte aligned variables.
172Echo WARNING: Therefore Emacs cannot support buffers larger than 128MB.
173rem The following line disables DECL_ALIGN which in turn disables USE_LSB_TAG
174rem For details see lisp.h where it defines USE_LSB_TAG
175echo #define NO_DECL_ALIGN >>config.h2
176:alignOk
177rm -f junk.c junk junk.exe
178update config.h2 config.h >nul
179rm -f config.tmp config.h2
180
181rem   On my system dir.h gets in the way.  It's a VMS file so who cares.
182if exist dir.h ren dir.h vmsdir.h
183
184rem   Create "makefile" from "makefile.in".
185rm -f Makefile junk.c
186sed -e "1,/== start of cpp stuff ==/s@^# .*$@@" <Makefile.in >junk.c
187If "%DJGPP_VER%" == "1" Goto mfV1
188gcc -E -traditional junk.c | sed -f ../msdos/sed1v2.inp >Makefile
189goto mfDone
190:mfV1
191gcc -E -traditional junk.c | sed -f ../msdos/sed1.inp >Makefile
192:mfDone
193rm -f junk.c
194
195if "%X11%" == "" goto src5
196mv Makefile makefile.tmp
197sed -f ../msdos/sed1x.inp <makefile.tmp >Makefile
198rm -f makefile.tmp
199:src5
200
201if "%nodebug%" == "" goto src6
202sed -e "/^CFLAGS *=/s/ *-gcoff//" <Makefile >makefile.tmp
203sed -e "/^LDFLAGS *=/s/=/=-s/" <makefile.tmp >Makefile
204rm -f makefile.tmp
205:src6
206cd ..
207rem   ----------------------------------------------------------------------
208Echo Configuring the library source directory...
209cd lib-src
210rem   Create "makefile" from "makefile.in".
211sed -e "1,/== start of cpp stuff ==/s@^#[ 	].*$@@" <Makefile.in >junk.c
212gcc -E -traditional -I. -I../src junk.c | sed -e "s/^ /	/" -e "/^#/d" -e "/^[ 	]*$/d" >makefile.new
213If "%DJGPP_VER%" == "2" goto libsrc-v2
214sed -f ../msdos/sed3.inp <makefile.new >Makefile
215Goto libsrc2
216:libsrc-v2
217sed -f ../msdos/sed3v2.inp <makefile.new >Makefile
218:libsrc2
219rm -f makefile.new junk.c
220if "%nodebug%" == "" goto libsrc3
221sed -e "/^CFLAGS *=/s/ *-gcoff//" <Makefile >makefile.tmp
222sed -e "/^ALL_CFLAGS *=/s/=/= -s/" <makefile.tmp >Makefile
223rm -f makefile.tmp
224:libsrc3
225cd ..
226rem   ----------------------------------------------------------------------
227if "%X11%" == "" goto oldx1
228Echo Configuring the oldxmenu directory...
229cd oldxmenu
230sed -f ../msdos/sed5x.inp <Makefile.in >Makefile
231if "%nodebug%" == "" goto oldx2
232sed -e "/^CFLAGS *=/s/ *-gcoff//" <Makefile >makefile.tmp
233mv -f makefile.tmp Makefile
234:oldx2
235cd ..
236:oldx1
237rem   ----------------------------------------------------------------------
238Echo Configuring the manual directory...
239cd man
240sed -f ../msdos/sed6.inp < Makefile.in > Makefile
241cd ..
242rem   ----------------------------------------------------------------------
243Echo Configuring the ELisp manual directory...
244cd lispref
245sed -f ../msdos/sed6.inp < Makefile.in > Makefile
246cd ..
247rem   ----------------------------------------------------------------------
248Echo Configuring the ELisp Introduction manual directory...
249Rem The two variants for the line below is for when the shell
250Rem supports long file names but DJGPP does not
251if exist lispintro\Makefile.in cd lispintro
252if exist lispintr\Makefile.in cd lispintr
253sed -f ../msdos/sed6.inp < Makefile.in > Makefile
254cd ..
255rem   ----------------------------------------------------------------------
256Echo Configuring the lisp directory...
257cd lisp
258sed -f ../msdos/sedlisp.inp < Makefile.in > Makefile
259cd ..
260rem   ----------------------------------------------------------------------
261If not Exist leim\quail\latin-pre.el goto maindir
262Echo Configuring the leim directory...
263cd leim
264sed -f ../msdos/sedleim.inp < Makefile.in > Makefile
265cd ..
266rem   ----------------------------------------------------------------------
267:maindir
268Echo Configuring the main directory...
269If "%DJGPP_VER%" == "1" goto mainv1
270Echo Looking for the GDB init file...
271If Exist src\.gdbinit update src/.gdbinit src/_gdbinit
272If Exist src\_gdbinit goto gdbinitOk
273Echo ERROR:
274Echo I cannot find the GDB init file.  It was called ".gdbinit" in
275Echo the Emacs distribution, but was probably renamed to some other
276Echo name without the leading dot when you untarred the archive.
277Echo It should be in the "src/" subdirectory.  Please make sure this
278Echo file exists and is called "_gdbinit" with a leading underscore.
279Echo Then run CONFIG.BAT again with the same arguments you did now.
280goto End
281:gdbinitOk
282Echo Looking for the GDB init file...found
283copy msdos\mainmake.v2 Makefile >nul
284:mainv1
285If "%DJGPP_VER%" == "1" copy msdos\mainmake Makefile >nul
286rem   ----------------------------------------------------------------------
287goto End
288:SmallEnv
289echo Your environment size is too small.  Please enlarge it and run me again.
290echo For example, type "command.com /e:2048" to have 2048 bytes available.
291set $foo$=
292:end
293set X11=
294set nodebug=
295set djgpp_ver=
296
297goto skipArchTag
298   arch-tag: 2d2fed23-4dc6-4006-a2e4-49daf0031f33
299:skipArchTag
300