Configure and make mechnism for windows from windows branch

This commit is contained in:
jasonmoxham 2009-07-12 19:20:21 +00:00
parent 11ccfb52de
commit 0df3e1850a
4 changed files with 241 additions and 3 deletions

22
build.vc9/config.guess.c Executable file
View File

@ -0,0 +1,22 @@
long cpuid(char *p,int i)
{int a[4];
__cpuid(a,i);
memcpy(p,&(a[1]),4);
memcpy(p+4,&(a[3]),4);
memcpy(p+8,&(a[2]),4);
return a[0];}
main (int argc,char *argv[])
{char *p;int a=sizeof(p)*8;
#define CONFIG_GUESS 1
// safe to always try 32bit
#define CONFIG_GUESS_32BIT 1
#define CONFIG_GUESS_64BIT 0
#define FAT32 0
#define FAT64 0
#define INFAT 0
#include "../cpuid.c"
if(argc==2){printf("set GCPU=%s\nset GBITS=%d\n",modelstr,a);return 0;}
printf("%s-pc-Win%d\n",modelstr,a);return 0;}

132
build.vc9/configure.bat Normal file
View File

@ -0,0 +1,132 @@
@echo off
set LIBTYPE=lib
set CPU=?
set BITS=?
set GBITS=?
set GCPU=?
:lp
shift
if "%0" == "" goto :exitlp
if "%0" == "--enable-shared" ( set LIBTYPE=dll)
if "%0" == "--enable-static" ( set LIBTYPE=lib)
if "%0" == "--disable-shared" ( set LIBTYPE=lib)
if "%0" == "--disable-static" ( set LIBTYPE=dll)
if "%0" == "--ABI32" ( set BITS=32)
if "%0" == "--ABI64" ( set BITS=64)
if "%0" == "--cpu-none" ( set CPU=none)
if "%0" == "--cpu-x86_64" ( set CPU=x86_64)
if "%0" == "--cpu-i486" ( set CPU=i486)
if "%0" == "--cpu-pentium" ( set CPU=pentium)
if "%0" == "--cpu-pentiummmx" ( set CPU=pentiummmx)
if "%0" == "--cpu-pentiumpro" ( set CPU=pentiumpro)
if "%0" == "--cpu-pentium2" ( set CPU=pentium2)
if "%0" == "--cpu-pentium3" ( set CPU=pentium3)
if "%0" == "--cpu-core" ( set CPU=core)
if "%0" == "--cpu-core2" ( set CPU=core2)
if "%0" == "--cpu-penryn" ( set CPU=penryn)
if "%0" == "--cpu-nehalem" ( set CPU=nehalem)
if "%0" == "--cpu-atom" ( set CPU=atom)
if "%0" == "--cpu-netburst" ( set CPU=netburst)
if "%0" == "--cpu-netburstlahf" ( set CPU=netburstlahf)
if "%0" == "--cpu-pentium4" ( set CPU=pentium4)
if "%0" == "--cpu-prescott" ( set CPU=prescott)
if "%0" == "--cpu-k5" ( set CPU=k5)
if "%0" == "--cpu-k6" ( set CPU=k6)
if "%0" == "--cpu-k62" ( set CPU=k62)
if "%0" == "--cpu-k63" ( set CPU=k63)
if "%0" == "--cpu-k7" ( set CPU=k7)
if "%0" == "--cpu-k8" ( set CPU=k8)
if "%0" == "--cpu-k10" ( set CPU=k10)
if "%0" == "--cpu-viac3" ( set CPU=viac3)
if "%0" == "--cpu-viac32" ( set CPU=viac32)
goto :lp
:exitlp
if %BITS% == ? (
set BITS=64
if %PROCESSOR_ARCHITECTURE% == x86 (set BITS=32)
)
set ARCH=x86
set ARCHW=Win32
if %BITS% == 64 (
set ARCH=amd64
set ARCHW=x64
)
cl config.guess.c > nul 2>&1
if errorlevel 1 goto :nocc1
config.guess.exe print > config.guess.bat
call config.guess.bat
if %GBITS% == %BITS% goto :gotcc
:nocc1
if exist "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" (
call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" %ARCH%
)
cl config.guess.c > nul 2>&1
if errorlevel 1 goto :nocc
config.guess.exe print > config.guess.bat
call config.guess.bat
if %GBITS% == %BITS% goto :gotcc
:nocc
echo Cant find a compiler for %ARCH%
goto :EOF
:gotcc
set YASM="%VCINSTALLDIR%\bin\yasm.exe"
if not exist %YASM% (
echo Cant find %YASM%
echo Download from http://www.tortall.net/projects/yasm/ and install to above
goto :EOF
)
set YASMRULES="%VCINSTALLDIR%\VCProjectDefaults\yasm.rules"
if not exist %YASMRULES% (
echo Cant find %YASMRULES%
echo copy from this directory to above
goto :EOF
)
if %CPU% == ? ( set CPU=%GCPU%)
set BCPU=none
if %BITS% == 64 (
if %CPU% == x86_64 ( set BCPU=gc)
if %CPU% == core2 ( set BCPU=core2)
if %CPU% == penryn ( set BCPU=core2)
if %CPU% == nehalem ( set BCPU=core2)
if %CPU% == atom ( set BCPU=gc)
if %CPU% == netburst ( set BCPU=gc)
if %CPU% == netburstlahf ( set BCPU=gc)
if %CPU% == k8 ( set BCPU=amd64)
if %CPU% == k10 ( set BCPU=amd64)
)
if %BITS% == 32 (
if %CPU% == i486 ( set BCPU=gc)
if %CPU% == pentium ( set BCPU=p0)
if %CPU% == pentiummmx ( set BCPU=p0)
if %CPU% == pentiumpro ( set BCPU=p0)
if %CPU% == pentium2 ( set BCPU=p0)
if %CPU% == pentium3 ( set BCPU=p3)
if %CPU% == core ( set BCPU=p3)
if %CPU% == core2 ( set BCPU=p3)
if %CPU% == penryn ( set BCPU=p3)
if %CPU% == nehalem ( set BCPU=p3)
if %CPU% == atom ( set BCPU=p3)
if %CPU% == netburst ( set BCPU=p4)
if %CPU% == netburstlahf ( set BCPU=p4)
if %CPU% == pentium4 ( set BCPU=p4)
if %CPU% == prescott ( set BCPU=p4)
if %CPU% == k5 ( set BCPU=p0)
if %CPU% == k6 ( set BCPU=p0)
if %CPU% == k62 ( set BCPU=p0)
if %CPU% == k63 ( set BCPU=p0)
if %CPU% == k7 ( set BCPU=p3)
if %CPU% == k8 ( set BCPU=p3)
if %CPU% == k10 ( set BCPU=p3)
if %CPU% == viac3 ( set BCPU=p0)
if %CPU% == viac32 ( set BCPU=p0)
)
if %CPU% == none ( set BCPU=gc)
echo Detected %GCPU%
echo (set LIBTYPE=%LIBTYPE%) > config_params.bat
echo (set ARCHW=%ARCHW%) >> config_params.bat
echo (set BCPU=%BCPU%) >> config_params.bat
echo setting params to
type config_params.bat
:EOF

