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 { sub patch_makefile {
my ($in_ref, $out_ref, $data) = @_; my ($content, @variables) = @_;
open(my $src, '<', $in_ref); for my $v (@variables) {
open(my $dst, '>', $out_ref); if ($v =~ /^([A-Z0-9_]+)\s*=.*$/si) {
my $l = 0; my $name = $1;
while (<$src>) { $content =~ s/\n\Q$name\E\b.*?[^\\]\n/\n$v\n/s;
if ($_ =~ /START_INS/) { }
print {$dst} $_; else {
$l = 1; die "patch_makefile failed: " . substr($v, 0, 30) . "..";
print {$dst} $data;
} elsif ($_ =~ /END_INS/) {
print {$dst} $_;
$l = 0;
} elsif ($l == 0) {
print {$dst} $_;
} }
} }
close $dst; return $content;
close $src; }
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 { 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'); find({ no_chdir => 1, wanted => sub { push @h, $_ if -f $_ && $_ =~ /\.h$/ && $_ !~ /dh_static.h$/ } }, 'src');
my @all = (); my @all = ();
find({ no_chdir => 1, wanted => sub { push @all, $_ if -f $_ && $_ =~ /\.(c|h)$/ } }, 'src'); 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 @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_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']); 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/) { for my $m (qw/libtomcrypt_VS2008.vcproj/) {
my $old = read_file($m); 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 ); # update OBJECTS + HEADERS in makefile*
for my $m (@makefiles) { for my $m (qw/ makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) {
my $old = read_file($m); my $old = read_file($m);
my $new; my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_to, @ver_version)
if ($m eq 'makefile.msvc') { : patch_makefile($old, $var_o, $var_h, $var_to, @ver_version);
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");
}
if ($old ne $new) { if ($old ne $new) {
write_file($m, $new) if $write; write_file($m, $new) if $write;
warn "changed: $m\n"; warn "changed: $m\n";
$changed_count++; $changed_count++;
} }
} }
if ($write) { if ($write) {
return 0; # no failures return 0; # no failures
} }
@ -283,13 +290,13 @@ sub die_usage {
MARKER MARKER
} }
GetOptions( "check-source" => \my $check_source, GetOptions( "s|check-source" => \my $check_source,
"check-defines" => \my $check_defines, "d|check-defines" => \my $check_defines,
"check-hashes" => \my $check_hashes, "h|check-hashes" => \my $check_hashes,
"check-makefiles" => \my $check_makefiles, "m|check-makefiles" => \my $check_makefiles,
"check-all" => \my $check_all, "a|check-all" => \my $check_all,
"update-makefiles" => \my $update_makefiles, "u|update-makefiles" => \my $update_makefiles,
"help" => \my $help "h|help" => \my $help
) or die_usage; ) or die_usage;
my $failure; my $failure;

View File

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

View File

