From 0523e2a015bfac3ef50d32df308c5d687a502eb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Wed, 20 Oct 2004 00:43:28 +0200
Subject: [PATCH] (INCLUDES): Need -I flags for VPATH build. (clean distclean
 mostlyclean maintainer-clean): Clean subdirectories first. (DISTFILES): Added
 a bunch of files. (des_headers): Added desCore rules. (install-here): Split
 off target install-headers, which uses $^ to refer to the files. (distdir):
 Use $^ to refer to the files. distcheck): Fixes.

Rev: src/nettle/Makefile.in:1.2
---
 Makefile.in | 78 +++++++++++++++++++++++++++++++++--------------------
 1 file changed, 49 insertions(+), 29 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 7ff27640..98173917 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -11,13 +11,19 @@ SUBDIRS = tools testsuite examples
 
 include config.make
 
+# FIXME: Really need -I$(srcdir) ???
+INCLUDES = -I. -I$(srcdir)
 
 TARGETS = aesdata$(EXEEXT) desdata$(EXEEXT) shadata$(EXEEXT) libnettle.a $(SHLIBTARGET)
 
-all check install uninstall clean distclean mostlyclean maintainer-clean distdir:
+all check install uninstall:
 	$(MAKE) $@-here
 	set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
 
+clean distclean mostlyclean maintainer-clean:
+	set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
+	$(MAKE) $@-here
+
 check-here:
 	true
 
@@ -84,9 +90,12 @@ 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.guess config.sub install-sh texinfo.tex \
 	config.h.in config.m4.in config.make.in	Makefile.in \
 	README AUTHORS COPYING INSTALL NEWS TODO \
+	memxor.c $(des_headers) descore.README \
+	aes-internal.h cast128_sboxes.h desinfo.h desCode.h \
+	serpent_sboxes.h nettle-internal.h \
 	nettle.texinfo nettle.info sha-example.c
 
 # Rules building libnettle.a
@@ -129,6 +138,19 @@ desdata$(EXEEXT): desdata.$(OBJEXT)
 shadata$(EXEEXT): shadata.$(OBJEXT)
 	$(LINK) $^ $(LIBS) -lm -o $@
 
+# 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)
+
 # 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
@@ -154,12 +176,15 @@ shadata$(EXEEXT): shadata.$(OBJEXT)
 Makefile: $(srcdir)/Makefile.in config.status
 	$(SHELL) ./config.status $@
 
-settings: $(srcdir)/settings.in config.status
+config.make: $(srcdir)/config.make.in config.status
 	$(SHELL) ./config.status $@
 
 config.status: $(srcdir)/configure
 	$(SHELL) ./config.status --recheck
 
+config.m4: config.status $(srcdir)/config.m4.in
+	$(SHELL) ./config.status $@
+
 configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4
 	cd $(srcdir) && $(AUTOCONF)
 
@@ -178,10 +203,8 @@ $(srcdir)/config.h.in: $(srcdir)/configure.ac
 	touch $@
 
 # Installation
-install-here: install-info libnettle.a $(SHLIBTARGET) $(INSTALL_HEADERS) $(SHLIBINSTALL)
-	$(INSTALL) -d $(includedir)/nettle
+install-here: install-info install-headers libnettle.a $(SHLIBTARGET) $(SHLIBINSTALL)
 	$(INSTALL) -d $(libdir)
-	$(INSTALL_DATA) $(INSTALL_HEADERS) $(includedir)/nettle
 	$(INSTALL_DATA) libnettle.a $(libdir)
 
 install-shared: $(SHLIBFORLINK)
@@ -194,21 +217,29 @@ install-shared: $(SHLIBFORLINK)
 
 install-info: nettle.info
 	$(INSTALL) -d $(infodir)
-	$(INSTALL_DATA) nettle.info $(infodir) ; \
+	$(INSTALL_DATA) $< $(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 ; \
+	  install-info --info-dir="$(infodir)" $< ; \
 	else : ; fi
 
+install-headers: $(INSTALL_HEADERS)
+	$(INSTALL) -d $(includedir)/nettle
+	$(INSTALL_DATA) $^ $(includedir)/nettle
+
 # Distribution
 distdir = $(PACKAGE_NAME)-$(PACKAGE_VERSION)
 top_distdir = $(distdir)
 
 # $(distdir) must always be a relative path!
-distdir-here: $(DISTFILES)
+distdir: $(DISTFILES)
 	rm -rf $(distdir)
 	mkdir $(distdir)
-	cp $(DISTFILES) $(distdir)
+	cp $^ $(distdir)
+	set -e; for d in sparc x86 ; do \
+	  mkdir $(distdir)/$$d ; \
+	  cp $(srcdir)/$$d/*.asm $(srcdir)/$$d/*.m4 $(distdir)/$$d ; \
+	done
 	set -e; for d in $(SUBDIRS); do \
 	  sd=$(distdir)/$$d ; \
 	  mkdir $$sd && $(MAKE) -C $$d distdir=../$$sd $@ ; \
@@ -220,12 +251,13 @@ dist: distdir
 
 rm_distcheck = test ! -d distcheck-tmp \
 	    || { find distcheck-tmp -type d ! -perm -200 -exec chmod u+w {} ';' \
-          && rm -fr distcheck-tmp; }; }
+                 && 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)
+	gzip -d < $(distdir).tar.gz \
+	  | { cd distcheck-tmp && 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`
@@ -234,7 +266,7 @@ distcheck: dist
 	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/build && $(MAKE) distclean
 	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:" ; \
@@ -242,23 +274,11 @@ distcheck: dist
 	       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
+	-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 $@
+distclean-here: clean-here
+	-rm -f config.h stamp-h1 config.log config.status \
+	config.make config.m4 Makefile nettle-types.h
 
 -include $(SOURCES:.c=.$(OBJEXT).d) $(SOURCES:.c=.p$(OBJEXT).d)
-- 
GitLab