drop the need for testprof/makefile*

This commit is contained in:
Karel Miko 2017-05-02 20:47:00 +02:00 committed by Steffen Jaeckel
parent 2c97498554
commit bf45ea66e5
8 changed files with 189 additions and 145 deletions

View File

@ -201,24 +201,27 @@ sub prepare_msvc_files_xml {
}
sub patch_makefile {
my ($in_ref, $out_ref, $data) = @_;
open(my $src, '<', $in_ref);
open(my $dst, '>', $out_ref);
my $l = 0;
while (<$src>) {
if ($_ =~ /START_INS/) {
print {$dst} $_;
$l = 1;
print {$dst} $data;
} elsif ($_ =~ /END_INS/) {
print {$dst} $_;
$l = 0;
} elsif ($l == 0) {
print {$dst} $_;
my ($content, @variables) = @_;
for my $v (@variables) {
if ($v =~ /^([A-Z0-9_]+)\s*=.*$/si) {
my $name = $1;
$content =~ s/\n\Q$name\E\b.*?[^\\]\n/\n$v\n/s;
}
else {
die "patch_makefile failed: " . substr($v, 0, 30) . "..";
}
}
close $dst;
close $src;
return $content;
}
sub version_form_tomcrypt_h {
my $h = read_file(shift);
if ($h =~ /\n#define\s*SCRYPT\s*"([0-9]+)\.([0-9]+)"/s) {
return "VERSION_MAJ=$1", "VERSION_MIN=$2", "VERSION=$1.$2", "VERSION_LT=0:$1$2";
}
else {
die "#define SCRYPT not found in tomcrypt.h";
}
}
sub process_makefiles {
@ -230,12 +233,20 @@ sub process_makefiles {
find({ no_chdir => 1, wanted => sub { push @h, $_ if -f $_ && $_ =~ /\.h$/ && $_ !~ /dh_static.h$/ } }, 'src');
my @all = ();
find({ no_chdir => 1, wanted => sub { push @all, $_ if -f $_ && $_ =~ /\.(c|h)$/ } }, 'src');
my @t = qw();
find({ no_chdir => 1, wanted => sub { push @t, $_ if $_ =~ /(no_prng|test_driver|x86_prof|_tests?).c$/ } }, 'testprof');
my @o = sort ('src/ciphers/aes/aes_enc.o', map { $_ =~ s/\.c$/.o/; $_ } @c);
my $var_o = prepare_variable("OBJECTS", @o);
my $var_o = prepare_variable("OBJECTS", @o);
my $var_h = prepare_variable("HEADERS", (sort @h));
(my $var_obj = $var_o) =~ s/\.o\b/.obj/sg;
my $var_h = prepare_variable("HEADERS", (sort @h, 'testprof/tomcrypt_test.h'));
my $var_to = prepare_variable("TOBJECTS", sort map { $_ =~ s/\.c$/.o/; $_ } @t);
(my $var_tobj = $var_to) =~ s/\.o\b/.obj/sg;
my @ver_version = version_form_tomcrypt_h("src/headers/tomcrypt.h");
# update MSVC project files
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);
@ -248,22 +259,18 @@ sub process_makefiles {
}
}
my @makefiles = qw( makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc );
for my $m (@makefiles) {
# update OBJECTS + HEADERS in makefile*
for my $m (qw/ makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) {
my $old = read_file($m);
my $new;
if ($m eq 'makefile.msvc') {
patch_makefile(\$old, \$new, "$var_obj\n\n$var_h\n\n");
}
else {
patch_makefile(\$old, \$new, "$var_o\n\n$var_h\n\n");
}
my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_to, @ver_version)
: patch_makefile($old, $var_o, $var_h, $var_to, @ver_version);
if ($old ne $new) {
write_file($m, $new) if $write;
warn "changed: $m\n";
$changed_count++;
}
}
if ($write) {
return 0; # no failures
}
@ -283,13 +290,13 @@ sub die_usage {
MARKER
}
GetOptions( "check-source" => \my $check_source,
"check-defines" => \my $check_defines,
"check-hashes" => \my $check_hashes,
"check-makefiles" => \my $check_makefiles,
"check-all" => \my $check_all,
"update-makefiles" => \my $update_makefiles,
"help" => \my $help
GetOptions( "s|check-source" => \my $check_source,
"d|check-defines" => \my $check_defines,
"h|check-hashes" => \my $check_hashes,
"m|check-makefiles" => \my $check_makefiles,
"a|check-all" => \my $check_all,
"u|update-makefiles" => \my $update_makefiles,
"h|help" => \my $help
) or die_usage;
my $failure;

View File

@ -1,10 +1,10 @@
prefix=/usr
prefix=@to-be-replaced@
exec_prefix=${prefix}
libdir=@LIBDIR@
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: LibTomCrypt
Description: public domain open source cryptographic toolkit
Version: 1.17
Version: @to-be-replaced@
Libs: -L${libdir} -ltomcrypt
Cflags: -I${includedir}

View File

@ -35,10 +35,8 @@ endif
ifndef LIBTEST
LIBTEST=libtomcrypt_prof.a
endif
LIBTEST_S=$(LIBTEST)
#List of objects to compile.
#START_INS
# List of objects to compile (all goes to libtomcrypt.a)
OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \
src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \
src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \
@ -190,13 +188,20 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream
src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
src/stream/sober128/sober128_test.o
# List of test objects to compile (all goes to libtomcrypt_prof.a)
TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \
testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \
testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \
testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \
testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \
testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o
# The following headers will be installed by "make install"
HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h
#END_INS
src/headers/tomcrypt_prng.h
#Files left over from making the crypt.pdf.
LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out *.lof
@ -223,7 +228,9 @@ src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
#This rule makes the libtomcrypt library.
library: $(LIBNAME)
#Dependencies on *.h
$(OBJECTS): $(HEADERS)
$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h
$(LIBNAME): $(OBJECTS)
ifneq ($V,1)
@ -235,22 +242,27 @@ ifneq ($V,1)
endif
${silent} $(RANLIB) $@
.PHONY: testprof/$(LIBTEST)
testprof/$(LIBTEST):
${silent} CFLAGS="$(CFLAGS)" LIBTEST_S=$(LIBTEST_S) CC="$(CC)" LD="$(LD)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" RANLIB="$(RANLIB)" V="$(V)" $(MAKE) -C testprof
$(LIBTEST): $(TOBJECTS)
ifneq ($V,1)
@echo " * ${AR} $@"
endif
${silent} $(AR) $(ARFLAGS) $@ $(TOBJECTS)
ifneq ($V,1)
@echo " * ${RANLIB} $@"
endif
${silent} $(RANLIB) $@
timing: library testprof/$(LIBTEST) $(TIMINGS)
timing: library $(LIBTEST) $(TIMINGS)
ifneq ($V,1)
@echo " * ${CC} $@"
endif
${silent} $(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TIMING)
${silent} $(CC) $(LDFLAGS) $(TIMINGS) $(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TIMING)
.PHONY: test
test: library testprof/$(LIBTEST) $(TESTS)
test: library $(LIBTEST) $(TESTS)
ifneq ($V,1)
@echo " * ${CC} $@"
endif
${silent} $(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TEST)
${silent} $(CC) $(LDFLAGS) $(TESTS) $(LIBTEST) $(LIB_PRE) $(LIBNAME) $(LIB_POST) $(EXTRALIBS) -o $(TEST)
# build the demos from a template
define DEMO_template
@ -277,19 +289,20 @@ install: library docs
else
install: library
endif
install -d $(DESTDIR)$(LIBPATH)
install -d $(DESTDIR)$(INCPATH)
install -d $(DESTDIR)$(DATAPATH)
install -m 644 $(LIBNAME) $(DESTDIR)$(LIBPATH)
install -m 644 $(HEADERS) $(DESTDIR)$(INCPATH)
install -d $(LIBPATH)
install -d $(INCPATH)
install -d $(DATAPATH)
install -m 644 $(LIBNAME) $(LIBPATH)
install -m 644 $(HEADERS) $(INCPATH)
ifndef NODOCS
install -m 644 doc/crypt.pdf $(DESTDIR)$(DATAPATH)
install -m 644 doc/crypt.pdf $(DATAPATH)
endif
install_test: testprof/$(LIBTEST)
install -d $(DESTDIR)$(LIBPATH)
install -d $(DESTDIR)$(INCPATH)
install -m 644 testprof/$(LIBTEST) $(DESTDIR)$(LIBPATH)
install_test: $(LIBTEST)
install -d $(LIBPATH)
install -d $(INCPATH)
install -m 644 $(LIBTEST) $(LIBPATH)
install -m 644 testprof/tomcrypt_test.h $(INCPATH)
install_hooks:
for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done
@ -342,6 +355,8 @@ clean:
rm -f `find . -type f -name "*.obj" | xargs`
rm -f `find . -type f -name "*.lib" | xargs`
rm -f `find . -type f -name "*.exe" | xargs`
rm -f `find . -type f -name "*.dll" | xargs`
rm -f `find . -type f -name "*.so" | xargs`
rm -f `find . -type f -name "*.gcov" | xargs`
rm -f `find . -type f -name "*.gcda" | xargs`
rm -f `find . -type f -name "*.gcno" | xargs`

View File

@ -70,7 +70,6 @@ ifndef LIBNAME
endif
ifndef LIBTEST
LIBTEST=libtomcrypt_prof.a
LIBTEST_S=$(LIBTEST)
endif
HASH=hashsum
CRYPT=encrypt
@ -96,8 +95,7 @@ ifndef DATAPATH
DATAPATH=/usr/share/doc/libtomcrypt/pdf
endif
#List of objects to compile.
#START_INS
# List of objects to compile (all goes to libtomcrypt.a)
OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \
src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \
src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \
@ -249,13 +247,20 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream
src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
src/stream/sober128/sober128_test.o
# List of test objects to compile (all goes to libtomcrypt_prof.a)
TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \
testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \
testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \
testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \
testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \
testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o
# The following headers will be installed by "make install"
HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h
#END_INS
src/headers/tomcrypt_prng.h
#Who do we install as?
ifdef INSTALL_USER
@ -297,9 +302,13 @@ src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
#This rule makes the libtomcrypt library.
library: $(LIBNAME)
.PHONY: testprof/$(LIBTEST)
testprof/$(LIBTEST):
cd testprof ; LIBTEST_S=$(LIBTEST) CFLAGS="$(CFLAGS)" CC="$(CC)" AR="$(AR)" $(MAKE) -f makefile.icc
#Dependencies on *.h
$(OBJECTS): $(HEADERS)
$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h
$(LIBTEST): $(TOBJECTS)
$(AR) $(ARFLAGS) $@ $(TOBJECTS)
$(RANLIB) $@
$(LIBNAME): $(OBJECTS)
$(AR) $(ARFLAGS) $@ $(OBJECTS)
@ -320,12 +329,11 @@ small: library $(SMALLOBJECTS)
tv_gen: library $(TVS)
$(CC) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
timing: library $(TIMINGS) testprof/$(LIBTEST)
$(CC) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
timing: library $(TIMINGS) $(LIBTEST)
$(CC) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
.PHONY: test
test: library $(TESTS) testprof/$(LIBTEST)
$(CC) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
test: library $(TESTS) $(LIBTEST)
$(CC) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
all_test: test tv_gen hashsum crypt small timing
@ -333,11 +341,11 @@ all_test: test tv_gen hashsum crypt small timing
#as root in order to have a high enough permission to write to the correct
#directories and to set the owner and group to root.
install: library
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH)
install -g $(GROUP) -o $(USER) $(LIBTEST) $(DESTDIR)$(LIBPATH)
install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH)
install -d -g $(GROUP) -o $(USER) $(LIBPATH)
install -d -g $(GROUP) -o $(USER) $(INCPATH)
install -g $(GROUP) -o $(USER) $(LIBNAME) $(LIBPATH)
install -g $(GROUP) -o $(USER) $(LIBTEST) $(LIBPATH)
install -g $(GROUP) -o $(USER) $(HEADERS) $(INCPATH)
# $Source$
# $Revision$

View File

@ -98,22 +98,13 @@ DEMOS=hashsum crypt small tv_gen sizes constants
TIMINGS=demos/timing.o
TESTS=demos/test.o
#LIBPATH-The directory for libtomcrypt to be installed to.
#INCPATH-The directory to install the header files for libtomcrypt.
#DATAPATH-The directory to install the pdf docs.
ifndef DESTDIR
DESTDIR=
endif
ifndef LIBPATH
LIBPATH=/usr/lib
endif
ifndef INCPATH
INCPATH=/usr/include
endif
ifndef DATAPATH
DATAPATH=/usr/share/doc/libtomcrypt/pdf
endif
#LIBPATH The directory for libtomcrypt to be installed to.
#INCPATH The directory to install the header files for libtomcrypt.
#DATAPATH The directory to install the pdf docs.
DESTDIR ?= /usr/local
LIBPATH ?= $(DESTDIR)/lib
INCPATH ?= $(DESTDIR)/include
DATAPATH ?= $(DESTDIR)/share/doc/libtomcrypt/pdf
#Who do we install as?
ifdef INSTALL_USER

View File

@ -32,8 +32,7 @@ INSTPREFIX=c:\devel-libtom
LIBPATH=$(INSTPREFIX)\lib
INCPATH=$(INSTPREFIX)\include
#List of objects to compile.
#START_INS
# List of objects to compile (all goes to libtomcrypt.a)
OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \
src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \
src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \
@ -185,13 +184,20 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream
src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
src/stream/sober128/sober128_test.o
# List of test objects to compile (all goes to libtomcrypt_prof.a)
TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \
testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \
testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \
testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \
testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \
testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o
# The following headers will be installed by "make install"
HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h
#END_INS
src/headers/tomcrypt_prng.h
TESTOBJECTS=demos/test.o
HASHOBJECTS=demos/hashsum.o
@ -220,9 +226,13 @@ src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
#This rule makes the libtomcrypt library.
library: $(LIBNAME)
.PHONY: testprof/$(LIBTEST)
testprof/$(LIBTEST):
$(MAKE) -C testprof -f makefile.mingw LIBTEST_S=$(LIBTEST) CC=$(CC) LD=$(LD) AR=$(AR) ARFLAGS=$(ARFLAGS) RANLIB=$(RANLIB)
#Dependencies on *.h
$(OBJECTS): $(HEADERS)
$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h
$(LIBTEST): $(TOBJECTS)
$(AR) $(ARFLAGS) $@ $(TOBJECTS)
$(RANLIB) $@
%.o: %.c
${CC} ${CFLAGS} -c $< -o $@
@ -246,24 +256,24 @@ small: library $(SMALLOBJECTS)
tv_gen: library $(TVS)
$(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
timing: library testprof/$(LIBTEST) $(TIMINGS)
$(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
timing: library $(LIBTEST) $(TIMINGS)
$(CC) $(LDFLAGS) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
.PHONY: test
test: library testprof/$(LIBTEST) $(TESTS)
$(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
test: library $(LIBTEST) $(TESTS)
$(CC) $(LDFLAGS) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
all_test: test tv_gen hashsum crypt small timing
install: library
cmd /c if not exist "$(DESTDIR)$(LIBPATH)" mkdir "$(DESTDIR)$(LIBPATH)"
cmd /c if not exist "$(DESTDIR)$(INCPATH)" mkdir "$(DESTDIR)$(INCPATH)"
copy /Y $(LIBNAME) "$(DESTDIR)$(LIBPATH)"
copy /Y src\headers\tomcrypt*.h "$(DESTDIR)$(INCPATH)"
cmd /c if not exist "$(LIBPATH)" mkdir "$(LIBPATH)"
cmd /c if not exist "$(INCPATH)" mkdir "$(INCPATH)"
copy /Y $(LIBNAME) "$(LIBPATH)"
copy /Y src\headers\tomcrypt*.h "$(INCPATH)"
install_test: testprof/$(LIBTEST)
cmd /c if not exist "$(DESTDIR)$(LIBPATH)" mkdir "$(DESTDIR)$(LIBPATH)"
copy /Y testprof\$(LIBTEST) "$(DESTDIR)$(LIBPATH)"
install_test: $(LIBTEST)
cmd /c if not exist "$(LIBPATH)" mkdir "$(LIBPATH)"
copy /Y testprof\$(LIBTEST) "$(LIBPATH)"
clean:
cmd /c del /Q /S *.o *.a *.exe

View File

@ -8,7 +8,7 @@ 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
# List of objects to compile (all goes to libtomcrypt.lib)
OBJECTS=src/ciphers/aes/aes.obj src/ciphers/aes/aes_enc.obj src/ciphers/anubis.obj src/ciphers/blowfish.obj \
src/ciphers/camellia.obj src/ciphers/cast5.obj src/ciphers/des.obj src/ciphers/kasumi.obj src/ciphers/khazad.obj \
src/ciphers/kseed.obj src/ciphers/multi2.obj src/ciphers/noekeon.obj src/ciphers/rc2.obj src/ciphers/rc5.obj \
@ -160,13 +160,20 @@ src/stream/chacha/chacha_keystream.obj src/stream/chacha/chacha_setup.obj src/st
src/stream/rc4/rc4.obj src/stream/rc4/rc4_test.obj src/stream/sober128/sober128.obj \
src/stream/sober128/sober128_test.obj
# List of test objects to compile (all goes to libtomcrypt_prof.lib)
TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \
testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \
testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \
testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \
testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \
testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o
# The following headers will be installed by "make install"
HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h
#END_INS
src/headers/tomcrypt_prng.h
default: library
@ -177,11 +184,9 @@ default: library
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
library: $(OBJECTS)
library: $(OBJECTS) $(TOBJECTS)
lib /out:tomcrypt.lib $(OBJECTS)
cd testprof
nmake -f makefile.msvc
cd ..
lib /out:tomcrypt_prof.lib $(TOBJECTS)
tv_gen: demos/tv_gen.c library
cl $(CFLAGS) demos/tv_gen.c tomcrypt.lib advapi32.lib $(EXTRALIBS)
@ -189,12 +194,11 @@ tv_gen: demos/tv_gen.c library
hashsum: demos/hashsum.c library
cl $(CFLAGS) demos/hashsum.c tomcrypt.lib advapi32.lib $(EXTRALIBS)
.PHONY: test
test: demos/test.c library
cl $(CFLAGS) demos/test.c testprof/tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS)
cl $(CFLAGS) demos/test.c tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS)
timing: demos/timing.c library
cl $(CFLAGS) demos/timing.c testprof/tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS)
cl $(CFLAGS) demos/timing.c tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS)
all_test: test tv_gen hashsum timing

