From 6af678616531eb1f3d3d0a052313ef9d8125bac7 Mon Sep 17 00:00:00 2001
From: "L. Donnie Smith" <donnie.smith@gatech.edu>
Date: Thu, 4 Feb 2010 22:53:41 -0500
Subject: [PATCH] fix link options for --as-needed (#90)

also fix a couple of includes
---
 common/include/app.mak    | 2 +-
 common/include/lib.mak.in | 4 ++--
 common/include/plugin.mak | 2 +-
 lswm/Makefile.in          | 2 +-
 python/Makefile.in        | 2 +-
 python/Wiimote.c          | 2 +-
 python/cwiidmodule.c      | 2 +-
 wmdemo/wmdemo.c           | 1 +
 wmgui/Makefile.in         | 2 +-
 wminput/Makefile.in       | 2 +-
 wminput/main.c            | 1 +
 11 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/common/include/app.mak b/common/include/app.mak
index f00cf12..c26d0ff 100644
--- a/common/include/app.mak
+++ b/common/include/app.mak
@@ -10,7 +10,7 @@ DEST_INST_DIR = $(ROOTDIR)$(INST_DIR)
 all: $(APP_NAME)
 
 $(APP_NAME): $(OBJECTS)
-	$(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(LDLIBS)
+	$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS)
 
 install: $(APP_NAME)
 	install -D $(APP_NAME) $(DEST_INST_DIR)/$(APP_NAME)
diff --git a/common/include/lib.mak.in b/common/include/lib.mak.in
index 5e81ff3..3afbb14 100644
--- a/common/include/lib.mak.in
+++ b/common/include/lib.mak.in
@@ -25,8 +25,8 @@ $(STATIC_LIB): $(OBJECTS)
 	ar rcs $(STATIC_LIB) $(OBJECTS)
 
 $(SHARED_LIB): $(OBJECTS)
-	$(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) $(LDLIBS) \
-	      -o $(SHARED_LIB) $(OBJECTS)
+	$(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $(SHARED_LIB) \
+	      $(OBJECTS) $(LDLIBS)
 
 install: install_header install_static install_shared
 
diff --git a/common/include/plugin.mak b/common/include/plugin.mak
index 0f61502..a2d5c85 100644
--- a/common/include/plugin.mak
+++ b/common/include/plugin.mak
@@ -16,7 +16,7 @@ DEST_INST_DIR = $(INST_DIR)
 all: $(LIB_NAME)
 
 $(LIB_NAME): $(OBJECTS)
-	$(CC) -shared $(LDFLAGS) $(LDLIBS) -o $(LIB_NAME) $(OBJECTS)
+	$(CC) -shared $(LDFLAGS) -o $(LIB_NAME) $(OBJECTS) $(LDLIBS)
 
 install: $(LIB_NAME)
 	install -D $(LIB_NAME) $(DEST_INST_DIR)/$(LIB_NAME)
diff --git a/lswm/Makefile.in b/lswm/Makefile.in
index 79e8b5b..017104f 100644
--- a/lswm/Makefile.in
+++ b/lswm/Makefile.in
@@ -8,7 +8,7 @@ SOURCES = lswm.c
 
 CFLAGS += -I@top_builddir@/libcwiid
 LDFLAGS += -L@top_builddir@/libcwiid
-LDLIBS += -lcwiid
+LDLIBS += -lcwiid -lbluetooth
 INST_DIR = @bindir@
 
 include $(COMMON)/include/app.mak
diff --git a/python/Makefile.in b/python/Makefile.in
index 0d7efdf..0ca57ca 100644
--- a/python/Makefile.in
+++ b/python/Makefile.in
@@ -7,7 +7,7 @@ ifdef ROOTDIR
 endif
 
 all:
-	$(PYTHON) setup.py build_ext $(DEBUGFLAGS) -I@top_builddir@/libcwiid -L@top_builddir@/libcwiid -lcwiid
+	$(PYTHON) setup.py build_ext $(DEBUGFLAGS) -I@top_builddir@/libcwiid -L@top_builddir@/libcwiid -lcwiid -lbluetooth
 
 install:
 	$(PYTHON) setup.py install --install-lib=${libdir}/python@PYTHON_VERSION@/site-packages $(SET_ROOT_DIR)
diff --git a/python/Wiimote.c b/python/Wiimote.c
index 794e7e2..523185e 100644
--- a/python/Wiimote.c
+++ b/python/Wiimote.c
@@ -24,7 +24,7 @@
 #include "structmember.h"
 #include <errno.h>
 #include <bluetooth/bluetooth.h>
-#include "cwiid.h"
+#include <cwiid.h>
 
 #if (PY_VERSION_HEX < 0x02050000)
   #ifndef PY_SSIZE_T_MIN
diff --git a/python/cwiidmodule.c b/python/cwiidmodule.c
index f6a8f33..a01ed82 100644
--- a/python/cwiidmodule.c
+++ b/python/cwiidmodule.c
@@ -24,7 +24,7 @@
 
 #include <stdlib.h>
 
-#include "cwiid.h"
+#include <cwiid.h>
 #include "structmember.h"
 
 /* externally defined types */
diff --git a/wmdemo/wmdemo.c b/wmdemo/wmdemo.c
index 70a25a1..b7aaa7f 100644
--- a/wmdemo/wmdemo.c
+++ b/wmdemo/wmdemo.c
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <bluetooth/bluetooth.h>
 #include <cwiid.h>
 
 /* This is a sample program written to demonstrate basic CWiid libwiimote
diff --git a/wmgui/Makefile.in b/wmgui/Makefile.in
index 41b205e..14d1c1e 100644
--- a/wmgui/Makefile.in
+++ b/wmgui/Makefile.in
@@ -8,7 +8,7 @@ SOURCES = main.c interface.c support.c
 
 CFLAGS += @GTK_CFLAGS@ -I@top_builddir@/libcwiid
 LDFLAGS += -L@top_builddir@/libcwiid
-LDLIBS += @GTK_LIBS@ -lm -lcwiid
+LDLIBS += @GTK_LIBS@ -lcwiid -lbluetooth -lm
 INST_DIR = @bindir@
 
 include $(COMMON)/include/app.mak
diff --git a/wminput/Makefile.in b/wminput/Makefile.in
index 009d4d5..d3c3679 100644
--- a/wminput/Makefile.in
+++ b/wminput/Makefile.in
@@ -14,7 +14,7 @@ CFLAGS += -I@top_builddir@/libcwiid \
 	-DWMINPUT_CONFIG_DIR=\"$(WMINPUT_CONFIG_DIR)\" \
 	-DCWIID_PLUGINS_DIR=\"$(CWIID_PLUGINS_DIR)\"
 
-LDLIBS += -lcwiid -ldl
+LDLIBS += -lcwiid -lbluetooth -ldl -lpthread
 LDFLAGS += -L@top_builddir@/libcwiid -rdynamic
 INST_DIR = @bindir@
 
diff --git a/wminput/main.c b/wminput/main.c
index c3a7445..bbc98d9 100644
--- a/wminput/main.c
+++ b/wminput/main.c
@@ -30,6 +30,7 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <bluetooth/bluetooth.h>
 
 #include <cwiid.h>
 
-- 
1.8.5.2

