The following patch should be applied after all the other patches that I've submitted recently.
I suspect that this whole patch series will result in some debate, and so I intend to make adjustments as issues are brought to light, and then submit a consolidated, refreshed series that includes all of these patches in a more coherent format. Sincerely, Michael Witten To apply this patch, save this email to a file: /path/to/email and then apply it: git am --scissors /path/to/email Here is the scissors-line across which git will cut in order to throw away the text above it. 8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<---- There's a lot going on here that makes it difficult to support out-of-tree builds entirely, but this commit goes a long way: This commit allows for the out-of-tree building of the binaries for Dropbear and for the built-in `libtom{crypto,math}' dependencies. That's basically all users of Dropbear care about. Overall, the key is to ensure that `make' is given good values for the `VPATH' and `srcdir' variables, and then also to use `$(srcdir)' where appropriate. Setting `VPATH' and `scrdir' is as easy as ensuring that the `configure' script is told about the various makefiles, and then including places in those makefiles to be so configured. The irritating part is ensuring that `$(srcdir)' is used appropriately; the only place where this is really a problem is in the makefiles for `libtommath', which were not written in a way that supports out-of-tree building in general (while it does work to build the binaries, it doesn't work to build the ancillary files, such as the documentation). Configure needs to know about the following files (which, at the moment, simply provide for a working `clean' target): libtommath/etc/makefile libtommath/pics/makefile This is achieved by adding them to `configure.ac' as files that need to be configured; unfortunately, this seems to require those files to end with a `.in' extension. To keep the naming consistent, this commit renames each of those files to `Makefile.in'. At this point, neither of those files has been edited to include a place for `configure' to insert a value for `VPATH' or `srcdir'; there are 2 reasons for this: * `git' will better be able to determine that a file has been renamed if it has not been modified at the same time. * The `clean' targets in them work without modification, and the rest of their targets are not useful to the main purpose of this commit: To make it possible to perform out-of-tree building of the *binaries*. So, why not just copy those files into the out-of-tree build directory without modifying those names or telling `configure' about them? Well, because it's probably useful to prepare the way for a possible future commit that does get the rest of the targets working; then it will just be a matter of modifying those files to do the right thing. --- configure.ac | 3 ++- libtomcrypt/Makefile.in | 4 ++-- libtommath/Makefile.in | 7 ++++--- libtommath/etc/{makefile => Makefile.in} | 0 libtommath/pics/{makefile => Makefile.in} | 0 5 files changed, 8 insertions(+), 6 deletions(-) rename libtommath/etc/{makefile => Makefile.in} (100%) rename libtommath/pics/{makefile => Makefile.in} (100%) diff --git a/configure.ac b/configure.ac index 8be542a..0467d7e 100644 --- a/configure.ac +++ b/configure.ac @@ -828,6 +828,7 @@ AS_MKDIR_P(libtomcrypt/src/modes/ecb) AS_MKDIR_P(libtomcrypt/src/modes/ofb) AS_MKDIR_P(libtomcrypt/src/modes/f8) AS_MKDIR_P(libtomcrypt/src/modes/lrw) +AS_MKDIR_P(libtomcrypt/src/modes/xts) AS_MKDIR_P(libtomcrypt/src/pk/asn1/der/bit) AS_MKDIR_P(libtomcrypt/src/pk/asn1/der/boolean) AS_MKDIR_P(libtomcrypt/src/pk/asn1/der/choice) @@ -848,7 +849,7 @@ AS_MKDIR_P(libtomcrypt/src/pk/katja) AS_MKDIR_P(libtomcrypt/src/pk/pkcs1) AS_MKDIR_P(libtomcrypt/src/pk/rsa) AS_MKDIR_P(libtomcrypt/src/prngs) -LIBTOM_FILES="libtomcrypt/Makefile libtommath/Makefile" +LIBTOM_FILES="libtomcrypt/Makefile libtommath/Makefile libtommath/etc/Makefile libtommath/pics/Makefile" fi AC_CONFIG_HEADER(config.h) AC_CONFIG_FILES(Makefile $LIBTOM_FILES) diff --git a/libtomcrypt/Makefile.in b/libtomcrypt/Makefile.in index d8f9a6d..e42b03e 100644 --- a/libtomcrypt/Makefile.in +++ b/libtomcrypt/Makefile.in @@ -8,8 +8,8 @@ VERSION=1.17 PLATFORM := $(shell uname | sed -e 's/_.*//') - -srcdir=. +VPATH=@srcdir@ +srcdir=@srcdir@ # Compiler and Linker Names #CC=gcc diff --git a/libtommath/Makefile.in b/libtommath/Makefile.in index 2fec4ce..1f0280c 100644 --- a/libtommath/Makefile.in +++ b/libtommath/Makefile.in @@ -2,7 +2,8 @@ # #Tom St Denis -srcdir=. +VPATH=@srcdir@ +srcdir=@srcdir@ # So that libtommath can include Dropbear headers for options and m_burn() CFLAGS += -I$(srcdir) -I../libtomcrypt/src/headers/ -I$(srcdir)/../libtomcrypt/src/headers/ -I../ -I$(srcdir)/../ @@ -17,7 +18,7 @@ endif ifneq ($V,1) @echo " * ${CC} $@" endif - ${silent} ${CC} -c ${CFLAGS} $*.c -o $@ + ${silent} ${CC} -c ${CFLAGS} $(filter %.c,$^) -o $@ #default files to install ifndef LIBNAME @@ -26,7 +27,7 @@ endif coverage: LIBNAME:=-Wl,--whole-archive $(LIBNAME) -Wl,--no-whole-archive -include makefile.include +include $(srcdir)/makefile.include LCOV_ARGS=--directory . diff --git a/libtommath/etc/makefile b/libtommath/etc/Makefile.in similarity index 100% rename from libtommath/etc/makefile rename to libtommath/etc/Makefile.in diff --git a/libtommath/pics/makefile b/libtommath/pics/Makefile.in similarity index 100% rename from libtommath/pics/makefile rename to libtommath/pics/Makefile.in -- 2.10.0