[PATCH] Update autotools to simplify cross-compiling

Michael Steinert mike.steinert at gmail.com
Fri Dec 3 08:54:46 PST 2010


* Scanner

The scanner was renamed to "wayland-scanner" and is now an installed
program. When configure detects cross-compilation it will look for
wayland-scanner in $PATH instead of compiling it. The environment
variable $WAYLAND_SCANNER may be supplied at configure time if
wayland-scanner is not installed in $PATH.

Scanner output will be directed to the source directory when
$top_builddir != $top_srcdir.

* Sample clients & compositor

The sample clients & compositor can now be disabled via the configure
options --disable-compositor and --disable-clients. These options
default to "auto", i.e. they will be built if all of the prerequisites
are satisfied.

* General

Updated .gitignore for the case where $top_builddir != $top_srcdir.

All C files now properly include "config.h".

Pkg-config files are installed in "$(libdir)/pkgconfig".

Signed-off-by: Michael Steinert <mike.steinert at gmail.com>
---
 .gitignore                      |   15 +++-
 Makefile.am                     |    3 +-
 clients/Makefile.am             |   89 +++++++++++++++-------
 clients/cairo-util.c            |    4 +
 clients/dnd.c                   |    4 +
 clients/flower.c                |    4 +
 clients/gears.c                 |    4 +
 clients/image.c                 |    4 +
 clients/screenshot.c            |    4 +
 clients/smoke.c                 |    4 +
 clients/terminal.c              |    4 +
 clients/view.c                  |    4 +
 clients/wayland-glib.c          |    4 +
 clients/window.c                |    4 +-
 compositor/Makefile.am          |   17 +++--
 compositor/compositor-drm.c     |    4 +
 compositor/compositor-wayland.c |    2 +-
 compositor/compositor-x11.c     |    2 +-
 compositor/compositor.c         |    4 +
 compositor/drm.c                |    4 +
 compositor/screenshooter.c      |    4 +
 compositor/shm.c                |    4 +
 configure.ac                    |  155 +++++++++++++++++++++++++++-----------
 m4/wayland.m4                   |   15 ++++
 wayland/Makefile.am             |   52 ++++++++-----
 wayland/connection.c            |    4 +
 wayland/event-loop.c            |   21 +++++-
 wayland/scanner.c               |    4 +
 wayland/scanner.mk              |   12 ++--
 wayland/wayland-client.c        |    4 +
 wayland/wayland-hash.c          |    4 +
 wayland/wayland-server.c        |    4 +
 wayland/wayland-util.c          |    4 +
 33 files changed, 353 insertions(+), 118 deletions(-)
 create mode 100644 m4/wayland.m4

diff --git a/.gitignore b/.gitignore
index 7c5bfe5..6f47900 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+*.a
 *.deps
 *.jpg
 *.la
@@ -7,22 +8,26 @@
 *.so
 *.swp
 *~
+*-client-protocol.h
+*-protocol.c
+*-server-protocol.h
 .libs
 /aclocal.m4
 /autom4te.cache
 /config.guess
-/config.h
+config.h
 /config.h.in
-/config.log
+config.log
 /config.mk
-/config.status
+config.status
 /config.sub
 /configure
 /depcomp
 /install-sh
-/libtool
+libtool
 /ltmain.sh
 /missing
-/stamp-h1
+stamp-h1
 Makefile
 Makefile.in
+wayland-scanner
diff --git a/Makefile.am b/Makefile.am
index 03d15db..67ba936 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,4 @@
-SUBDIRS = wayland compositor clients data
+SUBDIRS = wayland data $(WAYLAND_COMPOSITOR) $(WAYLAND_CLIENTS)
+DIST_SUBDIRS = compositor clients
 
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
diff --git a/clients/Makefile.am b/clients/Makefile.am
index 56b6a2b..8faf198 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -1,42 +1,73 @@
-noinst_PROGRAMS = gears flower screenshot terminal image view dnd smoke
+noinst_PROGRAMS = dnd flower gears image screenshot smoke terminal view
 noinst_LTLIBRARIES = libtoytoolkit.la
 
-INCLUDES =					\
-	-I$(top_srcdir)/wayland			\
-	-I$(top_builddir)/wayland			\
-	$(CLIENT_CFLAGS) $(POPPLER_CFLAGS)
+AM_CPPFLAGS =						\
+	-DDATADIR='"$(datadir)"'			\
+	$(CLIENT_CFLAGS)
 