@ -35,10 +35,8 @@ endif
ifndef LIBTEST ifndef LIBTEST
LIBTEST=libtomcrypt_prof.a LIBTEST=libtomcrypt_prof.a
endif endif
LIBTEST_S=$(LIBTEST)
#List of objects to compile. # List of objects to compile (all goes to libtomcrypt.a)
#START_INS
OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ 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/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 \ 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/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
src/stream/sober128/sober128_test.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 \ 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_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_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_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
#Files left over from making the crypt.pdf. #Files left over from making the crypt.pdf.
LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out *.lof 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. #This rule makes the libtomcrypt library.
library: $(LIBNAME) library: $(LIBNAME)
#Dependencies on *.h
$(OBJECTS): $(HEADERS) $(OBJECTS): $(HEADERS)
$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h
$(LIBNAME): $(OBJECTS) $(LIBNAME): $(OBJECTS)
ifneq ($V,1) ifneq ($V,1)
@ -235,22 +242,27 @@ ifneq ($V,1)
endif endif
${silent} $(RANLIB) $@ ${silent} $(RANLIB) $@
.PHONY: testprof/$(LIBTEST) $(LIBTEST): $(TOBJECTS)
testprof/$(LIBTEST): ifneq ($V,1)
${silent} CFLAGS="$(CFLAGS)" LIBTEST_S=$(LIBTEST_S) CC="$(CC)" LD="$(LD)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" RANLIB="$(RANLIB)" V="$(V)" $(MAKE) -C testprof @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) ifneq ($V,1)
@echo " * ${CC} $@" @echo " * ${CC} $@"
endif 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 $(LIBTEST) $(TESTS)
test: library testprof/$(LIBTEST) $(TESTS)
ifneq ($V,1) ifneq ($V,1)
@echo " * ${CC} $@" @echo " * ${CC} $@"
endif 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 # build the demos from a template
define DEMO_template define DEMO_template
@ -277,19 +289,20 @@ install: library docs
else else
install: library install: library
endif endif
install -d $(DESTDIR)$(LIBPATH) install -d $(LIBPATH)
install -d $(DESTDIR)$(INCPATH) install -d $(INCPATH)
install -d $(DESTDIR)$(DATAPATH) install -d $(DATAPATH)
install -m 644 $(LIBNAME) $(DESTDIR)$(LIBPATH) install -m 644 $(LIBNAME) $(LIBPATH)
install -m 644 $(HEADERS) $(DESTDIR)$(INCPATH) install -m 644 $(HEADERS) $(INCPATH)
ifndef NODOCS ifndef NODOCS
install -m 644 doc/crypt.pdf $(DESTDIR)$(DATAPATH) install -m 644 doc/crypt.pdf $(DATAPATH)
endif endif
install_test: testprof/$(LIBTEST) install_test: $(LIBTEST)
install -d $(DESTDIR)$(LIBPATH) install -d $(LIBPATH)
install -d $(DESTDIR)$(INCPATH) install -d $(INCPATH)
install -m 644 testprof/$(LIBTEST) $(DESTDIR)$(LIBPATH) install -m 644 $(LIBTEST) $(LIBPATH)
install -m 644 testprof/tomcrypt_test.h $(INCPATH)
install_hooks: install_hooks:
for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done 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 "*.obj" | xargs`
rm -f `find . -type f -name "*.lib" | xargs` rm -f `find . -type f -name "*.lib" | xargs`
rm -f `find . -type f -name "*.exe" | 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 "*.gcov" | xargs`
rm -f `find . -type f -name "*.gcda" | xargs` rm -f `find . -type f -name "*.gcda" | xargs`
rm -f `find . -type f -name "*.gcno" | xargs` rm -f `find . -type f -name "*.gcno" | xargs`

View File

@ -70,7 +70,6 @@ ifndef LIBNAME
endif endif
ifndef LIBTEST ifndef LIBTEST
LIBTEST=libtomcrypt_prof.a LIBTEST=libtomcrypt_prof.a
LIBTEST_S=$(LIBTEST)
endif endif
HASH=hashsum HASH=hashsum
CRYPT=encrypt CRYPT=encrypt
@ -96,8 +95,7 @@ ifndef DATAPATH
DATAPATH=/usr/share/doc/libtomcrypt/pdf DATAPATH=/usr/share/doc/libtomcrypt/pdf
endif endif
#List of objects to compile. # List of objects to compile (all goes to libtomcrypt.a)
#START_INS
OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ 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/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 \ 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/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
src/stream/sober128/sober128_test.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 \ 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_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_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_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
#Who do we install as? #Who do we install as?
ifdef INSTALL_USER 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. #This rule makes the libtomcrypt library.
library: $(LIBNAME) library: $(LIBNAME)
.PHONY: testprof/$(LIBTEST) #Dependencies on *.h
testprof/$(LIBTEST): $(OBJECTS): $(HEADERS)
cd testprof ; LIBTEST_S=$(LIBTEST) CFLAGS="$(CFLAGS)" CC="$(CC)" AR="$(AR)" $(MAKE) -f makefile.icc $(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h
$(LIBTEST): $(TOBJECTS)
$(AR) $(ARFLAGS) $@ $(TOBJECTS)
$(RANLIB) $@
$(LIBNAME): $(OBJECTS) $(LIBNAME): $(OBJECTS)
$(AR) $(ARFLAGS) $@ $(OBJECTS) $(AR) $(ARFLAGS) $@ $(OBJECTS)
@ -320,12 +329,11 @@ small: library $(SMALLOBJECTS)
tv_gen: library $(TVS) tv_gen: library $(TVS)
$(CC) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV) $(CC) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
timing: library $(TIMINGS) testprof/$(LIBTEST) timing: library $(TIMINGS) $(LIBTEST)
$(CC) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) $(CC) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
.PHONY: test test: library $(TESTS) $(LIBTEST)
test: library $(TESTS) testprof/$(LIBTEST) $(CC) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
$(CC) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
all_test: test tv_gen hashsum crypt small timing 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 #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. #directories and to set the owner and group to root.
install: library install: library
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH) install -d -g $(GROUP) -o $(USER) $(LIBPATH)
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH) install -d -g $(GROUP) -o $(USER) $(INCPATH)
install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH) install -g $(GROUP) -o $(USER) $(LIBNAME) $(LIBPATH)
install -g $(GROUP) -o $(USER) $(LIBTEST) $(DESTDIR)$(LIBPATH) install -g $(GROUP) -o $(USER) $(LIBTEST) $(LIBPATH)
install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH) install -g $(GROUP) -o $(USER) $(HEADERS) $(INCPATH)
# $Source$ # $Source$
# $Revision$ # $Revision$

View File

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

View File

@ -32,8 +32,7 @@ INSTPREFIX=c:\devel-libtom
LIBPATH=$(INSTPREFIX)\lib LIBPATH=$(INSTPREFIX)\lib
INCPATH=$(INSTPREFIX)\include INCPATH=$(INSTPREFIX)\include
#List of objects to compile. # List of objects to compile (all goes to libtomcrypt.a)
#START_INS
OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ 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/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 \ 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/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
src/stream/sober128/sober128_test.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 \ 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_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_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_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
TESTOBJECTS=demos/test.o TESTOBJECTS=demos/test.o
HASHOBJECTS=demos/hashsum.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. #This rule makes the libtomcrypt library.
library: $(LIBNAME) library: $(LIBNAME)
.PHONY: testprof/$(LIBTEST) #Dependencies on *.h
testprof/$(LIBTEST): $(OBJECTS): $(HEADERS)
$(MAKE) -C testprof -f makefile.mingw LIBTEST_S=$(LIBTEST) CC=$(CC) LD=$(LD) AR=$(AR) ARFLAGS=$(ARFLAGS) RANLIB=$(RANLIB) $(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h
$(LIBTEST): $(TOBJECTS)
$(AR) $(ARFLAGS) $@ $(TOBJECTS)
$(RANLIB) $@
%.o: %.c %.o: %.c
${CC} ${CFLAGS} -c $< -o $@ ${CC} ${CFLAGS} -c $< -o $@
@ -246,24 +256,24 @@ small: library $(SMALLOBJECTS)
tv_gen: library $(TVS) tv_gen: library $(TVS)
$(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV) $(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
timing: library testprof/$(LIBTEST) $(TIMINGS) timing: library $(LIBTEST) $(TIMINGS)
$(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING) $(CC) $(LDFLAGS) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
.PHONY: test .PHONY: test
test: library testprof/$(LIBTEST) $(TESTS) test: library $(LIBTEST) $(TESTS)
$(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST) $(CC) $(LDFLAGS) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
all_test: test tv_gen hashsum crypt small timing all_test: test tv_gen hashsum crypt small timing
install: library install: library
cmd /c if not exist "$(DESTDIR)$(LIBPATH)" mkdir "$(DESTDIR)$(LIBPATH)" cmd /c if not exist "$(LIBPATH)" mkdir "$(LIBPATH)"
cmd /c if not exist "$(DESTDIR)$(INCPATH)" mkdir "$(DESTDIR)$(INCPATH)" cmd /c if not exist "$(INCPATH)" mkdir "$(INCPATH)"
copy /Y $(LIBNAME) "$(DESTDIR)$(LIBPATH)" copy /Y $(LIBNAME) "$(LIBPATH)"
copy /Y src\headers\tomcrypt*.h "$(DESTDIR)$(INCPATH)" copy /Y src\headers\tomcrypt*.h "$(INCPATH)"
install_test: testprof/$(LIBTEST) install_test: $(LIBTEST)
cmd /c if not exist "$(DESTDIR)$(LIBPATH)" mkdir "$(DESTDIR)$(LIBPATH)" cmd /c if not exist "$(LIBPATH)" mkdir "$(LIBPATH)"
copy /Y testprof\$(LIBTEST) "$(DESTDIR)$(LIBPATH)" copy /Y testprof\$(LIBTEST) "$(LIBPATH)"
clean: clean:
cmd /c del /Q /S *.o *.a *.exe 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) 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 \ 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/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 \ 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/rc4/rc4.obj src/stream/rc4/rc4_test.obj src/stream/sober128/sober128.obj \
src/stream/sober128/sober128_test.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 \ 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_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_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_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
default: library 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 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 $(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) lib /out:tomcrypt.lib $(OBJECTS)
cd testprof lib /out:tomcrypt_prof.lib $(TOBJECTS)
nmake -f makefile.msvc
cd ..
tv_gen: demos/tv_gen.c library tv_gen: demos/tv_gen.c library
cl $(CFLAGS) demos/tv_gen.c tomcrypt.lib advapi32.lib $(EXTRALIBS) 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 hashsum: demos/hashsum.c library
cl $(CFLAGS) demos/hashsum.c tomcrypt.lib advapi32.lib $(EXTRALIBS) cl $(CFLAGS) demos/hashsum.c tomcrypt.lib advapi32.lib $(EXTRALIBS)
.PHONY: test
test: demos/test.c library 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 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 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/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
src/stream/sober128/sober128_test.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 \ 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_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_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_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 #END_INS
@ -198,7 +207,7 @@ default:library
#ciphers come in two flavours... enc+dec and enc #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 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. #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 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. #This rule makes the libtomcrypt library.
library: $(LIBNAME) library: $(LIBNAME)
.PHONY: testprof/$(LIBTEST) #Dependencies on *.h
testprof/$(LIBTEST): $(OBJECTS): $(HEADERS)
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 $(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h
.c.o: .c.o:
$(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -c $< $(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ -c $<
$(LIBNAME): $(OBJECTS) $(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: $(LIBNAME)
install -d $(DESTDIR)$(LIBPATH) install -d $(LIBPATH)/pkgconfig
$(LT) --mode=install install -c libtomcrypt.la $(DESTDIR)$(LIBPATH)/libtomcrypt.la install -d $(INCPATH)
install -d $(DESTDIR)$(INCPATH) $(LT) --mode=install install -c $(LIBNAME) $(LIBPATH)/$(LIBNAME)
install -m 644 $(HEADERS) $(DESTDIR)$(INCPATH) install -m 644 $(HEADERS) $(INCPATH)
install -d $(DESTDIR)$(LIBPATH)/pkgconfig sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(LIBPATH)/pkgconfig/libtomcrypt.pc
sed 's,@LIBDIR@,$(LIBPATH),g' libtomcrypt.pc.in > libtomcrypt.pc install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/libtomcrypt.pc
install -m 644 libtomcrypt.pc $(DESTDIR)$(LIBPATH)/pkgconfig/libtomcrypt.pc
install_test: testprof/$(LIBTEST) install_test: testprof/$(LIBTEST)
install -d $(DESTDIR)$(LIBPATH) install -d $(LIBPATH)
install -d $(DESTDIR)$(INCPATH) install -d $(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 -m 644 testprof/tomcrypt_test.h $(INCPATH)
$(LT) --mode=install install -c $(LIBTEST) $(LIBPATH)/$(LIBTEST)
.PHONY: test
test: library testprof/$(LIBTEST) $(TESTS) test: library testprof/$(LIBTEST) $(TESTS)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS)
timing: library testprof/$(LIBTEST) $(TIMINGS) timing: library testprof/$(LIBTEST) $(TIMINGS)
$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS)
# build the demos from a template # build the demos from a template
define DEMO_template define DEMO_template
$(1): demos/$(1).o library $(1): demos/$(1).o library