Browse Source

Merge pull request #208 from libtom/improve/makefiles

Re-work, improve & fix makefiles
Steffen Jaeckel 8 years ago
parent
commit
4efe229726
30 changed files with 828 additions and 1265 deletions
  1. 4 0
      .gitattributes
  2. 25 2
      .gitignore
  3. 27 16
      .travis.yml
  4. 6 3
      build.sh
  5. 5 15
      coverage.sh
  6. 24 0
      coverage_more.sh
  7. 0 0
      demos/ltcrypt.c
  8. 5 1
      demos/test.c
  9. 6 6
      doc/Doxyfile
  10. 0 0
      doc/crypt.tex
  11. 57 0
      doc/makefile
  12. 0 16
      fixupind.pl
  13. 53 37
      helper.pl
  14. 3 3
      libtomcrypt.pc.in
  15. 44 320
      makefile
  16. 0 116
      makefile.include
  17. 100 83
      makefile.mingw
  18. 96 33
      makefile.msvc
  19. 28 216
      makefile.shared
  20. 104 99
      makefile.unix
  21. 216 147
      makefile_include.mk
  22. 0 4
      mess.sh
  23. 1 1
      printinfo.sh
  24. 22 17
      testme.sh
  25. 0 43
      testprof/makefile
  26. 0 21
      testprof/makefile.icc
  27. 0 22
      testprof/makefile.mingw
  28. 0 15
      testprof/makefile.msvc
  29. 0 27
      testprof/makefile.shared
  30. 2 2
      updatemakes.sh

+ 4 - 0
.gitattributes

@@ -0,0 +1,4 @@
+/.gitattributes export-ignore
+/.gitignore     export-ignore
+
+/**             export-subst

+ 25 - 2
.gitignore

@@ -7,6 +7,10 @@
 /MSVC_*
 .libs/
 
+# release files
+/libtomcrypt-*
+/crypt-*
+
 # suppress output of build process
 gcc_[12].txt
 testok.txt
@@ -20,8 +24,8 @@ doc/refman.pdf
 # *nix/windows test executables
 constants
 constants.exe
-crypt
-crypt.exe
+ltcrypt
+ltcrypt.exe
 hashsum
 hashsum.exe
 multi
@@ -47,6 +51,11 @@ timing.exe
 *.idb
 *.pdb
 
+# Eclipse special files
+.project
+.cproject
+.settings/
+
 # oops ;) but we don't want them to appear in the repository...
 *.stackdump
 *.core
@@ -61,6 +70,20 @@ timing.exe
 *.gcda
 *.gcno
 *.gcov
+libtomcrypt.pc
+
+# output from doc generation
+doxygen/
+*.dvi
+*.log
+*.aux
+*.toc
+*.idx
+*.ilg
+*.ind
+*.out
+*.lof
+*.bak
 
 coverage/
 coverage*.info

+ 27 - 16
.travis.yml

@@ -1,8 +1,30 @@
 language: c
+
+addons:
+  apt:
+    sources:
+    - debian-sid
+    packages:
+    - binutils
+    - libtommath-dev
+
+before_script:
+  - gem install coveralls-lcov
+  - curl http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz | tar xz
+  - export PATH=$PATH:`pwd`/lcov-1.11/bin
+
+matrix:
+  fast_finish: true
+branches:
+  only:
+    - develop
+
 compiler:
   - gcc
   - clang
-script: bash "${BUILDSCRIPT}" "${BUILDNAME}" "${BUILDOPTIONS}" "makefile" "-DUSE_LTM -DLTM_DESC -I/usr/include" "/usr/lib/x86_64-linux-gnu/libtommath.a"
+
+script: bash "${BUILDSCRIPT}" "${BUILDNAME}" "${BUILDOPTIONS}" "makefile V=1" "-DUSE_LTM -DLTM_DESC -I/usr/include" "/usr/lib/x86_64-linux-gnu/libtommath.a"
+
 env:
   - |
     BUILDSCRIPT="check_source.sh"
@@ -76,25 +98,14 @@ env:
     BUILDSCRIPT="testbuild.sh"
     BUILDNAME="NOFILE"
     BUILDOPTIONS="-DLTC_NO_FILE"
-matrix:
-  fast_finish: true
-branches:
-  only:
-    - develop
-addons:
-  apt:
-    sources:
-    - debian-sid
-    packages:
-    - binutils
-    - libtommath-dev
-before_script:
-  - sudo apt-get update -qq
-  - sudo pip install cpp-coveralls
+
 after_failure:
   - cat test_std.txt
   - cat test_err.txt
+
 after_script:
+  - cat gcc_1.txt
   - cat gcc_2.txt
+
 notifications:
   irc: "chat.freenode.net#libtom-notifications"

+ 6 - 3
build.sh

@@ -42,11 +42,14 @@ if [ -a test ] && [ -f test ] && [ -x test ]; then
    fi
 fi
 
-lcov_opts="--capture --no-external --directory src -q"
-lcov_out=$(echo coverage_$1_$2_$3 | tr ' -=+' '_')".info"
 
 if [ -a testok.txt ] && [ -f testok.txt ]; then
-   [ "$LTC_COVERAGE" != "" ] && lcov $lcov_opts --output-file $lcov_out
+   if [ "$LTC_COVERAGE" != "" ]; then
+      ./coverage_more.sh > test_coverage_more.txt || exit 1
+      lcov_opts="--capture --no-external --directory src -q"
+      lcov_out=$(echo coverage_$1_$2_$3 | tr ' -=+' '_')".info"
+      lcov $lcov_opts --output-file $lcov_out
+   fi
    exit 0
 fi
 exit 1

+ 5 - 15
coverage.sh

@@ -20,7 +20,7 @@ fi
 # output version
 bash printinfo.sh
 
-bash build.sh " $1" " $2" " $3 COVERAGE=1" "$4 -fprofile-arcs -ftest-coverage " "$5 -lgcov"
+bash build.sh " $1" " $2" " $3 COVERAGE=1" "$4" "$5"
 if [ -a testok.txt ] && [ -f testok.txt ]; then
    echo
 else
@@ -29,24 +29,14 @@ else
    exit 1
 fi
 
-./sizes
-./constants
-
-for i in $(for j in $(echo $(./hashsum -h | tail -n +3)); do echo $j; done | sort); do echo -n "$i: " && ./hashsum -a $i testprof/test.key ; done > hashsum_tv.txt
-difftroubles=$(diff -i -w -B hashsum_tv.txt notes/hashsum_tv.txt | grep '^<') || true
-if [ -n "$difftroubles" ]; then
-  echo "FAILURE: hashsum_tv.tx"
-  diff -i -w -B hashsum_tv.txt notes/hashsum_tv.txt
-  echo "hashsum failed" && rm -f testok.txt && exit 1
-else
-  echo "hashsum okay"
-fi
+./coverage_more.sh > test_coverage_more.txt || { rm -f testok.txt && exit 1 ; }
 
+make lcov-single
 # if this was executed as './coverage.sh ...' create coverage locally
 if [[ "${0%% *}" == "./${0##*/}" ]]; then
-   make lcov-single
+   make lcov-html
 else
-   cpp-coveralls -e 'demos/' -e 'testprof/' -e 'notes/' -e 'src/headers/'
+   coveralls-lcov coverage.info
 fi
 
 exit 0

+ 24 - 0
coverage_more.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+
+set -e
+
+./sizes
+./constants
+
+for i in $(for j in $(echo $(./hashsum -h | tail -n +3)); do echo $j; done | sort); do echo -n "$i: " && ./hashsum -a $i testprof/test.key ; done > hashsum_tv.txt
+difftroubles=$(diff -i -w -B hashsum_tv.txt notes/hashsum_tv.txt | grep '^<') || true
+if [ -n "$difftroubles" ]; then
+  echo "FAILURE: hashsum_tv.tx"
+  diff -i -w -B hashsum_tv.txt notes/hashsum_tv.txt
+  echo "hashsum failed"
+  exit 1
+else
+  echo "hashsum okay"
+fi
+
+
+exit 0
+
+# $Source$
+# $Revision$
+# $Date$

+ 0 - 0
demos/crypt.c → demos/ltcrypt.c


+ 5 - 1
demos/test.c

@@ -1,5 +1,9 @@
 #include <tomcrypt_test.h>
 
+#ifndef GIT_VERSION
+#define GIT_VERSION "Undefined version"
+#endif
+
 #define LTC_TEST_FN(f)  { f, #f }
 
 static const struct {
@@ -37,7 +41,7 @@ int main(int argc, char **argv)
    long delta, dur = 0;
    reg_algs();
 
-   printf("build == \n%s\n", crypt_build_settings);
+   printf("build == %s\n%s\n", GIT_VERSION, crypt_build_settings);
 
 #ifdef USE_LTM
    ltc_mp = ltm_desc;

+ 6 - 6
Doxyfile → doc/Doxyfile

@@ -58,7 +58,7 @@ PROJECT_LOGO           =
 # entered, it will be relative to the location where doxygen was started. If
 # left blank the current directory will be used.
 
-OUTPUT_DIRECTORY       = doc/doxygen
+OUTPUT_DIRECTORY       = doxygen
 
 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
 # directories (in 2 levels) under the output directory of each output format and
@@ -161,7 +161,7 @@ STRIP_FROM_PATH        = src
 # specify the list of include paths that are normally passed to the compiler
 # using the -I flag.
 
-STRIP_FROM_INC_PATH    = src/headers
+STRIP_FROM_INC_PATH    = ../src/headers
 
 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
 # less readable) file names. This can be useful is your file systems doesn't
@@ -754,7 +754,7 @@ WARN_LOGFILE           =
 # spaces.
 # Note: If this tag is empty the current directory is searched.
 
-INPUT                  = src
+INPUT                  = ../src/
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1046,7 +1046,7 @@ HTML_FILE_EXTENSION    = .html
 # of the possible markers and block names see the documentation.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
-HTML_HEADER            = doc/header.html
+HTML_HEADER            = header.html
 
 # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
 # generated HTML page. If the tag is left blank doxygen will generate a standard
@@ -1056,7 +1056,7 @@ HTML_HEADER            = doc/header.html
 # that doxygen normally uses.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
-HTML_FOOTER            = doc/footer.html
+HTML_FOOTER            = footer.html
 
 # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
 # sheet that is used by each HTML page. It can be used to fine-tune the look of
@@ -1924,7 +1924,7 @@ SEARCH_INCLUDES        = YES
 # preprocessor.
 # This tag requires that the tag SEARCH_INCLUDES is set to YES.
 
-INCLUDE_PATH           = src/headers
+INCLUDE_PATH           = ../src//headers
 
 # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
 # patterns (like *.h and *.hpp) to filter out the header-files in the

+ 0 - 0
crypt.tex → doc/crypt.tex


+ 57 - 0
doc/makefile

@@ -0,0 +1,57 @@
+ifeq ($V,1)
+silent=
+silent_stdout=
+else
+silent=@
+silent_stdout= > /dev/null
+endif
+
+#Files left over from making the crypt.pdf.
+LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out *.lof
+
+#build the doxy files (requires Doxygen, tetex and patience)
+.PHONY: doxygen
+doxygen:
+	doxygen $(silent_stdout)
+
+doxy: doxygen
+	${MAKE} -C doxygen/latex $(silent_stdout) && mv -f doxygen/latex/refman.pdf .
+	@echo The huge doxygen PDF should be available as doc/refman.pdf
+
+#This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed
+#from the clean command! This is because most people would like to keep the
+#nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to
+#delete it if we are rebuilding it.
+docs crypt.pdf: crypt.tex
+	rm -f crypt.pdf $(LEFTOVERS)
+	cp crypt.tex crypt.bak
+	touch -r crypt.tex crypt.bak
+	(printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y crypt.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > crypt-deterministic.tex
+	printf "%s\n" "\pdfinfo{" >> crypt-deterministic.tex
+	printf "%s\n" "  /CreationDate (\fixedpdfdate)" >> crypt-deterministic.tex
+	printf "%s\n}\n" "  /ModDate (\fixedpdfdate)" >> crypt-deterministic.tex
+	cat crypt.tex >> crypt-deterministic.tex
+	mv crypt-deterministic.tex crypt.tex
+	touch -r crypt.bak crypt.tex
+	echo "hello" > crypt.ind
+	latex crypt $(silent_stdout)
+	latex crypt $(silent_stdout)
+	makeindex crypt.idx $(silent_stdout)
+	perl ../helper.pl --fixupind crypt.ind
+	pdflatex crypt $(silent_stdout)
+	sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' crypt.pdf
+	mv crypt.bak crypt.tex
+	rm -f $(LEFTOVERS)
+
+docdvi: crypt.tex
+	echo hello > crypt.ind
+	latex crypt $(silent_stdout)
+	latex crypt $(silent_stdout)
+	makeindex crypt.idx
+	perl ../helper.pl --fixupind crypt.ind
+	latex crypt $(silent_stdout)
+	latex crypt $(silent_stdout)
+
+clean:
+	rm -f $(LEFTOVERS)
+	rm -rf doxygen/

+ 0 - 16
fixupind.pl

@@ -1,16 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-open(my $in, '<', 'crypt.ind');
-open(my $out, '>', 'crypt.ind.tmp');
-my $a = <$in>;
-print {$out} "$a\n\\addcontentsline{toc}{chapter}{Index}\n";
-while (<$in>) {
-   print {$out} $_;
-}
-close $out;
-close $in;
-system("mv -f crypt.ind.tmp crypt.ind");
-

+ 53 - 37
helper.pl

@@ -72,7 +72,7 @@ sub check_defines {
   my $cryp_c = read_file("src/misc/crypt/crypt.c");
   $cust_h =~ s|/\*.*?\*/||sg; # remove comments
   $cryp_c =~ s|/\*.*?\*/||sg; # remove comments
-  my %def = map { $_ => 1 } map { $_ =~ s/^\s*#define\s+(LTC_\S+).*$/$1/; $_ } grep { /^\s*#define\s+LTC_\S+/ } split /\n/, $cust_h;
+  my %def = map { $_ => 1 } map { my $x = $_; $x =~ s/^\s*#define\s+(LTC_\S+).*$/$1/; $x } grep { /^\s*#define\s+LTC_\S+/ } split /\n/, $cust_h;
   for my $d (sort keys %def) {
     next if $d =~ /^LTC_(DH\d+|ECC\d+|ECC_\S+|MPI|MUTEX_\S+\(x\)|NO_\S+)$/;
     warn "$d missing in src/misc/crypt/crypt.c\n" and $fails++ if $cryp_c !~ /\Q$d\E/;
@@ -86,7 +86,7 @@ sub check_hashes {
   my @descriptors;
   find({ wanted => sub { push @src, $_ if $_ =~ /\.c$/ }, no_chdir=>1 }, './src/hashes/');
   for my $f (@src) {
-    my @n = map { $_ =~ s/^.*?ltc_hash_descriptor\s+(\S+).*$/$1/; $_ } grep { $_ =~ /ltc_hash_descriptor/ } split /\n/, read_file($f);
+    my @n = map { my $x = $_; $x =~ s/^.*?ltc_hash_descriptor\s+(\S+).*$/$1/; $x } grep { $_ =~ /ltc_hash_descriptor/ } split /\n/, read_file($f);
     push @descriptors, @n if @n;
   }
   my $fails = 0;
@@ -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) . "..";
+    }
+  }
+  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=$1.$2", "VERSION_LT=0:$1$2";
+  }
+  else {
+    die "#define SCRYPT not found in tomcrypt.h";
   }
-  close $dst;
-  close $src;
 }
 
 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 @o = sort ('src/ciphers/aes/aes_enc.o', map { my $x = $_; $x =~ s/\.c$/.o/; $x } @c);
+  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 { my $x = $_; $x =~ s/\.c$/.o/; $x } @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.shared makefile.unix makefile.mingw makefile.msvc makefile_include.mk /) {
     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_tobj, @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
   }
@@ -280,18 +287,27 @@ sub die_usage {
          $0 --check-makefiles
          $0 --check-all
          $0 --update-makefiles
+         $0 --fixupind crypt.ind
 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,
+            "f|fixupind=s"       => \my $fixupind,
+            "h|help"             => \my $help
           ) or die_usage;
 
+if ($fixupind) {
+  my $txt = read_file($fixupind);
+  $txt =~ s/^([^\n]*\n)/$1\n\\addcontentsline{toc}{chapter}{Index}\n/s;
+  write_file($fixupind, $txt);
+  exit 0;
+}
+
 my $failure;
 $failure ||= check_source()       if $check_all || $check_source;
 $failure ||= check_defines()      if $check_all || $check_defines;

+ 3 - 3
libtomcrypt.pc.in

@@ -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}

