[spice-common RFC] Introduce SPICE_COMMON_SETUP m4 macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This macro gathers the various checks/substitutions that spice-common's
configure.ac needs to do. It's meant to be called by users of the
spice-common submodule instead of calling AC_CONFIG_SUBDIRS() which is
much slower and less flexible.
This also removes spice-protocol as a submodule, it's a standalone module
with its own releases, so we can depend on it instead.
---
 Makefile.am        |   1 -
 autogen.sh         |  19 -------
 common/Makefile.am |  82 ++++++++++++++---------------
 configure.ac       | 152 -----------------------------------------------------
 m4/spice-common.m4 |  98 ++++++++++++++++++++++++++++++++++
 spice-protocol     |   1 -
 6 files changed, 138 insertions(+), 215 deletions(-)
 delete mode 100755 autogen.sh
 delete mode 100644 configure.ac
 create mode 100644 m4/spice-common.m4
 delete mode 160000 spice-protocol

diff --git a/Makefile.am b/Makefile.am
index 380bf24..e39273d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,6 @@ NULL =
 ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = python_modules common
-DIST_SUBDIRS = spice-protocol $(SUBDIRS)
 
 EXTRA_DIST =				\
 	spice_codegen.py		\
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index e4ada55..0000000
--- a/autogen.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-set -e # exit on errors
-
-srcdir=`dirname $0`
-test -z "$srcdir" && srcdir=.
-
-olddir=`pwd`
-cd "$srcdir"
-
-git submodule update --init
-
-mkdir -p m4
-autoreconf --verbose --force --install
-
-cd "$olddir"
-if [ -z "$NOCONFIGURE" ]; then
-    "$srcdir"/configure --enable-maintainer-mode ${1+"$@"}
-fi
diff --git a/common/Makefile.am b/common/Makefile.am
index 73703fc..aa71aa6 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -2,19 +2,19 @@ NULL =
 
 # Avoid need for python(pyparsing) by end users
 CLIENT_MARSHALLERS =					\
-	$(srcdir)/generated_client_demarshallers.c	\
-	$(srcdir)/generated_client_demarshallers1.c	\
-	$(srcdir)/generated_client_marshallers.c	\
-	$(srcdir)/generated_client_marshallers1.c	\
+	generated_client_demarshallers.c	\
+	generated_client_demarshallers1.c	\
+	generated_client_marshallers.c	\
+	generated_client_marshallers1.c	\
 	$(NULL)
 
 SERVER_MARSHALLERS =					\
-	$(srcdir)/generated_server_demarshallers.c	\
-	$(srcdir)/generated_server_marshallers.c	\
-	$(srcdir)/generated_server_marshallers.h	\
+	generated_server_demarshallers.c	\
+	generated_server_marshallers.c	\
+	generated_server_marshallers.h	\
 	$(NULL)
 
-BUILT_SOURCES = $(CLIENT_MARSHALLERS) $(SERVER_MARSHALLERS) $(top_srcdir)/spice-protocol/spice/enums.h
+BUILT_SOURCES = $(CLIENT_MARSHALLERS) $(SERVER_MARSHALLERS)
 
 noinst_LTLIBRARIES = libspice-common.la libspice-common-server.la libspice-common-client.la
 libspice_common_la_SOURCES =		\
@@ -80,61 +80,61 @@ libspice_common_la_SOURCES +=		\
 	$(NULL)
 endif
 
+#FIXME: need to make it possible for the toplevel module (spice) to be able
+#to add its own CFLAGS while letting the spice-common module silently adds
+#the flags it needs
+#AM_CPPFLAGS = $(AM_CPPFLAGS) $(xxxxx) ?
+#FIXME: need to remove the hardcoded -std=gnu99 here
 AM_CPPFLAGS =				\
-	$(GL_CFLAGS)			\
-	$(PIXMAN_CFLAGS)		\
-	$(CELT051_CFLAGS)		\
-	$(OPUS_CFLAGS)		        \
-	$(PROTOCOL_CFLAGS)		\
-	$(SMARTCARD_CFLAGS)		\
+	$(SPICE_COMMON_CFLAGS)		\
 	$(VISIBILITY_HIDDEN_CFLAGS)	\
 	$(WARN_CFLAGS)			\
 	-std=gnu99			\
 	$(NULL)
 
-libspice_common_la_LIBADD =				\
-	$(OPUS_LIBS)		                        \
-	$(CELT051_LIBS)
+libspice_common_la_LIBADD =	\
+	$(SPICE_COMMON_LIBS)
 
