3 SET CONFIG_H="%~dp0..\config.h"
4 SET CYG_CONFIG_H="%~dp0..\cygconfig.h"
5 SET WIN_CONFIG_H="%~dp0..\winconfig.h"
6 SET CONFIGURE_AC="%~dp0..\configure.ac"
7 SET VERSION_H="%~dp0..\mono\mini\version.h"
9 ECHO Setting up Mono configuration headers...
11 :: generate unique temp file path
12 uuidgen 2>nul || goto no_uuidgen
13 for /f %%a in ('uuidgen') do set monotemp=%%a
17 :: Random isn't very random or unique. %time% and %date% is not random but fairly unique.
18 set monotemp=%~n0%random%%time%%date%
21 :: Remove special characters.
22 set monotemp=%monotemp:-=%
23 set monotemp=%monotemp:\=%
24 set monotemp=%monotemp:/=%
25 set monotemp=%monotemp::=%
26 set monotemp=%monotemp: =%
27 set monotemp=%monotemp:.=%
28 set monotemp=%temp%\monotemp%monotemp%
29 mkdir "%monotemp%\.." 2>nul
30 set monotemp="%monotemp%"
33 REM Backup existing config.h into cygconfig.h if its not already replaced.
34 findstr /i /r /c:"#include *\"cygconfig.h\"" %config_h% >nul || copy /y %config_h% %cyg_config_h%
36 :: Extract MONO_VERSION from configure.ac.
37 for /f "delims=[] tokens=2" %%a in ('findstr /b /c:"AC_INIT(mono, [" %CONFIGURE_AC%') do (
41 :: Split MONO_VERSION into three parts.
42 for /f "delims=. tokens=1-3" %%a in ('echo %MONO_VERSION%') do (
43 set MONO_VERSION_MAJOR=%%a
44 set MONO_VERSION_MINOR=%%b
45 set MONO_VERSION_PATCH=%%c
47 :: configure.ac hardcodes this.
48 set MONO_VERSION_PATCH=00
50 :: Extract MONO_CORLIB_COUNTER from configure.ac.
51 for /f "tokens=*" %%a in ('findstr /b /c:MONO_CORLIB_COUNTER= %CONFIGURE_AC%') do set %%a
53 :: Pad out version pieces to 2 characters with zeros on left.
54 :: corlib_counter same but 3 characters.
55 if "%MONO_VERSION_MAJOR:~1%" == "" set MONO_VERSION_MAJOR=0%MONO_VERSION_MAJOR%
56 if "%MONO_VERSION_MINOR:~1%" == "" set MONO_VERSION_MINOR=0%MONO_VERSION_MINOR%
57 if "%MONO_CORLIB_COUNTER:~2%" == "" set MONO_CORLIB_COUNTER=0%MONO_CORLIB_COUNTER%
58 if "%MONO_CORLIB_COUNTER:~2%" == "" set MONO_CORLIB_COUNTER=0%MONO_CORLIB_COUNTER%
60 set MONO_CORLIB_VERSION=1%MONO_VERSION_MAJOR%%MONO_VERSION_MINOR%%MONO_VERSION_PATCH%%MONO_CORLIB_COUNTER%
62 :: Remove every define VERSION from config.h and add what we want.
63 findstr /v /b /i /c:"#define PACKAGE_VERSION " /c:"#define VERSION " /c:"#define MONO_CORLIB_VERSION " %win_config_h% > %monotemp%
64 echo #define PACKAGE_VERSION "%MONO_VERSION%" >> %monotemp%
65 echo #define VERSION "%MONO_VERSION%" >> %monotemp%
66 echo #define MONO_CORLIB_VERSION %MONO_CORLIB_VERSION% >> %monotemp%
68 :: If the file is different, replace it.
69 fc %monotemp% %config_h% >nul || move /y %monotemp% %config_h%
72 echo #define FULL_VERSION "Visual Studio built mono" > %monotemp%
73 fc %monotemp% %version_h% || move /y %monotemp% %version_h%
76 :: Log environment variables that start "mono".
79 ECHO Successfully setup Mono configuration headers.