From 7c59bc5e163144702340f428ab8b87a4c25b2c68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Wed, 20 Oct 2004 21:04:59 +0200
Subject: [PATCH] * config.make.in: Insert $(PRE_CPPFLAGS) and $(PRE_LDFLAGS)
 before $(CPPFLAGS) and $(LDFLAGS). This mechanism replaces $(INCLUDES).

* examples/Makefile.in (PRE_CPPFLAGS, PRE_LDFLAGS): Use these
flags to get -I.. and -L.. early on the command line.
* testsuite/Makefile.in: Likewise
* tools/Makefile.in: Likewise.

Rev: src/nettle/ChangeLog:1.283
Rev: src/nettle/config.make.in:1.4
Rev: src/nettle/examples/Makefile.in:1.4
Rev: src/nettle/testsuite/Makefile.in:1.4
Rev: src/nettle/tools/Makefile.in:1.5
---
 ChangeLog             | 10 ++++++++++
 config.make.in        |  7 +++++--
 examples/Makefile.in  |  9 +++++----
 testsuite/Makefile.in |  5 +++--
 tools/Makefile.in     |  7 ++++---
 5 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 91142861..c440c6a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-10-20  Niels Möller  <nisse@lysator.liu.se>
+
+	* config.make.in: Insert $(PRE_CPPFLAGS) and $(PRE_LDFLAGS) before
+	$(CPPFLAGS) and $(LDFLAGS). This mechanism replaces $(INCLUDES).
+
+	* examples/Makefile.in (PRE_CPPFLAGS, PRE_LDFLAGS): Use these
+	flags to get -I.. and -L.. early on the command line.
+	* testsuite/Makefile.in: Likewise
+	* tools/Makefile.in: Likewise.
+
 2004-10-20  Niels Möller  <niels@s3.kth.se>
 
 	* Makefile.in: In the assembler rules, there's no need to look in
diff --git a/config.make.in b/config.make.in
index f00c4210..24a305f4 100644
--- a/config.make.in
+++ b/config.make.in
@@ -54,8 +54,11 @@ libdir =	@libdir@
 includedir =	@includedir@
 infodir =	@infodir@
 
-COMPILE = $(CC) $(CPPFLAGS) $(INCLUDES) $(DEFS) $(CFLAGS) $(CCPIC) $(DEP_FLAGS)
-LINK = $(CC) $(CFLAGS) $(LDFLAGS)
+# PRE_CPPFLAGS and PRE_LDFLAGS lets each Makefile.in prepend its own
+# flags before CPPFLAGS and LDFLAGS.
+
+COMPILE = $(CC) $(PRE_CPPFLAGS) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(CCPIC) $(DEP_FLAGS)
+LINK = $(CC) $(CFLAGS) $(PRE_LDFLAGS) $(LDFLAGS)
 
 # Disable builtin rule
 %$(EXEEXT) : %.c
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 73216db3..9a835332 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -7,7 +7,8 @@ top_srcdir = @top_srcdir@
 
 include ../config.make
 
-INCLUDES = -I.. -I$(top_srcdir)
+PRE_CPPFLAGS = -I.. -I$(top_srcdir)
+PRE_LDFLAGS = -L..
 
 OPENSSL_LIBFLAGS = @OPENSSL_LIBFLAGS@
 TARGETS = nettle-benchmark @RSA_EXAMPLES@
@@ -23,12 +24,12 @@ DISTFILES= $(SOURCES) Makefile.in $(TS_ALL) run-tests setup-env teardown-env \
 all: $(TARGETS)
 
 .c.$(OBJEXT):
-	$(COMPILE) -I.. -c $<
+	$(COMPILE) -c $<
 .o$(EXEEXT):
-	$(LINK) $^ $(LIBS) -L.. -lnettle -o $@
+	$(LINK) $^ -lnettle $(LIBS) -o $@
 
 nettle-benchmark: nettle-benchmark.o nettle-openssl.o ../libnettle.a
-	$(LINK) $^ $(LIBS) -L.. -lnettle $(OPENSSL_LIBFLAGS) -o $@
+	$(LINK) $^ -lnettle $(LIBS) $(OPENSSL_LIBFLAGS) -o $@
 
 $(TARGETS) : io.o ../libnettle.a
 
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index 14c61564..77d0d114 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -7,7 +7,8 @@ top_srcdir = @top_srcdir@
 
 include ../config.make
 
-INCLUDES = -I.. -I$(top_srcdir)
+PRE_CPPFLAGS = -I.. -I$(top_srcdir)
+PRE_LDFLAGS = -L..
 
 TS_SOURCES = aes-test.c arcfour-test.c arctwo-test.c \
 	     blowfish-test.c cast128-test.c \
@@ -38,7 +39,7 @@ all: $(TARGETS)
 	$(COMPILE) -I.. -c $< && $(DEP_PROCESS)
 
 .o$(EXEEXT):
-	$(LINK) $< testutils.o $(LIBS) -L.. -lnettle -o $@
+	$(LINK) $< testutils.o -lnettle $(LIBS) -o $@
 # .c$(EXEEXT):
 # 	$(COMPILE) -I..
 # 	$(CC) $(CFLAGS) $(LDFLAGS) $*.o testutils.o -L.. -lnettle $(LIBS) -o $@
diff --git a/tools/Makefile.in b/tools/Makefile.in
index ba7f65e5..70f31b65 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -7,7 +7,8 @@ top_srcdir = @top_srcdir@
 
 include ../config.make
 
-INCLUDES = -I.. -I$(top_srcdir)
+PRE_CPPFLAGS = -I.. -I$(top_srcdir)
+PRE_LDFLAGS = -L..
 
 TARGETS = sexp-conv nettle-lfib-stream
 
@@ -21,10 +22,10 @@ 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) $^ $(LIBS) -L.. -lnettle -o $@
+	$(LINK) $^ -lnettle $(LIBS) -o $@
 
 nettle-lfib-stream: nettle-lfib-stream.$(OBJEXT) ../libnettle.a
-	$(LINK) $^ $(LIBS) -L.. -lnettle -o $@
+	$(LINK) $^ -lnettle $(LIBS) -o $@
 
 .c.$(OBJEXT):
 	$(COMPILE) -c $< && $(DEP_PROCESS)
-- 
GitLab