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