From 73ee1fe132f212f8ec6759173fd7b3b234acdae1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Sun, 28 Nov 2004 11:38:19 +0100
Subject: [PATCH] * Makefile.in (distdir): Handle absolute $distdir. Avoid
 using the GNU extension $^.

* examples/Makefile.in: Avoid using the GNU extension $^.
* tools/Makefile.in: Likewise.
* testsuite/Makefile.in: Likewise.

Rev: src/nettle/ChangeLog:1.308
Rev: src/nettle/Makefile.in:1.15
Rev: src/nettle/examples/Makefile.in:1.10
Rev: src/nettle/testsuite/Makefile.in:1.10
Rev: src/nettle/tools/Makefile.in:1.11
---
 ChangeLog             |  9 ++++++++
 Makefile.in           | 49 +++++++++++++++++++++++--------------------
 examples/Makefile.in  |  9 ++++----
 testsuite/Makefile.in |  2 +-
 tools/Makefile.in     | 11 ++++++----
 5 files changed, 48 insertions(+), 32 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 63339a5d..347e6a02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-11-28  Niels Möller  <nisse@lysator.liu.se>
+
+	* Makefile.in (distdir): Handle absolute $distdir.
+	Avoid using the GNU extension $^.
+
+	* examples/Makefile.in: Avoid using the GNU extension $^.
+	* tools/Makefile.in: Likewise.
+	* testsuite/Makefile.in: Likewise.
+
 2004-11-24  Niels Möller  <niels@s3.kth.se>
 
 	* configure.ac: Fixed typo, preventing the creation of dependency
diff --git a/Makefile.in b/Makefile.in
index 2c9ea82c..c5419fe4 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -108,9 +108,12 @@ DISTFILES = $(SOURCES) $(HEADERS) .bootstrap aclocal.m4 configure.ac \
 
 # Rules building libnettle.a
 # FIXME: Do we really need to delete the archive first?
-libnettle.a: $(nettle_SOURCES:.c=.o) $(LIBOBJS)
+nettle_OBJS = $(nettle_SOURCES:.c=.$(OBJEXT)) $(LIBOBJS)
+nettle_PURE_OBJS = $(nettle_OBJS:.$(OBJEXT)=.p$(OBJEXT))
+
+libnettle.a: $(nettle_OBJS)
 	-rm -f $@
-	$(AR) $(ARFLAGS) $@ $^
+	$(AR) $(ARFLAGS) $@ $(nettle_OBJS)
 	$(RANLIB) $@
 
 .c.$(OBJEXT):
@@ -118,8 +121,8 @@ libnettle.a: $(nettle_SOURCES:.c=.o) $(LIBOBJS)
 	&& $(DEP_PROCESS)
 
 # Rules building libnettle.so
-$(SHLIBFORLINK): $(nettle_SOURCES:.c=.p$(OBJEXT)) $(LIBOBJS:.$(OBJEXT)=.p$(OBJEXT))
-	$(SHLIBLINK) $^ -o $@ $(SHLIBLIBS)
+$(SHLIBFORLINK): $(nettle_PURE_OBJS)
+	$(SHLIBLINK) $(nettle_PURE_OBJS) -o $@ $(SHLIBLIBS)
 	-mkdir .lib 2>/dev/null
 	[ -z "$(SHLIBSONAME)" ] || (cd .lib \
           && ln -sf ../$(SHLIBFORLINK) $(SHLIBSONAME))