+ 44 - 320
makefile

@@ -2,13 +2,8 @@
 #
 # Tom St Denis
 # Modified by Clay Culver
-
-include makefile.include
-
-# The version
-VERSION=1.17
-
-PLATFORM := $(shell uname | sed -e 's/_.*//')
+#
+#  (GNU make only)
 
 ifeq ($V,1)
 silent=
@@ -18,12 +13,6 @@ silent=@
 silent_stdout= > /dev/null
 endif
 
-%.o: %.c
-ifneq ($V,1)
-	@echo "   * ${CC} $@"
-endif
-	${silent} ${CC} ${CFLAGS} -c $< -o $@
-
 # ranlib tools
 ifndef RANLIB
 ifeq ($(PLATFORM), Darwin)
@@ -32,6 +21,7 @@ else
 RANLIB:=$(PREFIX)ranlib
 endif
 endif
+INSTALL_CMD = install
 
 #Output filenames for various targets.
 ifndef LIBNAME
@@ -40,195 +30,26 @@ endif
 ifndef LIBTEST
    LIBTEST=libtomcrypt_prof.a
 endif
-LIBTEST_S=$(LIBTEST)
-
-#List of objects to compile.
-#START_INS
-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 \
-src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \
-src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_add_aad.o \
-src/encauth/ccm/ccm_add_nonce.o src/encauth/ccm/ccm_done.o src/encauth/ccm/ccm_init.o \
-src/encauth/ccm/ccm_memory.o src/encauth/ccm/ccm_process.o src/encauth/ccm/ccm_reset.o \
-src/encauth/ccm/ccm_test.o src/encauth/chachapoly/chacha20poly1305_add_aad.o \
-src/encauth/chachapoly/chacha20poly1305_decrypt.o src/encauth/chachapoly/chacha20poly1305_done.o \
-src/encauth/chachapoly/chacha20poly1305_encrypt.o src/encauth/chachapoly/chacha20poly1305_init.o \
-src/encauth/chachapoly/chacha20poly1305_memory.o src/encauth/chachapoly/chacha20poly1305_setiv.o \
-src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.o \
-src/encauth/chachapoly/chacha20poly1305_test.o src/encauth/eax/eax_addheader.o \
-src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \
-src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \
-src/encauth/eax/eax_init.o src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o \
-src/encauth/gcm/gcm_add_iv.o src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o \
-src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_mult_h.o \
-src/encauth/gcm/gcm_process.o src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o \
-src/encauth/ocb/ocb_decrypt.o src/encauth/ocb/ocb_decrypt_verify_memory.o \
-src/encauth/ocb/ocb_done_decrypt.o src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \
-src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \
-src/encauth/ocb/ocb_shift_xor.o src/encauth/ocb/ocb_test.o src/encauth/ocb/s_ocb_done.o \
-src/encauth/ocb3/ocb3_add_aad.o src/encauth/ocb3/ocb3_decrypt.o src/encauth/ocb3/ocb3_decrypt_last.o \
-src/encauth/ocb3/ocb3_decrypt_verify_memory.o src/encauth/ocb3/ocb3_done.o \
-src/encauth/ocb3/ocb3_encrypt.o src/encauth/ocb3/ocb3_encrypt_authenticate_memory.o \
-src/encauth/ocb3/ocb3_encrypt_last.o src/encauth/ocb3/ocb3_init.o \
-src/encauth/ocb3/ocb3_int_aad_add_block.o src/encauth/ocb3/ocb3_int_calc_offset_zero.o \
-src/encauth/ocb3/ocb3_int_ntz.o src/encauth/ocb3/ocb3_int_xor_blocks.o src/encauth/ocb3/ocb3_test.o \
-src/hashes/blake2b.o src/hashes/blake2s.o src/hashes/chc/chc.o src/hashes/helper/hash_file.o \
-src/hashes/helper/hash_filehandle.o src/hashes/helper/hash_memory.o \
-src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o src/hashes/md5.o \
-src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o src/hashes/sha1.o \
-src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o src/hashes/sha2/sha512.o \
-src/hashes/sha2/sha512_224.o src/hashes/sha2/sha512_256.o src/hashes/sha3.o src/hashes/sha3_test.o \
-src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/blake2/blake2bmac.o \
-src/mac/blake2/blake2bmac_file.o src/mac/blake2/blake2bmac_memory.o \
-src/mac/blake2/blake2bmac_memory_multi.o src/mac/blake2/blake2bmac_test.o src/mac/blake2/blake2smac.o \
-src/mac/blake2/blake2smac_file.o src/mac/blake2/blake2smac_memory.o \
-src/mac/blake2/blake2smac_memory_multi.o src/mac/blake2/blake2smac_test.o src/mac/f9/f9_done.o \
-src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \
-src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \
-src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \
-src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \
-src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \
-src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \
-src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \
-src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
-src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \
-src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/poly1305/poly1305.o \
-src/mac/poly1305/poly1305_file.o src/mac/poly1305/poly1305_memory.o \
-src/mac/poly1305/poly1305_memory_multi.o src/mac/poly1305/poly1305_test.o src/mac/xcbc/xcbc_done.o \
-src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \
-src/mac/xcbc/xcbc_memory_multi.o src/mac/xcbc/xcbc_process.o src/mac/xcbc/xcbc_test.o \
-src/math/fp/ltc_ecc_fp_mulmod.o src/math/gmp_desc.o src/math/ltm_desc.o src/math/multi.o \
-src/math/rand_bn.o src/math/rand_prime.o src/math/tfm_desc.o src/misc/adler32.o \
-src/misc/base64/base64_decode.o src/misc/base64/base64_encode.o src/misc/burn_stack.o src/misc/crc32.o \
-src/misc/crypt/crypt.o src/misc/crypt/crypt_argchk.o src/misc/crypt/crypt_cipher_descriptor.o \
-src/misc/crypt/crypt_cipher_is_valid.o src/misc/crypt/crypt_constants.o \
-src/misc/crypt/crypt_find_cipher.o src/misc/crypt/crypt_find_cipher_any.o \
-src/misc/crypt/crypt_find_cipher_id.o src/misc/crypt/crypt_find_hash.o \
-src/misc/crypt/crypt_find_hash_any.o src/misc/crypt/crypt_find_hash_id.o \
-src/misc/crypt/crypt_find_hash_oid.o src/misc/crypt/crypt_find_prng.o src/misc/crypt/crypt_fsa.o \
-src/misc/crypt/crypt_hash_descriptor.o src/misc/crypt/crypt_hash_is_valid.o \
-src/misc/crypt/crypt_inits.o src/misc/crypt/crypt_ltc_mp_descriptor.o \
-src/misc/crypt/crypt_prng_descriptor.o src/misc/crypt/crypt_prng_is_valid.o \
-src/misc/crypt/crypt_prng_rng_descriptor.o src/misc/crypt/crypt_register_cipher.o \
-src/misc/crypt/crypt_register_hash.o src/misc/crypt/crypt_register_prng.o src/misc/crypt/crypt_sizes.o \
-src/misc/crypt/crypt_unregister_cipher.o src/misc/crypt/crypt_unregister_hash.o \
-src/misc/crypt/crypt_unregister_prng.o src/misc/error_to_string.o src/misc/hkdf/hkdf.o \
-src/misc/hkdf/hkdf_test.o src/misc/mem_neq.o src/misc/pk_get_oid.o src/misc/pkcs5/pkcs_5_1.o \
-src/misc/pkcs5/pkcs_5_2.o src/misc/pkcs5/pkcs_5_test.o src/misc/zeromem.o src/modes/cbc/cbc_decrypt.o \
-src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o src/modes/cbc/cbc_getiv.o \
-src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o src/modes/cfb/cfb_decrypt.o \
-src/modes/cfb/cfb_done.o src/modes/cfb/cfb_encrypt.o src/modes/cfb/cfb_getiv.o \
-src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o src/modes/ctr/ctr_decrypt.o \
-src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o src/modes/ctr/ctr_getiv.o \
-src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o src/modes/ctr/ctr_test.o \
-src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \
-src/modes/ecb/ecb_start.o src/modes/f8/f8_decrypt.o src/modes/f8/f8_done.o src/modes/f8/f8_encrypt.o \
-src/modes/f8/f8_getiv.o src/modes/f8/f8_setiv.o src/modes/f8/f8_start.o src/modes/f8/f8_test_mode.o \
-src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o src/modes/lrw/lrw_encrypt.o \
-src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o src/modes/lrw/lrw_setiv.o \
-src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \
-src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \
-src/modes/ofb/ofb_start.o src/modes/xts/xts_decrypt.o src/modes/xts/xts_done.o \
-src/modes/xts/xts_encrypt.o src/modes/xts/xts_init.o src/modes/xts/xts_mult_x.o \
-src/modes/xts/xts_test.o src/pk/asn1/der/bit/der_decode_bit_string.o \
-src/pk/asn1/der/bit/der_decode_raw_bit_string.o src/pk/asn1/der/bit/der_encode_bit_string.o \
-src/pk/asn1/der/bit/der_encode_raw_bit_string.o src/pk/asn1/der/bit/der_length_bit_string.o \
-src/pk/asn1/der/boolean/der_decode_boolean.o src/pk/asn1/der/boolean/der_encode_boolean.o \
-src/pk/asn1/der/boolean/der_length_boolean.o src/pk/asn1/der/choice/der_decode_choice.o \
-src/pk/asn1/der/generalizedtime/der_decode_generalizedtime.o \
-src/pk/asn1/der/generalizedtime/der_encode_generalizedtime.o \
-src/pk/asn1/der/generalizedtime/der_length_generalizedtime.o \
-src/pk/asn1/der/ia5/der_decode_ia5_string.o src/pk/asn1/der/ia5/der_encode_ia5_string.o \
-src/pk/asn1/der/ia5/der_length_ia5_string.o src/pk/asn1/der/integer/der_decode_integer.o \
-src/pk/asn1/der/integer/der_encode_integer.o src/pk/asn1/der/integer/der_length_integer.o \
-src/pk/asn1/der/object_identifier/der_decode_object_identifier.o \
-src/pk/asn1/der/object_identifier/der_encode_object_identifier.o \
-src/pk/asn1/der/object_identifier/der_length_object_identifier.o \
-src/pk/asn1/der/octet/der_decode_octet_string.o src/pk/asn1/der/octet/der_encode_octet_string.o \
-src/pk/asn1/der/octet/der_length_octet_string.o \
-src/pk/asn1/der/printable_string/der_decode_printable_string.o \
-src/pk/asn1/der/printable_string/der_encode_printable_string.o \
-src/pk/asn1/der/printable_string/der_length_printable_string.o \
-src/pk/asn1/der/sequence/der_decode_sequence_ex.o \
-src/pk/asn1/der/sequence/der_decode_sequence_flexi.o \
-src/pk/asn1/der/sequence/der_decode_sequence_multi.o \
-src/pk/asn1/der/sequence/der_decode_subject_public_key_info.o \
-src/pk/asn1/der/sequence/der_encode_sequence_ex.o \
-src/pk/asn1/der/sequence/der_encode_sequence_multi.o \
-src/pk/asn1/der/sequence/der_encode_subject_public_key_info.o \
-src/pk/asn1/der/sequence/der_length_sequence.o src/pk/asn1/der/sequence/der_sequence_free.o \
-src/pk/asn1/der/sequence/der_sequence_shrink.o src/pk/asn1/der/set/der_encode_set.o \
-src/pk/asn1/der/set/der_encode_setof.o src/pk/asn1/der/short_integer/der_decode_short_integer.o \
-src/pk/asn1/der/short_integer/der_encode_short_integer.o \
-src/pk/asn1/der/short_integer/der_length_short_integer.o \
-src/pk/asn1/der/teletex_string/der_decode_teletex_string.o \
-src/pk/asn1/der/teletex_string/der_length_teletex_string.o \
-src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \
-src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \
-src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \
-src/pk/dh/dh.o src/pk/dh/dh_static.o src/pk/dh/dh_sys.o src/pk/dsa/dsa_decrypt_key.o \
-src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o \
-src/pk/dsa/dsa_import_radix.o src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o \
-src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \
-src/pk/ecc/ecc_ansi_x963_export.o src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o \
-src/pk/ecc/ecc_encrypt_key.o src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o \
-src/pk/ecc/ecc_import.o src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o \
-src/pk/ecc/ecc_sign_hash.o src/pk/ecc/ecc_sizes.o src/pk/ecc/ecc_test.o src/pk/ecc/ecc_verify_hash.o \
-src/pk/ecc/ltc_ecc_is_valid_idx.o src/pk/ecc/ltc_ecc_map.o src/pk/ecc/ltc_ecc_mul2add.o \
-src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \
-src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \
-src/pk/katja/katja_decrypt_key.o src/pk/katja/katja_encrypt_key.o src/pk/katja/katja_export.o \
-src/pk/katja/katja_exptmod.o src/pk/katja/katja_free.o src/pk/katja/katja_import.o \
-src/pk/katja/katja_make_key.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \
-src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \
-src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \
-src/pk/pkcs1/pkcs_1_v1_5_encode.o src/pk/rsa/rsa_decrypt_key.o src/pk/rsa/rsa_encrypt_key.o \
-src/pk/rsa/rsa_export.o src/pk/rsa/rsa_exptmod.o src/pk/rsa/rsa_free.o src/pk/rsa/rsa_get_size.o \
-src/pk/rsa/rsa_import.o src/pk/rsa/rsa_import_radix.o src/pk/rsa/rsa_import_x509.o \
-src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_sign_hash.o src/pk/rsa/rsa_sign_saltlen_get.o \
-src/pk/rsa/rsa_verify_hash.o src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o \
-src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o \
-src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \
-src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \
-src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o \
-src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
-src/stream/sober128/sober128_test.o
-
-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
 
