From 4cf5a3226da34ffae99854041c552425042041fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Tue, 19 Oct 2004 22:17:48 +0200
Subject: [PATCH] Stop using automake. Replaced each Makefile.am with a
 hand-written Makefile.in. * configure.ac: New output variable CCPIC_MAYBE.
 New output file config.make. Replaced automake constructions.

Rev: src/nettle/Makefile.am:1.81(DEAD)
Rev: src/nettle/Makefile.in:1.1
Rev: src/nettle/configure.ac:1.45
Rev: src/nettle/examples/Makefile.am:1.22(DEAD)
Rev: src/nettle/examples/Makefile.in:1.1
Rev: src/nettle/testsuite/Makefile.am:1.42(DEAD)
Rev: src/nettle/testsuite/Makefile.in:1.1
Rev: src/nettle/tools/Makefile.am:1.8(DEAD)
Rev: src/nettle/tools/Makefile.in:1.1
---
 Makefile.am           | 175 -----------------
 Makefile.in           | 442 +++++++++++++++++++++++++-----------------
 configure.ac          |  24 ++-
 examples/Makefile.am  |  33 ----
 examples/Makefile.in  |  72 +++++++
 testsuite/Makefile.am |  44 -----
 testsuite/Makefile.in |  85 ++++++++
 tools/Makefile.am     |  23 ---
 tools/Makefile.in     |  69 +++++++
 9 files changed, 504 insertions(+), 463 deletions(-)
 delete mode 100644 Makefile.am
 delete mode 100644 examples/Makefile.am
 create mode 100644 examples/Makefile.in
 delete mode 100644 testsuite/Makefile.am
 create mode 100644 testsuite/Makefile.in
 delete mode 100644 tools/Makefile.am
 create mode 100644 tools/Makefile.in

diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index a0ca2d16..00000000
--- a/Makefile.am
+++ /dev/null
@@ -1,175 +0,0 @@
-SUBDIRS = . tools testsuite examples
-
-noinst_PROGRAMS = aesdata desdata shadata
-
-libnettleincludedir = $(includedir)/nettle
-
-lib_LIBRARIES = libnettle.a
-libnettleinclude_HEADERS = aes.h arcfour.h arctwo.h bignum.h blowfish.h \
-			   base16.h base64.h buffer.h cast128.h \
-			   cbc.h \
-			   des.h des-compat.h dsa.h \
-			   hmac.h \
-			   knuth-lfib.h \
-			   macros.h \
-			   md2.h md4.h \
-			   md5.h md5-compat.h \
-			   memxor.h \
-			   nettle-meta.h \
-			   pgp.h pkcs1.h realloc.h rsa.h rsa-compat.h \
-			   sexp.h \
-			   serpent.h sha.h twofish.h \
-			   yarrow.h
-
-nodist_libnettleinclude_HEADERS = nettle-types.h
-noinst_HEADERS = aes-internal.h cast128_sboxes.h desinfo.h desCode.h \
-		 serpent_sboxes.h nettle-internal.h
-
-libnettle_a_SOURCES = aes.c \
-		      aes-decrypt-table.c aes-decrypt.c \
-		      aes-encrypt-table.c aes-encrypt.c \
-		      aes-set-encrypt-key.c aes-set-decrypt-key.c aes-meta.c \
-		      arcfour.c arcfour-crypt.c arcfour-meta.c \
-		      arctwo.c arctwo-meta.c \
-		      base16-encode.c base16-decode.c base16-meta.c \
-                      base64-encode.c base64-decode.c base64-meta.c \
-		      cast128.c cast128-meta.c \
-		      blowfish.c \
-		      cbc.c \
-		      des.c \
-		      des3.c des-compat.c \
-		      hmac.c hmac-md5.c hmac-sha1.c hmac-sha256.c \
-		      knuth-lfib.c \
-		      md2.c md2-meta.c md4.c md4-meta.c \
-		      md5.c md5-compat.c md5-meta.c \
-		      sha1.c sha1-compress.c sha1-meta.c sha256.c sha256-meta.c \
-		      serpent.c serpent-meta.c \
-		      twofish.c twofish-meta.c \
-		      yarrow256.c yarrow_key_event.c \
-		      sexp.c sexp-format.c \
-		      sexp-transport.c sexp-transport-format.c \
-		      bignum.c bignum-random.c sexp2bignum.c \
-		      pkcs1.c pkcs1-rsa-md5.c pkcs1-rsa-sha1.c \
-		      rsa.c rsa-sign.c rsa-verify.c \
-		      rsa-md5-sign.c rsa-md5-verify.c \
-		      rsa-sha1-sign.c rsa-sha1-verify.c \
-		      rsa-encrypt.c rsa-decrypt.c \
-		      rsa-keygen.c rsa-compat.c \
-		      rsa2sexp.c sexp2rsa.c \
-		      dsa.c dsa-sign.c dsa-verify.c dsa-keygen.c \
-		      sexp2dsa.c \
-		      pgp-encode.c rsa2openpgp.c \
-		      buffer.c buffer-init.c realloc.c \
-		      nettle-internal.c
-
-libnettle_a_CFLAGS = $(CCPIC)
-
-LIBOBJS = @LIBOBJS@
-libnettle_a_LIBADD = $(LIBOBJS)
-
-shadata_LDADD = -lm
-
-info_TEXINFOS = nettle.texinfo
-
-all-local: nettle.html
-
-EXTRA_DIST = $(des_headers) descore.README nettle.html \
-	sha-example.c .bootstrap $(des_headers) \
-	sparc/aes.asm sparc/machine.m4 \
-	x86/aes.asm x86/aes-encrypt.asm x86/aes-decrypt.asm \
-	x86/aes_tables.asm x86/arcfour-crypt.asm x86/sha1-compress.asm
-
-DISTCLEANFILES = aes.asm aes.s \
-	aes-decrypt.asm aes-decrypt.s aes-encrypt.asm aes-encrypt.s \
-	arcfour-crypt.asm arcfour-crypt.s sha1-compress.asm sha1-compress.s \
-	machine.m4 nettle-types.h
-
-CLEANFILES = $(SHLIBFORLINK)
-clean-local:
-	rm -rf .lib
-
-# Using assembler files. Should get precedence before the .c.o rule.
-SUFFIXES = .asm .html
-
-# can be overridden during development, eg. "make RM_TMP=: aes.o"
-RM_TMP = rm -f
-
-# FIXME: How to write this without using GNU make features?
-# For now, use automake to disable these rules when they are not needed.
-
-if ENABLE_ASSEMBLER
-
-# NOTE: We have to use an explicit rule .asm -> .o, to override the .c
-# -> .o rule. Using rules involving .s doesn't seem to work.
-# %.s: %.asm asm.m4 machine.m4 config.m4
-# 	$(M4) $(srcdir)/asm.m4 machine.m4 config.m4 \
-# 		`test -f $< || echo '$(srcdir)/'`$< >$@
-
-# FIXME: For some reason, this rule breaks builds on Tru64 5.1B (on
-# alpha), with the system make. It fails with "Don't know how to make
-# aes.asm", which is very strange, since the make program on this
-# system is not supposed to know about %-style pattern rules, and
-# "aes.asm" doesn't not occur explicitly in any target or dependency.
-
-# NOTE: We create an empty .deps-file, to make the make/automake
-# dependency tracking happier.
-%.$(OBJEXT): %.asm asm.m4 machine.m4 config.m4
-	$(M4) $(srcdir)/asm.m4 machine.m4 config.m4 \
-		`test -f $< || echo '$(srcdir)/'`$< >$*.s
-	$(COMPILE) -c $*.s -o $@
-	echo >.deps/$*.Po
-
-# Assembler files must contain only PIC-clean code.
-%_p.$(OBJEXT): %.asm asm.m4 machine.m4 config.m4
-	$(M4) $(srcdir)/asm.m4 machine.m4 config.m4 \
-		`test -f $< || echo '$(srcdir)/'`$< >$*.s
-	$(COMPILE) -c $*.s -o $@
-	echo >.deps/$*.Po
-endif
-
-if ENABLE_SHARED
-# FIXME: This rule doesn't get dependencies right.
-%_p.$(OBJEXT): %.c
-	$(COMPILE) $(SHLIBCFLAGS) -c $< -o $@
-
-SHLIBOBJECTS = $(patsubst %.c,%_p.$(OBJEXT),$(libnettle_a_SOURCES)) \
-               $(patsubst %.$(OBJEXT),%_p.$(OBJEXT),$(LIBOBJS))
-
-# The point of the sym links is to use -Lnettle-dir at linktime,
-# and LD_LIBRARY_PATH=nettle-dir/.lib at run time.
-$(SHLIBFORLINK): $(SHLIBOBJECTS)
-	$(SHLIBLINK) $^ -o $@ $(SHLIBLIBS)
-	-mkdir .lib 2>/dev/null
-	[ -z "$(SHLIBSONAME)" ] || (cd .lib \
-          && ln -sf ../$(SHLIBFORLINK) $(SHLIBSONAME))
-
-endif
-
-# Shared library rules
-all-local: $(SHLIBTARGET)
-install-data-local: $(SHLIBINSTALL)
-
-install-shared: $(SHLIBFORLINK)
-	$(INSTALL_DATA) $(SHLIBFORLINK) $(DESTDIR)$(libdir)/$(SHLIBFILE)
-	[ -z "$(SHLIBSONAME)" ] \
-                || (cd $(DESTDIR)$(libdir) \
-		&& ln -sf $(SHLIBFILE) $(SHLIBSONAME) \
-		&& ln -sf $(SHLIBFILE) $(SHLIBFORLINK) )
-
-.texinfo.html:
-	(cd $(srcdir) \
-	 && $(MAKEINFO) --html --no-split --output $@T $(<F) \
-	 ; test -s $@T && mv -f $@T $@)
-
-# desCore rules
-# It seems using $(srcdir)/ doesn't work with GNU make 3.79.1
-# des_headers = $(srcdir)/parity.h $(srcdir)/rotors.h $(srcdir)/keymap.h 
-des_headers = parity.h rotors.h keymap.h 
-
-# Generate DES headers.
-$(des_headers): desdata.c
-	$(MAKE) desdata$(EXEEXT)
-	./desdata$(EXEEXT) $(@F) > $@T
-	test -s $@T && mv -f $@T $@
-
-des.o: des.c des.h $(des_headers)
diff --git a/Makefile.in b/Makefile.in
index 270dcdea..7ff27640 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,178 +1,264 @@
-# $Id$
-#
-# Makefile for low-level crypto library
-
-CC=@CC@
-CPP=@CPP@
-RANLIB=@RANLIB@
-AR=ar
-
-# Reset VPATH
-SRCDIR=@srcdir@
-VPATH=$(SRCDIR):$(EXTRA_VPATH)
-
-# The flags to generate a shared library
-CPPFLAGS=$(PREFLAGS) $(DEFS) $(EXTRA_CPPFLAGS)
-LDFLAGS=@LDFLAGS@
-
-default: algorithms.a
-
-### Magic Makefile for descore
-
-# Interesting defines are sparc, mc68000, vax and i386
-# Rely on gcc defining them appropriately.
-# CPPFLAGS=	-Dsparc		# use 6+8 general regs
-# CPPFLAGS=	-Dmc68000	# use 3+4 addr (1+4 live), and 3+3 data regs
-# CPPFLAGS=	-Dvax		# use 6+0 general regs
-# CPPFLAGS=	-Di386		# use 3+0 regs, and 3+0 normal variables
-
-CODEGEN.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -S
-COMPILE.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -c
-LINK.c=		$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-
-# hand-entered files that go into the library
-SC=		desKerb.c desUtil.c desQuick.c
-SO=		desKerb.o desUtil.o desQuick.o
-
-# special generated files
-GH=		parity.h rotors.h keymap.h
-GC=		desSmallFips.c desSmallCore.c desQuickFips.c desQuickCore.c
-GI=		desSmallFips.i desSmallCore.i desQuickFips.i desQuickCore.i
-GO=		desSmallFips.o desSmallCore.o desQuickFips.o desQuickCore.o
-
-O=		$(SO) $(GO)
-
-# prefer compilation from .i if .i exists
-#.SUFFIXES:
-#.SUFFIXES:	.i .o .c $(SUFFIXES)
-
-desTest:	desCore.a desTest.o
-		$(LINK.c) -o $@ desTest.o desCore.a
-		./desTest
-
-# test all performance enhancement flags
-sure:
-		make clean ; make desTest 'CPPFLAGS=-Di386 -Umc68000 -Usparc'
-		make clean ; make desTest 'CPPFLAGS=-Dvax -Umc68000 -Usparc'
-		make clean ; make desTest 'CPPFLAGS=-Dmc68000 -Usparc'
-		make clean ; make desTest 'CPPFLAGS=-Dsparc   -Umc68000'
-		make clean ; make desTest
-
-clean:
-	-rm -f *.o *.i *.x *.a ./desTest
-	-rm -f $(GC) $(GH) desdata
-
-depend:
-
-desCore.a:	$O
-		$(AR) cru $@ $O
-		$(RANLIB) $@
-
-desdata.o:	desinfo.h $(SRCDIR)/../include/des.h
-desUtil.o:	$(GH)
-$(SO):		$(SRCDIR)/../include/des.h
-$(GI):		desCode.h $(SRCDIR)/../include/des.h Makefile
-desTest.o:	$(SRCDIR)/../include/des.h
-
-$(GH):		desdata
-		./desdata $@ > $@
-
-desdata:	desdata.o
-		$(LINK.c) -o $@ desdata.o
-
-# new rules  (note: tr|sed|tr is NOT necessary,  just there so .i is readable)
-.c.i:
-	$(CPP) $(CFLAGS) $(CPPFLAGS) $< > $*.x
-	@tr ';'\\012 \\012';' < $*.x |			\
-	 sed	-e 's/[ 	][ 	]*/ /g'		\
-		-e 's/^ //'				\
-		-e 's/ $$//'				\
-		-e '/^$$/d'				\
-		-e '/^[^;]/s/^/;/'			\
-		-e 's/#[^;]*;//g'			\
-		-e 's/\([){]\) *\(register\)/\1;\2/g'	\
-		-e 's/\([[(]\) /\1/g'			\
-		-e 's/ \([])]\)/\1/g'			\
-		-e 's/\([^]+0123 ]\) =/\1  =/g'		\
-		-e 's/}/};;/g'				\
-		-e 's/ *; */;/g'			\
-		-e 's/;;;*/;;/g'			\
-		-e '1s/^;*//' |				\
-	 tr ';'\\012 \\012';' > $@
-	@echo ""  >> $@
-#	@echo "}" >> $@			# last definition must be a procedure
-
-#		-e 's/\(;[kmxyz][0-9]*\)\([^;]*=\)/\1  \2/g'
-
-.i.o:
-		$(CODEGEN.c) $<
-		$(COMPILE.c) $*.s
-
-# slowest to quickest
-desSmallFips.c:
-		@echo '#include "desCode.h"' > $@
-		@echo \
-'ENCRYPT(DesSmallFipsEncrypt,TEMPSMALL,LOADFIPS,KEYMAPSMALL,SAVEFIPS)' >> $@
-		@echo \
-'DECRYPT(DesSmallFipsDecrypt,TEMPSMALL,LOADFIPS,KEYMAPSMALL,SAVEFIPS)' >> $@
-desSmallCore.c:
-		@echo '#include "desCode.h"' > $@
-		@echo \
-'ENCRYPT(DesSmallCoreEncrypt,TEMPSMALL,LOADCORE,KEYMAPSMALL,SAVECORE)' >> $@
-		@echo \
-'DECRYPT(DesSmallCoreDecrypt,TEMPSMALL,LOADCORE,KEYMAPSMALL,SAVECORE)' >> $@
-desQuickFips.c:
-		@echo '#include "desCode.h"' > $@
-		@echo \
-'ENCRYPT(DesQuickFipsEncrypt,TEMPQUICK,LOADFIPS,KEYMAPQUICK,SAVEFIPS)' >> $@
-		@echo \
-'DECRYPT(DesQuickFipsDecrypt,TEMPQUICK,LOADFIPS,KEYMAPQUICK,SAVEFIPS)' >> $@
-desQuickCore.c:
-		@echo '#include "desCode.h"' > $@
-		@echo \
-'ENCRYPT(DesQuickCoreEncrypt,TEMPQUICK,LOADCORE,KEYMAPQUICK,SAVECORE)' >> $@
-		@echo \
-'DECRYPT(DesQuickCoreDecrypt,TEMPQUICK,LOADCORE,KEYMAPQUICK,SAVECORE)' >> $@
-
-### End of rules for desCore
-
-SRCS = sha.c md5.c idea.c rc4.c cast.c $(SC) $(GC)
-OBJS = $(SRCS:.c=.o)
-
-algorithms.a: $(OBJS)
-	rm -f algorithms.a
-	$(AR) cru algorithms.a $(OBJS)
-	$(RANLIB) algorithms.a
-
-#### Remaking the Makefile and configure scripts. ####
-
-#${srcdir}/configure: configure.in aclocal.m4
-${srcdir}/configure: configure.in
-	cd ${srcdir} && autoconf
-
-# autoheader might not change config.h.in, so touch a stamp file.
-${srcdir}/config.h.in: stamp-h.in
-
-#${srcdir}/stamp-h.in: configure.in aclocal.m4 acconfig.h \
-#    config.h.top config.h.bot
-
-${srcdir}/stamp-h.in: configure.in 
-	cd ${srcdir} && autoheader
-	echo timestamp > ${srcdir}/stamp-h.in
-
-config.h: stamp-h
-
-stamp-h: config.h.in config.status
-	./config.status
-
-Makefile: Makefile.in config.status
-	./config.status
-
-config.status: configure
-	./config.status --recheck
-
-%.d: %.c
-	$(SHELL) -ec '$(CC) -MM -MG $(CPPFLAGS) $(DEFS) $< \
-		| sed '\''s/\($*\)\.o:/\1\.o $@ : /g'\'' > $@'
-
-include $(SRCS:.c=.d)
+# Nettle Makefile
+
+@SET_MAKE@
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+LIBOBJS = @LIBOBJS@
+
+SUBDIRS = tools testsuite examples
+
+include config.make
+
+
+TARGETS = aesdata$(EXEEXT) desdata$(EXEEXT) shadata$(EXEEXT) libnettle.a $(SHLIBTARGET)
+
+all check install uninstall clean distclean mostlyclean maintainer-clean distdir:
+	$(MAKE) $@-here
+	set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
+
+check-here:
+	true
+
+.SUFFIXES:
+.SUFFIXES: .asm .html .c .dvi .info .$(OBJEXT) .p$(OBJEXT) .exe .pdf .ps .texinfo
+
+all-here: $(TARGETS)
+
+nettle_SOURCES = aes.c \
+	         aes-decrypt-table.c aes-decrypt.c \
+		 aes-encrypt-table.c aes-encrypt.c \
+		 aes-set-encrypt-key.c aes-set-decrypt-key.c aes-meta.c \
+		 arcfour.c arcfour-crypt.c arcfour-meta.c \
+		 arctwo.c arctwo-meta.c \
+		 base16-encode.c base16-decode.c base16-meta.c \
+                 base64-encode.c base64-decode.c base64-meta.c \
+		 cast128.c cast128-meta.c \
+		 blowfish.c \
+		 cbc.c \
+		 des.c \
+		 des3.c des-compat.c \
+		 hmac.c hmac-md5.c hmac-sha1.c hmac-sha256.c \
+		 knuth-lfib.c \
+		 md2.c md2-meta.c md4.c md4-meta.c \
+		 md5.c md5-compat.c md5-meta.c \
+		 sha1.c sha1-compress.c sha1-meta.c sha256.c sha256-meta.c \
+		 serpent.c serpent-meta.c \
+		 twofish.c twofish-meta.c \
+		 yarrow256.c yarrow_key_event.c \
+		 sexp.c sexp-format.c \
+		 sexp-transport.c sexp-transport-format.c \
+		 bignum.c bignum-random.c sexp2bignum.c \
+		 pkcs1.c pkcs1-rsa-md5.c pkcs1-rsa-sha1.c \
+		 rsa.c rsa-sign.c rsa-verify.c \
+		 rsa-md5-sign.c rsa-md5-verify.c \
+		 rsa-sha1-sign.c rsa-sha1-verify.c \
+		 rsa-encrypt.c rsa-decrypt.c \
+		 rsa-keygen.c rsa-compat.c \
+		 rsa2sexp.c sexp2rsa.c \
+		 dsa.c dsa-sign.c dsa-verify.c dsa-keygen.c \
+		 sexp2dsa.c \
+		 pgp-encode.c rsa2openpgp.c \
+		 buffer.c buffer-init.c realloc.c \
+		 nettle-internal.c
+
+HEADERS = aes.h arcfour.h arctwo.h bignum.h blowfish.h \
+	  base16.h base64.h buffer.h cast128.h \
+	  cbc.h \
+	  des.h des-compat.h dsa.h \
+	  hmac.h \
+	  knuth-lfib.h \
+	  macros.h \
+	  md2.h md4.h \
+	  md5.h md5-compat.h \
+	  memxor.h \
+	  nettle-meta.h \
+	  pgp.h pkcs1.h realloc.h rsa.h rsa-compat.h \
+	  sexp.h \
+	  serpent.h sha.h twofish.h \
+	  yarrow.h
+
+INSTALL_HEADERS = $(HEADERS) nettle-types.h
+
+SOURCES = $(nettle_SOURCES) aesdata.c desdata.c shadata.c
+
+DISTFILES = $(SOURCES) $(HEADERS) .bootstrap aclocal.m4 configure.ac configure \
+	config.guess config.sub texinfo.tex \
+	config.h.in config.m4.in config.make.in	Makefile.in \
+	README AUTHORS COPYING INSTALL NEWS TODO \
+	nettle.texinfo nettle.info sha-example.c
+
+# Rules building libnettle.a
+# FIXME: Do we really need to delete the archive first?
+libnettle.a: $(nettle_SOURCES:.c=.o) $(LIBOBJS)
+	-rm -f $@
+	$(AR) $(ARFLAGS) $@ $^
+	$(RANLIB) $@
+
+.c.$(OBJEXT):
+	$(COMPILE) $(CCPIC_MAYBE) -c $< \
+	&& $(DEP_PROCESS)
+
+# Rules building libnettle.so
+$(SHLIBFORLINK): $(nettle_SOURCES:.c=.p$(OBJEXT)) $(LIBOBJS:.$(OBJEXT)=.p$(OBJEXT))
+	$(SHLIBLINK) $^ -o $@ $(SHLIBLIBS)
+	-mkdir .lib 2>/dev/null
+	[ -z "$(SHLIBSONAME)" ] || (cd .lib \
+          && ln -sf ../$(SHLIBFORLINK) $(SHLIBSONAME))
+
+.c.p$(OBJEXT):
+	$(COMPILE) $(SHLIBCFLAGS) -c $< -o $@ \
+	&& $(DEP_PROCESS)
+
+.o$(EXEEXT):
+	$(LINK) $^ $(LIBS) -o $@
+
+# aesdata.$(OBJEXT) : aesdata.c
+# 	$(COMPILE) -c $< && $(DEP_PROCESS)
+aesdata$(EXEEXT): aesdata.$(OBJEXT)
+	$(LINK) $^ $(LIBS) -o $@
+
+# desdata.$(OBJEXT) : desdata.c
+# 	$(COMPILE)  -c $< && $(DEP_PROCESS)
+desdata$(EXEEXT): desdata.$(OBJEXT)
+	$(LINK) $^ $(LIBS) -o $@
+
+# shadata.$(OBJEXT) : shadata.c
+# 	$(COMPILE)  -c $< && $(DEP_PROCESS)
+shadata$(EXEEXT): shadata.$(OBJEXT)
+	$(LINK) $^ $(LIBS) -lm -o $@
+
+# FIXME: For some reason, this rule breaks builds on Tru64 5.1B (on
+# alpha), with the system make. It fails with "Don't know how to make
+# aes.asm", which is very strange, since the make program on this
+# system is not supposed to know about %-style pattern rules, and
+# "aes.asm" doesn't occur explicitly in any target or dependency.
+
+@IF_ENABLE_ASM@%.$(OBJEXT): %.asm asm.m4 machine.m4 config.m4
+@IF_ENABLE_ASM@	$(M4) $(srcdir)/asm.m4 machine.m4 config.m4 \
+@IF_ENABLE_ASM@		`test -f $< || echo '$(srcdir)/'`$< >$*.s
+@IF_ENABLE_ASM@	$(CC) $(CFLAGS) $(CCPIC_MAYBE) -c $*.s -o $@
+@IF_ENABLE_ASM@	echo >$*.d 
+
+# All assembler files should use pic-code only.
+@IF_ENABLE_ASM@%.p$(OBJEXT): %.asm asm.m4 machine.m4 config.m4
+@IF_ENABLE_ASM@	$(M4) $(srcdir)/asm.m4 machine.m4 config.m4 \
+@IF_ENABLE_ASM@		`test -f $< || echo '$(srcdir)/'`$< >$*.s
+@IF_ENABLE_ASM@	$(CC) $(CFLAGS) $(CCPIC) -c $*.s -o $@
+@IF_ENABLE_ASM@	echo >$*.d 
+
+# Configure-related rules
+
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in config.status
+	$(SHELL) ./config.status $@
+
+settings: $(srcdir)/settings.in config.status
+	$(SHELL) ./config.status $@
+
+config.status: $(srcdir)/configure
+	$(SHELL) ./config.status --recheck
+
+configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4
+	cd $(srcdir) && $(AUTOCONF)
+
+config.h: stamp-h1
+	@if test ! -f $@; then \
+	  rm -f stamp-h1; \
+	  $(MAKE) stamp-h1; \
+	else :; fi
+
+stamp-h1: $(srcdir)/config.h.in config.status
+	@rm -f stamp-h1
+	$(SHELL) ./config.status config.h
+$(srcdir)/config.h.in: $(srcdir)/configure.ac
+	cd $(srcdir) && $(AUTOHEADER)
+	rm -f stamp-h1
+	touch $@
+
+# Installation
+install-here: install-info libnettle.a $(SHLIBTARGET) $(INSTALL_HEADERS) $(SHLIBINSTALL)
+	$(INSTALL) -d $(includedir)/nettle
+	$(INSTALL) -d $(libdir)
+	$(INSTALL_DATA) $(INSTALL_HEADERS) $(includedir)/nettle
+	$(INSTALL_DATA) libnettle.a $(libdir)
+
+install-shared: $(SHLIBFORLINK)
+	$(INSTALL) -d $(libdir)
+	$(INSTALL_DATA) $(SHLIBFORLINK) $(libdir)/$(SHLIBFILE)
+	[ -z "$(SHLIBSONAME)" ] \
+                || (cd $(libdir) \
+		&& ln -sf $(SHLIBFILE) $(SHLIBSONAME) \
+		&& ln -sf $(SHLIBFILE) $(SHLIBFORLINK) )
+
+install-info: nettle.info
+	$(INSTALL) -d $(infodir)
+	$(INSTALL_DATA) nettle.info $(infodir) ; \
+	if (install-info --version && \
+	    install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
+	  install-info --info-dir="$(infodir)" nettle.info ; \
+	else : ; fi
+
+# Distribution
+distdir = $(PACKAGE_NAME)-$(PACKAGE_VERSION)
+top_distdir = $(distdir)
+
+# $(distdir) must always be a relative path!
+distdir-here: $(DISTFILES)
+	rm -rf $(distdir)
+	mkdir $(distdir)
+	cp $(DISTFILES) $(distdir)
+	set -e; for d in $(SUBDIRS); do \
+	  sd=$(distdir)/$$d ; \
+	  mkdir $$sd && $(MAKE) -C $$d distdir=../$$sd $@ ; \
+	done
+
+dist: distdir
+	tar cf - $(distdir) | gzip -c >$(distdir).tar.gz	
+	rm -rf $(distdir)
+
+rm_distcheck = test ! -d distcheck-tmp \
+	    || { find distcheck-tmp -type d ! -perm -200 -exec chmod u+w {} ';' \
+          && rm -fr distcheck-tmp; }; }
+
+distcheck: dist
+	$(rm_distcheck)
+	mkdir distcheck-tmp
+	cd distcheck-tmp && gzip -d < $(distdir).tar.gz | tar xf - && chmod -R a-w $(distdir)
+	mkdir distcheck-tmp/build
+	mkdir distcheck-tmp/install
+	cd distcheck-tmp/build && ../$(distdir)/configure --prefix=`cd ../install && pwd`
+	cd distcheck-tmp/build && $(MAKE)
+	cd distcheck-tmp/build && $(MAKE) check
+	cd distcheck-tmp/build && $(MAKE) install
+	cd distcheck-tmp/build && $(MAKE) dist
+	cd distcheck-tmp/build && rm *.gz
+	cd distcheck-tmp/build && $(MAKE) distcleancheck
+	cd distcheck-tmp && find build -type f -print > leftover-files
+	@test `cat distcheck-tmp/leftover-files | wc -l` -eq 0  \
+	  || { echo "ERROR: files left in build directory after distclean:" ; \
+	       cat distcheck-tmp/leftover-files ; \
+	       exit 1; }
+	$(rm_distcheck)
+
+distcleancheck: distclean
+	@if test '$(srcdir)' = . ; then \
+	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+	  exit 1 ; \
+	fi
+	@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+	  || { echo "ERROR: files left in build directory after distclean:" ; \
+	       $(distcleancheck_listfiles) ; \
+	       exit 1; } >&2
+
+
+clean-here:
+	rm -f $(TARGETS) *.$(OBJEXT) *.p$(OBJEXT) *.d
+
+distclean-hdr:
+	-rm -f config.h stamp-h1
+config.m4: config.status $(srcdir)/config.m4.in
+	$(SHELL) ./config.status $@
+
+-include $(SOURCES:.c=.$(OBJEXT).d) $(SOURCES:.c=.p$(OBJEXT).d)
diff --git a/configure.ac b/configure.ac
index f225467f..7ff158ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,14 +2,13 @@ dnl -*- mode: shell-script; sh-indentation: 2; -*-
 
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT([nettle], [1.10])
+AC_INIT([nettle], [1.11], [nettle-bugs@lists.lysator.liu.se])
 AC_PREREQ(2.50)
 AC_CONFIG_SRCDIR([arcfour.c])
 # Needed to stop autoconf from looking for files in parent directories.
 AC_CONFIG_AUX_DIR([.])
 
