Build the builtin plugins along with the daemon
diff --git a/.gitignore b/.gitignore
index 7c2c08b..9ee703d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,7 +32,7 @@
 bluez.pc
 include/bluetooth
 src/bluetoothd
-plugins/builtin.h
+src/builtin.h
 audio/telephony.c
 scripts/bluetooth.rules
 
diff --git a/Makefile.am b/Makefile.am
index c4c6322..fce7260 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
 
-SUBDIRS = include lib sbc gdbus common plugins src client\
+SUBDIRS = include lib sbc gdbus common src client plugins \
 			network serial input audio tools \
 			rfcomm compat cups test scripts doc
 
@@ -9,12 +9,10 @@
 
 pkgconfig_DATA = bluez.pc
 
-DISTCHECK_CONFIGURE_FLAGS = --disable-gtk-doc \
-				--disable-udevrules
+DISTCHECK_CONFIGURE_FLAGS = --disable-gtk-doc --disable-udevrules
 
 DISTCLEANFILES = $(pkgconfig_DATA)
 
 MAINTAINERCLEANFILES = Makefile.in \
 	aclocal.m4 configure config.h.in config.sub config.guess \
 	ltmain.sh depcomp compile missing install-sh mkinstalldirs ylwrap
-
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 9d9f970..3895e27 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -3,39 +3,12 @@
 
 plugin_LTLIBRARIES =
 
-builtin_modules =
-builtin_sources =
-builtin_cflags =
-
-if SERVICEPLUGIN
-builtin_modules += service
-builtin_sources += service.c
-endif
-
-builtin_modules += hciops
-builtin_sources += hciops.c
-
 if NETLINK
 plugin_LTLIBRARIES += netlink.la
 netlink_la_LIBADD = @NETLINK_LIBS@
 endif
 
-builtin_modules += hal
-builtin_sources += hal.c
-
-builtin_modules += storage
-builtin_sources += storage.c
-
-noinst_LTLIBRARIES = libbuiltin.la echo.la
-
-libbuiltin_la_SOURCES = $(builtin_sources)
-libbuiltin_la_LDFLAGS =
-libbuiltin_la_CFLAGS = $(AM_CFLAGS) \
-			$(builtin_cflags) -DBLUETOOTH_PLUGIN_BUILTIN
-
-BUILT_SOURCES = builtin.h
-
-nodist_libbuiltin_la_SOURCES = $(BUILT_SOURCES)
+noinst_LTLIBRARIES = echo.la
 
 AM_LDFLAGS = -module -avoid-version -no-undefined
 
@@ -44,28 +17,4 @@
 
 INCLUDES = -I$(top_srcdir)/common -I$(top_srcdir)/src
 
-CLEANFILES = $(BUILT_SOURCES)
-
 MAINTAINERCLEANFILES = Makefile.in
-
-builtin.h:
-	echo "" > $@
-	list='$(builtin_modules)'; for i in $$list; \
-	  do echo "extern struct bluetooth_plugin_desc __bluetooth_builtin_$$i;" >> $@; done
-	echo "" >> $@
-	echo "static struct bluetooth_plugin_desc *__bluetooth_builtin[] = {" >> $@
-	list='$(builtin_modules)'; for i in $$list; \
-	  do echo "&__bluetooth_builtin_$$i," >> $@; done
-	echo "NULL };" >> $@
-
-all-local:
-	@$(LN_S) -f $(top_srcdir)/input/.libs/input.so
-	@$(LN_S) -f $(top_srcdir)/audio/.libs/audio.so
-	@$(LN_S) -f $(top_srcdir)/serial/.libs/serial.so
-	@$(LN_S) -f $(top_srcdir)/network/.libs/network.so
-
-clean-local:
-	@rm -f network.so
-	@rm -f serial.so
-	@rm -f audio.so
-	@rm -f input.so
diff --git a/src/Makefile.am b/src/Makefile.am
index 569c060..bd68d50 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,37 @@
 state_DATA =
 endif
 
+builtin_modules =
+builtin_sources =
+builtin_cflags =
+
+if SERVICEPLUGIN
+builtin_modules += service
+builtin_sources += $(top_srcdir)/plugins/service.c
+endif
+
+builtin_modules += hciops
+builtin_sources += $(top_srcdir)/plugins/hciops.c
+
+builtin_modules += hal
+builtin_sources += $(top_srcdir)/plugins/hal.c
+
+builtin_modules += storage
+builtin_sources += $(top_srcdir)/plugins/storage.c
+
+noinst_LTLIBRARIES = libbuiltin.la
+
+libbuiltin_la_SOURCES = $(builtin_sources)
+libbuiltin_la_LDFLAGS =
+libbuiltin_la_CFLAGS = $(AM_CFLAGS) \
+			$(builtin_cflags) -DBLUETOOTH_PLUGIN_BUILTIN
+
+BUILT_SOURCES = builtin.h
+
+nodist_libbuiltin_la_SOURCES = $(BUILT_SOURCES)
+
+CLEANFILES = $(BUILT_SOURCES)
+
 sbin_PROGRAMS = bluetoothd
 
 bluetoothd_SOURCES = main.c security.c hcid.h sdpd.h \
@@ -21,14 +52,15 @@
 	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 \
-			$(top_builddir)/plugins/libbuiltin.la \
+bluetoothd_LDADD = $(top_builddir)/common/libhelper.a libbuiltin.la \
 			@GDBUS_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @BLUEZ_LIBS@ -ldl
 
 bluetoothd_LDFLAGS = -Wl,--export-dynamic
 
+bluetoothd_DEPENDENCIES = libbuiltin.la
+
 if MAINTAINER_MODE
-plugindir = $(abs_top_srcdir)/plugins
+plugindir = $(abs_top_srcdir)/plugins/.libs
 else
 plugindir = $(libdir)/bluetooth/plugins
 endif
@@ -36,7 +68,7 @@
 AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ @GDBUS_CFLAGS@ \
 						-DPLUGINDIR=\""$(plugindir)"\"
 
-INCLUDES = -I$(top_srcdir)/common -I$(top_builddir)/plugins
+INCLUDES = -I$(top_srcdir)/common
 
 if MANPAGES
 man_MANS = bluetoothd.8
@@ -45,3 +77,13 @@
 EXTRA_DIST = bluetooth.conf bluetoothd.8 main.conf
 
 MAINTAINERCLEANFILES = Makefile.in
+
+builtin.h:
+	echo "" > $@
+	list='$(builtin_modules)'; for i in $$list; \
+	  do echo "extern struct bluetooth_plugin_desc __bluetooth_builtin_$$i;" >> $@; done
+	echo "" >> $@
+	echo "static struct bluetooth_plugin_desc *__bluetooth_builtin[] = {" >> $@
+	list='$(builtin_modules)'; for i in $$list; \
+	  do echo "&__bluetooth_builtin_$$i," >> $@; done
+	echo "NULL };" >> $@