-LDADD = libtoytoolkit.la				\
+LDADD =							\
+	libtoytoolkit.la				\
 	$(top_builddir)/wayland/libwayland-client.la	\
 	$(CLIENT_LIBS) -lrt -lm
 
-AM_CFLAGS = $(GCC_CFLAGS)
-AM_CPPFLAGS = -DDATADIR='"$(datadir)"'
+# dnd: drag 'n' drop demo
+dnd_SOURCES =						\
+	dnd.c
 
-libtoytoolkit_la_SOURCES =			\
-	window.c				\
-	window.h				\
-	wayland-glib.c				\
-	wayland-glib.h				\
-	cairo-util.c				\
-	cairo-util.h
+# flower: display a rotating flower
+flower_SOURCES =					\
+	flower.c
+
+# gears: similar to the X11 glxgears demo
+gears_SOURCES =						\
+	gears.c
 
-flower_SOURCES = flower.c
-smoke_SOURCES = smoke.c
-gears_SOURCES = gears.c
-screenshot_SOURCES = screenshot.c screenshooter-protocol.c
-terminal_SOURCES = terminal.c
-image_SOURCES = image.c
-view_SOURCES = view.c
-dnd_SOURCES = dnd.c
-
-BUILT_SOURCES =					\
-	screenshooter-client-protocol.h		\
+# image: display image
+image_SOURCES =						\
+	image.c
+
+# screeshot: create a screenshot image
+screenshot_SOURCES =					\
+	screenshot.c					\
 	screenshooter-protocol.c
 
+# smoke:
+smoke_SOURCES =						\
+	smoke.c
+
+# terminal: a simple terminal emulator
+terminal_LDADD = -lutil
+
+terminal_SOURCES =					\
+	terminal.c
+
+# view: display PDF files (requires a URI)
+view_CPPFLAGS =						\
+	$(POPPLER_CFLAGS)
+
+view_LDADD = $(POPPLER_LIBS)
+
+view_SOURCES =						\
+	view.c
+
+# libtoytoolkit: support library
+libtoytoolkit_la_SOURCES =				\
+	window.c					\
+	window.h					\
+	wayland-glib.c					\
+	wayland-glib.h					\
+	cairo-util.c					\
+	cairo-util.h
+
+if CROSS_COMPILING
+else
+$(BUILT_SOURCES): $(top_srcdir)/wayland/wayland-scanner
+endif
+
+BUILT_SOURCES =						\
+	$(srcdir)/screenshooter-client-protocol.h	\
+	$(srcdir)/screenshooter-protocol.c
+
 CLEANFILES = $(BUILT_SOURCES)
 
 include $(top_srcdir)/wayland/scanner.mk
-
-terminal_LDADD = $(LDADD) -lutil
-view_LDADD = $(LDADD) $(POPPLER_LIBS)
diff --git a/clients/cairo-util.c b/clients/cairo-util.c
index 3aef0af..5377054 100644
--- a/clients/cairo-util.c
+++ b/clients/cairo-util.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/clients/dnd.c b/clients/dnd.c
index e6dd091..988a32a 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/clients/flower.c b/clients/flower.c
index b919cf5..3ce585e 100644
--- a/clients/flower.c
+++ b/clients/flower.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/clients/gears.c b/clients/gears.c
index 7d3c310..d8d8e83 100644
--- a/clients/gears.c
+++ b/clients/gears.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/clients/image.c b/clients/image.c
index bb563ed..6c193df 100644
--- a/clients/image.c
+++ b/clients/image.c
@@ -21,6 +21,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/clients/screenshot.c b/clients/screenshot.c
index 8f44460..0e501ac 100644
--- a/clients/screenshot.c
+++ b/clients/screenshot.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/clients/smoke.c b/clients/smoke.c
index 43226ad..078a374 100644
--- a/clients/smoke.c
+++ b/clients/smoke.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/clients/terminal.c b/clients/terminal.c
index 2f12f8a..3eef1f7 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/clients/view.c b/clients/view.c
index 67149fb..499199d 100644
--- a/clients/view.c
+++ b/clients/view.c
@@ -21,6 +21,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/clients/wayland-glib.c b/clients/wayland-glib.c
index fa7a9f5..95c8e5a 100644
--- a/clients/wayland-glib.c
+++ b/clients/wayland-glib.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdint.h>
 #include <glib/giochannel.h>
 #include "wayland-client.h"