+topdir=$(abs_srcdir)/..
 MARSHALLERS_DEPS =					\
-	$(top_srcdir)/python_modules/__init__.py	\
-	$(top_srcdir)/python_modules/codegen.py		\
-	$(top_srcdir)/python_modules/demarshal.py	\
-	$(top_srcdir)/python_modules/marshal.py		\
-	$(top_srcdir)/python_modules/ptypes.py		\
-	$(top_srcdir)/python_modules/spice_parser.py	\
-	$(top_srcdir)/spice_codegen.py			\
+	$(topdir)/python_modules/__init__.py	\
+	$(topdir)/python_modules/codegen.py		\
+	$(topdir)/python_modules/demarshal.py	\
+	$(topdir)/python_modules/marshal.py		\
+	$(topdir)/python_modules/ptypes.py		\
+	$(topdir)/python_modules/spice_parser.py	\
+	$(topdir)/spice_codegen.py			\
 	$(NULL)
 
 # Note despite being autogenerated these are not part of CLEANFILES, they are
 # actually a part of EXTRA_DIST, to avoid the need for pyparser by end users
-generated_client_demarshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS)
-	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --client --include messages.h $< $@ >/dev/null
+generated_client_demarshallers.c: $(topdir)/spice.proto $(MARSHALLERS_DEPS)
+	$(AM_V_GEN)$(PYTHON) $(topdir)/spice_codegen.py --generate-demarshallers --client --include messages.h $< $@ >/dev/null
 
-generated_client_demarshallers1.c: $(top_srcdir)/spice1.proto $(MARSHALLERS_DEPS)
-	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --client --include messages.h --prefix 1 --ptrsize 8 $< $@ >/dev/null
+generated_client_demarshallers1.c: $(topdir)/spice1.proto $(MARSHALLERS_DEPS)
+	$(AM_V_GEN)$(PYTHON) $(topdir)/spice_codegen.py --generate-demarshallers --client --include messages.h --prefix 1 --ptrsize 8 $< $@ >/dev/null
 
-generated_client_marshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS)
-	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include messages.h --include client_marshallers.h --client $< $@ >/dev/null
+generated_client_marshallers.c: $(topdir)/spice.proto $(MARSHALLERS_DEPS)
+	$(AM_V_GEN)$(PYTHON) $(topdir)/spice_codegen.py --generate-marshallers -P --include messages.h --include client_marshallers.h --client $< $@ >/dev/null
 
-generated_client_marshallers1.c: $(top_srcdir)/spice1.proto $(MARSHALLERS_DEPS)
-	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include messages.h --include client_marshallers.h --client --prefix 1 --ptrsize 8 $< $@ >/dev/null
+generated_client_marshallers1.c: $(topdir)/spice1.proto $(MARSHALLERS_DEPS)
+	$(AM_V_GEN)$(PYTHON) $(topdir)/spice_codegen.py --generate-marshallers -P --include messages.h --include client_marshallers.h --client --prefix 1 --ptrsize 8 $< $@ >/dev/null
 
-generated_server_demarshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS)
-	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --server --include messages.h $< $@ >/dev/null
+generated_server_demarshallers.c: $(topdir)/spice.proto $(MARSHALLERS_DEPS)
+	$(AM_V_GEN)$(PYTHON) $(topdir)/spice_codegen.py --generate-demarshallers --server --include messages.h $< $@ >/dev/null
 
 STRUCTS = -M String -M Rect -M Point -M DisplayBase -M Fill -M Opaque -M Copy -M Blend -M Blackness -M Whiteness -M Invers -M Rop3 -M Stroke -M Text -M Transparent -M AlphaBlend -M Composite
-generated_server_marshallers.c: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS)
-	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers $(STRUCTS) --server --include messages.h $< $@ >/dev/null
+generated_server_marshallers.c: $(topdir)/spice.proto $(MARSHALLERS_DEPS)
+	$(AM_V_GEN)$(PYTHON) $(topdir)/spice_codegen.py --generate-marshallers $(STRUCTS) --server --include messages.h $< $@ >/dev/null
 
-generated_server_marshallers.h: $(top_srcdir)/spice.proto $(MARSHALLERS_DEPS)
-	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers $(STRUCTS) --server --include messages.h -H $< $@ >/dev/null
+generated_server_marshallers.h: $(topdir)/spice.proto $(MARSHALLERS_DEPS)
+	$(AM_V_GEN)$(PYTHON) $(topdir)/spice_codegen.py --generate-marshallers $(STRUCTS) --server --include messages.h -H $< $@ >/dev/null
 
 # this is going to upset automake distcheck, since we try to write to
 # readonly srcdir. To limit the fail chances, rebuild automatically
 # enums.h only if the spice.proto has changed.