-AM_INIT_AUTOMAKE
-AM_CONFIG_HEADER([config.h])
+AC_CONFIG_HEADER([config.h])
 
 SHLIBMAJOR=2
 SHLIBMINOR=2
@@ -74,12 +73,15 @@ fi
 
 AC_PROG_MAKE_SET
 AC_PROG_RANLIB
-AM_PROG_CC_STDC
 
-if test "x$am_cv_prog_cc_stdc" = xno ; then
+if test "x$ac_cv_prog_cc_stdc" = xno ; then
   AC_ERROR([the C compiler doesn't handle ANSI-C])
 fi
 
+AC_PROG_INSTALL
+
+LSH_DEPENDENCY_TRACKING
+
 # Select assembler code
 asm_path=
 case "$host" in
@@ -146,12 +148,14 @@ else
   SHLIBINSTALL=''
 fi
 
-if test "x$enable_pic" = xyes; then : ; else
-  CCPIC=''
+if test "x$enable_pic" = xyes; then
+  CCPIC_MAYBE="$CCPIC"
+else
+  CCPIC_MAYBE=''
 fi
+AC_SUBST([CCPIC_MAYBE])
 
-AM_CONDITIONAL([ENABLE_ASSEMBLER], [test x$enable_assembler = xyes])
-AM_CONDITIONAL([ENABLE_SHARED],  [test x$enable_shared = xyes])
+LSH_MAKE_CONDITIONAL([ENABLE_ASM], [test x$enable_assembler = xyes])
 
 AC_SUBST(SHLIBCFLAGS)
 AC_SUBST(SHLIBMAJOR)
@@ -236,5 +240,5 @@ if test x$GCC = xyes ; then
 # inttypes.h.
 fi
 
-AC_OUTPUT(Makefile tools/Makefile testsuite/Makefile examples/Makefile config.m4)
+AC_OUTPUT(Makefile config.make config.m4 tools/Makefile testsuite/Makefile examples/Makefile)
 
diff --git a/examples/Makefile.am b/examples/Makefile.am
deleted file mode 100644
index acc65f7a..00000000
--- a/examples/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-
-OPENSSL_LIBFLAGS = @OPENSSL_LIBFLAGS@
-AM_CPPFLAGS = -I$(top_srcdir)
-
-# We need .. to be searched before standard places, in order to pick
-# up the newly built libnettle.a/libnettle.so, rather than any
-# installed version.
-AM_LDFLAGS = -L..
-
-# There's no program "io", it's just a trick to get automake to keep track
-# of dependencies for io.o.
-EXTRA_PROGRAMS = rsa-keygen rsa-sign rsa-verify rsa-encrypt rsa-decrypt io
-noinst_PROGRAMS = nettle-benchmark @RSA_EXAMPLES@
-
-nettle_benchmark_SOURCES = nettle-benchmark.c nettle-openssl.c
-rsa_encrypt_SOURCES = rsa-encrypt.c getopt.h getopt.c getopt1.c
-rsa_decrypt_SOURCES = rsa-decrypt.c getopt.h getopt.c getopt1.c
-rsa_keygen_SOURCES = rsa-keygen.c getopt.h getopt.c getopt1.c
-
-# libnettle.a for the dependency
-LDADD = io.o -lnettle ../libnettle.a
-
-nettle_benchmark_LDADD = -lnettle ../libnettle.a $(OPENSSL_LIBFLAGS)
-
-TS_PROGS = rsa-sign-test rsa-verify-test rsa-encrypt-test
-EXTRA_DIST = io.h rsa-session.h run-tests setup-env teardown-env $(TS_PROGS)
-
-.PHONY: run-tests
-run-tests: $(TS_PROGS)
-	LD_LIBRARY_PATH=../.lib srcdir="$(srcdir)" \
-	  "$(srcdir)"/run-tests $(TS_PROGS)
-
-check: run-tests
diff --git a/examples/Makefile.in b/examples/Makefile.in
new file mode 100644
index 00000000..b51d8d9c
--- /dev/null
+++ b/examples/Makefile.in
@@ -0,0 +1,72 @@
+@SET_MAKE@
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+top_srcdir = @top_srcdir@
+
+include ../config.make
+
+OPENSSL_LIBFLAGS = @OPENSSL_LIBFLAGS@
+TARGETS = nettle-benchmark @RSA_EXAMPLES@
+SOURCES = nettle-benchmark.c nettle-openssl.c \
+	io.c getopt.c getopt1.c \
+	rsa-encrypt.c rsa-decrypt.c rsa-keygen.c
+
+TS_ALL = rsa-sign-test rsa-verify-test rsa-encrypt-test
+
+DISTFILES= $(SOURCES) Makefile.in $(TS_ALL) run-tests setup-env teardown-env \
+	io.h rsa-session.h 
+
+all: $(TARGETS)
+
+.c.$(OBJEXT):
+	$(COMPILE) -I.. -c $<
+.o$(EXEEXT):
+	$(LINK) $^ $(LIBS) -L.. -lnettle -o $@
+
+nettle-benchmark: nettle-benchmark.o nettle-openssl.o ../libnettle.a
+	$(LINK) $^ $(LIBS) -L.. -lnettle $(OPENSSL_LIBFLAGS) -o $@
+
+$(TARGETS) : io.o ../libnettle.a
+
+
+check: $(TS_ALL)
+	LD_LIBRARY_PATH=../.lib srcdir="$(srcdir)" \
+	  "$(srcdir)"/run-tests $(TS_ALL)
+
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in ../config.status
+	cd .. && $(SHELL) ./config.status examples/$@
+
+../config.make: $(top_srcdir)/config.make.in ../config.status
+	cd .. && $(SHELL) ./config.status config.make
+
+../config.status: $(top_srcdir)/configure
+	cd .. && $(SHELL) ./config.status --recheck
+
+../configure: $(top_srcdir)/configure.ac $(top_srcdir)/aclocal.m4
+	cd $(top_srcdir) && $(AUTOCONF)
+
+# # FIXME: To we really need all this in all subdirs?
+# ../config.h: ../stamp-h1
+# 	@cd .. $(MAKE) stamp-h1;
+# 
+# ../stamp-h1: $(top_srcdir)/config.h.in ../config.status
+# 	cd .. && $(MAKE) stamp-h1
+# 
+# $(top_srcdir)/config.h.in: $(top_srcdir)/configure.ac
+# 	cd $(top_srcdir) && $(AUTOHEADER)
+# 	rm -f ../stamp-h1
+# 	touch $@
+
+install:
+	true
+
+distdir: $(DISTFILES)
+	cp $(DISTFILES) $(distdir)
+
+clean:
+	rm -f $(TARGETS) *.o *.d
+
+-include $(SOURCES:.c=.$(OBJEXT).d)
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
deleted file mode 100644
index 79173336..00000000
--- a/testsuite/Makefile.am
+++ /dev/null
@@ -1,44 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir)
-
-# We need .. to be searched before standard places, in order to pick
-# up the newly built libnettle.a/libnettle.so, rather than any
-# installed version.
-AM_LDFLAGS = -L..
-
-noinst_PROGRAMS = aes-test arcfour-test arctwo-test \
-	   blowfish-test cast128-test \
-           base16-test base64-test \
-	   des-test des3-test des-compat-test \
-	   md2-test md4-test md5-test md5-compat-test \
-	   sha1-test sha256-test \
-	   serpent-test twofish-test \
-	   buffer-test sexp-test sexp-format-test \
-	   rsa2sexp-test sexp2rsa-test \
-	   knuth-lfib-test \
-	   cbc-test hmac-test bignum-test \
-	   pkcs1-test \
-	   rsa-test rsa-encrypt-test rsa-keygen-test \
-	   dsa-test dsa-keygen-test \
-	   yarrow-test
-
-TS_PROGS = $(noinst_PROGRAMS)
-TS_SH = sexp-conv-test symbols-test
-
-TS_ALL = $(TS_PROGS) $(TS_SH)
-
-# Workaround to get automake to keep dependencies for testutils.o
-EXTRA_PROGRAMS = testutils
-
-# libnettle.a is added at the end to make sure all programs depend on it.
-# It seems there's no DEPENDENCIES variable that affects all programs.
-
-LDADD = testutils.o -lnettle ../libnettle.a
-EXTRA_DIST = $(TS_SH) testutils.h \
-	     run-tests rfc1750.txt
-
-CLEANFILES = test.in test1.out test2.out
-
-.PHONY: check 
-check: $(TS_ALL) $(srcdir)/run-tests
-	LD_LIBRARY_PATH=../.lib srcdir="$(srcdir)" \
-	  $(srcdir)/run-tests $(TS_ALL)
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
new file mode 100644
index 00000000..5b408de9
--- /dev/null
+++ b/testsuite/Makefile.in
@@ -0,0 +1,85 @@
+@SET_MAKE@
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+top_srcdir = @top_srcdir@
+
+include ../config.make
+
+TS_SOURCES = aes-test.c arcfour-test.c arctwo-test.c \
+	     blowfish-test.c cast128-test.c \
+             base16-test.c base64-test.c \
+	     des-test.c des3-test.c des-compat-test.c \
+	     md2-test.c md4-test.c md5-test.c md5-compat-test.c \
+	     sha1-test.c sha256-test.c \
+	     serpent-test.c twofish-test.c \
+	     buffer-test.c sexp-test.c sexp-format-test.c \
+	     rsa2sexp-test.c sexp2rsa-test.c \
+	     knuth-lfib-test.c \
+	     cbc-test.c hmac-test.c bignum-test.c \
+	     pkcs1-test.c \
+	     rsa-test.c rsa-encrypt-test.c rsa-keygen-test.c \
+	     dsa-test.c dsa-keygen-test.c \
+	     yarrow-test.c
+TARGETS = $(TS_SOURCES:.c=$(EXEEXT))
+TS_SH = sexp-conv-test symbols-test
+TS_ALL = $(TARGETS) $(TS_SH)
+
+SOURCES = $(TS_SOURCES) testutils.c
+
+DISTFILES = $(SOURCES) Makefile.in $(TS_SH) run-tests rfc1750.txt testutils.h
+
+all: $(TARGETS)
+
+.c.$(OBJEXT):
+	$(COMPILE) -I.. -c $< && $(DEP_PROCESS)
+
+.o$(EXEEXT):
+	$(LINK) $< testutils.o $(LIBS) -L.. -lnettle -o $@
+# .c$(EXEEXT):
+# 	$(COMPILE) -I..
+# 	$(CC) $(CFLAGS) $(LDFLAGS) $*.o testutils.o -L.. -lnettle $(LIBS) -o $@
+
+$(TARGETS) : testutils.$(OBJEXT) ../libnettle.a
+
+check: $(TS_ALL) $(srcdir)/run-tests
+	LD_LIBRARY_PATH=../.lib srcdir="$(srcdir)" \
+	  $(srcdir)/run-tests $(TS_ALL)
+
+
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in ../config.status
+	cd .. && $(SHELL) ./config.status testsuite/$@
+
+../config.make: $(top_srcdir)/config.make.in ../config.status
+	cd .. && $(SHELL) ./config.status config.make
+
+../config.status: $(top_srcdir)/configure
+	cd .. && $(SHELL) ./config.status --recheck
+
+../configure: $(top_srcdir)/configure.ac $(top_srcdir)/aclocal.m4
+	cd $(top_srcdir) && $(AUTOCONF)
+
+# # FIXME: To we really need all this in all subdirs?
+# ../config.h: ../stamp-h1
+# 	@cd .. $(MAKE) stamp-h1;
+# 
+# ../stamp-h1: $(top_srcdir)/config.h.in ../config.status
+# 	cd .. && $(MAKE) stamp-h1
+# 
+# $(top_srcdir)/config.h.in: $(top_srcdir)/configure.ac
+# 	cd $(top_srcdir) && $(AUTOHEADER)
+# 	rm -f ../stamp-h1
+# 	touch $@
+
+install:
+	true
+
+distdir: $(DISTFILES)
+	cp $(DISTFILES) $(distdir)
+
+clean:
+	rm -f $(TARGETS) *.o *.d
+
+-include $(SOURCES:.c=.$(OBJEXT).d)
diff --git a/tools/Makefile.am b/tools/Makefile.am
deleted file mode 100644
index 6316e7ce..00000000
--- a/tools/Makefile.am
+++ /dev/null
@@ -1,23 +0,0 @@
-AM_CFLAGS = -I$(top_srcdir)
-
-# We need .. to be searched before standard places, in order to pick
-# up the newly built libnettle.a/libnettle.so, rather than any
-# installed version.
-AM_LDFLAGS = -L..
-
-bin_PROGRAMS = sexp-conv nettle-lfib-stream
-
-# libnettle.a is added at the end to make sure all programs depend on it.
-# It seems there's no DEPENDENCIES variable that affects all programs.
-LDADD = -lnettle ../libnettle.a
-
-# Explicit use of DEPENDENCIES is more correct, but scales badly to a
-# large number of programs.
-
-# sexp_conv_DEPENDENCIES = ../libnettle.a
-# nettle_lfib_stream_DEPENDENCIES = ../libnettle.a
-
-EXTRA_DIST = misc.h input.h output.h parse.h getopt.h
-
-sexp_conv_SOURCES = sexp-conv.c input.c output.c parse.c \
-	getopt.c getopt1.c misc.c
diff --git a/tools/Makefile.in b/tools/Makefile.in
new file mode 100644
index 00000000..b5a17d90
--- /dev/null
+++ b/tools/Makefile.in
@@ -0,0 +1,69 @@
+@SET_MAKE@
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+top_srcdir = @top_srcdir@
+
+include ../config.make
+
+TARGETS = sexp-conv nettle-lfib-stream
+
+all: $(TARGETS)
+
+sexp_conv_SOURCES = sexp-conv.c input.c output.c parse.c \
+	getopt.c getopt1.c misc.c
+
+SOURCES = $(sexp_conv_SOURCES) nettle-lfib-stream.c
+
+DISTFILES = $(SOURCES) Makefile.in
+
+sexp-conv: $(sexp_conv_SOURCES:.c=.$(OBJEXT)) ../libnettle.a
+	$(LINK) $^ $(LIBS) -L.. -lnettle -o $@
+
+nettle-lfib-stream: nettle-lfib-stream.$(OBJEXT) ../libnettle.a
+	$(LINK) $^ $(LIBS) -L.. -lnettle -o $@
+
+.c.$(OBJEXT):
+	$(COMPILE) -I.. -c $< && $(DEP_PROCESS)
+
+
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in ../config.status
+	cd .. && $(SHELL) ./config.status tools/$@
+
+../config.make: $(top_srcdir)/config.make.in ../config.status
+	cd .. && $(SHELL) ./config.status config.make
+
+../config.status: $(top_srcdir)/configure
+	cd .. && $(SHELL) ./config.status --recheck
+
+../configure: $(top_srcdir)/configure.ac $(top_srcdir)/aclocal.m4
+	cd $(top_srcdir) && $(AUTOCONF)
+
+# # FIXME: To we really need all this in all subdirs?
+# ../config.h: ../stamp-h1
+# 	@cd .. $(MAKE) stamp-h1;
+# 
+# ../stamp-h1: $(top_srcdir)/config.h.in ../config.status
+# 	cd .. && $(MAKE) stamp-h1
+# 
+# $(top_srcdir)/config.h.in: $(top_srcdir)/configure.ac
+# 	cd $(top_srcdir) && $(AUTOHEADER)
+# 	rm -f ../stamp-h1
+# 	touch $@
+
+check:
+	true
+
+install: $(TARGETS)
+	$(INSTALL) -d $(bindir)
+	$(INSTALL_PROGRAM) $(TARGETS) $(bindir)
+
+distdir: $(DISTFILES)
+	cp $(DISTFILES) $(distdir)
+
+clean:
+	rm -f $(TARGETS) *.o *.d
+
+-include $(SOURCES:.c=.$(OBJEXT).d)
-- 
GitLab