84
build.vc9/make.bat Normal file
View File

@ -0,0 +1,84 @@
@echo off
if not exist config_params.bat (
echo run configure first
goto :EOF
)
call config_params.bat
if "%1" == "" goto :make
if "%1" == "clean" goto :clean
if "%1" == "install" goto :install
if "%1" == "check" goto :check
if "%1" == "speed" goto :speed
if "%1" == "tune" goto :speed
if "%1" == "try" goto :try
if "%1" == "help" (
echo Usage : make [clean|install|check|speed|tune|try|help]
goto :EOF
)
echo Unkwown option
goto :EOF
:make
vcbuild gen-mpir\gen-mpir.vcproj "Release|Win32"
vcbuild gen-bases\gen-bases.vcproj "Release|Win32"
vcbuild gen-fac_ui\gen-fac_ui.vcproj "Release|Win32%"
vcbuild gen-fib\gen-fib.vcproj "Release|Win32"
vcbuild gen-psqr\gen-psqr.vcproj "Release|Win32"
set LIBBUILD=%LIBTYPE%_mpir_%BCPU%
vcbuild %LIBBUILD%\%LIBBUILD%.vcproj "Release|%ARCHW%"
:: c++ to build if static
if %LIBTYPE% == lib (
vcbuild lib_mpir_cpp\lib_mpir_cpp.vcproj "Release|%ARCHW%"
)
goto :EOF
:check
:: this gives an error if we dont build the c++ stuff
vcbuild mpir-tests.sln "Release|%ARCHW%"
::copy gmp-mparam.h %LIBTYPE%\%ARCHW%\Release\gmp-mparam.h
::vcbuild /override:mpir-tests\test-config.vsprops mpir-tests\add-test-lib.vcproj "Release|%ARCHW%"
::vcbuild mpir-tests\add-test-lib.vcproj "Release|%ARCHW%"
cd mpir-tests
python --version >nul 2>&1
if not errorlevel 1 goto :got
if exist c:\Python26 (
set PATH=%PATH%;c:\Python26
python --version >nul 2>&1
if not errorlevel 1 goto :got
)
if exist c:\Python30 (
set PATH=%PATH%;c:\Python30
python --version >nul 2>&1
if not errorlevel 1 goto :got
)
echo ERROR Could not find PYTHON
goto :EOF
:got
python run-tests.py
cd ..
goto :EOF
:install
goto :EOF
:speed
vcbuild speed.sln "Release|%ARCHW%"
echo tune.exe and speed.exe are in %ARCHW%\Release\
goto :EOF
:try
vcbuild try\try.vcproj "Release|%ARCHW%"
echo try.exe is in try\%ARCHW%\Release\
goto :EOF
:clean
del config_params.bat config.guess.bat config.guess.exe config.guess.obj last_build.txt
set LIBBUILD=%LIBTYPE%_mpir_%BCPU%
del /q/s gen-psqr\gen-psqr.exe gen-fac_ui\gen-fac_ui.exe gen-bases\gen-bases.exe
del /q/s gen-fib\gen-fib.exe gen-mpir\gen-mpir.exe gen-mpir\gen-mpir.pdb
rmdir /s/q x64 win32 %LIBBUILD%\%ARCHW% lib_mpir_cpp\%ARCHW% lib\%ARCHW% dll\%ARCHW% mpir-tests\%ARCHW%
rmdir /s/q gen-psqr\%ARCHW% gen-fac_ui\%ARCHW% gen-bases\%ARCHW% gen-fib\%ARCHW% gen-mpir\%ARCHW%
rmdir /s/q lib_speed\%ARCHW% speed\%ARCHW% tune\%ARCHW% try\%ARCHW%
goto :EOF
:EOF

View File

@ -12,7 +12,7 @@
char vendor_string[13];
char features[12];
long fms;
int family, model, stepping;
int family, model, stepping,feat;
char *modelstr;
__gmpn_cpuid (vendor_string, 0);
@ -58,11 +58,11 @@
#if CONFIG_GUESS_64BIT || FAT64
__gmpn_cpuid(features,0x80000001);
if ( features[8]&1 ){ CPUIS(netburstlahf);break;}
CPUIS(netburst);
CPUIS(netburst);break;
#endif
#if CONFIG_GUESS_32BIT || FAT32
if (model <= 6) { CPUIS(pentium4);break;}
int feat = ((int *)features)[2];
feat = ((int *)features)[2];
if (feat & 1) { CPUIS(prescott);break;}
#endif
break;