build: Move clients/Makefile.am into toplevel Makefile.am
diff --git a/Makefile.am b/Makefile.am
index 6c5fd85..3bdad87 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,13 +1,12 @@
 bin_PROGRAMS =
 noinst_PROGRAMS =
+libexec_PROGRAMS =
 moduledir = $(libdir)/weston
 module_LTLIBRARIES =
 noinst_LTLIBRARIES =
 BUILT_SOURCES =
 
-SUBDIRS =					\
-	shared					\
-	clients
+SUBDIRS = shared
 
 DISTCHECK_CONFIGURE_FLAGS = --disable-setuid-install
 
@@ -27,11 +26,13 @@
 AM_CPPFLAGS = 					\
 	-I$(top_srcdir)/src			\
 	-I$(top_builddir)/src			\
+	-I$(top_builddir)/clients		\
 	-I$(top_builddir)/tests			\
 	-I$(top_srcdir)/shared			\
 	-DDATADIR='"$(datadir)"'		\
 	-DMODULEDIR='"$(moduledir)"'		\
-	-DLIBEXECDIR='"$(libexecdir)"'
+	-DLIBEXECDIR='"$(libexecdir)"'		\
+	-DBINDIR='"$(bindir)"'
 
 CLEANFILES = weston.ini $(BUILT_SOURCES)
 
@@ -343,6 +344,258 @@
 	src/scaler-protocol.c				\
 	src/git-version.h
 
