1 | @echo off
|
---|
2 | rem Copyright (C) 1996-2016 Free Software Foundation, Inc.
|
---|
3 | rem This file is part of GNU Make.
|
---|
4 | rem
|
---|
5 | rem GNU Make is free software; you can redistribute it and/or modify it under
|
---|
6 | rem the terms of the GNU General Public License as published by the Free
|
---|
7 | rem Software Foundation; either version 3 of the License, or (at your option)
|
---|
8 | rem any later version.
|
---|
9 | rem
|
---|
10 | rem GNU Make is distributed in the hope that it will be useful, but WITHOUT
|
---|
11 | rem ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
12 | rem FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for.
|
---|
13 | rem more details.
|
---|
14 | rem
|
---|
15 | rem You should have received a copy of the GNU General Public License along
|
---|
16 | rem with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 |
|
---|
18 | call :Reset
|
---|
19 |
|
---|
20 | if "%1" == "-h" goto Usage
|
---|
21 | if "%1" == "--help" goto Usage
|
---|
22 |
|
---|
23 | set MAKE=gnumake
|
---|
24 | set GUILE=Y
|
---|
25 | set COMPILER=msvc
|
---|
26 |
|
---|
27 | :ParseSW
|
---|
28 | if "%1" == "--debug" goto SetDebug
|
---|
29 | if "%1" == "--without-guile" goto NoGuile
|
---|
30 | if "%1" == "gcc" goto SetCC
|
---|
31 | if "%1" == "" goto DoneSW
|
---|
32 |
|
---|
33 | :SetDebug
|
---|
34 | set DEBUG=Y
|
---|
35 | shift
|
---|
36 | goto ParseSW
|
---|
37 |
|
---|
38 | :NoGuile
|
---|
39 | set GUILE=N
|
---|
40 | echo Building without Guile
|
---|
41 | shift
|
---|
42 | goto ParseSW
|
---|
43 |
|
---|
44 | :SetCC
|
---|
45 | set COMPILER=gcc
|
---|
46 | echo Building with GCC
|
---|
47 | shift
|
---|
48 | goto ParseSW
|
---|
49 |
|
---|
50 | rem Build with Guile is supported only on NT and later versions
|
---|
51 | :DoneSW
|
---|
52 | echo.
|
---|
53 | echo Creating GNU Make for Windows 9X/NT/2K/XP/Vista/7/8
|
---|
54 | if "%DEBUG%" == "Y" echo Building without compiler optimizations
|
---|
55 |
|
---|
56 | if "%COMPILER%" == "gcc" goto GccBuild
|
---|
57 |
|
---|
58 | set OUTDIR=.\WinRel
|
---|
59 | set "OPTS=/O2 /D NDEBUG"
|
---|
60 | set LINKOPTS=
|
---|
61 | if "%DEBUG%" == "Y" set OUTDIR=.\WinDebug
|
---|
62 | if "%DEBUG%" == "Y" set "OPTS=/Zi /Od /D _DEBUG"
|
---|
63 | if "%DEBUG%" == "Y" set LINKOPTS=/DEBUG
|
---|
64 | call :Build
|
---|
65 | goto Done
|
---|
66 |
|
---|
67 | :GccBuild
|
---|
68 | set OUTDIR=.\GccRel
|
---|
69 | set OPTS=-O2
|
---|
70 | if "%DEBUG%" == "Y" set OPTS=-O0
|
---|
71 | if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug
|
---|
72 | call :Build
|
---|
73 | goto Done
|
---|
74 |
|
---|
75 | :Done
|
---|
76 | call :Reset
|
---|
77 | goto :EOF
|
---|
78 |
|
---|
79 | :Build
|
---|
80 | :: Clean the directory if it exists
|
---|
81 | if exist %OUTDIR%\nul rmdir /S /Q %OUTDIR%
|
---|
82 |
|
---|
83 | :: Recreate it
|
---|
84 | mkdir %OUTDIR%
|
---|
85 | mkdir %OUTDIR%\glob
|
---|
86 | mkdir %OUTDIR%\w32
|
---|
87 | mkdir %OUTDIR%\w32\compat
|
---|
88 | mkdir %OUTDIR%\w32\subproc
|
---|
89 |
|
---|
90 | if "%GUILE%" == "Y" call :ChkGuile
|
---|
91 |
|
---|
92 | echo.
|
---|
93 | echo Compiling %OUTDIR% version
|
---|
94 |
|
---|
95 | if exist config.h.W32.template call :ConfigSCM
|
---|
96 | copy config.h.W32 %OUTDIR%\config.h
|
---|
97 |
|
---|
98 | call :Compile ar
|
---|
99 | call :Compile arscan
|
---|
100 | call :Compile commands
|
---|
101 | call :Compile default
|
---|
102 | call :Compile dir
|
---|
103 | call :Compile expand
|
---|
104 | call :Compile file
|
---|
105 | call :Compile function
|
---|
106 | call :Compile getloadavg
|
---|
107 | call :Compile getopt
|
---|
108 | call :Compile getopt1
|
---|
109 | call :Compile glob\fnmatch
|
---|
110 | call :Compile glob\glob
|
---|
111 | call :Compile guile GUILE
|
---|
112 | call :Compile hash
|
---|
113 | call :Compile implicit
|
---|
114 | call :Compile job
|
---|
115 | call :Compile load
|
---|
116 | call :Compile loadapi
|
---|
117 | call :Compile main GUILE
|
---|
118 | call :Compile misc
|
---|
119 | call :Compile output
|
---|
120 | call :Compile read
|
---|
121 | call :Compile remake
|
---|
122 | call :Compile remote-stub
|
---|
123 | call :Compile rule
|
---|
124 | call :Compile signame
|
---|
125 | call :Compile strcache
|
---|
126 | call :Compile variable
|
---|
127 | call :Compile version
|
---|
128 | call :Compile vpath
|
---|
129 | call :Compile w32\compat\posixfcn
|
---|
130 | call :Compile w32\pathstuff
|
---|
131 | call :Compile w32\subproc\misc
|
---|
132 | call :Compile w32\subproc\sub_proc
|
---|
133 | call :Compile w32\subproc\w32err
|
---|
134 | call :Compile w32\w32os
|
---|
135 |
|
---|
136 | if not "%COMPILER%" == "gcc" call :Compile w32\compat\dirent
|
---|
137 |
|
---|
138 | call :Link
|
---|
139 |
|
---|
140 | echo.
|
---|
141 | if not exist %OUTDIR%\%MAKE%.exe echo %OUTDIR% build FAILED!
|
---|
142 | if exist %OUTDIR%\%MAKE%.exe echo %OUTDIR% build succeeded.
|
---|
143 | goto :EOF
|
---|
144 |
|
---|
145 | :Compile
|
---|
146 | set EXTRAS=
|
---|
147 | if "%2" == "GUILE" set "EXTRAS=%GUILECFLAGS%"
|
---|
148 | if "%COMPILER%" == "gcc" goto GccCompile
|
---|
149 |
|
---|
150 | :: MSVC Compile
|
---|
151 | echo on
|
---|
152 | cl.exe /nologo /MT /W4 /EHsc %OPTS% /I %OUTDIR% /I . /I glob /I w32/include /D WINDOWS32 /D WIN32 /D _CONSOLE /D HAVE_CONFIG_H /FR%OUTDIR% /Fp%OUTDIR%\%MAKE%.pch /Fo%OUTDIR%\%1.obj /Fd%OUTDIR%\%MAKE%.pdb %EXTRAS% /c %1.c
|
---|
153 | @echo off
|
---|
154 | echo %OUTDIR%\%1.obj >>%OUTDIR%\link.sc
|
---|
155 | goto :EOF
|
---|
156 |
|
---|
157 | :GccCompile
|
---|
158 | :: GCC Compile
|
---|
159 | echo on
|
---|
160 | gcc -mthreads -Wall -std=gnu99 -gdwarf-2 -g3 %OPTS% -I%OUTDIR% -I. -I./glob -I./w32/include -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%\%1.o -c %1.c
|
---|
161 | @echo off
|
---|
162 | goto :EOF
|
---|
163 |
|
---|
164 | :Link
|
---|
165 | echo Linking %OUTDIR%/%MAKE%.exe
|
---|
166 | if "%COMPILER%" == "gcc" goto GccLink
|
---|
167 |
|
---|
168 | :: MSVC Link
|
---|
169 | echo %GUILELIBS% kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib >>%OUTDIR%\link.sc
|
---|
170 | echo on
|
---|
171 | link.exe /NOLOGO /SUBSYSTEM:console /PDB:%OUTDIR%\%MAKE%.pdb %LINKOPTS% /OUT:%OUTDIR%\%MAKE%.exe @%OUTDIR%\link.sc
|
---|
172 | @echo off
|
---|
173 | goto :EOF
|
---|
174 |
|
---|
175 | :GccLink
|
---|
176 | :: GCC Link
|
---|
177 | echo on
|
---|
178 | gcc -mthreads -gdwarf-2 -g3 -o %OUTDIR%\%MAKE%.exe %OUTDIR%\variable.o %OUTDIR%\rule.o %OUTDIR%\remote-stub.o %OUTDIR%\commands.o %OUTDIR%\file.o %OUTDIR%\getloadavg.o %OUTDIR%\default.o %OUTDIR%\signame.o %OUTDIR%\expand.o %OUTDIR%\dir.o %OUTDIR%\main.o %OUTDIR%\getopt1.o %OUTDIR%\guile.o %OUTDIR%\job.o %OUTDIR%\output.o %OUTDIR%\read.o %OUTDIR%\version.o %OUTDIR%\getopt.o %OUTDIR%\arscan.o %OUTDIR%\remake.o %OUTDIR%\misc.o %OUTDIR%\hash.o %OUTDIR%\strcache.o %OUTDIR%\ar.o %OUTDIR%\function.o %OUTDIR%\vpath.o %OUTDIR%\implicit.o %OUTDIR%\loadapi.o %OUTDIR%\load.o %OUTDIR%\glob\glob.o %OUTDIR%\glob\fnmatch.o %OUTDIR%\w32\pathstuff.o %OUTDIR%\w32\compat\posixfcn.o %OUTDIR%\w32\w32os.o %OUTDIR%\w32\subproc\misc.o %OUTDIR%\w32\subproc\sub_proc.o %OUTDIR%\w32\subproc\w32err.o %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -Wl,--out-implib=%OUTDIR%\libgnumake-1.dll.a
|
---|
179 | @echo off
|
---|
180 | goto :EOF
|
---|
181 |
|
---|
182 | :ConfigSCM
|
---|
183 | echo Generating config from SCM templates
|
---|
184 | sed -n "s/^AC_INIT(\[GNU make\],\[\([^]]\+\)\].*/s,%%VERSION%%,\1,g/p" configure.ac > %OUTDIR%\config.h.W32.sed
|
---|
185 | echo s,%%PACKAGE%%,make,g >> %OUTDIR%\config.h.W32.sed
|
---|
186 | sed -f %OUTDIR%\config.h.W32.sed config.h.W32.template > config.h.W32
|
---|
187 | echo static const char *const GUILE_module_defn = ^" \> gmk-default.h
|
---|
188 | sed -e "s/;.*//" -e "/^[ \t]*$/d" -e "s/\"/\\\\\"/g" -e "s/$/ \\\/" gmk-default.scm >> gmk-default.h
|
---|
189 | echo ^";>> gmk-default.h
|
---|
190 | goto :EOF
|
---|
191 |
|
---|
192 | :ChkGuile
|
---|
193 | if not "%OS%" == "Windows_NT" goto NoGuile
|
---|
194 | pkg-config --help > %OUTDIR%\guile.tmp 2> NUL
|
---|
195 | if ERRORLEVEL 1 goto NoPkgCfg
|
---|
196 |
|
---|
197 | echo Checking for Guile 2.0
|
---|
198 | if not "%COMPILER%" == "gcc" set PKGMSC=--msvc-syntax
|
---|
199 | pkg-config --cflags --short-errors "guile-2.0" > %OUTDIR%\guile.tmp
|
---|
200 | if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\guile.tmp
|
---|
201 |
|
---|
202 | pkg-config --libs --static --short-errors %PKGMSC% "guile-2.0" > %OUTDIR%\guile.tmp
|
---|
203 | if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\guile.tmp
|
---|
204 |
|
---|
205 | if not "%GUILECFLAGS%" == "" goto GuileDone
|
---|
206 |
|
---|
207 | echo Checking for Guile 1.8
|
---|
208 | pkg-config --cflags --short-errors "guile-1.8" > %OUTDIR%\guile.tmp
|
---|
209 | if not ERRORLEVEL 1 set /P GUILECFLAGS= < %OUTDIR%\guile.tmp
|
---|
210 |
|
---|
211 | pkg-config --libs --static --short-errors %PKGMSC% "guile-1.8" > %OUTDIR%\guile.tmp
|
---|
212 | if not ERRORLEVEL 1 set /P GUILELIBS= < %OUTDIR%\guile.tmp
|
---|
213 |
|
---|
214 | if not "%GUILECFLAGS%" == "" goto GuileDone
|
---|
215 |
|
---|
216 | echo No Guile found, building without Guile
|
---|
217 | goto GuileDone
|
---|
218 |
|
---|
219 | :NoPkgCfg
|
---|
220 | echo pkg-config not found, building without Guile
|
---|
221 |
|
---|
222 | :GuileDone
|
---|
223 | if "%GUILECFLAGS%" == "" goto :EOF
|
---|
224 |
|
---|
225 | echo Guile found, building with Guile
|
---|
226 | set "GUILECFLAGS=%GUILECFLAGS% -DHAVE_GUILE"
|
---|
227 | goto :EOF
|
---|
228 |
|
---|
229 | :Usage
|
---|
230 | echo Usage: %0 [options] [gcc]
|
---|
231 | echo Options:
|
---|
232 | echo. --debug For GCC only, make a debug build
|
---|
233 | echo. (MSVC build always makes both debug and release)
|
---|
234 | echo. --without-guile Do not compile Guile support even if found
|
---|
235 | echo. --help Display these instructions and exit
|
---|
236 | goto :EOF
|
---|
237 |
|
---|
238 | :Reset
|
---|
239 | set COMPILER=
|
---|
240 | set DEBUG=
|
---|
241 | set GUILE=
|
---|
242 | set GUILECFLAGS=
|
---|
243 | set GUILELIBS=
|
---|
244 | set LINKOPTS=
|
---|
245 | set MAKE=
|
---|
246 | set NOGUILE=
|
---|
247 | set OPTS=
|
---|
248 | set OUTDIR=
|
---|
249 | set PKGMSC=
|
---|
250 | goto :EOF
|
---|