Make all major plugins builtin to simplify debugging
diff --git a/Makefile.am b/Makefile.am
index fce7260..a6ea785 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
 
-SUBDIRS = include lib sbc gdbus common src client plugins \
-			network serial input audio tools \
-			rfcomm compat cups test scripts doc
+SUBDIRS = include lib sbc gdbus common \
+		plugins network serial input audio src \
+		client tools rfcomm compat cups test scripts doc
 
 EXTRA_DIST = bluez.m4
 
diff --git a/audio/Makefile.am b/audio/Makefile.am
index 52ad212..f396fcd 100644
--- a/audio/Makefile.am
+++ b/audio/Makefile.am
@@ -2,9 +2,7 @@
 BUILT_SOURCES = telephony.c
 
 if AUDIOPLUGIN
-plugindir = $(libdir)/bluetooth/plugins
-
-plugin_LTLIBRARIES = audio.la
+noinst_LTLIBRARIES = audio.la libipc.la
 
 audio_la_SOURCES = main.c \
 	ipc.h ipc.c unix.h unix.c manager.h manager.c telephony.h \
@@ -19,6 +17,8 @@
 LDADD = $(top_builddir)/common/libhelper.a \
 		@GDBUS_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@
 
+libipc_la_SOURCES = ipc.h ipc.c
+
 if ALSA
 alsadir = $(libdir)/alsa-lib
 
@@ -61,17 +61,13 @@
 libgstbluetooth_la_CFLAGS = -fvisibility=hidden -fno-strict-aliasing \
 			 @GSTREAMER_CFLAGS@ @BLUEZ_CFLAGS@ @SBC_CFLAGS@
 endif
-endif
-
-noinst_LTLIBRARIES = libipc.la
-
-libipc_la_SOURCES = ipc.h ipc.c
 
 noinst_PROGRAMS = ipctest
 
 ipctest_LDADD= libipc.la @SBC_LIBS@ @GLIB_LIBS@
+endif
 
-AM_CFLAGS = -fvisibility=hidden @SBC_CFLAGS@ \
+AM_CFLAGS = -fvisibility=hidden -DBLUETOOTH_PLUGIN_BUILTIN @SBC_CFLAGS@ \
 		@BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ @GDBUS_CFLAGS@
 
 CLEANFILES = $(BUILT_SOURCES)
diff --git a/input/Makefile.am b/input/Makefile.am
index 98ce928..66ed896 100644
--- a/input/Makefile.am
+++ b/input/Makefile.am
@@ -1,20 +1,15 @@
 
 if INPUTPLUGIN
-plugindir = $(libdir)/bluetooth/plugins
-
-plugin_LTLIBRARIES = input.la
+noinst_LTLIBRARIES = input.la
 
 input_la_SOURCES = main.c manager.h manager.c \
 			server.h server.c device.h device.c \
 						fakehid.c fakehid.h
-
-LDADD = $(top_builddir)/common/libhelper.a \
-		@GDBUS_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@
 endif
 
 AM_LDFLAGS = -module -avoid-version -no-undefined
 
-AM_CFLAGS = -fvisibility=hidden \
+AM_CFLAGS = -fvisibility=hidden -DBLUETOOTH_PLUGIN_BUILTIN \
 		@BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ @GDBUS_CFLAGS@
 
 INCLUDES = -I$(top_srcdir)/common -I$(top_srcdir)/src
diff --git a/input/manager.c b/input/manager.c
index 567075b..e4c68b2 100644
--- a/input/manager.c
+++ b/input/manager.c
@@ -45,7 +45,7 @@
 static int idle_timeout = 0;
 
 static DBusConnection *connection = NULL;