@@ -129,22 +132,16 @@ $(SHLIBFORLINK): $(nettle_SOURCES:.c=.p$(OBJEXT)) $(LIBOBJS:.$(OBJEXT)=.p$(OBJEX
 	&& $(DEP_PROCESS)
 
 .o$(EXEEXT):
-	$(LINK) $^ $(LIBS) -o $@
+	$(LINK) $< $(LIBS) -o $@
 
-# aesdata.$(OBJEXT) : aesdata.c
-# 	$(COMPILE) -c $< && $(DEP_PROCESS)
 aesdata$(EXEEXT): aesdata.$(OBJEXT)
-	$(LINK) $^ $(LIBS) -o $@
+	$(LINK) $< $(LIBS) -o $@
 
-# desdata.$(OBJEXT) : desdata.c
-# 	$(COMPILE)  -c $< && $(DEP_PROCESS)
 desdata$(EXEEXT): desdata.$(OBJEXT)
-	$(LINK) $^ $(LIBS) -o $@
+	$(LINK) $< $(LIBS) -o $@
 
-# shadata.$(OBJEXT) : shadata.c
-# 	$(COMPILE)  -c $< && $(DEP_PROCESS)
 shadata$(EXEEXT): shadata.$(OBJEXT)
-	$(LINK) $^ $(LIBS) -lm -o $@
+	$(LINK) $< $(LIBS) -lm -o $@
 
 # desCore rules
 # It seems using $(srcdir)/ doesn't work with GNU make 3.79.1
@@ -231,9 +228,11 @@ install-info: nettle.info
 	  install-info --info-dir="$(DESTDIR)$(infodir)" $< ; \
 	else : ; fi
 
+# NOTE: I'd like to use $^, but that's a GNU extension. $? should be
+# more portable, and equivalent for phony targets.
 install-headers: $(INSTALL_HEADERS)
 	$(INSTALL) -d $(DESTDIR)$(includedir)/nettle
-	$(INSTALL_DATA) $^ $(DESTDIR)$(includedir)/nettle
+	$(INSTALL_DATA) $? $(DESTDIR)$(includedir)/nettle
 
 # Uninstall
 uninstall-here: uninstall-info uninstall-headers uninstall-shared
@@ -259,18 +258,22 @@ uninstall-shared:
 distdir = $(PACKAGE_NAME)-$(PACKAGE_VERSION)
 top_distdir = $(distdir)
 
-# $(distdir) must always be a relative path!
+# NOTE: Depending on the automake version in the parent dir,
+# we must handle both absolute and relative $destdir.
+
+# NOTE: I'd like to use $^, but that's a GNU extension. $? should be
+# more portable, and equivalent for phony targets.
 distdir: $(DISTFILES)
-	rm -rf $(distdir)
-	mkdir $(distdir)
-	cp $^ $(distdir)
+	rm -rf "$(distdir)"
+	mkdir "$(distdir)"
+	cp $? "$(distdir)"
 	set -e; for d in sparc x86 ; do \
-	  mkdir $(distdir)/$$d ; \
-	  cp $(srcdir)/$$d/*.asm $(srcdir)/$$d/*.m4 $(distdir)/$$d ; \
+	  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 $@ ; \
+	  sd="$(distdir)/$$d" ; \
+	  mkdir "$$sd" && $(MAKE) -C $$d distdir="`cd $$sd && pwd`" $@ ; \
 	done
 
 dist: distdir
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 79892d62..f742124b 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -26,10 +26,11 @@ all: $(TARGETS)
 .c.$(OBJEXT):
 	$(COMPILE) -c $<
 .o$(EXEEXT):
-	$(LINK) $^ -lnettle $(LIBS) -o $@
+	$(LINK) $< io.o -lnettle $(LIBS) -o $@
 
-nettle-benchmark: nettle-benchmark.o nettle-openssl.o ../libnettle.a
-	$(LINK) $^ -lnettle $(LIBS) $(OPENSSL_LIBFLAGS) -o $@
+nettle-benchmark: nettle-benchmark.o nettle-openssl.o
+	$(LINK) nettle-benchmark.o nettle-openssl.o io.o \
+	-lnettle $(LIBS) $(OPENSSL_LIBFLAGS) -o $@
 
 $(TARGETS) : io.o ../libnettle.a
 
@@ -45,7 +46,7 @@ install uninstall:
 	true
 
 distdir: $(DISTFILES)
-	cp $^ $(distdir)
+	cp $? $(distdir)
 
 clean:
 	-rm -f $(TARGETS) *.o
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index 90d172d9..dc8ba6fa 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -58,7 +58,7 @@ install uninstall:
 	true
 
 distdir: $(DISTFILES)
-	cp $^ $(distdir)
+	cp $? $(distdir)
 
 clean:
 	-rm -f $(TARGETS) *.o test.in test1.out test2.out
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 895ffd04..7928e6eb 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -21,11 +21,12 @@ SOURCES = $(sexp_conv_SOURCES) nettle-lfib-stream.c
 
 DISTFILES = $(SOURCES) Makefile.in getopt.h input.h misc.h output.h parse.h
 
-sexp-conv: $(sexp_conv_SOURCES:.c=.$(OBJEXT)) ../libnettle.a
-	$(LINK) $^ -lnettle $(LIBS) -o $@
+sexp_conv_OBJS = $(sexp_conv_SOURCES:.c=.$(OBJEXT))
+sexp-conv: $(sexp_conv_OBJS) ../libnettle.a
+	$(LINK) $(sexp_conv_OBJS) -lnettle $(LIBS) -o $@
 
 nettle-lfib-stream: nettle-lfib-stream.$(OBJEXT) ../libnettle.a
-	$(LINK) $^ -lnettle $(LIBS) -o $@
+	$(LINK) $< -lnettle $(LIBS) -o $@
 
 .c.$(OBJEXT):
 	$(COMPILE) -c $< && $(DEP_PROCESS)
@@ -46,8 +47,10 @@ uninstall:
 	  rm -f $(DESTDIR)$(bindir)/$$f ; \
 	done
 
+# NOTE: I'd like to use $^, but that's a GNU extension. $? should be
+# more portable, equivalent for phony targets.
 distdir: $(DISTFILES)
-	cp $^ $(distdir)
+	cp $? $(distdir)
 
 clean:
 	-rm -f $(TARGETS) *.o
-- 
GitLab