View File

@ -185,11 +185,20 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream
src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
src/stream/sober128/sober128_test.o
# List of test objects to compile (all goes to libtomcrypt_prof.a)
TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \
testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \
testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \
testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test.o \
testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \
testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o
# The following headers will be installed by "make install"
HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h
src/headers/tomcrypt_prng.h
#END_INS
@ -198,7 +207,7 @@ default:library
#ciphers come in two flavours... enc+dec and enc
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
$(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
$(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
#These are the rules to make certain object files.
src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
@ -212,39 +221,39 @@ src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
#This rule makes the libtomcrypt library.
library: $(LIBNAME)
.PHONY: testprof/$(LIBTEST)
testprof/$(LIBTEST):
cd testprof ; CFLAGS="$(CFLAGS)" GROUP=$(GROUP) USER=$(USER) VERSION=$(VERSION_LT) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) LT=$(LT) CC="$(CC)" make -f makefile.shared
#Dependencies on *.h
$(OBJECTS): $(HEADERS)
$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h
.c.o:
$(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -c $<
$(LIBNAME): $(OBJECTS)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./src -type f -name "*.lo"` $(EXTRALIBS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_LT)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./src -type f -name "*.lo"` $(EXTRALIBS) -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT)
$(LIBTEST): $(TOBJECTS)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./testprof -type f -name "*.lo"` -o $@ -rpath $(LIBPATH) -version-info $(VERSION_LT)
install: $(LIBNAME)
install -d $(DESTDIR)$(LIBPATH)
$(LT) --mode=install install -c libtomcrypt.la $(DESTDIR)$(LIBPATH)/libtomcrypt.la
install -d $(DESTDIR)$(INCPATH)
install -m 644 $(HEADERS) $(DESTDIR)$(INCPATH)
install -d $(DESTDIR)$(LIBPATH)/pkgconfig
sed 's,@LIBDIR@,$(LIBPATH),g' libtomcrypt.pc.in > libtomcrypt.pc
install -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
install -d $(LIBPATH)/pkgconfig
install -d $(INCPATH)
$(LT) --mode=install install -c $(LIBNAME) $(LIBPATH)/$(LIBNAME)
install -m 644 $(HEADERS) $(INCPATH)
sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(LIBPATH)/pkgconfig/libtomcrypt.pc
install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/libtomcrypt.pc
install_test: testprof/$(LIBTEST)
install -d $(DESTDIR)$(LIBPATH)
install -d $(DESTDIR)$(INCPATH)
cd testprof ; CFLAGS="$(CFLAGS)" VERSION=$(VERSION_LT) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) DESTDIR=$(DESTDIR) LT=$(LT) CC=$(CC) make -f makefile.shared install
install -d $(LIBPATH)
install -d $(INCPATH)
install -m 644 testprof/tomcrypt_test.h $(INCPATH)
$(LT) --mode=install install -c $(LIBTEST) $(LIBPATH)/$(LIBTEST)
.PHONY: test
test: library testprof/$(LIBTEST) $(TESTS)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS)
timing: library testprof/$(LIBTEST) $(TIMINGS)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS)
# build the demos from a template
define DEMO_template
$(1): demos/$(1).o library