-GSList *adapters = NULL;
+static GSList *adapters = NULL;
 
 static void input_remove(struct btd_device *device, const char *uuid)
 {
diff --git a/network/Makefile.am b/network/Makefile.am
index f5cb320..2a14630 100644
--- a/network/Makefile.am
+++ b/network/Makefile.am
@@ -1,20 +1,15 @@
 
 if NETWORKPLUGIN
-plugindir = $(libdir)/bluetooth/plugins
-
-plugin_LTLIBRARIES = network.la
+noinst_LTLIBRARIES = network.la
 
 network_la_SOURCES = main.c manager.h manager.c \
 				server.h server.c bridge.h bridge.c \
 				connection.h connection.c common.h common.c
-
-LDADD = $(top_builddir)/common/libhelper.a \
-		@GDBUS_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@
 endif
 
 AM_LDFLAGS = -module -avoid-version -no-undefined
 
-AM_CFLAGS = -fvisibility=hidden \
+AM_CFLAGS = -fvisibility=hidden -DBLUETOOTH_PLUGIN_BUILTIN \
 		@BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ @GDBUS_CFLAGS@
 
 INCLUDES = -I$(top_srcdir)/common -I$(top_srcdir)/src
diff --git a/serial/Makefile.am b/serial/Makefile.am
index f8f26e2..04c4984 100644
--- a/serial/Makefile.am
+++ b/serial/Makefile.am
@@ -1,20 +1,15 @@
 
 if SERIALPLUGIN
-plugindir = $(libdir)/bluetooth/plugins
+noinst_LTLIBRARIES = serial.la
 
-plugin_LTLIBRARIES = serial.la
+serial_la_SOURCES = main.c manager.h manager.c \
+			port.h port.c proxy.h proxy.c
 
-serial_la_SOURCES = main.c \
-			manager.h manager.c port.h port.c \
-			proxy.h proxy.c
-
-LDADD = $(top_builddir)/common/libhelper.a \
-		@GDBUS_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@
 endif
 
 AM_LDFLAGS = -module -avoid-version -no-undefined
 
-AM_CFLAGS = -fvisibility=hidden \
+AM_CFLAGS = -fvisibility=hidden -DBLUETOOTH_PLUGIN_BUILTIN \
 		@BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ @GDBUS_CFLAGS@
 
 INCLUDES = -I$(top_srcdir)/common -I$(top_srcdir)/src
diff --git a/serial/manager.c b/serial/manager.c
index 71f1a5e..2022fcb 100644
--- a/serial/manager.c
+++ b/serial/manager.c
@@ -73,7 +73,6 @@
 #define RFCOMM_UUID_STR		"00000003-0000-1000-8000-00805F9B34FB"
 
 static DBusConnection *connection = NULL;
-GSList *adapters = NULL;
 
 static int serial_probe(struct btd_device *device, const char *uuid)
 {
diff --git a/src/Makefile.am b/src/Makefile.am
index bd68d50..ba73a72 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,6 +16,7 @@
 builtin_modules =
 builtin_sources =
 builtin_cflags =
+builtin_libadd =
 
 if SERVICEPLUGIN
 builtin_modules += service
@@ -31,6 +32,26 @@
 builtin_modules += storage
 builtin_sources += $(top_srcdir)/plugins/storage.c
 
+if NETWORKPLUGIN
+builtin_modules += network
+builtin_libadd += $(top_builddir)/network/network.la
+endif
+
+if SERIALPLUGIN
+builtin_modules += serial
+builtin_libadd += $(top_builddir)/serial/serial.la
+endif
+
+if INPUTPLUGIN
+builtin_modules += input
+builtin_libadd += $(top_builddir)/input/input.la
+endif
+
+if AUDIOPLUGIN
+builtin_modules += audio
+builtin_libadd += $(top_builddir)/audio/audio.la
+endif
+
 noinst_LTLIBRARIES = libbuiltin.la
 
 libbuiltin_la_SOURCES = $(builtin_sources)
@@ -52,7 +73,8 @@
 	error.h error.c manager.h manager.c adapter.h adapter.c \
 	device.h device.c dbus-common.c dbus-common.h dbus-hci.h dbus-hci.c
 
-bluetoothd_LDADD = $(top_builddir)/common/libhelper.a libbuiltin.la \
+bluetoothd_LDADD = $(top_builddir)/common/libhelper.a \
+			libbuiltin.la $(builtin_libadd) \
 			@GDBUS_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@ -ldl
 
 bluetoothd_LDFLAGS = -Wl,--export-dynamic