build: Add rules to auto-generate wayland headers from protocol xml
authorDerek Foreman <derekf@osg.samsung.com>
Tue, 17 Jan 2017 21:37:50 +0000 (15:37 -0600)
committerDerek Foreman <derekf@osg.samsung.com>
Wed, 18 Jan 2017 19:04:47 +0000 (13:04 -0600)
We've been checking in protocol headers and implementations that
wayland-scanner generates.  We should just generate them from the upstream
xml files.

configure.ac
src/Makefile.am

index 06946b2..45af31b 100644 (file)
@@ -1975,7 +1975,19 @@ AC_ARG_ENABLE([wayland],
    [want_wayland="no"])
 
 if test "${want_wayland}" = "yes"; then
-   EFL_PKG_CHECK_STRICT([wayland-client >= 1.11.0])
+   EFL_PKG_CHECK_STRICT([wayland-client >= 1.11.0 wayland-scanner >= 1.11.0])
+   PKG_CHECK_MODULES([WAYLAND], [wayland-scanner >= 1.11.0],
+    [
+      AC_ARG_VAR([wayland_scanner], [The wayland-scanner executable])
+      AC_PATH_PROG([wayland_scanner], [wayland-scanner])
+      if test x$wayland_scanner = x; then
+        PKG_CHECK_MODULES(WAYLAND_SCANNER, [wayland-scanner])
+        wayland_scanner=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
+      fi
+      AM_CONDITIONAL([HAVE_WAYLAND_SCANNER], [test x$wayland_scanner != x])
+      ac_wayland_protocols_pkgdatadir=`$PKG_CONFIG --variable=pkgdatadir wayland-protocols`
+      AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, $ac_wayland_protocols_pkgdatadir)
+    ])
 fi
 
 # Wayland IVI-Shell
index b29bfda..4c92039 100644 (file)
@@ -192,3 +192,39 @@ install-exec-hook:
           mv $$FNAMEEXT $$FNAME; \
        done
        $(EFL_INSTALL_EXEC_HOOK)
+
+#At the bottom because .SECONDEXPANSION is applied to all following rules.
+if HAVE_WAYLAND_SCANNER
+#Stolen from weston's Makefile.am and modified for Enlightenment
+.SECONDEXPANSION:
+
+define protostability
+$(if $(findstring unstable,$1),unstable,stable)
+endef
+
+define protoname
+$(shell echo $1 | sed 's/\([a-z\-]\+\)-[a-z]\+-v[0-9]\+/\1/')
+endef
+
+#rules for generating protocol from wayland_protocols
+%-protocol.c : $(WAYLAND_PROTOCOLS_DATADIR)/$$(call protostability,$$*)/$$(call protoname,$$*)/$$*.xml
+       $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) code < $< > $@
+
+%-server-protocol.h : $(WAYLAND_PROTOCOLS_DATADIR)/$$(call protostability,$$*)/$$(call protoname,$$*)/$$*.xml
+       $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) server-header < $< > $@
+
+%-client-protocol.h : $(WAYLAND_PROTOCOLS_DATADIR)/$$(call protostability,$$*)/$$(call protoname,$$*)/$$*.xml
+       $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header < $< > $@
+
+#rules for generating local protocols which must be in src/wayland_protocol
+%-protocol.c : $(top_srcdir)/src/wayland_protocol/$(notdir $$*).xml
+       $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) code < $< > $@
+
+%-server-protocol.h : $(top_srcdir)/src/wayland_protocol/$(notdir $$*).xml
+       $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) server-header < $< > $@
+
+%-client-protocol.h : $(top_srcdir)/src/wayland_protocol/$(notdir $$*).xml
+       $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header < $< > $@
+
+#End of weston stuff
+endif