VirtualBox

source: kBuild/vendor/gnumake/current/build_w32.bat@ 3138

Last change on this file since 3138 was 3138, checked in by bird, 7 years ago

Imported make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6) from https://git.savannah.gnu.org/git/make.git.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette