improving MS Windows builds (msvc)

This commit is contained in:
Karel Miko 2017-03-14 23:09:14 +01:00
parent 783cbc7917
commit 7bb7bdde1d
12 changed files with 325 additions and 1709 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@
*.l[oa]
[Dd]ebug/
[Rr]elease/
/MSVC_*
.libs/
# suppress output of build process

View File

@ -217,8 +217,8 @@ sub process_makefiles {
(my $var_obj = $var_o) =~ s/\.o\b/.obj/sg;
my $var_h = prepare_variable("HEADERS", (sort @h, 'testprof/tomcrypt_test.h'));
my $msvc_files = prepare_msvc_files_xml(\@all, qr/tab\.c$/, ['Debug|Win32', 'Release|Win32']);
for my $m (qw/libtomcrypt_VS2008.vcproj libtomcrypt_VS2005.vcproj/) {
my $msvc_files = prepare_msvc_files_xml(\@all, qr/tab\.c$/, ['Debug|Win32', 'Release|Win32', 'Debug|x64', 'Release|x64']);
for my $m (qw/libtomcrypt_VS2008.vcproj/) {
my $old = read_file($m);
my $new = $old;
$new =~ s|<Files>.*</Files>|$msvc_files|s;

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtomcrypt", "libtomcrypt_VS2005.vcproj", "{3EBCE29D-8BCC-4DDC-BEA3-60A0081579BB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3EBCE29D-8BCC-4DDC-BEA3-60A0081579BB}.Debug|Win32.ActiveCfg = Debug|Win32
{3EBCE29D-8BCC-4DDC-BEA3-60A0081579BB}.Debug|Win32.Build.0 = Debug|Win32
{3EBCE29D-8BCC-4DDC-BEA3-60A0081579BB}.Release|Win32.ActiveCfg = Release|Win32
{3EBCE29D-8BCC-4DDC-BEA3-60A0081579BB}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -6,13 +6,19 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E3802982-DCB6-4D85-A2BD-6B08F0657E79}.Debug|Win32.ActiveCfg = Debug|Win32
{E3802982-DCB6-4D85-A2BD-6B08F0657E79}.Debug|Win32.Build.0 = Debug|Win32
{E3802982-DCB6-4D85-A2BD-6B08F0657E79}.Debug|x64.ActiveCfg = Debug|x64
{E3802982-DCB6-4D85-A2BD-6B08F0657E79}.Debug|x64.Build.0 = Debug|x64
{E3802982-DCB6-4D85-A2BD-6B08F0657E79}.Release|Win32.ActiveCfg = Release|Win32
{E3802982-DCB6-4D85-A2BD-6B08F0657E79}.Release|Win32.Build.0 = Release|Win32
{E3802982-DCB6-4D85-A2BD-6B08F0657E79}.Release|x64.ActiveCfg = Release|x64
{E3802982-DCB6-4D85-A2BD-6B08F0657E79}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -11,19 +11,21 @@
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
OutputDirectory="MSVC_$(PlatformName)_$(ConfigurationName)"
IntermediateDirectory="MSVC_$(PlatformName)_$(ConfigurationName)\Intermediate"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
@ -44,17 +46,19 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="src\headers,..\libtommath"
PreprocessorDefinitions="_DEBUG;LTM_DESC;WIN32;_LIB;LTC_SOURCE;USE_LTM"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/libtomcrypt.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
PrecompiledHeaderFile="$(IntDir)\libtomcrypt.pch"
AssemblerListingLocation="$(IntDir)\"
ObjectFile="$(IntDir)\"
ProgramDataBaseFileName="$(IntDir)\"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -69,7 +73,7 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile="Debug\tomcrypt.lib"
OutputFile="$(OutDir)\tomcryptd.lib"
SuppressStartupBanner="true"
/>
<Tool
@ -92,13 +96,12 @@
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
OutputDirectory="MSVC_$(PlatformName)_$(ConfigurationName)"
IntermediateDirectory="MSVC_$(PlatformName)_$(ConfigurationName)\Intermediate"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
@ -120,16 +123,18 @@
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="src\headers,..\libtommath"
PreprocessorDefinitions="NDEBUG;LTM_DESC;WIN32;_LIB;LTC_SOURCE;USE_LTM;;LTC_NO_TEST"
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
StringPooling="true"
ExceptionHandling="0"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/libtomcrypt.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
PrecompiledHeaderFile="$(IntDir)\libtomcrypt.pch"
AssemblerListingLocation="$(IntDir)\"
ObjectFile="$(IntDir)\"
ProgramDataBaseFileName="$(IntDir)\"
WarningLevel="3"
SuppressStartupBanner="true"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -144,7 +149,161 @@
/>
<Tool
Name="VCLibrarianTool"
OutputFile="Release\tomcrypt.lib"
OutputFile="$(OutDir)\tomcrypt.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/libtomcrypt.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="MSVC_$(PlatformName)_$(ConfigurationName)"
IntermediateDirectory="MSVC_$(PlatformName)_$(ConfigurationName)\Intermediate"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="src\headers,..\libtommath"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile="$(IntDir)\libtomcrypt.pch"
AssemblerListingLocation="$(IntDir)\"
ObjectFile="$(IntDir)\"
ProgramDataBaseFileName="$(IntDir)\"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\tomcryptd.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/libtomcrypt.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="MSVC_$(PlatformName)_$(ConfigurationName)"
IntermediateDirectory="MSVC_$(PlatformName)_$(ConfigurationName)\Intermediate"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="src\headers,..\libtommath"
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;LTM_DESC;LTC_SOURCE;LTC_NO_TEST;LTC_NO_PROTOTYPES"
StringPooling="true"
ExceptionHandling="0"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile="$(IntDir)\libtomcrypt.pch"
AssemblerListingLocation="$(IntDir)\"
ObjectFile="$(IntDir)\"
ProgramDataBaseFileName="$(IntDir)\"
WarningLevel="3"
SuppressStartupBanner="true"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)\tomcrypt.lib"
SuppressStartupBanner="true"
/>
<Tool
@ -262,6 +421,26 @@
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
<Filter
@ -294,6 +473,26 @@
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\ciphers\safer\saferp.c"
@ -330,6 +529,26 @@
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
</Filter>
@ -686,6 +905,26 @@
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
</Filter>
@ -1979,6 +2218,26 @@
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\prngs\sprng.c"

View File

@ -1,20 +1,12 @@
# MAKEFILE for use with MS Windows gcc compiler + GNU make (aka mingw32-make)
#
# open a command prompt with gcc + gmake in PATH
# and start: gmake -f makefile.mingw
#
### should work with the following native compilers (not cross-compilers)
# 32bit gcc compiler by mingw.org
# 32bit gcc compiler by mingw-w64.sf.net
# 64bit gcc compiler by mingw-w64.sf.net
EXTRALIBS=../libtommath/libtommath.a
EXTRAINCLUDE=../libtommath
### build instruction (32bit)
# gmake -f makefile.mingw CFLAGS_OPTS="-DUSE_LTM -DLTM_DESC -Iz:\dev_libtom\include"
# gmake -f makefile.mingw CFLAGS_OPTS="-DUSE_LTM -DLTM_DESC -Iz:\dev_libtom\include" INSTPREFIX=z:\dev_libtom install
# gmake -f makefile.mingw CFLAGS_OPTS="-DUSE_LTM -DLTM_DESC -Iz:\dev_libtom\include" EXTRALIBS="-Lz:\dev_libtom\lib -ltommath" test small tv_gen multi timing
# gmake -f makefile.mingw CFLAGS_OPTS="-DUSE_LTM -DLTM_DESC -Iz:\dev_libtom\include" INSTPREFIX=z:\dev_libtom install_test
# gmake -f makefile.mingw clean
### build instruction (64bit)
# nearly the same as 32bit build
# just use: CFLAGS_OPTS="-DUSE_LTM -DLTM_DESC -DLTC_NO_ASM -Iz:\dev_libtom\include"
CFLAGS = -Wall -Wextra -c -I./src/headers -I$(EXTRAINCLUDE) -I./testprof -DUSE_LTM -DLTM_DESC -DLTC_SOURCE -DLTC_NO_PROTOTYPES -O2 ${CFLAGS_OPTS}
# Compiler and Linker Names
CC=gcc
@ -23,9 +15,6 @@ AR=ar
ARFLAGS=rc
RANLIB=ranlib
# Compilation flags. Note the += does not write over the user's CFLAGS!
CFLAGS = -c -I./testprof/ -I./src/headers/ -DLTC_SOURCE -O2 ${CFLAGS_OPTS} -o $@
LIBNAME=libtomcrypt.a
LIBTEST=libtomcrypt_prof.a
@ -214,7 +203,10 @@ library: $(LIBNAME)
.PHONY: testprof/$(LIBTEST)
testprof/$(LIBTEST):
$(MAKE) -C testprof -f makefile.mingw CFLAGS_OPTS="$(CFLAGS)" LIBTEST_S=$(LIBTEST) CC="$(CC)" LD=$(LD) AR=$(AR) ARFLAGS="$(ARFLAGS)" RANLIB=$(RANLIB)
$(MAKE) -C testprof -f makefile.mingw LIBTEST_S=$(LIBTEST) CC=$(CC) LD=$(LD) AR=$(AR) ARFLAGS=$(ARFLAGS) RANLIB=$(RANLIB)
%.o: %.c
${CC} ${CFLAGS} -c $< -o $@
$(LIBNAME): $(OBJECTS)
$(AR) $(ARFLAGS) $@ $(OBJECTS)

View File

@ -1,7 +1,12 @@
#MSVC Makefile [tested with MSVC 6.00 with SP5]
#
#Tom St Denis
CFLAGS = /Isrc/headers/ /Itestprof/ /Ox /DWIN32 /DLTC_SOURCE /W3 /Fo$@ $(CF)
# open a command prompt with WinSDK variables set
# and start: nmake -f makefile.msvc
#
EXTRALIBS=../libtommath/tommath.lib
EXTRAINCLUDE=../libtommath
CFLAGS = /nologo /Isrc/headers/ /I$(EXTRAINCLUDE) /Itestprof/ /Ox /D_CRT_SECURE_NO_WARNINGS /DUSE_LTM /DLTM_DESC /DLTC_SOURCE /DLTC_NO_PROTOTYPES /W3 $(CF)
#START_INS
OBJECTS=src/ciphers/aes/aes.obj src/ciphers/aes/aes_enc.obj src/ciphers/anubis.obj src/ciphers/blowfish.obj \
@ -144,6 +149,9 @@ src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h
default: library
.c.obj:
$(CC) $(CFLAGS) /c $< /Fo$@
#ciphers come in two flavours... enc+dec and enc
src/ciphers/aes/aes_enc.obj: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
$(CC) $(CFLAGS) /DENCRYPT_ONLY /c src/ciphers/aes/aes.c /Fosrc/ciphers/aes/aes_enc.obj
@ -169,6 +177,9 @@ timing: demos/timing.c library
all_test: test tv_gen hashsum timing
clean:
cmd /c del /Q /S *.OBJ *.LIB *.EXE
# $Source$
# $Revision$
# $Date$

View File

@ -188,7 +188,7 @@ int crypt_list_all_constants(char *names_list, unsigned int *names_list_size) {
/* calculate amount of memory required for the list */
for (i=0; i<count; i++) {
total_len += strlen(_crypt_constants[i].name) + 1;
total_len += (unsigned int)strlen(_crypt_constants[i].name) + 1;
/* the above +1 is for the commas */
number_len = snprintf(number, sizeof(number), "%d", _crypt_constants[i].value);
if ((number_len < 0) ||

View File

@ -275,13 +275,13 @@ int crypt_list_all_sizes(char *names_list, unsigned int *names_list_size) {
/* calculate amount of memory required for the list */
for (i=0; i<count; i++) {
total_len += strlen(_crypt_sizes[i].name) + 1;
total_len += (unsigned int)strlen(_crypt_sizes[i].name) + 1;
/* the above +1 is for the commas */
number_len = snprintf(number, sizeof(number), "%u", _crypt_sizes[i].size);
if ((number_len < 0) ||
((unsigned int)number_len >= sizeof(number)))
return -1;
total_len += strlen(number) + 1;
total_len += (unsigned int)strlen(number) + 1;
/* this last +1 is for newlines (and ending NULL) */
}

View File

@ -2,7 +2,7 @@
# BEWARE: do not run make from testprof directory, run 'gmake ... test' from libtomcrypt root dir
CFLAGS = $(CFLAGS_OPTS) -W -I../src/headers -I. -Wall -W
CFLAGS = $(CFLAGS_OPTS) -I../src/headers -I../../libtommath -I. -Wall -Wextra -DUSE_LTM -DLTM_DESC
OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o \
dsa_test.o ecc_test.o mac_test.o misc_test.o modes_test.o pkcs_1_test.o rsa_test.o \
@ -11,6 +11,9 @@ pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o
default: $(LIBTEST_S)
%.o: %.c
${CC} ${CFLAGS} -c $< -o $@
$(LIBTEST_S): $(OBJECTS)
$(AR) $(ARFLAGS) $@ $(OBJECTS)
$(RANLIB) $@

View File

@ -1,4 +1,4 @@
CFLAGS = /I../src/headers/ /I./ /Ox /DWIN32 /DLTC_SOURCE /W3 /Fo$@
CFLAGS = /I../src/headers/ /I./ /Ox /DWIN32 /DLTC_SOURCE /DUSE_LTM /W3
OBJECTS=base64_test.obj cipher_hash_test.obj der_tests.obj no_prng.obj \
dsa_test.obj ecc_test.obj mac_test.obj modes_test.obj pkcs_1_test.obj \
@ -6,6 +6,9 @@ rsa_test.obj store_test.obj rotate_test.obj test_driver.obj x86_prof.obj katja_t
dh_test.obj misc_test.obj pkcs_1_pss_test.obj pkcs_1_oaep_test.obj \
pkcs_1_emsa_test.obj pkcs_1_eme_test.obj
.c.obj:
$(CC) $(CFLAGS) /c $< /Fo$@
tomcrypt_prof.lib: $(OBJECTS)
lib /out:tomcrypt_prof.lib $(OBJECTS)