+if BUILD_CLIENTS
+
+bin_PROGRAMS += weston-terminal weston-info
+
+libexec_PROGRAMS +=				\
+	weston-desktop-shell			\
+	weston-screenshooter			\
+	weston-keyboard				\
+	weston-simple-im
+
+demo_clients =					\
+	weston-flower				\
+	weston-image				\
+	weston-cliptest				\
+	weston-dnd				\
+	weston-smoke				\
+	weston-resizor				\
+	weston-eventdemo			\
+	weston-clickdot				\
+	weston-transformed			\
+	weston-fullscreen			\
+	weston-stacking				\
+	weston-calibrator			\
+	weston-scaler
+
+if INSTALL_DEMO_CLIENTS
+bin_PROGRAMS += $(demo_clients)
+else
+noinst_PROGRAMS += $(demo_clients)
+endif
+
+
+if BUILD_SIMPLE_CLIENTS
+demo_clients +=					\
+	weston-simple-shm			\
+	weston-simple-touch			\
+	weston-multi-resource
+
+weston_simple_shm_SOURCES =			\
+	clients/simple-shm.c			\
+	shared/os-compatibility.c		\
+	shared/os-compatibility.h
+weston_simple_shm_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
+weston_simple_shm_LDADD = $(SIMPLE_CLIENT_LIBS)
+
+weston_simple_touch_SOURCES =			\
+	clients/simple-touch.c			\
+	shared/os-compatibility.c		\
+	shared/os-compatibility.h
+weston_simple_touch_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
+weston_simple_touch_LDADD = $(SIMPLE_CLIENT_LIBS)
+
+weston_multi_resource_SOURCES =			\
+	clients/multi-resource.c		\
+	shared/os-compatibility.c		\
+	shared/os-compatibility.h
+weston_multi_resource_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
+weston_multi_resource_LDADD = $(SIMPLE_CLIENT_LIBS) -lm
+endif
+
+if BUILD_SIMPLE_EGL_CLIENTS
+demo_clients += weston-simple-egl
+weston_simple_egl_SOURCES = clients/simple-egl.c
+weston_simple_egl_CPPFLAGS = $(SIMPLE_EGL_CLIENT_CFLAGS)
+weston_simple_egl_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
+endif
+
+noinst_LTLIBRARIES += libtoytoolkit.la
+
+libtoytoolkit_la_SOURCES =				\
+	clients/window.c				\
+	clients/window.h				\
+	clients/text-cursor-position-protocol.c		\
+	clients/text-cursor-position-client-protocol.h	\
+	clients/scaler-protocol.c			\
+	clients/scaler-client-protocol.h		\
+	clients/workspaces-protocol.c			\
+	clients/workspaces-client-protocol.h
+
+libtoytoolkit_la_LIBADD =			\
+	$(CLIENT_LIBS)				\
+	$(CAIRO_EGL_LIBS)			\
+	shared/libshared-cairo.la -lrt -lm
+libtoytoolkit_la_CFLAGS = $(CLIENT_CFLAGS) $(CAIRO_EGL_CFLAGS)
+
+weston_flower_SOURCES = clients/flower.c
+weston_flower_LDADD = libtoytoolkit.la
+weston_flower_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_screenshooter_SOURCES =			\
+	clients/screenshot.c				\
+	clients/screenshooter-protocol.c		\
+	clients/screenshooter-client-protocol.h		\
+	shared/os-compatibility.c		\
+	shared/os-compatibility.h
+weston_screenshooter_LDADD = $(CLIENT_LIBS)
+weston_screenshooter_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_terminal_SOURCES = clients/terminal.c
+weston_terminal_LDADD = libtoytoolkit.la -lutil
+weston_terminal_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_image_SOURCES = clients/image.c
+weston_image_LDADD = libtoytoolkit.la
+weston_image_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_cliptest_SOURCES = clients/cliptest.c
+weston_cliptest_CFLAGS = $(AM_CPPFLAGS) $(CLIENT_CFLAGS)
+weston_cliptest_LDADD = libtoytoolkit.la
+
+weston_dnd_SOURCES = clients/dnd.c
+weston_dnd_LDADD = libtoytoolkit.la
+weston_dnd_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_smoke_SOURCES = clients/smoke.c
+weston_smoke_LDADD = libtoytoolkit.la
+weston_smoke_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_resizor_SOURCES = clients/resizor.c
+weston_resizor_LDADD = libtoytoolkit.la
+weston_resizor_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_scaler_SOURCES = clients/scaler.c
+weston_scaler_LDADD = libtoytoolkit.la
+weston_scaler_CFLAGS = $(CLIENT_CFLAGS)
+
+if HAVE_CAIRO_GLESV2
+demo_clients += weston-nested weston-nested-client
+
+weston_nested_SOURCES = clients/nested.c
+weston_nested_LDADD = libtoytoolkit.la $(SERVER_LIBS)
+weston_nested_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_nested_client_SOURCES = clients/nested-client.c
+weston_nested_client_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
+endif
+
+weston_eventdemo_SOURCES = clients/eventdemo.c
+weston_eventdemo_LDADD = libtoytoolkit.la
+weston_eventdemo_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_clickdot_SOURCES = clients/clickdot.c
+weston_clickdot_LDADD = libtoytoolkit.la
+weston_clickdot_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_transformed_SOURCES = clients/transformed.c
+weston_transformed_LDADD = libtoytoolkit.la
+weston_transformed_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_fullscreen_SOURCES = clients/fullscreen.c
+weston_fullscreen_LDADD = libtoytoolkit.la
+weston_fullscreen_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_stacking_SOURCES = clients/stacking.c
+weston_stacking_LDADD = libtoytoolkit.la
+weston_stacking_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_calibrator_SOURCES = clients/calibrator.c	\
+	shared/matrix.c					\
+	shared/matrix.h
+weston_calibrator_LDADD = libtoytoolkit.la
+weston_calibrator_CFLAGS = $(CLIENT_CFLAGS)
+
+if BUILD_SUBSURFACES_CLIENT
+demo_clients += weston-subsurfaces
+weston_subsurfaces_SOURCES = clients/subsurfaces.c
+weston_subsurfaces_CFLAGS = $(SIMPLE_EGL_CLIENT_CFLAGS) $(CLIENT_CFLAGS)
+weston_subsurfaces_LDADD = libtoytoolkit.la $(SIMPLE_EGL_CLIENT_LIBS) -lm
+endif
+
+if HAVE_PANGO
+demo_clients += weston-editor
+weston_editor_SOURCES =				\
+	clients/editor.c			\
+	clients/text-protocol.c			\
+	clients/text-client-protocol.h
+weston_editor_LDADD = libtoytoolkit.la $(PANGO_LIBS)
+weston_editor_CFLAGS = $(CLIENT_CFLAGS) $(PANGO_CFLAGS)
+endif
+
+weston_keyboard_SOURCES =			\
+	clients/keyboard.c			\
+	clients/desktop-shell-client-protocol.h	\
+	clients/desktop-shell-protocol.c	\
+	clients/input-method-protocol.c		\
+	clients/input-method-client-protocol.h
+weston_keyboard_LDADD = libtoytoolkit.la
+weston_keyboard_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_simple_im_SOURCES =			\
+	clients/weston-simple-im.c		\
+	clients/input-method-protocol.c		\
+	clients/input-method-client-protocol.h
+weston_simple_im_LDADD = $(CLIENT_LIBS)
+weston_simple_im_CFLAGS = $(CLIENT_CFLAGS)
+
+weston_info_SOURCES =				\
+	clients/weston-info.c			\
+	shared/os-compatibility.c		\
+	shared/os-compatibility.h
+weston_info_LDADD = $(WESTON_INFO_LIBS)
+
+weston_desktop_shell_SOURCES =			\
+	clients/desktop-shell.c			\
+	clients/desktop-shell-client-protocol.h	\
+	clients/desktop-shell-protocol.c
+weston_desktop_shell_LDADD = libtoytoolkit.la
+weston_desktop_shell_CFLAGS = $(CLIENT_CFLAGS)
+
+if BUILD_FULL_GL_CLIENTS
+demo_clients += weston-gears
+weston_gears_SOURCES = clients/gears.c
+weston_gears_LDADD = libtoytoolkit.la
+weston_gears_CFLAGS = $(CLIENT_CFLAGS)
+
+if HAVE_GLU
+libexec_PROGRAMS += weston-screensaver
+weston_screensaver_SOURCES =			\
+	clients/wscreensaver.c			\
+	clients/wscreensaver.h			\
+	clients/desktop-shell-client-protocol.h	\
+	clients/desktop-shell-protocol.c	\
+	clients/wscreensaver-glue.c		\
+	clients/wscreensaver-glue.h		\
+	clients/glmatrix.c			\
+	clients/matrix3.xpm
+weston_screensaver_LDADD = libtoytoolkit.la $(GLU_LIBS)
+weston_screensaver_CFLAGS = $(GLU_CFLAGS) $(CLIENT_CFLAGS)
+
+endif
+
+endif
+
+endif
+
+BUILT_SOURCES +=					\
+	clients/screenshooter-client-protocol.h		\
+	clients/screenshooter-protocol.c		\
+	clients/text-cursor-position-client-protocol.h	\
+	clients/text-cursor-position-protocol.c		\
+	clients/text-protocol.c				\
+	clients/text-client-protocol.h			\
+	clients/input-method-protocol.c			\
+	clients/input-method-client-protocol.h		\
+	clients/desktop-shell-client-protocol.h		\
+	clients/desktop-shell-protocol.c		\
+	clients/scaler-client-protocol.h		\
+	clients/scaler-protocol.c			\
+	clients/workspaces-client-protocol.h		\
+	clients/workspaces-protocol.c
+
+
 westondatadir = $(datadir)/weston
 dist_westondata_DATA =				\
 	data/wayland.svg			\
