2 rem Copyright (C) 1996-2016 Free Software Foundation, Inc.
\r
3 rem This file is part of GNU Make.
\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
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
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
20 if "%1" == "-h" goto Usage
\r
21 if "%1" == "--help" goto Usage
\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
40 echo Building without Guile
\r
46 echo Building with GCC
\r
50 rem Build with Guile is supported only on NT and later versions
\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
56 if "%COMPILER%" == "gcc" goto GccBuild
\r
59 set "OPTS=/O2 /D NDEBUG"
\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
70 if "%DEBUG%" == "Y" set OPTS=-O0
\r
71 if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug
\r
80 :: Clean the directory if it exists
\r
81 if exist %OUTDIR%\nul rmdir /S /Q %OUTDIR%
\r
87 mkdir %OUTDIR%\w32\compat
\r
88 mkdir %OUTDIR%\w32\subproc
\r
90 if "%GUILE%" == "Y" call :ChkGuile
\r
93 echo Compiling %OUTDIR% version
\r
95 if exist config.h.W32.template call :ConfigSCM
\r
96 copy config.h.W32 %OUTDIR%\config.h
\r
99 call :Compile arscan
\r
100 call :Compile commands
\r
101 call :Compile default
\r
103 call :Compile expand
\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
113 call :Compile implicit
\r
116 call :Compile loadapi
\r
117 call :Compile main GUILE
\r
119 call :Compile output
\r
121 call :Compile remake
\r
122 call :Compile remote-stub
\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
136 if not "%COMPILER%" == "gcc" call :Compile w32\compat\dirent
\r
141 if not exist %OUTDIR%\%MAKE%.exe echo %OUTDIR% build FAILED!
\r
142 if exist %OUTDIR%\%MAKE%.exe echo %OUTDIR% build succeeded.
\r
147 if "%2" == "GUILE" set "EXTRAS=%GUILECFLAGS%"
\r
148 if "%COMPILER%" == "gcc" goto GccCompile
\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
154 echo %OUTDIR%\%1.obj >>%OUTDIR%\link.sc
\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
165 echo Linking %OUTDIR%/%MAKE%.exe
\r
166 if "%COMPILER%" == "gcc" goto GccLink
\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
171 link.exe /NOLOGO /SUBSYSTEM:console /PDB:%OUTDIR%\%MAKE%.pdb %LINKOPTS% /OUT:%OUTDIR%\%MAKE%.exe @%OUTDIR%\link.sc
\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
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
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
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
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
205 if not "%GUILECFLAGS%" == "" goto GuileDone
\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
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
214 if not "%GUILECFLAGS%" == "" goto GuileDone
\r
216 echo No Guile found, building without Guile
\r
220 echo pkg-config not found, building without Guile
\r
223 if "%GUILECFLAGS%" == "" goto :EOF
\r
225 echo Guile found, building with Guile
\r
226 set "GUILECFLAGS=%GUILECFLAGS% -DHAVE_GUILE"
\r
230 echo Usage: %0 [options] [gcc]
\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