diff --git a/clients/window.c b/clients/window.c
index d03ef4b..e07ebd4 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -20,7 +20,9 @@
  * OF THIS SOFTWARE.
  */
 
-#include "../config.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include <stdint.h>
 #include <stdio.h>
diff --git a/compositor/Makefile.am b/compositor/Makefile.am
index 0b28cad..f20b8b0 100644
--- a/compositor/Makefile.am
+++ b/compositor/Makefile.am
@@ -1,13 +1,11 @@
 noinst_PROGRAMS = compositor
 
-INCLUDES =					\
+compositor_CPPFLAGS = 				\
+	-DDATADIR='"$(datadir)"'		\
 	-I$(top_srcdir)/wayland			\
 	-I$(top_builddir)/wayland		\
 	$(COMPOSITOR_CFLAGS)
 
-AM_CFLAGS = $(GCC_CFLAGS)
-AM_CPPFLAGS = -DDATADIR='"$(datadir)"'
-
 compositor_LDADD =					\
 	$(top_builddir)/wayland/libwayland-server.la	\
 	$(top_builddir)/wayland/libwayland-client.la	\
@@ -30,9 +28,14 @@ udevrulesddir = $(sysconfdir)/udev/rules.d
 dist_udevrulesd_DATA =				\
 	70-wayland.rules
 
-BUILT_SOURCES =					\
-	screenshooter-server-protocol.h		\
-	screenshooter-protocol.c
+if CROSS_COMPILING
+else
+$(BUILT_SOURCES): $(top_srcdir)/wayland/wayland-scanner
+endif
+
+BUILT_SOURCES =						\
+	$(srcdir)/screenshooter-server-protocol.h	\
+	$(srcdir)/screenshooter-protocol.c
 
 CLEANFILES = $(BUILT_SOURCES)
 
diff --git a/compositor/compositor-drm.c b/compositor/compositor-drm.c
index 1d04c06..61b9316 100644
--- a/compositor/compositor-drm.c
+++ b/compositor/compositor-drm.c
@@ -16,6 +16,10 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/compositor/compositor-wayland.c b/compositor/compositor-wayland.c
index fa630bc..df625d9 100644
--- a/compositor/compositor-wayland.c
+++ b/compositor/compositor-wayland.c
@@ -17,7 +17,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
 #endif
 
 #include <stddef.h>
diff --git a/compositor/compositor-x11.c b/compositor/compositor-x11.c
index 3aa2475..bf1f2d6 100644
--- a/compositor/compositor-x11.c
+++ b/compositor/compositor-x11.c
@@ -17,7 +17,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
 #endif
 
 #include <stddef.h>
diff --git a/compositor/compositor.c b/compositor/compositor.c
index 025b022..23ec0a2 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -16,6 +16,10 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #define _GNU_SOURCE
 
 #include <stdio.h>
diff --git a/compositor/drm.c b/compositor/drm.c
index 59a72f2..5c6bf4e 100644
--- a/compositor/drm.c
+++ b/compositor/drm.c
@@ -16,6 +16,10 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/compositor/screenshooter.c b/compositor/screenshooter.c
index c1716ec..c8363ca 100644
--- a/compositor/screenshooter.c
+++ b/compositor/screenshooter.c
@@ -16,6 +16,10 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 #include <GLES2/gl2.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
diff --git a/compositor/shm.c b/compositor/shm.c
index 023cde0..4d9bb9c 100644
--- a/compositor/shm.c
+++ b/compositor/shm.c
@@ -16,6 +16,10 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/configure.ac b/configure.ac
index 5568218..ca456f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,62 +1,127 @@
+# Initialize autoconf & automake
 AC_PREREQ([2.64])