diff --git a/clients/Makefile.am b/clients/Makefile.am
deleted file mode 100644
index e90245f..0000000
--- a/clients/Makefile.am
+++ /dev/null
@@ -1,249 +0,0 @@
-bin_PROGRAMS = $(install_clients)
-
-demo_clients = \
-	$(clients_programs)			\
-	$(pango_programs)			\
-	$(simple_clients_programs)		\
-	$(simple_egl_clients_programs)
-
-if INSTALL_DEMO_CLIENTS
-bin_PROGRAMS += $(demo_clients)
-else
-noinst_PROGRAMS = $(demo_clients)
-endif
-
-AM_CFLAGS = $(GCC_CFLAGS)
-AM_CPPFLAGS =					\
-	-DDATADIR='"$(datadir)"'		\
-	-DBINDIR='"$(bindir)"'			\
-	$(CLIENT_CFLAGS) $(CAIRO_EGL_CFLAGS)
-
-if BUILD_SIMPLE_CLIENTS
-simple_clients_programs =			\
-	weston-simple-shm			\
-	weston-simple-touch			\
-	weston-multi-resource
-
-weston_simple_shm_SOURCES = simple-shm.c 	\
-	../shared/os-compatibility.c		\
-	../shared/os-compatibility.h
-weston_simple_shm_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
-weston_simple_shm_LDADD = $(SIMPLE_CLIENT_LIBS)
-
-weston_simple_touch_SOURCES = simple-touch.c	\
-	../shared/os-compatibility.c		\
-	../shared/os-compatibility.h
-weston_simple_touch_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
-weston_simple_touch_LDADD = $(SIMPLE_CLIENT_LIBS)
-
-weston_multi_resource_SOURCES = multi-resource.c	\
-	../shared/os-compatibility.c			\
-	../shared/os-compatibility.h
-weston_multi_resource_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS)
-weston_multi_resource_LDADD = $(SIMPLE_CLIENT_LIBS) -lm
-endif
-
-if BUILD_SIMPLE_EGL_CLIENTS
-simple_egl_clients_programs =			\
-	weston-simple-egl
-
-weston_simple_egl_SOURCES = simple-egl.c
-weston_simple_egl_CPPFLAGS = $(SIMPLE_EGL_CLIENT_CFLAGS)
-weston_simple_egl_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
-endif
-
-if BUILD_CLIENTS
-install_clients = weston-terminal weston-info
-
-libexec_PROGRAMS =				\
-	weston-desktop-shell			\
-	weston-screenshooter			\
-	$(screensaver)				\
-	weston-keyboard				\
-	weston-simple-im
-
-clients_programs =				\
-	weston-flower				\
-	weston-image				\
-	weston-cliptest				\
-	weston-dnd				\
-	weston-smoke				\
-	weston-resizor				\
-	weston-eventdemo			\
-	weston-clickdot				\
-	weston-transformed			\
-	weston-fullscreen			\
-	weston-stacking				\
-	weston-calibrator			\
-	weston-scaler				\
-	$(subsurfaces)				\
-	$(full_gl_client_programs)		\
-	$(cairo_glesv2_programs)
-
-noinst_LTLIBRARIES = libtoytoolkit.la
-
-libtoytoolkit_la_SOURCES =			\
-	window.c				\
-	window.h				\
-	text-cursor-position-protocol.c		\
-	text-cursor-position-client-protocol.h	\
-	scaler-protocol.c			\
-	scaler-client-protocol.h		\
-	workspaces-protocol.c			\
-	workspaces-client-protocol.h
-
-libtoytoolkit_la_LIBADD =			\
-	$(CLIENT_LIBS)				\
-	$(CAIRO_EGL_LIBS)			\
-	../shared/libshared-cairo.la -lrt -lm
-
-weston_flower_SOURCES = flower.c
-weston_flower_LDADD = libtoytoolkit.la
-
-weston_screenshooter_SOURCES =			\
-	screenshot.c				\
-	screenshooter-protocol.c		\
-	screenshooter-client-protocol.h		\
-	../shared/os-compatibility.c		\
-	../shared/os-compatibility.h
-weston_screenshooter_LDADD = $(CLIENT_LIBS)
-
-weston_terminal_SOURCES = terminal.c
-weston_terminal_LDADD = libtoytoolkit.la -lutil
-
-weston_image_SOURCES = image.c
-weston_image_LDADD = libtoytoolkit.la
-
-weston_cliptest_SOURCES = cliptest.c
-weston_cliptest_CPPFLAGS = $(AM_CPPFLAGS) $(PIXMAN_CFLAGS)
-weston_cliptest_LDADD = libtoytoolkit.la $(PIXMAN_LIBS)
-
-weston_dnd_SOURCES = dnd.c
-weston_dnd_LDADD = libtoytoolkit.la
-
-weston_smoke_SOURCES = smoke.c
-weston_smoke_LDADD = libtoytoolkit.la
-
-weston_resizor_SOURCES = resizor.c
-weston_resizor_LDADD = libtoytoolkit.la
-
-weston_scaler_SOURCES = scaler.c
-weston_scaler_LDADD = libtoytoolkit.la
-
-if HAVE_CAIRO_GLESV2
-cairo_glesv2_programs = weston-nested weston-nested-client
-
-weston_nested_SOURCES = nested.c
-weston_nested_LDADD = libtoytoolkit.la $(SERVER_LIBS)
-
-weston_nested_client_SOURCES = nested-client.c
-weston_nested_client_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
-endif
-
-weston_eventdemo_SOURCES = eventdemo.c
-weston_eventdemo_LDADD = libtoytoolkit.la
-
-weston_clickdot_SOURCES = clickdot.c
-weston_clickdot_LDADD = libtoytoolkit.la
-
-weston_transformed_SOURCES = transformed.c
-weston_transformed_LDADD = libtoytoolkit.la
-
-weston_fullscreen_SOURCES = fullscreen.c
-weston_fullscreen_LDADD = libtoytoolkit.la
-
-weston_stacking_SOURCES = stacking.c
-weston_stacking_LDADD = libtoytoolkit.la
-
-weston_calibrator_SOURCES = calibrator.c	\
-	../shared/matrix.c			\
-	../shared/matrix.h
-weston_calibrator_LDADD = libtoytoolkit.la
-
-if BUILD_SUBSURFACES_CLIENT
-subsurfaces = weston-subsurfaces
-weston_subsurfaces_SOURCES = subsurfaces.c
-weston_subsurfaces_CPPFLAGS = $(AM_CPPFLAGS) $(SIMPLE_EGL_CLIENT_CFLAGS)
-weston_subsurfaces_LDADD = libtoytoolkit.la $(SIMPLE_EGL_CLIENT_LIBS) -lm
-endif
-
-if HAVE_PANGO
-pango_programs = weston-editor
-weston_editor_SOURCES = 			\
-	editor.c				\
-	text-protocol.c				\
-	text-client-protocol.h
-weston_editor_LDADD = libtoytoolkit.la $(PANGO_LIBS)
-weston_editor_CPPFLAGS = $(AM_CPPFLAGS) $(PANGO_CFLAGS)
-endif
-
-weston_keyboard_SOURCES = 			\
-	keyboard.c				\
-	desktop-shell-client-protocol.h		\
-	desktop-shell-protocol.c		\
-	input-method-protocol.c			\
-	input-method-client-protocol.h
-weston_keyboard_LDADD = libtoytoolkit.la
-
-weston_simple_im_SOURCES = 			\
-	weston-simple-im.c			\
-	input-method-protocol.c			\
-	input-method-client-protocol.h
-weston_simple_im_LDADD = $(CLIENT_LIBS)
-
-weston_info_SOURCES =				\
-	weston-info.c				\
-	../shared/os-compatibility.c		\
-	../shared/os-compatibility.h
-weston_info_LDADD = $(WESTON_INFO_LIBS)
-
-weston_desktop_shell_SOURCES =			\
-	desktop-shell.c				\
-	desktop-shell-client-protocol.h		\
-	desktop-shell-protocol.c
-weston_desktop_shell_LDADD = libtoytoolkit.la
-
-BUILT_SOURCES =					\
-	screenshooter-client-protocol.h		\
-	screenshooter-protocol.c		\
-	text-cursor-position-client-protocol.h	\
-	text-cursor-position-protocol.c		\
-	text-protocol.c				\
-	text-client-protocol.h			\
-	input-method-protocol.c			\
-	input-method-client-protocol.h		\
-	desktop-shell-client-protocol.h		\
-	desktop-shell-protocol.c		\
-	scaler-client-protocol.h		\
-	scaler-protocol.c			\
-	workspaces-client-protocol.h		\
-	workspaces-protocol.c
-
-CLEANFILES = $(BUILT_SOURCES)
-endif
-
-if BUILD_FULL_GL_CLIENTS
-full_gl_client_programs = weston-gears
-
-weston_gears_SOURCES = gears.c
-weston_gears_LDADD = libtoytoolkit.la
-
-if HAVE_GLU
-screensaver = weston-screensaver
-weston_screensaver_SOURCES =			\
-	wscreensaver.c				\
-	wscreensaver.h				\
-	desktop-shell-client-protocol.h		\
-	desktop-shell-protocol.c		\
-	wscreensaver-glue.c			\
-	wscreensaver-glue.h			\
-	glmatrix.c				\
-	matrix3.xpm
-weston_screensaver_LDADD = libtoytoolkit.la $(GLU_LIBS)
-weston_screensaver_CFLAGS = $(GLU_CFLAGS)
-endif
-
-endif
-
-wayland_protocoldir = $(top_srcdir)/protocol
-include $(top_srcdir)/wayland-scanner.mk
diff --git a/configure.ac b/configure.ac
index b960618..a64c2fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -487,8 +487,7 @@
 AC_CONFIG_FILES([Makefile
 		 shared/Makefile
 		 src/version.h
-		 src/weston.pc
-		 clients/Makefile])
+		 src/weston.pc])
 AC_OUTPUT
 
 AC_MSG_RESULT([
diff --git a/shared/os-compatibility.h b/shared/os-compatibility.h
index c1edcfb..10dbb7d 100644
--- a/shared/os-compatibility.h
+++ b/shared/os-compatibility.h
@@ -25,7 +25,7 @@
 
 #include <sys/types.h>
 
-#include "../config.h"
+#include "config.h"
 
 #ifdef HAVE_EXECINFO_H
 #include <execinfo.h>