build: Move src/Makefile.am into toplevel Makefile.am
diff --git a/Makefile.am b/Makefile.am
index 3cc4deb..6c56f97 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,11 +1,12 @@
 bin_PROGRAMS =
+noinst_PROGRAMS =
 moduledir = $(libdir)/weston
 module_LTLIBRARIES =
+noinst_LTLIBRARIES =
 BUILT_SOURCES =
 
 SUBDIRS =					\
 	shared					\
-	src					\
 	clients					\
 	tests
 
@@ -22,8 +23,322 @@
 
 all-local : weston.ini validate-protocol-xml
 
+AM_CPPFLAGS = 					\
+	-I$(top_builddir)/src			\
+	-I$(top_srcdir)/shared			\
+	-DDATADIR='"$(datadir)"'		\
+	-DMODULEDIR='"$(moduledir)"'		\
+	-DLIBEXECDIR='"$(libexecdir)"'
+
 CLEANFILES = weston.ini $(BUILT_SOURCES)
 
+bin_PROGRAMS += weston
+
+weston_LDFLAGS = -export-dynamic
+weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
+weston_CFLAGS = $(GCC_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
+weston_LDADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
+	$(DLOPEN_LIBS) -lm shared/libshared.la
+
+weston_SOURCES =					\
+	src/git-version.h				\
+	src/log.c					\
+	src/compositor.c				\
+	src/compositor.h				\
+	src/input.c					\
+	src/data-device.c				\
+	src/filter.c					\
+	src/filter.h					\
+	src/screenshooter.c				\
+	src/screenshooter-protocol.c			\
+	src/screenshooter-server-protocol.h		\
+	src/clipboard.c					\
+	src/text-cursor-position-protocol.c		\
+	src/text-cursor-position-server-protocol.h	\
+	src/zoom.c					\
+	src/text-backend.c				\
+	src/text-protocol.c				\
+	src/text-server-protocol.h			\
+	src/input-method-protocol.c			\
+	src/input-method-server-protocol.h		\
+	src/workspaces-protocol.c			\
+	src/workspaces-server-protocol.h		\
+	src/scaler-protocol.c				\
+	src/scaler-server-protocol.h			\
+	src/bindings.c					\
+	src/animation.c					\
+	src/noop-renderer.c				\
+	src/pixman-renderer.c				\
+	src/pixman-renderer.h				\
+	shared/matrix.c					\
+	shared/matrix.h					\
+	shared/zalloc.h					\
+	src/weston-egl-ext.h
+
+noinst_LTLIBRARIES +=				\
+	libsession-helper.la
+
+libsession_helper_la_SOURCES =			\
+	src/weston-launch.h			\
+	src/launcher-util.c			\
+	src/launcher-util.h
+libsession_helper_la_CFLAGS = $(GCC_CFLAGS) $(LIBDRM_CFLAGS) $(PIXMAN_CFLAGS) $(COMPOSITOR_CFLAGS)
+libsession_helper_la_LIBADD = $(LIBDRM_LIBS)
+
+if ENABLE_DBUS
+if HAVE_SYSTEMD_LOGIN
+libsession_helper_la_SOURCES +=			\
+	src/dbus.h				\
+	src/dbus.c				\
+	src/logind-util.h			\
+	src/logind-util.c
+libsession_helper_la_CFLAGS += $(SYSTEMD_LOGIN_CFLAGS) $(DBUS_CFLAGS)
+libsession_helper_la_LIBADD += $(SYSTEMD_LOGIN_LIBS) $(DBUS_LIBS)
+endif
+endif
+
+src/git-version.h : .FORCE
+	$(AM_V_GEN)(echo "#define BUILD_ID \"$(shell git --git-dir=$(top_srcdir)/.git describe --always --dirty) $(shell git --git-dir=$(top_srcdir)/.git log -1 --format='%s (%ci)')\"" > $@-new; \
+	cmp -s $@ $@-new || cp $@-new $@; \
+	rm $@-new)
+
+.FORCE :
+
+if BUILD_WESTON_LAUNCH
+bin_PROGRAMS += weston-launch
+weston_launch_SOURCES = src/weston-launch.c src/weston-launch.h
+weston_launch_CPPFLAGS = -DBINDIR='"$(bindir)"'
+weston_launch_CFLAGS=				\
+	$(GCC_CFLAGS)				\
+	$(PAM_CFLAGS)				\
+	$(SYSTEMD_LOGIN_CFLAGS)			\
+	$(LIBDRM_CFLAGS)
+weston_launch_LDADD = $(PAM_LIBS) $(SYSTEMD_LOGIN_LIBS) $(LIBDRM_LIBS)
+
+if ENABLE_SETUID_INSTALL
+install-exec-hook:
+	chown root $(DESTDIR)$(bindir)/weston-launch
+	chmod u+s $(DESTDIR)$(bindir)/weston-launch
+endif
+
+endif # BUILD_WESTON_LAUNCH
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = src/weston.pc
+
+westonincludedir = $(includedir)/weston
+westoninclude_HEADERS =				\
+	src/version.h				\
+	src/compositor.h			\
+	shared/matrix.h				\
+	shared/config-parser.h			\
+	shared/zalloc.h
+
+if ENABLE_EGL
+module_LTLIBRARIES += gl-renderer.la
+gl_renderer_la_LDFLAGS = -module -avoid-version
+gl_renderer_la_LIBADD = $(COMPOSITOR_LIBS) $(EGL_LIBS)
+gl_renderer_la_CFLAGS =				\
+	$(COMPOSITOR_CFLAGS)			\
+	$(EGL_CFLAGS)				\
+	$(GCC_CFLAGS)
+gl_renderer_la_SOURCES =			\
+	src/gl-renderer.h			\
+	src/gl-renderer.c			\
+	src/vertex-clipping.c			\
+	src/vertex-clipping.h
+endif
+
+if ENABLE_X11_COMPOSITOR
+module_LTLIBRARIES += x11-backend.la
+x11_backend_la_LDFLAGS = -module -avoid-version
+x11_backend_la_LIBADD = $(COMPOSITOR_LIBS) $(X11_COMPOSITOR_LIBS) \
+	shared/libshared-cairo.la
+x11_backend_la_CFLAGS =				\
+	$(COMPOSITOR_CFLAGS)			\
+	$(EGL_CFLAGS)				\
+	$(PIXMAN_CFLAGS)			\
+	$(CAIRO_CFLAGS)				\
+	$(X11_COMPOSITOR_CFLAGS)		\
+	$(GCC_CFLAGS)
+x11_backend_la_SOURCES = src/compositor-x11.c
+endif
+
+if ENABLE_DRM_COMPOSITOR
+module_LTLIBRARIES += drm-backend.la
+drm_backend_la_LDFLAGS = -module -avoid-version
+drm_backend_la_LIBADD =				\
+	$(COMPOSITOR_LIBS)			\
+	$(DRM_COMPOSITOR_LIBS)			\
+	shared/libshared.la -lrt		\
+	libsession-helper.la
+drm_backend_la_CFLAGS =				\
+	$(COMPOSITOR_CFLAGS)			\
+	$(EGL_CFLAGS)				\
+	$(DRM_COMPOSITOR_CFLAGS)		\
+	$(GCC_CFLAGS)
+drm_backend_la_SOURCES =			\
+	src/compositor-drm.c			\
+	src/udev-seat.c				\
+	src/udev-seat.h				\
+	src/evdev.c				\
+	src/evdev.h				\
+	src/evdev-touchpad.c			\
+	src/libbacklight.c			\
+	src/libbacklight.h
+
+if ENABLE_VAAPI_RECORDER
+drm_backend_la_SOURCES += src/vaapi-recorder.c src/vaapi-recorder.h
+drm_backend_la_LIBADD += $(LIBVA_LIBS)
+drm_backend_la_CFLAGS += $(LIBVA_CFLAGS)
+endif
+endif
+
+if ENABLE_WAYLAND_COMPOSITOR
+module_LTLIBRARIES += wayland-backend.la
+wayland_backend_la_LDFLAGS = -module -avoid-version
+wayland_backend_la_LIBADD =			\
+	$(COMPOSITOR_LIBS)			\
+	$(WAYLAND_COMPOSITOR_LIBS)		\
+	shared/libshared-cairo.la
+wayland_backend_la_CFLAGS =			\
+	$(COMPOSITOR_CFLAGS)			\
+	$(EGL_CFLAGS)				\
+	$(PIXMAN_CFLAGS)			\
+	$(CAIRO_CFLAGS)				\
+	$(WAYLAND_COMPOSITOR_CFLAGS)		\
+	$(GCC_CFLAGS)
+wayland_backend_la_SOURCES = src/compositor-wayland.c
+endif
+
+if ENABLE_RPI_COMPOSITOR
+if INSTALL_RPI_COMPOSITOR
+module_LTLIBRARIES += rpi-backend.la
+else
+noinst_LTLIBRARIES += rpi-backend.la
+endif
+
+rpi_backend_la_LDFLAGS = -module -avoid-version
+rpi_backend_la_LIBADD = $(COMPOSITOR_LIBS)	\
+	$(RPI_COMPOSITOR_LIBS)			\
+	$(RPI_BCM_HOST_LIBS)			\
+	libsession-helper.la			\
+	shared/libshared.la
+rpi_backend_la_CFLAGS =				\
+	$(GCC_CFLAGS)				\
+	$(COMPOSITOR_CFLAGS)			\
+	$(RPI_COMPOSITOR_CFLAGS)		\
+	$(RPI_BCM_HOST_CFLAGS)
+rpi_backend_la_SOURCES =			\
+	src/compositor-rpi.c			\
+	src/rpi-renderer.c			\
+	src/rpi-renderer.h			\
+	src/rpi-bcm-stubs.h			\
+	src/udev-seat.c				\
+	src/udev-seat.h				\
+	src/evdev.c				\
+	src/evdev.h				\
+	src/evdev-touchpad.c
+
+if ENABLE_EGL
+rpi_backend_la_LIBADD += $(EGL_LIBS)
+rpi_backend_la_CFLAGS += $(EGL_CFLAGS)
+endif
+
+endif
+
+if ENABLE_HEADLESS_COMPOSITOR
+module_LTLIBRARIES += headless-backend.la
+headless_backend_la_LDFLAGS = -module -avoid-version
+headless_backend_la_LIBADD = $(COMPOSITOR_LIBS) \
+	shared/libshared.la
+headless_backend_la_CFLAGS =			\
+	$(COMPOSITOR_CFLAGS)			\
+	$(GCC_CFLAGS)
+headless_backend_la_SOURCES = src/compositor-headless.c
+endif
+
+if ENABLE_FBDEV_COMPOSITOR
+module_LTLIBRARIES += fbdev-backend.la
+fbdev_backend_la_LDFLAGS = -module -avoid-version
+fbdev_backend_la_LIBADD =			\
+	$(COMPOSITOR_LIBS)			\
+	$(FBDEV_COMPOSITOR_LIBS)		\
+	libsession-helper.la			\
+	shared/libshared.la
+fbdev_backend_la_CFLAGS =			\
+	$(COMPOSITOR_CFLAGS)			\
+	$(EGL_CFLAGS)				\
+	$(FBDEV_COMPOSITOR_CFLAGS)		\
+	$(PIXMAN_CFLAGS)			\
+	$(GCC_CFLAGS)
+fbdev_backend_la_SOURCES =			\
+	src/compositor-fbdev.c			\
+	src/udev-seat.c				\
+	src/udev-seat.h				\
+	src/evdev.c				\
+	src/evdev.h				\
+	src/evdev-touchpad.c
+endif
+
+if ENABLE_RDP_COMPOSITOR
+module_LTLIBRARIES += rdp-backend.la
+rdp_backend_la_LDFLAGS = -module -avoid-version
+rdp_backend_la_LIBADD = $(COMPOSITOR_LIBS) \
+	$(RDP_COMPOSITOR_LIBS) \
+	shared/libshared.la
+rdp_backend_la_CFLAGS =				\
+	$(COMPOSITOR_CFLAGS)			\
+	$(RDP_COMPOSITOR_CFLAGS)		\
+	$(GCC_CFLAGS)
+rdp_backend_la_SOURCES = src/compositor-rdp.c
+endif
+
+if HAVE_LCMS
+module_LTLIBRARIES += cms-static.la
+cms_static_la_LDFLAGS = -module -avoid-version
+cms_static_la_LIBADD = $(COMPOSITOR_LIBS) $(LCMS_LIBS) shared/libshared.la
+cms_static_la_CFLAGS = $(GCC_CFLAGS) $(COMPOSITOR_CFLAGS) $(LCMS_CFLAGS)
+cms_static_la_SOURCES =				\
+	src/cms-static.c				\
+	src/cms-helper.c				\
+	src/cms-helper.h
+if ENABLE_COLORD
+module_LTLIBRARIES += cms-colord.la
+cms_colord_la_LDFLAGS = -module -avoid-version
+cms_colord_la_LIBADD = $(COMPOSITOR_LIBS) $(COLORD_LIBS)
+cms_colord_la_CFLAGS = $(GCC_CFLAGS) $(COMPOSITOR_CFLAGS) $(COLORD_CFLAGS)
+cms_colord_la_SOURCES =				\
+	src/cms-colord.c				\
+	src/cms-helper.c				\
+	src/cms-helper.h
+endif
+endif
+
+noinst_PROGRAMS += spring-tool
+spring_tool_CFLAGS = $(GCC_CFLAGS) $(COMPOSITOR_CFLAGS)
+spring_tool_LDADD = $(COMPOSITOR_LIBS) -lm
+spring_tool_SOURCES =				\
+	src/spring-tool.c			\
+	src/animation.c				\
+	shared/matrix.c				\
+	shared/matrix.h				\
+	src/compositor.h
+
+BUILT_SOURCES +=					\
+	src/screenshooter-server-protocol.h		\
+	src/screenshooter-protocol.c			\
+	src/text-cursor-position-server-protocol.h	\
+	src/text-cursor-position-protocol.c		\
+	src/text-protocol.c				\
+	src/text-server-protocol.h			\
+	src/input-method-protocol.c			\
+	src/input-method-server-protocol.h		\
+	src/workspaces-server-protocol.h		\
+	src/workspaces-protocol.c			\
+	src/scaler-server-protocol.h			\
+	src/scaler-protocol.c				\
+	src/git-version.h
 
 westondatadir = $(datadir)/weston
 dist_westondata_DATA =				\