-$(top_srcdir)/spice-protocol/spice/enums.h: $(top_srcdir)/spice.proto # $(MARSHALLERS_DEPS)
-	$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-enums $< $@ >/dev/null
+$(top_srcdir)/spice-protocol/spice/enums.h: $(topdir)/spice.proto # $(MARSHALLERS_DEPS)
+	$(AM_V_GEN)$(PYTHON) $(topdir)/spice_codegen.py --generate-enums $< $@ >/dev/null
 
 EXTRA_DIST =				\
 	$(CLIENT_MARSHALLERS)		\
@@ -154,5 +154,3 @@ EXTRA_DIST =				\
 	sw_canvas.c			\
 	sw_canvas.h			\
 	$(NULL)
-
--include $(top_srcdir)/git.mk
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index bb469c6..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,152 +0,0 @@
-AC_PREREQ([2.63])
-
-AC_INIT([spice-common],
-        [noversion],
-        [spice-devel@xxxxxxxxxxxxxxxxxxxxx])
-
-AC_CONFIG_SRCDIR([common/bitops.h])
-AC_CONFIG_MACRO_DIR([m4])
-AM_CONFIG_HEADER([config.h])
-AC_CONFIG_AUX_DIR([build-aux])
-
-# For automake >= 1.12
-m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
-
-# Checks for programs
-AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip tar-ustar foreign -Wall -Werror])
-AM_MAINTAINER_MODE
-AM_SILENT_RULES([yes])
-LT_INIT
-
-AC_PROG_CC
-AC_PROG_CC_C99
-if test "x$ac_cv_prog_cc_c99" = xno; then
-    AC_MSG_ERROR([C99 compiler is required.])
-fi
-AM_PROG_CC_C_O
-
-# Checks for libraries
-AC_CONFIG_SUBDIRS([spice-protocol])
-PROTOCOL_CFLAGS='-I ${top_srcdir}/spice-protocol'
-AC_SUBST(PROTOCOL_CFLAGS)
-
-PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.17.7)
-AC_SUBST(PIXMAN_CFLAGS)
-
-AC_ARG_ENABLE([smartcard],
-  AS_HELP_STRING([--enable-smartcard=@<:@yes/no/auto@:>@],
-                 [Enable smartcard support @<:@default=auto@:>@]),
-  [],
-  [enable_smartcard="auto"])
-
-have_smartcard=no
-if test "x$enable_smartcard" != "xno"; then
-  PKG_CHECK_MODULES(SMARTCARD, libcacard >= 0.1.2, [have_smartcard=yes], [have_smartcard=no])
-  if test "x$enable_smartcard" != "xauto" && test "x$have_smartcard" = "xno"; then
-    AC_MSG_ERROR("Smartcard support requested but libcacard could not be found")
-  fi
-  if test "x$have_smartcard" = "xyes"; then
-    AC_DEFINE(USE_SMARTCARD, [1], [Define if supporting smartcard proxying])
-  fi
-fi
-AM_CONDITIONAL([WITH_SMARTCARD], [test "x$have_smartcard" = "xyes"])
-
-AC_ARG_ENABLE(celt051,
-[  --disable-celt051       Disable celt051 audio codec (enabled by default)],,
-[enable_celt051="yes"])
-
-if test "x$enable_celt051" = "xyes"; then
-    PKG_CHECK_MODULES(CELT051, celt051 >= 0.5.1.1, have_celt051=yes, have_celt051=no)
-    AC_SUBST(CELT051_CFLAGS)
-    AC_SUBST(CELT051_LIBS)
-    AC_SUBST(CELT051_LIBDIR)
-else
-    have_celt051=no
-fi
-
-AM_CONDITIONAL([HAVE_CELT051], [test "x$have_celt051" = "xyes"])
-AM_COND_IF([HAVE_CELT051], AC_DEFINE([HAVE_CELT051], 1, [Define if we have celt051 codec]))
-
-PKG_CHECK_MODULES([OPUS], [opus >= 0.9.14], have_opus=yes, have_opus=no)
-
-AM_CONDITIONAL([HAVE_OPUS], [test "x$have_opus" = "xyes"])
-if test "x$have_opus" = "xyes" ; then
-  AC_DEFINE([HAVE_OPUS], [1], [Define if we have OPUS])
-  SPICE_REQUIRES+=" opus >= 0.9.14"
-  opus_version=`pkg-config --modversion opus`
-fi
-
-AC_ARG_ENABLE([opengl],
-  AS_HELP_STRING([--enable-opengl=@<:@yes/no@:>@],
-                 [Enable opengl support (not recommended) @<:@default=no@:>@]),
-  [],
-  [enable_opengl="no"])
-AM_CONDITIONAL(SUPPORT_GL, test "x$enable_opengl" = "xyes")
-
-if test "x$enable_opengl" = "xyes"; then
-   AC_CHECK_LIB(GL, glBlendFunc, GL_LIBS="$GL_LIBS -lGL", enable_opengl=no)
-   AC_CHECK_LIB(GLU, gluSphere, GL_LIBS="$GL_LIBS -lGLU", enable_opengl=no)
-   AC_DEFINE([USE_OPENGL], [1], [Define to build with OpenGL support])
-   AC_DEFINE([GL_GLEXT_PROTOTYPES], [], [Enable GLExt prototypes])
-
-   if test "x$enable_opengl" = "xno"; then
-      AC_MSG_ERROR([GL libraries not available])
-   fi
-fi
-AC_SUBST(GL_CFLAGS)
-AC_SUBST(GL_LIBS)
-
-# Checks for header files
-AC_PATH_X
-AC_FUNC_ALLOCA
-AC_CHECK_HEADERS([arpa/inet.h malloc.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/socket.h unistd.h])
-
-# Checks for typedefs, structures, and compiler characteristics
-AC_C_INLINE
-AC_TYPE_INT16_T
-AC_TYPE_INT32_T
-AC_TYPE_INT64_T
-AC_TYPE_INT8_T
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-AC_TYPE_UINT16_T
-AC_TYPE_UINT32_T
-AC_TYPE_UINT64_T
-AC_TYPE_UINT8_T
-
-# Checks for library functions
-# do not check malloc or realloc, since that cannot be cross-compiled checked
-AC_FUNC_ERROR_AT_LINE
-AC_FUNC_FORK
-AC_CHECK_FUNCS([dup2 floor inet_ntoa memmove memset pow sqrt])
-
-# Others
-AC_CANONICAL_HOST
-
-AC_MSG_CHECKING([for native Win32])
-case "$host_os" in
-     *mingw*|*cygwin*)
-        os_win32=yes
-        ;;
-     *)
-        os_win32=no
-        ;;
-esac
-AC_MSG_RESULT([$os_win32])
-AM_CONDITIONAL([OS_WIN32],[test "$os_win32" = "yes"])
-
-# The End!
-AC_CONFIG_FILES([
-  Makefile
-  common/Makefile
-  python_modules/Makefile
-])
-
-AH_BOTTOM([
-/* argh.. this is evil */
-#if defined(FIXME_SERVER_SMARTCARD) && defined(USE_SMARTCARD)
-%:undef USE_SMARTCARD
-#endif
-])
-
-AC_OUTPUT
diff --git a/m4/spice-common.m4 b/m4/spice-common.m4
new file mode 100644
index 0000000..ab34f09
--- /dev/null
+++ b/m4/spice-common.m4
@@ -0,0 +1,98 @@
+dnl Input: relative path to the spice-common dir from $top_srcdir
+dnl SPICE_COMMON_CFLAGS
+dnl SPICE_COMMON_LIBS
+dnl SPICE_COMMON_REQUIRES
+dnl AC_DEFINE(USE_SMARTCARD)
+dnl AM_CONDITIONAL(WITH_SMARTCARD)
+dnl AC_DEFINE(HAVE_CELT051)
+dnl AM_CONDITIONAL(HAVE_CELT051)
+dnl AC_DEFINE(HAVE_OPUS)
+dnl AM_CONDITIONAL(HAVE_OPUS)
+AC_DEFUN([SPICE_COMMON_SETUP], [
+    SPICE_COMMON_CFLAGS="-I\${top_srcdir}/$1/"
+    SPICE_COMMON_LIBS=
+    SPICE_COMMON_REQUIRES=
+
+
+    PKG_CHECK_MODULES(ac_spice_PROTOCOL, spice-protocol >= 0.12.0)
+    SPICE_COMMON_CFLAGS+=" $ac_spice_PROTOCOL_CFLAGS"
+    SPICE_COMMON_LIBS+=" $ac_spice_PROTOCOL_LIBS"
+
+
+    PKG_CHECK_MODULES(ac_spice_PIXMAN, pixman-1 >= 0.17.7)
+    SPICE_COMMON_CFLAGS+=" $ac_spice_PIXMAN_CFLAGS"
+    SPICE_COMMON_LIBS+=" $ac_spice_PIXMAN_LIBS"
+    SPICE_COMMON_REQUIRES+=" pixman-1 >= 0.17.7"
+
+
+    AC_ARG_ENABLE([smartcard],
+      AS_HELP_STRING([--enable-smartcard=@<:@yes/no/auto@:>@],
+                     [Enable smartcard support @<:@default=auto@:>@]),
+      [],
+      [ac_spice_enable_smartcard="auto"])
+
+
+    ac_spice_have_smartcard=no
+    if test "x$ac_spice_enable_smartcard" != "xno"; then
+      PKG_CHECK_MODULES(ac_spice_SMARTCARD, libcacard >= 0.1.2,
+                        [ac_spice_have_smartcard=yes],
+                        [ac_spice_have_smartcard=no])
+      if test "x$ac_spice_enable_smartcard" != "xauto" && test "x$ac_spice_have_smartcard" = "xno"; then
+        AC_MSG_ERROR("Smartcard support requested but libcacard could not be found")
+      fi
+      if test "x$ac_spice_have_smartcard" = "xyes"; then
+        AC_DEFINE(USE_SMARTCARD, [1], [Define if supporting smartcard proxying])
+        SPICE_COMMON_REQUIRES+=" libcacard >= 0.1.2"
+      fi
+    fi
+    AM_CONDITIONAL([WITH_SMARTCARD], [test "x$ac_spice_have_smartcard" = "xyes"])
+    SPICE_COMMON_CFLAGS+=" $ac_spice_SMARTCARD_CFLAGS"
+    SPICE_COMMON_LIBS+=" $ac_spice_SMARTCARD_LIBS"
+
+
+    AC_ARG_ENABLE(celt051,
+                  [  --disable-celt051       Disable celt051 audio codec (enabled by default)],,
+                  [ac_spice_enable_celt051="yes"])
+
+    if test "x$ac_spice_enable_celt051" = "xyes"; then
+        PKG_CHECK_MODULES(ac_spice_CELT051, celt051 >= 0.5.1.1, ac_spice_have_celt051=yes, ac_spice_have_celt051=no)
+    else
+        ac_spice_have_celt051=no
+    fi
+
+    AM_CONDITIONAL([HAVE_CELT051], [test "x$ac_spice_have_celt051" = "xyes"])
+    AM_COND_IF([HAVE_CELT051],
+                SPICE_COMMON_REQUIRES+=" celt051 >= 0.5.1.1"
+                AC_DEFINE([HAVE_CELT051], 1, [Define if we have celt051 codec]))
+    SPICE_COMMON_CFLAGS+=" $ac_spice_CELT051_CFLAGS"
+    SPICE_COMMON_LIBS+=" $ac_spice_CELT051_LIBS"
+
+
+    PKG_CHECK_MODULES([ac_spice_OPUS], [opus >= 0.9.14], ac_spice_have_opus=yes, ac_spice_have_opus=no)
+
+    AM_CONDITIONAL([HAVE_OPUS], [test "x$ac_spice_have_opus" = "xyes"])
+    if test "x$ac_spice_have_opus" = "xyes" ; then
+      AC_DEFINE([HAVE_OPUS], [1], [Define if we have OPUS])
+      SPICE_COMMON_REQUIRES+=" opus >= 0.9.14"
+    fi
+    SPICE_COMMON_CFLAGS+=" $ac_spice_OPUS_CFLAGS"
+    SPICE_COMMON_LIBS+=" $ac_spice_OPUS_LIBS"
+    echo "SPICE_COMMON CFLAGS: $SPICE_COMMON_CFLAGS"
+    echo "SPICE_COMMON_REQUIRES: $SPICE_COMMON_REQUIRES"
+
+    AC_CONFIG_FILES([
+      $1/Makefile
+      $1/common/Makefile
+      $1/python_modules/Makefile
+    ])
+
+
+    dnl needed because the generated server-side demarshalling smartcard
+    dnl code does not compile for some reason
+    AH_BOTTOM([/* argh.. this is evil */
+               #if defined(FIXME_SERVER_SMARTCARD) && defined(USE_SMARTCARD)
+                   %:undef USE_SMARTCARD
+               #endif
+    ])
+])
+
diff --git a/spice-protocol b/spice-protocol
deleted file mode 160000
index a3de8dd..0000000
--- a/spice-protocol
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit a3de8dd8d250d6e3895c0167009cb58540c7ed19
-- 
1.8.4.2

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]