-AC_INIT([wayland],
-        [0.1],
-        [https://bugs.freedesktop.org/enter_bug.cgi?product=wayland],
-        [wayland],
-        [http://wayland.freedesktop.org/])
-
-AC_CONFIG_HEADERS([config.h])
+AC_INIT([Wayland], [0.1],
+	[https://bugs.freedesktop.org/enter_bug.cgi?product=wayland],
+	[wayland], [http://wayland.freedesktop.org/])
 AC_CONFIG_MACRO_DIR([m4])
-
 AM_INIT_AUTOMAKE([1.11 foreign dist-bzip2])
-
 AM_SILENT_RULES([yes])
+AC_CONFIG_SRCDIR([wayland/wayland-client.h])
 
 # Check for programs
 AC_PROG_CC
+PKG_PROG_PKG_CONFIG
 
 # Initialize libtool
 LT_PREREQ([2.2])
 LT_INIT
 
-PKG_PROG_PKG_CONFIG()
-PKG_CHECK_MODULES(FFI, [libffi])
+# Enable gcc options
+WAYLAND_GCC_OPTIONS([-Wall -g -Wstrict-prototypes -Wmissing-prototypes -fvisibility=hidden])
 
-PKG_CHECK_MODULES(COMPOSITOR,
-		  [egl glesv2 gdk-pixbuf-2.0 libudev >= 136 libdrm >= 2.4.17] xcb-dri2 xcb-xfixes)
-PKG_CHECK_MODULES(CLIENT, [egl gl cairo gdk-pixbuf-2.0 glib-2.0 gobject-2.0 xkbcommon libdrm])
-PKG_CHECK_MODULES(POPPLER, [poppler-glib gdk-2.0])
-PKG_CHECK_MODULES(CAIRO_GL, [cairo-gl],
-		  [have_cairo_gl=yes], [have_cairo_gl=no])
-AS_IF([test "x$have_cairo_gl" = "xyes"],
-      [AC_DEFINE([HAVE_CAIRO_GL], [1], [Have cairo-gl])])
+# Check Wayland prerequisites
+PKG_CHECK_MODULES([FFI], [libffi])
 
-if test $CC = gcc; then
-	GCC_CFLAGS="-Wall -g -Wstrict-prototypes -Wmissing-prototypes -fvisibility=hidden"
-fi
-AC_SUBST(GCC_CFLAGS)
-
-EXPAT_LIB=""
-AC_ARG_WITH(expat, [  --with-expat=<dir>      Use expat from here],
-		   [ expat=$withval
-		     CPPFLAGS="$CPPFLAGS -I$withval/include"
-		     LDFLAGS="$LDFLAGS -L$withval/lib" ] )
-AC_CHECK_HEADERS(expat.h, [AC_DEFINE(HAVE_EXPAT_H)], 
-		 [AC_MSG_ERROR([Can't find expat.h. Please install expat.])])
-AC_CHECK_LIB(expat, XML_ParserCreate, [EXPAT_LIBS="-lexpat"],
-	     [AC_MSG_ERROR([Can't find expat library. Please install expat.])])
-AC_SUBST(EXPAT_LIBS)
-
-# workaround a bug in xcb-dri2 generated by xcb-proto 1.6
-AC_CHECK_LIB(xcb-dri2, xcb_dri2_connect_alignment_pad, [],
-	     [AC_DEFINE([XCB_DRI2_CONNECT_DEVICE_NAME_BROKEN], [1],
+# signalfd & timerfd: Linux 2.6.22 [8 July 2007]
+AC_CHECK_HEADERS([sys/signalfd.h sys/timerfd.h])
+
+# Compositor option
+AC_ARG_ENABLE([compositor],
+	[AC_HELP_STRING([--enable-compositor],
+		[enable the test compositor @<:@default=auto@:>@])],,
+	[enableval=auto])
+AC_CACHE_CHECK([if the test compositor is enabled],
+	[wayland_cv_enable_compositor],
+	[wayland_cv_enable_compositor="$enableval"])
+if test "x$wayland_cv_enable_compositor" != "xno"; then
+	WAYLAND_COMPOSITOR=compositor
+	PKG_CHECK_MODULES([COMPOSITOR],
+		[egl glesv2 gdk-pixbuf-2.0 libudev >= 136 libdrm >= 2.4.17 xcb-dri2 xcb-xfixes],
+		[],
+		[WAYLAND_COMPOSITOR=
+		wayland_cv_enable_compositor=no])
+	# workaround a bug in xcb-dri2 generated by xcb-proto 1.6
+	AC_CHECK_LIB([xcb-dri2], [xcb_dri2_connect_alignment_pad], [],
+		[AC_DEFINE([XCB_DRI2_CONNECT_DEVICE_NAME_BROKEN], [1],
 			[Define to 1 if xcb_dri2_connect_device_name is broken])])
+fi
+AC_SUBST([WAYLAND_COMPOSITOR])
+
+# Clients option
+AC_ARG_ENABLE([clients],
+	[AC_HELP_STRING([--enable-clients],
+		[enable the test clients @<:@default=auto@:>@])],,
+	[enableval=auto])
+AC_CACHE_CHECK([if the test clients are enabled],
+	[wayland_cv_enable_clients],
+	[wayland_cv_enable_clients="$enableval"])
+if test "x$wayland_cv_enable_clients" != "xno"; then
+	WAYLAND_CLIENTS=clients
+	PKG_CHECK_MODULES([CLIENT],
+		[egl gl cairo gdk-pixbuf-2.0 glib-2.0 gobject-2.0 xkbcommon libdrm],
+		[],
+		[WAYLAND_CLIENTS=
+		wayland_cv_enable_clients=no])
+	PKG_CHECK_MODULES([POPPLER], [poppler-glib gdk-2.0],
+		[],
+		[WAYLAND_CLIENTS=
+		wayland_cv_enable_clients=no])
+	PKG_CHECK_MODULES([CAIRO_GL], [cairo-gl],
+		[AC_DEFINE([HAVE_CAIRO_GL], [1],
+			[Define to 1 if cairo-gl is available])],
+		[:])
+fi
+AC_SUBST([WAYLAND_CLIENTS])
 
-AC_CONFIG_FILES([wayland/wayland-server.pc
-		 wayland/wayland-client.pc
-		 Makefile
-		 wayland/Makefile
-		 compositor/Makefile
-		 clients/Makefile
-		 data/Makefile])
+# Configure the Wayland scanner
+AM_CONDITIONAL([CROSS_COMPILING], [test "x$cross_compiling" = "xyes"])
+if test "x$cross_compiling" = "xyes"; then
+	AC_ARG_VAR([WAYLAND_SCANNER],
+		[Set the full path to the Wayland scanner when cross-compiling])
+	AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner])
+	if test "x$WAYLAND_SCANNER" = "x"; then
+		AC_MSG_WARN([A native version of wayland-scanner is required when cross-compiling])
+		wayland_scanner=wayland-scanner
+	else
+		wayland_scanner=$WAYLAND_SCANNER
+	fi
+else
+	AC_ARG_WITH([expat],
+		[AC_HELP_STRING([--with-expat=PREFIX],
+			[Use Expat from PREFIX/include and PREFIX/lib])],
+		[if test "x$withval" = "xyes"; then
+			AC_MSG_WARN(['--with-expat' requires an argument.])
+		else
+			if test -d "$withval"; then
+				CPPFLAGS="$CPPFLAGS -I$withval/include"
+				LDFLAGS="$LDFLAGS -L$withval/lib"
+			else
+				AC_MSG_WARN(['--with-expat': $withval is not a directory])
+			fi
+		fi])
+	AC_CHECK_HEADERS([expat.h], [],
+		[AC_MSG_ERROR([Unable to find Expat header file; See http://expat.sourceforge.net/])])
+	AC_CHECK_LIB([expat], [XML_ParserCreate], [],
+		[AC_MSG_ERROR([Unable to find Expat library; See http://expat.sourceforge.net/])])
+	wayland_scanner='$(top_builddir)/wayland/wayland-scanner'
+fi
+AC_SUBST([wayland_scanner])
+
+# Output files
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_FILES([
+	clients/Makefile
+	compositor/Makefile
+	data/Makefile
+	Makefile
+	wayland/Makefile
+	wayland/wayland-server.pc
+	wayland/wayland-client.pc])
 AC_OUTPUT
+AC_MSG_RESULT([
+$PACKAGE_NAME build options
+	Host: $host
+	Version: $VERSION
+	Compositor: $wayland_cv_enable_compositor
+	Clients: $wayland_cv_enable_clients
+])
diff --git a/m4/wayland.m4 b/m4/wayland.m4
new file mode 100644
index 0000000..87d1413
--- /dev/null
+++ b/m4/wayland.m4
@@ -0,0 +1,15 @@
+#serial 1
+
+# WAYLAND_GCC_OPTIONS(options)
+# ----------------------------
+# Enable compiler options for gcc.
+AC_DEFUN([WAYLAND_GCC_OPTIONS],
+[if test "x$GCC" = "xyes"; then
+    for option in "$1"; do
+        case " $CFLAGS " in
+        *[[\ \	]]$option[[\ \	]]*) ;;
+        *) CFLAGS="$CFLAGS $option" ;;
+        esac
+    done
+fi
+])dnl
diff --git a/wayland/Makefile.am b/wayland/Makefile.am
index 6e48eb8..4f9ccae 100644
--- a/wayland/Makefile.am
+++ b/wayland/Makefile.am
@@ -1,48 +1,58 @@
-lib_LTLIBRARIES = libwayland-server.la libwayland-client.la
+lib_LTLIBRARIES = libwayland-client.la libwayland-server.la
 noinst_LTLIBRARIES = libwayland-util.la
 
 include_HEADERS =				\
-	wayland-util.h				\
-	wayland-server-protocol.h		\
-	wayland-server.h			\
+	wayland-client.h			\
 	wayland-client-protocol.h		\
-	wayland-client.h
+	wayland-server.h			\
+	wayland-server-protocol.h		\
+	wayland-util.h
 
+libwayland_util_la_CPPFLAGS = $(FFI_CFLAGS)
 libwayland_util_la_SOURCES =			\
 	connection.c				\
 	connection.h				\
+	wayland-hash.c				\
 	wayland-util.c				\
-	wayland-util.h				\
-	wayland-hash.c
+	wayland-util.h
 
+libwayland_server_la_CPPFLAGS = $(FFI_CFLAGS)
 libwayland_server_la_LIBADD = $(FFI_LIBS) libwayland-util.la
 libwayland_server_la_SOURCES =			\
+	event-loop.c				\
 	wayland-protocol.c			\
 	wayland-server.c			\
-	event-loop.c
+	wayland-server-protocol.h
 
+libwayland_client_la_CPPFLAGS = $(FFI_CFLAGS)
 libwayland_client_la_LIBADD = $(FFI_LIBS) libwayland-util.la
 libwayland_client_la_SOURCES =			\
-	wayland-protocol.c			\
-	wayland-client.c
-
-INCLUDES = $(FFI_CFLAGS)
-AM_CFLAGS = $(GCC_CFLAGS)
+	wayland-client.c			\
+	wayland-client-protocol.h		\
+	wayland-protocol.c
 
-include $(top_srcdir)/wayland/scanner.mk
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = 				\
+	wayland-client.pc 			\
+	wayland-server.pc
 
-noinst_PROGRAMS = scanner
+if CROSS_COMPILING
+else
+bin_PROGRAMS = wayland-scanner
 
-scanner_SOURCES =				\
+wayland_scanner_SOURCES =			\
 	scanner.c
 
-scanner_LDADD = $(EXPAT_LIBS) libwayland-util.la
+wayland_scanner_LDADD = libwayland-util.la
 
-$(BUILT_SOURCES) : scanner
+$(BUILT_SOURCES): wayland-scanner
+endif
 
 BUILT_SOURCES =					\
-	wayland-server-protocol.h		\
-	wayland-client-protocol.h		\
-	wayland-protocol.c
+	$(srcdir)/wayland-protocol.c		\
+	$(srcdir)/wayland-client-protocol.h 	\
+	$(srcdir)/wayland-server-protocol.h
 
 CLEANFILES = $(BUILT_SOURCES)
+
+include scanner.mk
diff --git a/wayland/connection.c b/wayland/connection.c
index dadf2c3..3d577a5 100644
--- a/wayland/connection.c
+++ b/wayland/connection.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
diff --git a/wayland/event-loop.c b/wayland/event-loop.c
index bf2a9aa..39dae23 100644
--- a/wayland/event-loop.c
+++ b/wayland/event-loop.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stddef.h>
 #include <stdio.h>
 #include <errno.h>
@@ -29,8 +33,12 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/epoll.h>
+#ifdef HAVE_SYS_SIGNALFD_H
 #include <sys/signalfd.h>
+#endif /* HAVE_SYS_SIGNALFD_H */
+#ifdef HAVE_SYS_TIMERFD_H
 #include <sys/timerfd.h>
+#endif /* HAVE_SYS_TIMERFD_H */
 #include <unistd.h>
 #include <assert.h>
 #include "wayland-server.h"
@@ -190,6 +198,7 @@ wl_event_loop_add_timer(struct wl_event_loop *loop,
 			wl_event_loop_timer_func_t func,
 			void *data)
 {
+#ifdef HAVE_SYS_TIMERFD_H
 	struct wl_event_source_timer *source;
 	struct epoll_event ep;
 
@@ -220,11 +229,15 @@ wl_event_loop_add_timer(struct wl_event_loop *loop,
 	}
 
 	return &source->base;
+#else /* HAVE_SYS_TIMERFD_H */
+	return NULL;
+#endif /* HAVE_SYS_TIMERFD_H */
 }
 
 WL_EXPORT int
 wl_event_source_timer_update(struct wl_event_source *source, int ms_delay)
 {
+#ifdef HAVE_SYS_TIMERFD_H
 	struct wl_event_source_timer *timer_source =
 		(struct wl_event_source_timer *) source;
 	struct itimerspec its;
@@ -237,7 +250,7 @@ wl_event_source_timer_update(struct wl_event_source *source, int ms_delay)
 		fprintf(stderr, "could not set timerfd\n: %m");
 		return -1;
 	}
-
+#endif /* HAVE_SYS_TIMERFD_H */
 	return 0;
 }
 
@@ -253,6 +266,7 @@ static void
 wl_event_source_signal_dispatch(struct wl_event_source *source,
 			       struct epoll_event *ep)
 {
+#ifdef HAVE_SYS_SIGNALFD_H
 	struct wl_event_source_signal *signal_source =
 		(struct wl_event_source_signal *) source;
 	struct signalfd_siginfo signal_info;
@@ -260,6 +274,7 @@ wl_event_source_signal_dispatch(struct wl_event_source *source,
 	read(signal_source->fd, &signal_info, sizeof signal_info);
 
 	signal_source->func(signal_source->signal_number, signal_source->data);
+#endif /* HAVE_SYS_SIGNALFD_H */
 }
 
 static int
@@ -287,6 +302,7 @@ wl_event_loop_add_signal(struct wl_event_loop *loop,
 			wl_event_loop_signal_func_t func,
 			void *data)
 {
+#ifdef HAVE_SYS_SIGNALFD_H
 	struct wl_event_source_signal *source;
 	struct epoll_event ep;
 	sigset_t mask;
@@ -321,6 +337,9 @@ wl_event_loop_add_signal(struct wl_event_loop *loop,
 	}
 
 	return &source->base;
+#else /* HAVE_SYS_SIGNALFD_H */
+	return NULL;
+#endif /* HAVE_SYS_SIGNALFD_H */
 }
 
 struct wl_event_source_idle {
diff --git a/wayland/scanner.c b/wayland/scanner.c
index 9d099fb..106d9dd 100644
--- a/wayland/scanner.c
+++ b/wayland/scanner.c
@@ -16,6 +16,10 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
diff --git a/wayland/scanner.mk b/wayland/scanner.mk
index efdb42b..729ffd2 100644
--- a/wayland/scanner.mk
+++ b/wayland/scanner.mk
@@ -1,8 +1,8 @@
-%-protocol.c : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(top_builddir)/wayland/scanner code < $< > $@
+$(srcdir)/%-protocol.c: $(top_srcdir)/protocol/%.xml
+	$(AM_V_GEN)$(wayland_scanner) code < $< > $@
 
-%-server-protocol.h : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(top_builddir)/wayland/scanner server-header < $< > $@
+$(srcdir)/%-server-protocol.h: $(top_srcdir)/protocol/%.xml
+	$(AM_V_GEN)$(wayland_scanner) server-header < $< > $@
 
-%-client-protocol.h : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(top_builddir)/wayland/scanner client-header < $< > $@
+$(srcdir)/%-client-protocol.h: $(top_srcdir)/protocol/%.xml
+	$(AM_V_GEN)$(wayland_scanner) client-header < $< > $@
diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c
index 0259017..806f59f 100644
--- a/wayland/wayland-client.c
+++ b/wayland/wayland-client.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 #include <stdint.h>
 #include <stddef.h>
diff --git a/wayland/wayland-hash.c b/wayland/wayland-hash.c
index b299a33..3c35b30 100644
--- a/wayland/wayland-hash.c
+++ b/wayland/wayland-hash.c
@@ -32,6 +32,10 @@
  *    Keith Packard <keithp at keithp.com>
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 
 #include "wayland-util.h"
diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
index 57599fa..41bccb3 100644
--- a/wayland/wayland-server.c
+++ b/wayland/wayland-server.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 #include <stdint.h>
 #include <stddef.h>
diff --git a/wayland/wayland-util.c b/wayland/wayland-util.c
index a287cce..fbce075 100644
--- a/wayland/wayland-util.c
+++ b/wayland/wayland-util.c
@@ -20,6 +20,10 @@
  * OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
-- 
1.7.3.2



More information about the wayland-devel mailing list