From 890f5bf2654b695a866262d72bfa9750af921a3b Mon Sep 17 00:00:00 2001
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 23 Aug 2014 12:26:37 -0700
Subject: [PATCH] Fix linking of libraries used by libreg

The math and crypto libraries are called by and need to be linked to
libreg.so, not to the executables.

Upstream-Status: Backport [http://www.spinics.net/lists/linux-wireless/msg126027.html]

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
---
 Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index a3ead30..da2dcc3 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ CFLAGS += -std=gnu99 -Wall -Werror -pedantic
 CFLAGS += -Wall -g
 LDLIBREG += -lreg
 LDLIBS += $(LDLIBREG)
-LDLIBS += -lm
+LIBREGLDLIBS += -lm
 LIBREG += libreg.so
 LDFLAGS += -L ./
 
@@ -40,13 +40,13 @@ all_noverify: $(LIBREG) crda intersect regdbdump db2rd optimize
 
 ifeq ($(USE_OPENSSL),1)
 CFLAGS += -DUSE_OPENSSL -DPUBKEY_DIR=\"$(RUNTIME_PUBKEY_DIR)\" `pkg-config --cflags openssl`
-LDLIBS += `pkg-config --libs openssl`
+LIBREGLDLIBS += `pkg-config --libs openssl`
 
 $(LIBREG): keys-ssl.c
 
 else
 CFLAGS += -DUSE_GCRYPT
-LDLIBS += -lgcrypt
+LIBREGLDLIBS += -lgcrypt
 
 $(LIBREG): keys-gcrypt.c
 
@@ -116,7 +116,7 @@ keys-%.c: utils/key2pub.py $(wildcard $(PUBKEY_DIR)/*.pem)
 
 $(LIBREG): regdb.h reglib.h reglib.c
 	$(NQ) '  CC  ' $@
-	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -shared -Wl,-soname,$(LIBREG) $^
+	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -shared -Wl,-soname,$(LIBREG) $^ $(LIBREGLDLIBS)
 
 install-libreg-headers:
 	$(NQ) '  INSTALL  libreg-headers'
-- 
2.7.4