-#Files left over from making the crypt.pdf.
-LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out *.lof
 
-#Compressed filenames
-COMPRESSED=crypt-$(VERSION).tar.bz2 crypt-$(VERSION).zip
+include makefile_include.mk
 
-#The default rule for make builds the libtomcrypt library.
-default:library
+ifeq ($(COVERAGE),1)
+all_test: LIB_PRE = -Wl,--whole-archive
+all_test: LIB_POST = -Wl,--no-whole-archive
+CFLAGS += -fprofile-arcs -ftest-coverage
+EXTRALIBS += -lgcov
+endif
 
 #AES comes in two flavours... enc+dec and enc
 src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
 	${silent} ${CC} ${CFLAGS} -DENCRYPT_ONLY -c $< -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
-src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c
-src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c
-src/hashes/sha2/sha512.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c
-src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_224.c
-src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c
-src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
-
-#This rule makes the libtomcrypt library.
-library: $(LIBNAME)
-
-$(OBJECTS): $(HEADERS)
+.c.o:
+ifneq ($V,1)
+	@echo "   * ${CC} $@"
+endif
+	${silent} ${CC} ${CFLAGS} -c $< -o $@
 
 $(LIBNAME): $(OBJECTS)
 ifneq ($V,1)
@@ -240,26 +61,31 @@ 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: $(LIBNAME) $(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: $(LIBNAME) $(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
-$(1): demos/$(1).o library
+$(1): demos/$(1).o $$(LIBNAME)
 ifneq ($V,1)
 	@echo "   * $${CC} $$@"
 endif
@@ -268,36 +94,15 @@ endef
 
 $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
 
-all_test: test tv_gen $(DEMOS)
-ifeq ($(COVERAGE),1)
-all_test: LIB_PRE = -Wl,--whole-archive
-all_test: LIB_POST = -Wl,--no-whole-archive
-endif
 
 #This rule installs the library and the header files. This must be run
 #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.
-ifndef NODOCS
-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)
-ifndef NODOCS
-	install -m 644 doc/crypt.pdf $(DESTDIR)$(DATAPATH)
-endif
+install: .common_install
 
-install_test: testprof/$(LIBTEST)
-	install -d $(DESTDIR)$(LIBPATH)
-	install -d $(DESTDIR)$(INCPATH)
-	install -m 644 testprof/$(LIBTEST) $(DESTDIR)$(LIBPATH)
+install_bins: .common_install_bins
 
-install_hooks:
-	for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done
+install_test: .common_install_test
 
 profile:
 	CFLAGS="$(CFLAGS) -fprofile-generate" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
@@ -314,14 +119,20 @@ cleancov-clean:
 	rm -f `find . -type f -name "*.info" | xargs`
 	rm -rf coverage/
 
+# merges all coverage_*.info files into coverage.info
+coverage.info:
+	lcov `find -name 'coverage_*.info' -exec echo -n " -a {}" \;` -o coverage.info
+
 # generates html output from all coverage_*.info files
-lcov:
-	lcov `find -name 'coverage_*.info' -exec echo -n " -a {}" \;` -o coverage.info -q 2>/dev/null
+lcov-html: coverage.info
 	genhtml coverage.info --output-directory coverage -q
 
 # combines all necessary steps to create the coverage from a single testrun with e.g.
 # CFLAGS="-DUSE_LTM -DLTM_DESC -I../libtommath" EXTRALIBS="../libtommath/libtommath.a" make coverage -j9
-lcov-single: | cleancov-clean lcov-single-create lcov
+lcov-single:
+	$(MAKE) cleancov-clean
+	$(MAKE) lcov-single-create
+	$(MAKE) coverage.info
 
 
 #make the code coverage of the library
@@ -333,96 +144,9 @@ coverage: LIB_POST = -Wl,--no-whole-archive
 coverage: test
 	./test
 
-
 # cleans everything - coverage output and standard 'clean'
 cleancov: cleancov-clean clean
 
-#This rule cleans the source tree of all compiled code, not including the pdf
-#documentation.
-clean:
-	rm -f `find . -type f -name "*.o" | xargs`
-	rm -f `find . -type f -name "*.lo"  | xargs`
-	rm -f `find . -type f -name "*.a" | xargs`
-	rm -f `find . -type f -name "*.la"  | xargs`
-	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 "*.gcov" | xargs`
-	rm -f `find . -type f -name "*.gcda" | xargs`
-	rm -f `find . -type f -name "*.gcno" | xargs`
-	rm -f `find . -type f -name "*.il" | xargs`
-	rm -f `find . -type f -name "*.dyn" | xargs`
-	rm -f `find . -type f -name "*.dpi" | xargs`
-	rm -rf `find . -type d -name "*.libs" | xargs`
-	rm -f crypt.aux  crypt.dvi  crypt.idx  crypt.ilg  crypt.ind  crypt.log crypt.toc
-	rm -f $(TV) $(SMALL) $(CRYPT) $(HASH) $(TIMING) $(TEST)
-	rm -f $(SIZES) $(CONSTANTS)
-	rm -rf doc/doxygen
-	rm -f `find . -type f -name "*.pdf" | grep -FL crypt.pdf | xargs`
-	rm -f *.txt
-	cd testprof ; $(MAKE) clean
-
-#build the doxy files (requires Doxygen, tetex and patience)
-doxygen:
-	doxygen $(silent_stdout)
-
-doxy: doxygen
-	cd doc/doxygen/latex ; ${MAKE} $(silent_stdout) ; mv -f refman.pdf ../../.
-	@echo The huge doxygen PDF should be available as doc/refman.pdf
-
-#This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed
-#from the clean command! This is because most people would like to keep the
-#nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to
-#delete it if we are rebuilding it.
-docs: crypt.tex
-	rm -f doc/crypt.pdf $(LEFTOVERS)
-	cp crypt.tex crypt.bak
-	touch --reference=crypt.tex crypt.bak
-	(printf "%s" "\def\fixedpdfdate{"; date +'D:%Y%m%d%H%M%S%:z' -d @$$(stat --format=%Y crypt.tex) | sed "s/:\([0-9][0-9]\)$$/'\1'}/g") > crypt-deterministic.tex
-	printf "%s\n" "\pdfinfo{" >> crypt-deterministic.tex
-	printf "%s\n" "  /CreationDate (\fixedpdfdate)" >> crypt-deterministic.tex
-	printf "%s\n}\n" "  /ModDate (\fixedpdfdate)" >> crypt-deterministic.tex
-	cat crypt.tex >> crypt-deterministic.tex
-	mv crypt-deterministic.tex crypt.tex
-	touch --reference=crypt.bak crypt.tex
-	echo "hello" > crypt.ind
-	latex crypt $(silent_stdout)
-	latex crypt $(silent_stdout)
-	makeindex crypt.idx $(silent_stdout)
-	perl fixupind.pl
-	pdflatex crypt $(silent_stdout)
-	sed -b -i 's,^/ID \[.*\]$$,/ID [<0> <0>],g' crypt.pdf
-	mv -ivf crypt.pdf doc/crypt.pdf
-	mv crypt.bak crypt.tex
-	rm -f $(LEFTOVERS)
-
-docdvi: crypt.tex
-	echo hello > crypt.ind
-	latex crypt $(silent_stdout)
-	latex crypt $(silent_stdout)
-	makeindex crypt.idx
-	perl fixupind.pl
-	latex crypt $(silent_stdout)
-	latex crypt $(silent_stdout)
-
-#zipup the project (take that!)
-no_oops: clean
-	cd .. ; cvs commit
-	echo Scanning for scratch/dirty files
-	find . -type f | grep -v CVS | xargs -n 1 bash mess.sh
-
-zipup: no_oops docs
-	cd .. ; rm -rf crypt* libtomcrypt-$(VERSION) ; mkdir libtomcrypt-$(VERSION) ; \
-	cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)/ ; \
-	cd libtomcrypt-$(VERSION) ; rm -rf `find . -type d | grep CVS | xargs` ; cd .. ; \
-	tar -cjvf crypt-$(VERSION).tar.bz2 libtomcrypt-$(VERSION) ; \
-	zip -9r crypt-$(VERSION).zip libtomcrypt-$(VERSION) ; \
-	gpg -b -a crypt-$(VERSION).tar.bz2 ; gpg -b -a crypt-$(VERSION).zip ; \
-	mv -fv crypt* ~ ; rm -rf libtomcrypt-$(VERSION)
-
-perlcritic:
-	perlcritic *.pl
-
-# $Source$
-# $Revision$
-# $Date$
+# ref:         $Format:%D$
+# git commit:  $Format:%H$
+# commit time: $Format:%ai$

+ 0 - 116
makefile.include

@@ -1,116 +0,0 @@
-#
-# Include makefile for libtomcrypt
-#
-
-# Compiler and Linker Names
-ifndef PREFIX
-  PREFIX:=
-endif
-
-ifeq ($(CC),cc)
-  CC := $(PREFIX)gcc
-endif
-LD:=$(PREFIX)ld
-AR:=$(PREFIX)ar
-
-# Archiver [makes .a files]
-#AR=ar
-ARFLAGS:=r
-
-ifndef MAKE
-  MAKE:=make
-endif
-
-
-# Compilation flags. Note the += does not write over the user's CFLAGS!
-CFLAGS += -I./testprof/ -I./src/headers/ -Wall -Wsign-compare -Wshadow -DLTC_SOURCE
-
-ifdef OLD_GCC
-CFLAGS += -W
-# older GCCs can't handle the "rotate with immediate" ROLc/RORc/etc macros
-# define this to help
-CFLAGS += -DLTC_NO_ROLC
-else
-CFLAGS += -Wextra
-# additional warnings
-CFLAGS += -Wsystem-headers -Wbad-function-cast -Wcast-align
-CFLAGS += -Wstrict-prototypes -Wpointer-arith
-CFLAGS += -Wdeclaration-after-statement
-endif
-
-CFLAGS += -Wno-type-limits
-
-ifdef LTC_DEBUG
-# compile for DEBUGGING (required for ccmalloc checking!!!)
-ifneq (,$(strip $(LTC_DEBUG)))
-CFLAGS += -g3 -DLTC_NO_ASM -DLTC_TEST_DBG=$(LTC_DEBUG)
-else
-CFLAGS += -g3 -DLTC_NO_ASM -DLTC_TEST_DBG
-endif
-else
-
-ifdef LTC_SMALL
-# optimize for SIZE
-CFLAGS += -Os -DLTC_SMALL_CODE
-else
-
-ifndef IGNORE_SPEED
-# optimize for SPEED
-CFLAGS += -O3 -funroll-loops
-
-# add -fomit-frame-pointer.  hinders debugging!
-CFLAGS += -fomit-frame-pointer
-endif
-
-endif # COMPILE_SMALL
-endif # COMPILE_DEBUG
-
-
-ifneq ($(findstring clang,$(CC)),)
-CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare
-endif
-
-
-HASH=hashsum
-CRYPT=encrypt
-SMALL=small
-TV=tv_gen
-TIMING=timing
-TEST=test
-SIZES=sizes
-CONSTANTS=constants
-
-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
-
-#Who do we install as?
-ifdef INSTALL_USER
-USER=$(INSTALL_USER)
-else
-USER=root
-endif
-
-ifdef INSTALL_GROUP
-GROUP=$(INSTALL_GROUP)
-else
-GROUP=wheel
-endif

+ 100 - 83
makefile.mingw

@@ -1,39 +1,41 @@
+# MAKEFILE for MS Windows (mingw + gcc + gmake)
 #
-# open a command prompt with gcc + gmake in PATH
-# and start: gmake -f makefile.mingw
-#
-
-EXTRALIBS=../libtommath/libtommath.a
-EXTRAINCLUDE=../libtommath
+# BEWARE: variables OBJECTS, TOBJECTS, HEADERS, VERSION are updated via ./updatemakes.sh
 
-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
-LD=ld
-AR=ar
-ARFLAGS=rc
-RANLIB=ranlib
+### USAGE:
+# Open a command prompt with gcc + gmake in PATH and start:
+#
+# gmake -f makefile.mingw all
+# test.exe
+# gmake -f makefile.mingw DESTDIR=c:\devel\libtom install
+#
+#Or:
+#
+# gmake -f makefile.mingw CFLAGS="-O3 -DUSE_LTM -DLTM_DESC -Ic:/path/to/libtommath" EXTRALIBS="-Lc:/path/to/libtommath -ltommath" all
+#
 
-LIBNAME=libtomcrypt.a
-LIBTEST=libtomcrypt_prof.a
+#The following can be overridden from command line e.g. make -f makefile.mingw CC=gcc ARFLAGS=rcs
+DESTDIR   = c:\mingw
+CC        = gcc
+AR        = ar
+ARFLAGS   = r
+RANLIB    = ranlib
+STRIP     = strip
+CFLAGS    = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath
+EXTRALIBS = -L../libtommath -ltommath
 
-HASH=hashsum
-CRYPT=encrypt
-SMALL=small
-PROF=x86_prof
-TV=tv_gen
-TIMING=timing
-TEST=test
+#Compilation flags
+LTC_CFLAGS  = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE
+LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
+VERSION=1.17
 
-#LIBPATH-The directory for libtomcrypt to be installed to.
-#INCPATH-The directory to install the header files for libtomcrypt.
-INSTPREFIX=c:\devel-libtom
-LIBPATH=$(INSTPREFIX)\lib
-INCPATH=$(INSTPREFIX)\include
+#Libraries to be created
+LIBMAIN_S =libtomcrypt.a
+LIBMAIN_I =libtomcrypt.dll.a
+LIBMAIN_D =libtomcrypt.dll
+LIBTEST_S =libtomcrypt_prof.a
 
-#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,30 +187,29 @@ 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
-CRYPTOBJECTS=demos/encrypt.o
-SMALLOBJECTS=demos/small.o
-TVS=demos/tv_gen.o
-TIMINGS=demos/timing.o
-TESTS=demos/test.o
+#The default rule for make builds the libtomcrypt.a library (static)
+default: $(LIBMAIN_S)
 
-#The default rule for make builds the libtomcrypt library.
-default:library
-
-#ciphers come in two flavours... enc+dec and enc
+#SPECIAL: AES comes in two flavours - enc+dec and enc-only
 src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
-	$(CC) $(CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
+	$(CC) $(LTC_CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
 
-#These are the rules to make certain object files.
+#SPECIAL: 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/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c
 src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c
@@ -217,54 +218,70 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22
 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c
 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
 
-.PHONY: testprof/$(LIBTEST)
-testprof/$(LIBTEST):
-	$(MAKE) -C testprof -f makefile.mingw LIBTEST_S=$(LIBTEST) CC=$(CC) LD=$(LD) AR=$(AR) ARFLAGS=$(ARFLAGS) RANLIB=$(RANLIB)
+.c.o:
+	$(CC) $(LTC_CFLAGS) -c $< -o $@
 
-%.o: %.c
-	${CC} ${CFLAGS} -c $< -o $@
+#Create libtomcrypt_prof.a
+$(LIBTEST_S): $(TOBJECTS)
+	$(AR) $(ARFLAGS) $@ $(TOBJECTS)
+	$(RANLIB) $@
 
-$(LIBNAME): $(OBJECTS)
+#Create libtomcrypt.a
+$(LIBMAIN_S): $(OBJECTS)
 	$(AR) $(ARFLAGS) $@ $(OBJECTS)
 	$(RANLIB) $@
 
-#This rule makes the hash program included with libtomcrypt
-hashsum: library $(HASHOBJECTS)
-	$(CC) $(HASHOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(HASH) $(WARN)
+#Create DLL + import library libtomcrypt.dll.a
+$(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS)
+	$(CC) -s -shared -o $(LIBMAIN_D) $^ -Wl,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBMAIN_I) $(LTC_LDFLAGS)
+	$(STRIP) -S $(LIBMAIN_D)
 
-#makes the crypt program
-crypt: library $(CRYPTOBJECTS)
-	$(CC) $(CRYPTOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(CRYPT) $(WARN)
+#Demo tools/utilities
+hashsum.exe: demos/hashsum.o $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
+ltcrypt.exe: demos/ltcrypt.o $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
+small.exe: demos/small.o $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
+tv_gen.exe: demos/tv_gen.o $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 
-#makes the small program
-small: library $(SMALLOBJECTS)
-	$(CC) $(SMALLOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(SMALL) $(WARN)
+#Tests + timing tests
+timing.exe: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
+	@echo NOTICE: start the tests by: timing.exe
+test.exe: demos/test.o $(LIBTEST_S) $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
+	@echo NOTICE: start the tests by: test.exe
 
-tv_gen: library $(TVS)
-	$(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
+all: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) hashsum.exe ltcrypt.exe small.exe tv_gen.exe timing.exe test.exe
 
-timing: library testprof/$(LIBTEST) $(TIMINGS)
-	$(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
+test: test.exe
 
-.PHONY: test
-test: library testprof/$(LIBTEST) $(TESTS)
-	$(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
-
-all_test: test tv_gen hashsum crypt small timing
+clean:
+	@cmd /c del /Q *_tv.txt 2>nul
+	@cmd /c del /Q /S *.o *.a *.exe *.dll 2>nul
 
-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)"
+#Install the library + headers
+install: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S)
+	cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin"
+	cmd /c if not exist "$(DESTDIR)\lib" mkdir "$(DESTDIR)\lib"
+	cmd /c if not exist "$(DESTDIR)\include" mkdir "$(DESTDIR)\include"
+	copy /Y $(LIBMAIN_S) "$(DESTDIR)\lib"
+	copy /Y $(LIBMAIN_I) "$(DESTDIR)\lib"
+	copy /Y $(LIBMAIN_D) "$(DESTDIR)\bin"
+	copy /Y src\headers\tomcrypt*.h "$(DESTDIR)\include"
 
-install_test: testprof/$(LIBTEST)
-	cmd /c if not exist "$(DESTDIR)$(LIBPATH)" mkdir "$(DESTDIR)$(LIBPATH)"
-	copy /Y testprof\$(LIBTEST) "$(DESTDIR)$(LIBPATH)"
+#Install useful tools
+install_bins: hashsum
+	cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin"
+	copy /Y hashsum.exe "$(DESTDIR)\bin"
 
-clean:
-	cmd /c del /Q /S *.o *.a *.exe
-	$(MAKE) -C testprof -f makefile.mingw clean
+#Install documentation
+install_docs: doc/crypt.pdf
+	cmd /c if not exist "$(DESTDIR)\doc" mkdir "$(DESTDIR)\doc"
+	copy /Y doc\crypt.pdf "$(DESTDIR)\doc"

+ 96 - 33
makefile.msvc

@@ -1,14 +1,34 @@
+# MAKEFILE for MS Windows (nmake + Windows SDK)
 #
-# open a command prompt with WinSDK variables set
-# and start: nmake -f makefile.msvc
+# BEWARE: variables OBJECTS, TOBJECTS, HEADERS, VERSION are updated via ./updatemakes.sh
+
+### USAGE:
+# Open a command prompt with WinSDK variables set and start:
+#
+# nmake -f makefile.msvc all
+# test.exe
+# nmake -f makefile.msvc DESTDIR=c:\devel\libtom install
+#
+#Or:
+#
+# nmake -f makefile.msvc CFLAGS="/DUSE_LTM /DLTM_DESC /Ic:\path\to\libtommath" EXTRALIBS=c:\path\to\libtommath\tommath.lib all
 #
 
-EXTRALIBS=../libtommath/tommath.lib
-EXTRAINCLUDE=../libtommath
+#The following can be overridden from command line e.g. make -f makefile.msvc CC=gcc ARFLAGS=rcs
+DESTDIR   = c:\devel
+CFLAGS    = /Ox /DUSE_LTM /DLTM_DESC /I../libtommath
+EXTRALIBS = ../libtommath/tommath.lib
 
-CFLAGS = /nologo /Isrc/headers/ /I$(EXTRAINCLUDE) /Itestprof/ /Ox /D_CRT_SECURE_NO_WARNINGS /DUSE_LTM /DLTM_DESC /DLTC_SOURCE /DLTC_NO_PROTOTYPES /W3 $(CF)
+#Compilation flags
+LTC_CFLAGS  = $(CFLAGS) /nologo /Isrc/headers/ /Itestprof/ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /DLTC_SOURCE /W3
+LTC_LDFLAGS = advapi32.lib $(EXTRALIBS)
+VERSION=1.17
 
-#START_INS
+#Libraries to be created (this makefile builds only static libraries)
+LIBMAIN_S =tomcrypt.lib
+LIBTEST_S =tomcrypt_prof.lib
+
+#List of objects to compile (all goes to tomcrypt.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,47 +180,90 @@ 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 tomcrypt_prof.lib)
+TOBJECTS=testprof/base64_test.obj testprof/cipher_hash_test.obj testprof/der_tests.obj testprof/dh_test.obj \
+testprof/dsa_test.obj testprof/ecc_test.obj testprof/file_test.obj testprof/katja_test.obj testprof/mac_test.obj \
+testprof/misc_test.obj testprof/modes_test.obj testprof/multi_test.obj testprof/no_prng.obj \
+testprof/pkcs_1_eme_test.obj testprof/pkcs_1_emsa_test.obj testprof/pkcs_1_oaep_test.obj \
+testprof/pkcs_1_pss_test.obj testprof/pkcs_1_test.obj testprof/rotate_test.obj testprof/rsa_test.obj \
+testprof/store_test.obj testprof/test_driver.obj testprof/x86_prof.obj
+
+#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
+#The default rule for make builds the tomcrypt.lib library (static)
+default: $(LIBMAIN_S)
 
-default: library
+#SPECIAL: AES comes in two flavours - enc+dec and enc-only
+src/ciphers/aes/aes_enc.obj: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
+	$(CC) $(LTC_CFLAGS) /DENCRYPT_ONLY /c src/ciphers/aes/aes.c /Fosrc/ciphers/aes/aes_enc.obj
 
-.c.obj:
-	$(CC) $(CFLAGS) /c $< /Fo$@
+#SPECIAL: these are the rules to make certain object files
+src/ciphers/aes/aes.obj: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
+src/ciphers/twofish/twofish.obj: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c
+src/hashes/whirl/whirl.obj: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c
+src/hashes/sha2/sha512.obj: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c
+src/hashes/sha2/sha512_224.obj: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_224.c
+src/hashes/sha2/sha512_256.obj: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c
+src/hashes/sha2/sha256.obj: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
 
-#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
+#Dependencies on *.h
+$(OBJECTS): $(HEADERS)
+$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h
+
+.c.obj:
+	$(CC) $(LTC_CFLAGS) /c $< /Fo$@
 
-library: $(OBJECTS)
-	lib /out:tomcrypt.lib $(OBJECTS)
-	cd testprof
-	nmake -f makefile.msvc
-	cd ..
+#Create tomcrypt_prof.lib
+$(LIBTEST_S): $(TOBJECTS)
+	lib /out:$(LIBTEST_S) $(TOBJECTS)
 
-tv_gen: demos/tv_gen.c library
-	cl $(CFLAGS) demos/tv_gen.c tomcrypt.lib advapi32.lib $(EXTRALIBS)
+#Create tomcrypt.lib
+$(LIBMAIN_S): $(OBJECTS)
+	lib /out:$(LIBMAIN_S) $(OBJECTS)
 
-hashsum: demos/hashsum.c library
-	cl $(CFLAGS) demos/hashsum.c tomcrypt.lib advapi32.lib $(EXTRALIBS)
+#Demo tools/utilities
+hashsum.exe: demos/hashsum.c $(LIBMAIN_S)
+	cl $(LTC_CFLAGS) demos/hashsum.c $(LIBMAIN_S) $(LTC_LDFLAGS)
+ltcrypt.exe: demos/ltcrypt.c $(LIBMAIN_S)
+	cl $(LTC_CFLAGS) demos/ltcrypt.c $(LIBMAIN_S) $(LTC_LDFLAGS)
+small.exe: demos/small.c $(LIBMAIN_S)
+	cl $(LTC_CFLAGS) demos/small.c $(LIBMAIN_S) $(LTC_LDFLAGS)
+tv_gen.exe: demos/tv_gen.c $(LIBMAIN_S)
+	cl $(LTC_CFLAGS) demos/tv_gen.c $(LIBMAIN_S) $(LTC_LDFLAGS)
 
-.PHONY: test
-test: demos/test.c library
-	cl $(CFLAGS) demos/test.c testprof/tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS)
+#Tests + timing tests
+timing.exe: demos/timing.c $(LIBMAIN_S) $(LIBTEST_S)
+	cl $(LTC_CFLAGS) demos/timing.c $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS)
+test.exe: demos/test.c $(LIBMAIN_S) $(LIBTEST_S)
+	cl $(LTC_CFLAGS) demos/test.c $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS)
 
-timing: demos/timing.c library
-	cl $(CFLAGS) demos/timing.c testprof/tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS)
+all: $(LIBMAIN_S) $(LIBTEST_S) hashsum.exe ltcrypt.exe small.exe tv_gen.exe timing.exe test.exe
 
-all_test: test tv_gen hashsum timing
+test: test.exe
 
 clean:
-	cmd /c del /Q /S *.OBJ *.LIB *.EXE
+	@cmd /c del /Q *_tv.txt 2>nul
+	@cmd /c del /Q /S *.OBJ *.LIB *.EXE *.DLL 2>nul
+
+#Install the library + headers
+install: $(LIBMAIN_S) $(LIBTEST_S)
+	cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin"
+	cmd /c if not exist "$(DESTDIR)\lib" mkdir "$(DESTDIR)\lib"
+	cmd /c if not exist "$(DESTDIR)\include" mkdir "$(DESTDIR)\include"
+	copy /Y $(LIBMAIN_S) "$(DESTDIR)\lib"
+	copy /Y src\headers\tomcrypt*.h "$(DESTDIR)\include"
+
+#Install useful tools
+install_bins: hashsum
+	cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin"
+	copy /Y hashsum.exe "$(DESTDIR)\bin"
 
-# $Source$
-# $Revision$
-# $Date$
+#Install documentation
+install_docs: doc/crypt.pdf
+	cmd /c if not exist "$(DESTDIR)\doc" mkdir "$(DESTDIR)\doc"
+	copy /Y doc\crypt.pdf "$(DESTDIR)\doc"

+ 28 - 216
makefile.shared

@@ -4,258 +4,70 @@
 #
 # Thanks to Zed Shaw for helping debug this on BSD/OSX.
 # Tom St Denis
-
-include makefile.include
-
-# The version
-# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-VERSION=0:117
-
-
-LT ?= libtool
+#
+#  (GNU make only)
+
+ifndef LT
+  ifeq ($(PLATFORM), Darwin)
+    LT:=glibtool
+  else
+    LT:=libtool
+  endif
+endif
 LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC)
-
+INSTALL_CMD = $(LT) --mode=install install
 
 #Output filenames for various targets.
-ifndef LIBTEST_S
-   LIBTEST_S=libtomcrypt_prof.a
-endif
 ifndef LIBTEST
    LIBTEST=libtomcrypt_prof.la
 endif
 ifndef LIBNAME
    LIBNAME=libtomcrypt.la
 endif
-ifndef LIBNAME_S
-   LIBNAME_S=libtomcrypt.a
-endif
 
-#List of objects to compile.
-#START_INS
-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 \
-src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \
-src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_add_aad.o \
-src/encauth/ccm/ccm_add_nonce.o src/encauth/ccm/ccm_done.o src/encauth/ccm/ccm_init.o \
-src/encauth/ccm/ccm_memory.o src/encauth/ccm/ccm_process.o src/encauth/ccm/ccm_reset.o \
-src/encauth/ccm/ccm_test.o src/encauth/chachapoly/chacha20poly1305_add_aad.o \
-src/encauth/chachapoly/chacha20poly1305_decrypt.o src/encauth/chachapoly/chacha20poly1305_done.o \
-src/encauth/chachapoly/chacha20poly1305_encrypt.o src/encauth/chachapoly/chacha20poly1305_init.o \
-src/encauth/chachapoly/chacha20poly1305_memory.o src/encauth/chachapoly/chacha20poly1305_setiv.o \
-src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.o \
-src/encauth/chachapoly/chacha20poly1305_test.o src/encauth/eax/eax_addheader.o \
-src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \
-src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \
-src/encauth/eax/eax_init.o src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o \
-src/encauth/gcm/gcm_add_iv.o src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o \
-src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_mult_h.o \
-src/encauth/gcm/gcm_process.o src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o \
-src/encauth/ocb/ocb_decrypt.o src/encauth/ocb/ocb_decrypt_verify_memory.o \
-src/encauth/ocb/ocb_done_decrypt.o src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \
-src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \
-src/encauth/ocb/ocb_shift_xor.o src/encauth/ocb/ocb_test.o src/encauth/ocb/s_ocb_done.o \
-src/encauth/ocb3/ocb3_add_aad.o src/encauth/ocb3/ocb3_decrypt.o src/encauth/ocb3/ocb3_decrypt_last.o \
-src/encauth/ocb3/ocb3_decrypt_verify_memory.o src/encauth/ocb3/ocb3_done.o \
-src/encauth/ocb3/ocb3_encrypt.o src/encauth/ocb3/ocb3_encrypt_authenticate_memory.o \
-src/encauth/ocb3/ocb3_encrypt_last.o src/encauth/ocb3/ocb3_init.o \
-src/encauth/ocb3/ocb3_int_aad_add_block.o src/encauth/ocb3/ocb3_int_calc_offset_zero.o \
-src/encauth/ocb3/ocb3_int_ntz.o src/encauth/ocb3/ocb3_int_xor_blocks.o src/encauth/ocb3/ocb3_test.o \
-src/hashes/blake2b.o src/hashes/blake2s.o src/hashes/chc/chc.o src/hashes/helper/hash_file.o \
-src/hashes/helper/hash_filehandle.o src/hashes/helper/hash_memory.o \
-src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o src/hashes/md5.o \
-src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o src/hashes/sha1.o \
-src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o src/hashes/sha2/sha512.o \
-src/hashes/sha2/sha512_224.o src/hashes/sha2/sha512_256.o src/hashes/sha3.o src/hashes/sha3_test.o \
-src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/blake2/blake2bmac.o \
-src/mac/blake2/blake2bmac_file.o src/mac/blake2/blake2bmac_memory.o \
-src/mac/blake2/blake2bmac_memory_multi.o src/mac/blake2/blake2bmac_test.o src/mac/blake2/blake2smac.o \
-src/mac/blake2/blake2smac_file.o src/mac/blake2/blake2smac_memory.o \
-src/mac/blake2/blake2smac_memory_multi.o src/mac/blake2/blake2smac_test.o src/mac/f9/f9_done.o \
-src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \
-src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \
-src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \
-src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \
-src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \
-src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \
-src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \
-src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
-src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \
-src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/poly1305/poly1305.o \
-src/mac/poly1305/poly1305_file.o src/mac/poly1305/poly1305_memory.o \
-src/mac/poly1305/poly1305_memory_multi.o src/mac/poly1305/poly1305_test.o src/mac/xcbc/xcbc_done.o \
-src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \
-src/mac/xcbc/xcbc_memory_multi.o src/mac/xcbc/xcbc_process.o src/mac/xcbc/xcbc_test.o \
-src/math/fp/ltc_ecc_fp_mulmod.o src/math/gmp_desc.o src/math/ltm_desc.o src/math/multi.o \
-src/math/rand_bn.o src/math/rand_prime.o src/math/tfm_desc.o src/misc/adler32.o \
-src/misc/base64/base64_decode.o src/misc/base64/base64_encode.o src/misc/burn_stack.o src/misc/crc32.o \
-src/misc/crypt/crypt.o src/misc/crypt/crypt_argchk.o src/misc/crypt/crypt_cipher_descriptor.o \
-src/misc/crypt/crypt_cipher_is_valid.o src/misc/crypt/crypt_constants.o \
-src/misc/crypt/crypt_find_cipher.o src/misc/crypt/crypt_find_cipher_any.o \
-src/misc/crypt/crypt_find_cipher_id.o src/misc/crypt/crypt_find_hash.o \
-src/misc/crypt/crypt_find_hash_any.o src/misc/crypt/crypt_find_hash_id.o \
-src/misc/crypt/crypt_find_hash_oid.o src/misc/crypt/crypt_find_prng.o src/misc/crypt/crypt_fsa.o \
-src/misc/crypt/crypt_hash_descriptor.o src/misc/crypt/crypt_hash_is_valid.o \
-src/misc/crypt/crypt_inits.o src/misc/crypt/crypt_ltc_mp_descriptor.o \
-src/misc/crypt/crypt_prng_descriptor.o src/misc/crypt/crypt_prng_is_valid.o \
-src/misc/crypt/crypt_prng_rng_descriptor.o src/misc/crypt/crypt_register_cipher.o \
-src/misc/crypt/crypt_register_hash.o src/misc/crypt/crypt_register_prng.o src/misc/crypt/crypt_sizes.o \
-src/misc/crypt/crypt_unregister_cipher.o src/misc/crypt/crypt_unregister_hash.o \
-src/misc/crypt/crypt_unregister_prng.o src/misc/error_to_string.o src/misc/hkdf/hkdf.o \
-src/misc/hkdf/hkdf_test.o src/misc/mem_neq.o src/misc/pk_get_oid.o src/misc/pkcs5/pkcs_5_1.o \
-src/misc/pkcs5/pkcs_5_2.o src/misc/pkcs5/pkcs_5_test.o src/misc/zeromem.o src/modes/cbc/cbc_decrypt.o \
-src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o src/modes/cbc/cbc_getiv.o \
-src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o src/modes/cfb/cfb_decrypt.o \
-src/modes/cfb/cfb_done.o src/modes/cfb/cfb_encrypt.o src/modes/cfb/cfb_getiv.o \
-src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o src/modes/ctr/ctr_decrypt.o \
-src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o src/modes/ctr/ctr_getiv.o \
-src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o src/modes/ctr/ctr_test.o \
-src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \
-src/modes/ecb/ecb_start.o src/modes/f8/f8_decrypt.o src/modes/f8/f8_done.o src/modes/f8/f8_encrypt.o \
-src/modes/f8/f8_getiv.o src/modes/f8/f8_setiv.o src/modes/f8/f8_start.o src/modes/f8/f8_test_mode.o \
-src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o src/modes/lrw/lrw_encrypt.o \
-src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o src/modes/lrw/lrw_setiv.o \
-src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \
-src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \
-src/modes/ofb/ofb_start.o src/modes/xts/xts_decrypt.o src/modes/xts/xts_done.o \
-src/modes/xts/xts_encrypt.o src/modes/xts/xts_init.o src/modes/xts/xts_mult_x.o \
-src/modes/xts/xts_test.o src/pk/asn1/der/bit/der_decode_bit_string.o \
-src/pk/asn1/der/bit/der_decode_raw_bit_string.o src/pk/asn1/der/bit/der_encode_bit_string.o \
-src/pk/asn1/der/bit/der_encode_raw_bit_string.o src/pk/asn1/der/bit/der_length_bit_string.o \
-src/pk/asn1/der/boolean/der_decode_boolean.o src/pk/asn1/der/boolean/der_encode_boolean.o \
-src/pk/asn1/der/boolean/der_length_boolean.o src/pk/asn1/der/choice/der_decode_choice.o \
-src/pk/asn1/der/generalizedtime/der_decode_generalizedtime.o \
-src/pk/asn1/der/generalizedtime/der_encode_generalizedtime.o \
-src/pk/asn1/der/generalizedtime/der_length_generalizedtime.o \
-src/pk/asn1/der/ia5/der_decode_ia5_string.o src/pk/asn1/der/ia5/der_encode_ia5_string.o \
-src/pk/asn1/der/ia5/der_length_ia5_string.o src/pk/asn1/der/integer/der_decode_integer.o \
-src/pk/asn1/der/integer/der_encode_integer.o src/pk/asn1/der/integer/der_length_integer.o \
-src/pk/asn1/der/object_identifier/der_decode_object_identifier.o \
-src/pk/asn1/der/object_identifier/der_encode_object_identifier.o \
-src/pk/asn1/der/object_identifier/der_length_object_identifier.o \
-src/pk/asn1/der/octet/der_decode_octet_string.o src/pk/asn1/der/octet/der_encode_octet_string.o \
-src/pk/asn1/der/octet/der_length_octet_string.o \
-src/pk/asn1/der/printable_string/der_decode_printable_string.o \
-src/pk/asn1/der/printable_string/der_encode_printable_string.o \
-src/pk/asn1/der/printable_string/der_length_printable_string.o \
-src/pk/asn1/der/sequence/der_decode_sequence_ex.o \
-src/pk/asn1/der/sequence/der_decode_sequence_flexi.o \
-src/pk/asn1/der/sequence/der_decode_sequence_multi.o \
-src/pk/asn1/der/sequence/der_decode_subject_public_key_info.o \
-src/pk/asn1/der/sequence/der_encode_sequence_ex.o \
-src/pk/asn1/der/sequence/der_encode_sequence_multi.o \
-src/pk/asn1/der/sequence/der_encode_subject_public_key_info.o \
-src/pk/asn1/der/sequence/der_length_sequence.o src/pk/asn1/der/sequence/der_sequence_free.o \
-src/pk/asn1/der/sequence/der_sequence_shrink.o src/pk/asn1/der/set/der_encode_set.o \
-src/pk/asn1/der/set/der_encode_setof.o src/pk/asn1/der/short_integer/der_decode_short_integer.o \
-src/pk/asn1/der/short_integer/der_encode_short_integer.o \
-src/pk/asn1/der/short_integer/der_length_short_integer.o \
-src/pk/asn1/der/teletex_string/der_decode_teletex_string.o \
-src/pk/asn1/der/teletex_string/der_length_teletex_string.o \
-src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \
-src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \
-src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \
-src/pk/dh/dh.o src/pk/dh/dh_static.o src/pk/dh/dh_sys.o src/pk/dsa/dsa_decrypt_key.o \
-src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o src/pk/dsa/dsa_import.o \
-src/pk/dsa/dsa_import_radix.o src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_shared_secret.o \
-src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o \
-src/pk/ecc/ecc_ansi_x963_export.o src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o \
-src/pk/ecc/ecc_encrypt_key.o src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o \
-src/pk/ecc/ecc_import.o src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o \
-src/pk/ecc/ecc_sign_hash.o src/pk/ecc/ecc_sizes.o src/pk/ecc/ecc_test.o src/pk/ecc/ecc_verify_hash.o \
-src/pk/ecc/ltc_ecc_is_valid_idx.o src/pk/ecc/ltc_ecc_map.o src/pk/ecc/ltc_ecc_mul2add.o \
-src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \
-src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \
-src/pk/katja/katja_decrypt_key.o src/pk/katja/katja_encrypt_key.o src/pk/katja/katja_export.o \
-src/pk/katja/katja_exptmod.o src/pk/katja/katja_free.o src/pk/katja/katja_import.o \
-src/pk/katja/katja_make_key.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \
-src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \
-src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \
-src/pk/pkcs1/pkcs_1_v1_5_encode.o src/pk/rsa/rsa_decrypt_key.o src/pk/rsa/rsa_encrypt_key.o \
-src/pk/rsa/rsa_export.o src/pk/rsa/rsa_exptmod.o src/pk/rsa/rsa_free.o src/pk/rsa/rsa_get_size.o \
-src/pk/rsa/rsa_import.o src/pk/rsa/rsa_import_radix.o src/pk/rsa/rsa_import_x509.o \
-src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_sign_hash.o src/pk/rsa/rsa_sign_saltlen_get.o \
-src/pk/rsa/rsa_verify_hash.o src/prngs/chacha20.o src/prngs/fortuna.o src/prngs/rc4.o \
-src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o src/prngs/sprng.o \
-src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \
-src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \
-src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o \
-src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
-src/stream/sober128/sober128_test.o
 
-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
+include makefile_include.mk
 
-#END_INS
-
-#The default rule for make builds the libtomcrypt library.
-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
-
-#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/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c
-src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c
-src/hashes/sha2/sha512.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c
-src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_224.c
-src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c
-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) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) LT=$(LT) CC="$(CC)" make -f makefile.shared
+	$(LTCOMPILE) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
 
 .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) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) `find ./src -type f -name "*.lo"` $(EXTRALIBS) -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
+$(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_test: testprof/$(LIBTEST)
-	install -d $(DESTDIR)$(LIBPATH)
-	install -d $(DESTDIR)$(INCPATH)
-	cd testprof ; CFLAGS="$(CFLAGS)" VERSION=$(VERSION) LIBPATH=$(LIBPATH) LIBTEST=$(LIBTEST) LIBTEST_S=$(LIBTEST_S) DESTDIR=$(DESTDIR) LT=$(LT) CC=$(CC) make -f makefile.shared install
+install: .common_install
+	sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > libtomcrypt.pc
+	install -d $(LIBPATH)/pkgconfig
+	install -m 644 libtomcrypt.pc $(LIBPATH)/pkgconfig/
 
+install_bins: .common_install_bins
 
-.PHONY: test
-test: library testprof/$(LIBTEST) $(TESTS)
-	$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS)
+install_test: .common_install_test
 
-timing: library testprof/$(LIBTEST) $(TIMINGS)
-	$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS)
+test: $(LIBNAME) $(LIBTEST) $(TESTS)
+	$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TEST) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS)
 
+timing: $(LIBNAME) $(LIBTEST) $(TIMINGS)
+	$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $(TIMING) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS)
 
 # build the demos from a template
 define DEMO_template
-$(1): demos/$(1).o library
+$(1): demos/$(1).o $$(LIBNAME)
 ifneq ($V,1)
 	@echo "   * $${CC} $$@"
 endif
-	$$(LT) --mode=link --tag=CC $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(LDFLAGS) -o $(1) $$< $$(LIBNAME) $$(EXTRALIBS)
+	$$(LT) --mode=link --tag=CC $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(LDFLAGS) $$^ $$(EXTRALIBS) -o $(1)
 endef
 
 $(foreach demo, $(strip $(DEMOS)), $(eval $(call DEMO_template,$(demo))))
 
-all_test: test tv_gen $(DEMOS)
-
 # $Source$
 # $Revision$
 # $Date$

+ 104 - 99
makefile.unix

@@ -1,44 +1,46 @@
-# MAKEFILE for bsd make
+# MAKEFILE that is intended to be compatible with any kind of make (GNU make, BSD make, ...)
+# works on: Linux, *BSD, Cygwin, AIX, HP-UX and hopefully other UNIX systems
 #
-# Tom St Denis
-
-# Compiler and Linker Names
-CC=cc
-LD=ld
-
-# Archiver [makes .a files]
-AR=ar
-ARFLAGS=r
-
-# 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
-LIBTEST_S=$(LIBTEST)
+# Please do not use here neither any special make syntax nor any unusual tools/utilities!
+#
+# BEWARE: variables OBJECTS, TOBJECTS, HEADERS, VERSION are updated via ./updatemakes.sh
 
-HASH=hashsum
-CRYPT=encrypt
-SMALL=small
-PROF=x86_prof
-TV=tv_gen
-TIMING=timing
-TEST=test
+### USAGE:
+#
+# make -f makefile.unix all
+# ./test
+# make -f makefile.unix install
+#
+#Or:
+#
+# make -f makefile.unix CFLAGS="-O3 -DUSE_LTM -DLTM_DESC -I/path/to/libtommath" EXTRALIBS=/path/to/libtommath/libtommath.a all
+# ./test
+# make -f makefile.unix DESTDIR=/opt/libtom install
+#
+#Or if you are using Intel C compiler you might need something like:
+#
+# make -f makefile.unix CC=icc AR=xiar CFLAGS="-fast -DUSE_LTM -DLTM_DESC -I/path/to/libtommath" EXTRALIBS=/path/to/libtommath/libtommath.a all
+#
 
-#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.
-LIBPATH=/usr/local/lib
-INCPATH=/usr/local/include
-DATAPATH=/usr/local/share/doc/libtomcrypt/pdf
+#The following can be overridden from command line e.g. "make -f makefile.unix CC=gcc ARFLAGS=rcs"
+DESTDIR   = /usr/local
+CC        = cc
+AR        = ar
+ARFLAGS   = r
+RANLIB    = ranlib
+CFLAGS    = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath
+EXTRALIBS = ../libtommath/libtommath.a
 
-#Who do we install as?
-USER=root
+#Compilation flags
+LTC_CFLAGS  = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE
+LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
+VERSION=1.17
 
-GROUP=wheel
+#Libraries to be created (this makefile builds only static libraries)
+LIBMAIN_S =libtomcrypt.a
+LIBTEST_S =libtomcrypt_prof.a
 
-#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,36 +192,29 @@ 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
-
-TESTOBJECTS=demos/test.o
-HASHOBJECTS=demos/hashsum.o
-CRYPTOBJECTS=demos/encrypt.o
-SMALLOBJECTS=demos/small.o
-TVS=demos/tv_gen.o
-TIMINGS=demos/timing.o
-TESTS=demos/test.o
-
-#Files left over from making the crypt.pdf.
-LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out
+src/headers/tomcrypt_prng.h
 
-#Compressed filenames
-COMPRESSED=crypt-$(VERSION).tar.bz2 crypt-$(VERSION).zip
+#The default rule for make builds the libtomcrypt.a library (static)
+default: $(LIBMAIN_S)
 
-#The default rule for make builds the libtomcrypt library.
-default:library
-
-#ciphers come in two flavours... enc+dec and enc
+#SPECIAL: AES comes in two flavours - enc+dec and enc-only
 src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
-	$(CC) $(CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
+	$(CC) $(LTC_CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
 
-#These are the rules to make certain object files.
+#SPECIAL: 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/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c
 src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c
@@ -228,56 +223,66 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22
 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c
 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
 
-.PHONY: testprof/$(LIBTEST)
-testprof/$(LIBTEST):
-	cd testprof ; CFLAGS="$(CFLAGS)" LIBTEST_S=$(LIBTEST_S) CC="$(CC)" LD="$(LD)" AR="$(AR)" RANLIB="$(RANLIB)" $(MAKE)
+#This is necessary for compatibility with BSD make (namely on OpenBSD)
+.SUFFIXES: .o .c
+.c.o:
+	$(CC) $(LTC_CFLAGS) -c $< -o $@
 
-$(LIBNAME): $(OBJECTS)
-	$(AR) $(ARFLAGS) $@ $(OBJECTS)
+#Create libtomcrypt_prof.a
+$(LIBTEST_S): $(TOBJECTS)
+	$(AR) $(ARFLAGS) $@ $(TOBJECTS)
 	$(RANLIB) $@
 
-#This rule makes the hash program included with libtomcrypt
-hashsum: library $(HASHOBJECTS)
-	$(CC) $(HASHOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(HASH) $(WARN)
-
-#makes the crypt program
-crypt: library $(CRYPTOBJECTS)
-	$(CC) $(CRYPTOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(CRYPT) $(WARN)
+#Create libtomcrypt.a
+$(LIBMAIN_S): $(OBJECTS)
+	$(AR) $(ARFLAGS) $@ $(OBJECTS)
+	$(RANLIB) $@
 
-#makes the small program
-small: library $(SMALLOBJECTS)
-	$(CC) $(SMALLOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(SMALL) $(WARN)
-	
-tv_gen: library $(TVS)
-	$(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
+#Demo tools/utilities
+hashsum: demos/hashsum.o $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
+ltcrypt: demos/ltcrypt.o $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
+small: demos/small.o $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
+tv_gen: demos/tv_gen.o $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
 
-timing: library testprof/$(LIBTEST) $(TIMINGS)
-	$(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
+#Tests + timing tests
+timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
+	@echo "NOTICE: start the timing tests by: ./timing"
+test: demos/test.o $(LIBTEST_S) $(LIBMAIN_S)
+	$(CC) $? $(LTC_LDFLAGS) -o $@
+	@echo "NOTICE: start the tests by: ./test"
 
-.PHONY: test
-test: library testprof/$(LIBTEST) $(TESTS)
-	$(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
+all: $(LIBMAIN_S) $(LIBTEST_S) hashsum ltcrypt small tv_gen timing test
 
-all_test: test tv_gen hashsum crypt small timing
+#NOTE: this makefile works also on cygwin, thus we need to delete *.exe
+clean:
+	-@rm -f $(OBJECTS) $(TOBJECTS)
+	-@rm -f $(LIBMAIN_S) $(LIBTEST_S)
+	-@rm -f demos/*.o *_tv.txt
+	-@rm -f test tv_gen hashsum crypt small timing
+	-@rm -f test.exe tv_gen.exe hashsum.exe crypt.exe small.exe timing.exe
 
-#This rule installs the library and the header files. This must be run
-#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 -d -g $(GROUP) -o $(USER) $(DESTDIR)$(DATAPATH)
-	install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH)
-	install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH)
+#Install the library + headers
+install: $(LIBMAIN_S) $(HEADERS)
+	@mkdir -p $(DESTDIR)/include $(DESTDIR)/lib/pkgconfig
+	@cp $(LIBMAIN_S) $(DESTDIR)/lib/
+	@cp $(HEADERS) $(DESTDIR)/include/
+	@sed -e 's,^prefix=.*,prefix=$(DESTDIR),' -e 's,^Version:.*,Version: $(VERSION),' libtomcrypt.pc.in > $(DESTDIR)/lib/pkgconfig/libtomcrypt.pc
 
-install_test: testprof/$(LIBTEST)
-	install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
-	install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
-	install -g $(GROUP) -o $(USER) testprof/$(LIBTEST) $(DESTDIR)$(LIBPATH)
+#Install useful tools
+install_bins: hashsum
+	@mkdir -p $(DESTDIR)/bin
+	@cp hashsum $(DESTDIR)/bin/
 
-# $Source$
-# $Revision$
-# $Date$
+#Install documentation
+install_docs: doc/crypt.pdf
+	@mkdir -p $(DESTDIR)/share/doc/libtomcrypt/pdf
+	@cp doc/crypt.pdf $(DESTDIR)/share/doc/libtomcrypt/pdf/

+ 216 - 147
makefile.icc → makefile_include.mk

@@ -1,103 +1,143 @@
-# MAKEFILE for linux ICC (Intel C compiler)
 #
-# Tested with ICC v8....
-#
-# Be aware that ICC isn't quite as stable as GCC and several optimization switches
-# seem to break the code (that GCC and MSVC compile just fine).  In particular
-# "-ip" and "-x*" seem to break the code (ROL/ROR macro problems).  As the makefile
-# is shipped the code will build and execute properly.
-#
-# Also note that ICC often makes code that is slower than GCC.  This is probably due to
-# a mix of not being able to use "-ip" and just having fewer optimization algos than GCC.
-#
-# Tom St Denis
+# Include makefile used by makefile + makefile.shared
+#  (GNU make only)
+
+# The version - BEWARE: VERSION and VERSION_LT are updated via ./updatemakes.sh
+VERSION=1.17
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+VERSION_LT=0:117
+
+PLATFORM := $(shell uname | sed -e 's/_.*//')
 
 # Compiler and Linker Names
-CC=icc
+ifndef PREFIX
+  PREFIX:=
+endif
 
-#LD=ld
+ifeq ($(CC),cc)
+  CC := $(PREFIX)gcc
+endif
+LD:=$(PREFIX)ld
+AR:=$(PREFIX)ar
 
 # Archiver [makes .a files]
-# With compile option "-ipo" it can be necessary to archive with 'xiar'
 #AR=ar
-#ARFLAGS=r
+ARFLAGS:=r
 
 ifndef MAKE
-  MAKE=make
+  MAKE:=make
+endif
+
+ifndef INSTALL_CMD
+$(error your makefile must define INSTALL_CMD)
 endif
 
+ifndef EXTRALIBS
+ifneq ($(shell echo $(CFLAGS) | grep USE_LTM),)
+EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config libtommath --libs)
+else
+ifneq ($(shell echo $(CFLAGS) | grep USE_TFM),)
+EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config tomsfastmath --libs)
+endif
+endif
+endif
+
+
 # Compilation flags. Note the += does not write over the user's CFLAGS!
-CFLAGS += -c -I./testprof/ -I./src/headers/ -Wall -Wsign-compare -W -Wshadow -Wno-unused-parameter -DLTC_SOURCE
+CFLAGS += -I./src/headers/ -Wall -Wsign-compare -Wshadow -DLTC_SOURCE
 
-#The default rule for make builds the libtomcrypt library.
-default:library
+ifdef OLD_GCC
+CFLAGS += -W
+# older GCCs can't handle the "rotate with immediate" ROLc/RORc/etc macros
+# define this to help
+CFLAGS += -DLTC_NO_ROLC
+else
+CFLAGS += -Wextra
+# additional warnings
+CFLAGS += -Wsystem-headers -Wbad-function-cast -Wcast-align
+CFLAGS += -Wstrict-prototypes -Wpointer-arith
+CFLAGS += -Wdeclaration-after-statement
+endif
 
-# optimize for SPEED
-#
-# -mcpu= can be pentium, pentiumpro (covers PII through PIII) or pentium4
-# -a?	specifies make code specifically for ? but compatible with IA-32
-# -?	   specifies compile solely for ? [not specifically IA-32 compatible]
-#
-# where ? is
-#	mia   - PIII; has only option "-mia32", no "-amia32"
-#	msse2 - first P4 [Willamette]; has only option "-msse2", no "-amsse2"
-#	xSSE2 - P4 Northwood
-#	xSSE3 - P4 Prescott
-#
-# The easiest way - when compiling on one architecture, only for
-# this architecture - is to enable the compiler option "-fast", which enables
-# "all possible" optimizations for this architecture.
-# ICC 14.0.3 20140422 says "-fast" resolves to
-# "-xHOST -O3 -ipo -no-prec-div -static"
-#
-# Default to just generic max opts
-ifdef LTC_SMALL
-CFLAGS += -O1
+CFLAGS += -Wno-type-limits
+
+ifdef LTC_DEBUG
+# compile for DEBUGGING (required for ccmalloc checking!!!)
+ifneq (,$(strip $(LTC_DEBUG)))
+CFLAGS += -g3 -DLTC_NO_ASM -DLTC_TEST_DBG=$(LTC_DEBUG)
+else
+CFLAGS += -g3 -DLTC_NO_ASM -DLTC_TEST_DBG
 endif
+else
+
+ifdef LTC_SMALL
+# optimize for SIZE
+CFLAGS += -Os -DLTC_SMALL_CODE
+else
 
 ifndef IGNORE_SPEED
-CFLAGS += -O3
+# optimize for SPEED
+CFLAGS += -O3 -funroll-loops
+
+# add -fomit-frame-pointer.  hinders debugging!
+CFLAGS += -fomit-frame-pointer
 endif
 
-# want to see stuff?
-#CFLAGS += -opt_report
+endif # COMPILE_SMALL
+endif # COMPILE_DEBUG
 
-#These flags control how the library gets built.
 
-#Output filenames for various targets.
-ifndef LIBNAME
-   LIBNAME=libtomcrypt.a
+ifneq ($(findstring clang,$(CC)),)
+CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare
 endif
-ifndef LIBTEST
-   LIBTEST=libtomcrypt_prof.a
-   LIBTEST_S=$(LIBTEST)
+
+
+GIT_VERSION := $(shell [ -e .git ] && { echo -n git- ; git describe --tags --always --dirty ; } || echo $(VERSION))
+ifneq ($(GIT_VERSION),)
+CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
 endif
-HASH=hashsum
-CRYPT=encrypt
-SMALL=small
-PROF=x86_prof
-TV=tv_gen
+
+
+#List of demo objects
+DSOURCES = $(wildcard demos/*.c)
+DOBJECTS = $(DSOURCES:.c=.o)
+
+#List of testprof headers
+THEADERS = $(wildcard testprof/*.h)
+
 TIMING=timing
 TEST=test
 
-#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
+USEFUL_DEMOS=hashsum
+DEMOS=$(USEFUL_DEMOS) ltcrypt 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.
+#BINPATH  The directory to install the binaries provided.
+DESTDIR  ?= /usr/local
+LIBPATH  ?= $(DESTDIR)/lib
+INCPATH  ?= $(DESTDIR)/include
+DATAPATH ?= $(DESTDIR)/share/doc/libtomcrypt/pdf
+BINPATH  ?= $(DESTDIR)/bin
+
+#Who do we install as?
+ifdef INSTALL_USER
+USER=$(INSTALL_USER)
+else
+USER=root
 endif
-ifndef DATAPATH
-   DATAPATH=/usr/share/doc/libtomcrypt/pdf
+
+ifdef INSTALL_GROUP
+GROUP=$(INSTALL_GROUP)
+else
+GROUP=wheel
 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,41 +289,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
-
-#Who do we install as?
-ifdef INSTALL_USER
-USER=$(INSTALL_USER)
-else
-USER=root
-endif
-
-ifdef INSTALL_GROUP
-GROUP=$(INSTALL_GROUP)
-else
-GROUP=wheel
-endif
-
-#ciphers come in two flavours... enc+dec and enc
-aes_enc.o: aes.c aes_tab.c
-	$(CC) $(CFLAGS) -DENCRYPT_ONLY -c aes.c -o aes_enc.o
-
-HASHOBJECTS=demos/hashsum.o
-CRYPTOBJECTS=demos/encrypt.o
-SMALLOBJECTS=demos/small.o
-TVS=demos/tv_gen.o
-TIMINGS=demos/timing.o
-TESTS=demos/test.o
-
-#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
-	$(CC) $(CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
+src/headers/tomcrypt_prng.h
 
 #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
@@ -294,51 +313,101 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22
 src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c
 src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
 
+
+#The default rule for make builds the libtomcrypt library.
+default:library
+
+$(DOBJECTS): CFLAGS += -Itestprof
+$(TOBJECTS): CFLAGS += -Itestprof
+
 #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
-
-$(LIBNAME): $(OBJECTS)
-	$(AR) $(ARFLAGS) $@ $(OBJECTS)
-	ranlib $@
-
-#This rule makes the hash program included with libtomcrypt
-hashsum: library $(HASHOBJECTS)
-	$(CC) $(HASHOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(HASH) $(WARN)
-
-#makes the crypt program
-crypt: library $(CRYPTOBJECTS)
-	$(CC) $(CRYPTOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(CRYPT) $(WARN)
-
-#makes the small program
-small: library $(SMALLOBJECTS)
-	$(CC) $(SMALLOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(SMALL) $(WARN)
-	
-tv_gen: library $(TVS)
-	$(CC) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
-
-timing: library $(TIMINGS) testprof/$(LIBTEST)
-	$(CC) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
-
-.PHONY: test
-test: library $(TESTS) testprof/$(LIBTEST)
-	$(CC) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
-
-all_test: test tv_gen hashsum crypt small timing
-
-#This rule installs the library and the header files. This must be run
-#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)
-
-# $Source$
-# $Revision$
-# $Date$
+#Dependencies on *.h
+$(OBJECTS): $(HEADERS)
+$(DOBJECTS): $(HEADERS) $(THEADERS)
+$(TOBJECTS): $(HEADERS) $(THEADERS)
+
+bins: $(USEFUL_DEMOS)
+
+all_test: test tv_gen $(DEMOS)
+
+#build the doxy files (requires Doxygen, tetex and patience)
+doxygen doxy docs:
+	$(MAKE) -C doc/ $@ V=$(V)
+
+doc/crypt.pdf:
+	$(MAKE) -C doc/ crypt.pdf V=$(V)
+
+
+install_all: install install_bins install_docs install_test
+
+
+.common_install: $(LIBNAME)
+	install -d $(INCPATH)
+	install -d $(LIBPATH)
+	$(INSTALL_CMD) -m 644 $(LIBNAME) $(LIBPATH)/$(LIBNAME)
+	install -m 644 $(HEADERS) $(INCPATH)
+
+.common_install_bins: $(USEFUL_DEMOS)
+	install -d $(BINPATH)
+	$(INSTALL_CMD) -m 775 $(USEFUL_DEMOS) $(BINPATH)
+
+.common_install_test: $(LIBTEST)
+	install -d $(LIBPATH)
+	install -d $(INCPATH)
+	install -m 644 testprof/tomcrypt_test.h $(INCPATH)
+	$(INSTALL_CMD) -m 644 $(LIBTEST) $(LIBPATH)
+
+install_docs: doc/crypt.pdf
+	install -d $(DATAPATH)
+	install -m 644 doc/crypt.pdf $(DATAPATH)
+
+install_hooks:
+	for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done
+
+#This rule cleans the source tree of all compiled code, not including the pdf
+#documentation.
+clean:
+	find . -type f    -name "*.o"   \
+               -o -name "*.lo"  \
+               -o -name "*.a"   \
+               -o -name "*.la"  \
+               -o -name "*.obj" \
+               -o -name "*.lib" \
+               -o -name "*.exe" \
+               -o -name "*.dll" \
+               -o -name "*.so"  \
+               -o -name "*.gcov"\
+               -o -name "*.gcda"\
+               -o -name "*.gcno"\
+               -o -name "*.il"  \
+               -o -name "*.dyn" \
+               -o -name "*.dpi"  | xargs rm -f
+	rm -f $(TIMING) $(TEST) $(DEMOS)
+	rm -f *_tv.txt
+	rm -f *.pc
+	rm -rf `find . -type d -name "*.libs" | xargs`
+	$(MAKE) -C doc/ clean
+
+zipup: doc/crypt.pdf
+	@# Update the index, so diff-index won't fail in case the pdf has been created.
+	@#   As the pdf creation modifies crypt.tex, git sometimes detects the
+	@#   modified file, but misses that it's put back to its original version.
+	@git update-index --refresh
+	@git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 )
+	@perl helper.pl --check-all || ( echo "FAILURE: helper.pl --check-all errors" && exit 1 )
+	rm -rf libtomcrypt-$(VERSION) crypt-$(VERSION).*
+	@# files/dirs excluded from "git archive" are defined in .gitattributes
+	git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x
+	mkdir -p libtomcrypt-$(VERSION)/doc
+	cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf
+	tar -c libtomcrypt-$(VERSION)/ | xz -6e -c - > crypt-$(VERSION).tar.xz
+	zip -9rq crypt-$(VERSION).zip libtomcrypt-$(VERSION)
+	rm -rf libtomcrypt-$(VERSION)
+	gpg -b -a crypt-$(VERSION).tar.xz
+	gpg -b -a crypt-$(VERSION).zip
+
+codecheck:
+	perl helper.pl -a
+	perlcritic *.pl

+ 0 - 4
mess.sh

@@ -1,4 +0,0 @@
-#!/bin/bash
-if cvs log $1 >/dev/null 2>/dev/null; then exit 0; else echo "$1 shouldn't be here, removed"; rm -f $1 ; fi
-
-

+ 1 - 1
printinfo.sh

@@ -3,7 +3,7 @@
 version=$(git describe --tags --always --dirty 2>/dev/null)
 if [ ! -e ".git" ] || [ -z $version ]
 then
-   version=$(grep "^VERSION=" makefile | sed "s/.*=//")
+   version=$(grep "^VERSION=" makefile_include.mk | sed "s/.*=//")
 fi
 echo "Testing version:" $version
 #grep "VERSION=" makefile | perl -e "@a = split('=', <>); print @a[1];"`

+ 22 - 17
testme.sh

@@ -3,7 +3,8 @@
 if [ $# -lt 3 ]
 then
   echo "usage is: ${0##*/} <which makefile and other make options> <additional defines> <path to math provider>"
-  echo "e.g. \"${0##*/} \"makefile -j3\" \"-DUSE_LTM -DLTM_DESC -I/path/to/libtommath\" /path/to/libtommath/libtommath.a\""
+  echo "e.g. \"${0##*/} \"makefile -j9\" \"-DUSE_LTM -DLTM_DESC -I../libtommath\" ../libtommath/libtommath.a\""
+  echo "to create aggregate coverage: pre-pend with LTC_COVERAGE=1"
   exit -1
 fi
 
@@ -13,53 +14,57 @@ echo "date="`date`
 # check sources
 bash check_source.sh "CHECK_SOURCES" " " "$1" "$2" "$3" || exit 1
 
+mk="$1"
+
+[ "$LTC_COVERAGE" != "" ] && mk="$mk COVERAGE=1"
+
 # stock build
-bash run.sh "STOCK" " " "$1" "$2" "$3" || exit 1
+bash run.sh "STOCK" " " "$mk" "$2" "$3" || exit 1
 
 # EASY build
-bash run.sh "EASY" "-DLTC_EASY" "$1" "$2" "$3" || exit 1
+bash run.sh "EASY" "-DLTC_EASY" "$mk" "$2" "$3" || exit 1
 
 # SMALL code
-bash run.sh "SMALL" "-DLTC_SMALL_CODE" "$1" "$2" "$3" || exit 1
+bash run.sh "SMALL" "-DLTC_SMALL_CODE" "$mk" "$2" "$3" || exit 1
 
 # NOTABLES
-bash run.sh "NOTABLES" "-DLTC_NO_TABLES" "$1" "$2" "$3" || exit 1
+bash run.sh "NOTABLES" "-DLTC_NO_TABLES" "$mk" "$2" "$3" || exit 1
 
 # SMALL+NOTABLES
-bash run.sh "SMALL+NOTABLES" "-DLTC_SMALL_CODE -DLTC_NO_TABLES" "$1" "$2" "$3" || exit 1
+bash run.sh "SMALL+NOTABLES" "-DLTC_SMALL_CODE -DLTC_NO_TABLES" "$mk" "$2" "$3" || exit 1
 
 # CLEANSTACK
-bash run.sh "CLEANSTACK" "-DLTC_CLEAN_STACK" "$1" "$2" "$3" || exit 1
+bash run.sh "CLEANSTACK" "-DLTC_CLEAN_STACK" "$mk" "$2" "$3" || exit 1
 
 # CLEANSTACK + SMALL
-bash run.sh "CLEANSTACK+SMALL" "-DLTC_SMALL_CODE -DLTC_CLEAN_STACK" "$1" "$2" "$3" || exit 1
+bash run.sh "CLEANSTACK+SMALL" "-DLTC_SMALL_CODE -DLTC_CLEAN_STACK" "$mk" "$2" "$3" || exit 1
 
 # CLEANSTACK + NOTABLES
-bash run.sh "CLEANSTACK+NOTABLES" "-DLTC_NO_TABLES -DLTC_CLEAN_STACK" "$1" "$2" "$3" || exit 1
+bash run.sh "CLEANSTACK+NOTABLES" "-DLTC_NO_TABLES -DLTC_CLEAN_STACK" "$mk" "$2" "$3" || exit 1
 
 # CLEANSTACK + NOTABLES + SMALL
-bash run.sh "CLEANSTACK+NOTABLES+SMALL" "-DLTC_NO_TABLES -DLTC_CLEAN_STACK -DLTC_SMALL_CODE" "$1" "$2" "$3" || exit 1
+bash run.sh "CLEANSTACK+NOTABLES+SMALL" "-DLTC_NO_TABLES -DLTC_CLEAN_STACK -DLTC_SMALL_CODE" "$mk" "$2" "$3" || exit 1
 
 # NO_FAST
-bash run.sh "NO_FAST" "-DLTC_NO_FAST" "$1" "$2" "$3" || exit 1
+bash run.sh "NO_FAST" "-DLTC_NO_FAST" "$mk" "$2" "$3" || exit 1
 
 # NO_FAST + NOTABLES
-bash run.sh "NO_FAST+NOTABLES" "-DLTC_NO_FAST -DLTC_NO_TABLES" "$1" "$2" "$3" || exit 1
+bash run.sh "NO_FAST+NOTABLES" "-DLTC_NO_FAST -DLTC_NO_TABLES" "$mk" "$2" "$3" || exit 1
 
 # NO_ASM
-bash run.sh "NO_ASM" "-DLTC_NO_ASM" "$1" "$2" "$3" || exit 1
+bash run.sh "NO_ASM" "-DLTC_NO_ASM" "$mk" "$2" "$3" || exit 1
 
 # NO_TIMING_RESISTANCE
-bash run.sh "NO_TIMING_RESISTANCE" "-DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING" "$1" "$2" "$3" || exit 1
+bash run.sh "NO_TIMING_RESISTANCE" "-DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING" "$mk" "$2" "$3" || exit 1
 
 # CLEANSTACK+NOTABLES+SMALL+NO_ASM+NO_TIMING_RESISTANCE
-bash run.sh "CLEANSTACK+NOTABLES+SMALL+NO_ASM+NO_TIMING_RESISTANCE" "-DLTC_CLEAN_STACK -DLTC_NO_TABLES -DLTC_SMALL_CODE -DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING" "$1" "$2" "$3" || exit 1
+bash run.sh "CLEANSTACK+NOTABLES+SMALL+NO_ASM+NO_TIMING_RESISTANCE" "-DLTC_CLEAN_STACK -DLTC_NO_TABLES -DLTC_SMALL_CODE -DLTC_NO_ECC_TIMING_RESISTANT -DLTC_NO_RSA_BLINDING" "$mk" "$2" "$3" || exit 1
 
 # test build with no testing
-bash testbuild.sh "NOTEST" "-DLTC_NO_TEST" "$1" "$2" "$3" || exit 1
+bash testbuild.sh "NOTEST" "-DLTC_NO_TEST" "$mk" "$2" "$3" || exit 1
 
 # test build with no file routines
-bash testbuild.sh "NOFILE" "-DLTC_NO_FILE" "$1" "$2" "$3" || exit 1
+bash testbuild.sh "NOFILE" "-DLTC_NO_FILE" "$mk" "$2" "$3" || exit 1
 
 # $Source$
 # $Revision$

+ 0 - 43
testprof/makefile

@@ -1,43 +0,0 @@
-CFLAGS += -I../src/headers -I./ -Wall -W
-
-# ranlib tools
-ifndef RANLIB
-   RANLIB=ranlib
-endif
-
-ifeq ($V,1)
-silent=
-else
-silent=@
-endif
-
-%.o: %.c
-ifneq ($V,1)
-	@echo "   * ${CC} $@"
-endif
-	${silent} ${CC} ${CFLAGS} -c $< -o $@
-
-OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o file_test.o             \
-dsa_test.o ecc_test.o mac_test.o misc_test.o modes_test.o pkcs_1_test.o rsa_test.o       \
-store_test.o rotate_test.o test_driver.o x86_prof.o katja_test.o dh_test.o               \
-pkcs_1_pss_test.o pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o multi_test.o
-
-ifndef LIBTEST_S
-   LIBTEST_S=libtomcrypt_prof.a
-endif
-
-default: $(LIBTEST_S)
-
-$(LIBTEST_S): $(OBJECTS)
-ifneq ($V,1)
-	@echo "   * ${AR} $@"
-endif
-	${silent} $(AR) $(ARFLAGS) $@ $(OBJECTS)
-ifneq ($V,1)
-	@echo "   * ${RANLIB} $@"
-endif
-	${silent} $(RANLIB) $@
-
-clean:
-	rm -f *.o *.a *.gcov *.gcda *.gcno
-

+ 0 - 21
testprof/makefile.icc

@@ -1,21 +0,0 @@
-CFLAGS += -I../src/headers -I./
-CC?=icc
-
-OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o file_test.o             \
-dsa_test.o ecc_test.o mac_test.o modes_test.o pkcs_1_test.o rsa_test.o                   \
-store_test.o rotate_test.o test_driver.o x86_prof.o katja_test.o dh_test.o misc_test.o   \
-pkcs_1_pss_test.o pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o multi_test.o
-
-ifndef LIBTEST_S
-   LIBTEST_S = libtomcrypt_prof.a
-endif
-
-default: $(LIBTEST_S)
-
-$(LIBTEST_S): $(OBJECTS)
-	$(AR) $(ARFLAGS) $@ $(OBJECTS)
-	ranlib $@
-
-clean:
-	rm -f *.o *.a
-

+ 0 - 22
testprof/makefile.mingw

@@ -1,22 +0,0 @@
-# MAKEFILE for use with MS Windows gcc compiler + GNU make (aka mingw32-make)
-
-# BEWARE: do not run make from testprof directory, run 'gmake ... test' from libtomcrypt root dir
-
-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 file_test.o             \
-dsa_test.o ecc_test.o mac_test.o misc_test.o modes_test.o pkcs_1_test.o rsa_test.o       \
-store_test.o rotate_test.o test_driver.o x86_prof.o katja_test.o dh_test.o pkcs_1_pss_test.o \
-pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o multi_test.o
-
-default: $(LIBTEST_S)
-
-%.o: %.c
-	${CC} ${CFLAGS} -c $< -o $@
-
-$(LIBTEST_S): $(OBJECTS)
-	$(AR) $(ARFLAGS) $@ $(OBJECTS)
-	$(RANLIB) $@
-
-clean:
-	cmd /c del /Q *.o *.a

+ 0 - 15
testprof/makefile.msvc

@@ -1,15 +0,0 @@
-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 file_test.obj \
-dsa_test.obj ecc_test.obj mac_test.obj modes_test.obj pkcs_1_test.obj \
-rsa_test.obj store_test.obj rotate_test.obj test_driver.obj x86_prof.obj katja_test.obj \
-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 multi_test.obj
-
-.c.obj:
-	$(CC) $(CFLAGS) /c $< /Fo$@
-
-tomcrypt_prof.lib: $(OBJECTS)
-	lib /out:tomcrypt_prof.lib $(OBJECTS)
-
-

+ 0 - 27
testprof/makefile.shared

@@ -1,27 +0,0 @@
-ifeq ($(CC),cc)
-  CC = gcc
-endif
-LT  ?= libtool
-LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC)
-
-CFLAGS += -I../src/headers -I./ -Wall -Wsign-compare -W -Wshadow -Wno-unused-parameter
-
-OBJECTS = base64_test.o cipher_hash_test.o der_tests.o no_prng.o file_test.o             \
-dsa_test.o ecc_test.o mac_test.o modes_test.o pkcs_1_test.o rsa_test.o                   \
-store_test.o rotate_test.o test_driver.o x86_prof.o katja_test.o dh_test.o misc_test.o   \
-pkcs_1_pss_test.o pkcs_1_oaep_test.o pkcs_1_emsa_test.o pkcs_1_eme_test.o
-
-ifndef LIBTEST
-   LIBTEST=libtomcrypt_prof.la
-endif
-
-default: $(LIBTEST)
-
-.c.o:
-	$(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -o $@ -c $<
-
-$(LIBTEST): $(OBJECTS)
-	$(LT) --mode=link --tag=CC $(CC) $(CFLAGS) `find . -type f -name "*.lo"` -o $@ -rpath $(LIBPATH) -version-info $(VERSION)
-
-install: $(LIBTEST)
-	$(LT) --mode=install install -c $(LIBTEST) $(DESTDIR)$(LIBPATH)/$(LIBTEST)

+ 2 - 2
updatemakes.sh

@@ -2,8 +2,8 @@
 
 ./helper.pl --update-makefiles || exit 1
 
-makefiles=(makefile makefile.icc makefile.shared makefile.unix makefile.mingw makefile.msvc)
-vcproj=(libtomcrypt_VS2008.vcproj libtomcrypt_VS2005.vcproj)
+makefiles=(makefile makefile_include.mk makefile.shared makefile.unix makefile.mingw makefile.msvc)
+vcproj=(libtomcrypt_VS2008.vcproj)
 
 if [ $# -eq 1 ] && [ "$1" == "-c" ]; then
   git add ${makefiles[@]} ${vcproj[@]} && git commit -m 'Update makefiles'