[gupnp/gupnp-1.0] build: Backport meson support
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp/gupnp-1.0] build: Backport meson support
- Date: Sun, 11 Nov 2018 09:38:17 +0000 (UTC)
commit 63630bc172a9bc17bcab15be79d6d5f254450a8f
Author: Jens Georg <mail jensge org>
Date: Sun Nov 11 10:30:45 2018 +0100
build: Backport meson support
Makefile.am | 5 ++
doc/Makefile.am | 2 +-
doc/meson.build | 27 ++++++++++
examples/Makefile.am | 3 +-
examples/meson.build | 12 +++++
libgupnp/Makefile.am | 3 +-
libgupnp/meson.build | 123 +++++++++++++++++++++++++++++++++++++++++++
meson.build | 56 ++++++++++++++++++++
meson_options.txt | 5 ++
subprojects/guul/guul.c | 1 +
subprojects/guul/guul.h | 1 +
subprojects/guul/meson.build | 40 ++++++++++++++
tests/Makefile.am | 1 +
tests/gtest/Makefile.am | 2 +-
tests/gtest/meson.build | 12 +++++
tests/meson.build | 9 ++++
tools/Makefile.am | 1 +
tools/meson.build | 1 +
vala/Makefile.am | 3 +-
vala/meson.build | 5 ++
20 files changed, 307 insertions(+), 5 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 1185e35..a1062a8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,6 +6,11 @@ pkgconfig_DATA= gupnp-1.0.pc
pkgconfigdir = $(libdir)/pkgconfig
EXTRA_DIST = gupnp-1.0.pc.in gupnp-1.0-uninstalled.pc.in
+EXTRA_DIST = subprojects/guul/meson.build \
+ subprojects/guul/guul.h \
+ subprojects/guul/guul.c \
+ meson.build \
+ meson_options.txt
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 2e92132..9dadaea 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -99,7 +99,7 @@ include $(top_srcdir)/gtk-doc.make
# Other files to distribute
# e.g. EXTRA_DIST += version.xml.in
-EXTRA_DIST += version.xml.in
+EXTRA_DIST += version.xml.in meson.build
# Files not to distribute
# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types
diff --git a/doc/meson.build b/doc/meson.build
new file mode 100644
index 0000000..cfaec18
--- /dev/null
+++ b/doc/meson.build
@@ -0,0 +1,27 @@
+entities = configuration_data()
+entities.set('VERSION', meson.project_version())
+configure_file(input: 'version.xml.in',
+ output: 'version.xml', configuration:
+ entities)
+
+gnome.gtkdoc('gupnp',
+ main_xml : 'gupnp-docs.xml',
+ src_dir : [join_paths(meson.source_root(), 'libgupnp'),
+ join_paths(meson.build_root(), 'libgupnp')],
+ dependencies : libgupnp,
+ ignore_headers : [
+ 'gena-protocol.h',
+ 'xml-util.h',
+ 'gvalue-util.h',
+ 'http-headers.h',
+ 'gupnp-context-private.h',
+ 'gupnp-linux-context-manager.h',
+ 'gupnp-network-manager.h',
+ 'gupnp-unix-context-manager.h',
+ 'gupnp-device-info-private.h',
+ 'gupnp-error-private.h',
+ 'gupnp-resource-factory-private.h',
+ 'gupnp-service-introspection-private.h',
+ 'gupnp-types-private.h'
+ ],
+ install : true)
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 853cb7c..8ac0b99 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -12,4 +12,5 @@ light_client_LDFLAGS = $(GTHREAD_LIBS) $(LIBGUPNP_LIBS)
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = BinaryLight1.xml \
- SwitchPower1.xml
+ SwitchPower1.xml \
+ meson.build
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 0000000..dccd47b
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,12 @@
+executable(
+ 'light-server',
+ 'light-server.c',
+ export_dynamic : true,
+ dependencies : gupnp
+)
+
+executable(
+ 'light-client',
+ 'light-client.c',
+ dependencies : gupnp
+)
diff --git a/libgupnp/Makefile.am b/libgupnp/Makefile.am
index e5a9de1..f24d4f8 100644
--- a/libgupnp/Makefile.am
+++ b/libgupnp/Makefile.am
@@ -134,7 +134,8 @@ EXTRA_DIST = gupnp-marshal.list \
gupnp-unix-context-manager.c \
gupnp-unix-context-manager.h \
gupnp-windows-context-manager.c \
- gupnp-windows-context-manager.h
+ gupnp-windows-context-manager.h \
+ meson.build
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
diff --git a/libgupnp/meson.build b/libgupnp/meson.build
new file mode 100644
index 0000000..651f86b
--- /dev/null
+++ b/libgupnp/meson.build
@@ -0,0 +1,123 @@
+context_manager_impl = []
+context_manager_args = []
+system_deps = []
+
+if host_machine.system() == 'windows'
+ context_manager_impl += 'gupnp-windows-context-manager.c'
+ system_deps += cc.find_library('ws2_32', required : 'true')
+ system_deps += cc.find_library('iphlpapi', required : 'true')
+else
+ if ifaddrs_available
+ context_manager_impl += 'gupnp-unix-context-manager.c'
+ endif
+ if get_option('context_manager') == 'network-manager'
+ context_manager_impl += 'gupnp-network-manager.c'
+ context_manager_args += '-DUSE_NETWORK_MANAGER'
+ endif
+ if get_option('context_manager') == 'connman'
+ context_manager_impl += 'gupnp-connman-manager.c'
+ context_manager_args += '-DUSE_CONNMAN'
+ endif
+endif
+
+if netlink_available
+ context_manager_impl += 'gupnp-linux-context-manager.c'
+endif
+
+if get_option('context_manager') == 'linux' or (netlink_available and get_option('context_manager') ==
'system')
+ context_manager_args += '-DUSE_NETLINK'
+endif
+
+marshal = gnome.genmarshal(
+ 'gupnp-marshal',
+ sources : 'gupnp-marshal.list',
+ prefix : 'gupnp_marshal'
+)
+
+headers = files(
+ 'gupnp-acl.h',
+ 'gupnp-context.h',
+ 'gupnp-context-manager.h',
+ 'gupnp-control-point.h',
+ 'gupnp-device.h',
+ 'gupnp-device-info.h',
+ 'gupnp-device-proxy.h',
+ 'gupnp-error.h',
+ 'gupnp.h',
+ 'gupnp-resource-factory.h',
+ 'gupnp-root-device.h',
+ 'gupnp-service.h',
+ 'gupnp-service-info.h',
+ 'gupnp-service-introspection.h',
+ 'gupnp-service-proxy.h',
+ 'gupnp-types.h',
+ 'gupnp-uuid.h',
+ 'gupnp-white-list.h',
+ 'gupnp-xml-doc.h'
+)
+install_headers(headers, subdir : 'gupnp-1.0/libgupnp')
+
+sources = files(
+ 'gupnp-acl.c',
+ 'gupnp-context.c',
+ 'gupnp-context-manager.c',
+ 'gupnp-control-point.c',
+ 'gupnp-device.c',
+ 'gupnp-device-info.c',
+ 'gupnp-device-proxy.c',
+ 'gupnp-error.c',
+ 'gupnp-resource-factory.c',
+ 'gupnp-root-device.c',
+ 'gupnp-service.c',
+ 'gupnp-service-info.c',
+ 'gupnp-service-introspection.c',
+ 'gupnp-service-proxy.c',
+ 'gupnp-simple-context-manager.c',
+ 'gupnp-types.c',
+ 'gupnp-white-list.c',
+ 'gupnp-xml-doc.c',
+ 'gvalue-util.c',
+ 'http-headers.c',
+ 'xml-util.c'
+)
+
+libgupnp = library(
+ 'gupnp-1.0',
+ sources + context_manager_impl + marshal,
+ version : '0.0.0',
+ dependencies : dependencies + system_deps,
+ c_args : context_manager_args,
+ include_directories: include_directories('..'),
+ install: true
+)
+
+gupnp = declare_dependency(
+ link_with: libgupnp,
+ include_directories : include_directories('..'),
+ dependencies : dependencies
+)
+
+pkg.generate(
+ libraries : libgupnp,
+ subdirs: 'gupnp-1.0',
+ name : 'gupnp-1.0',
+ description : 'GObject-based UPnP library',
+ version : meson.project_version(),
+ filebase : 'gupnp-1.0'
+)
+
+if get_option('introspection')
+ gir = gnome.generate_gir(
+ libgupnp,
+ sources : headers + sources,
+ namespace : 'GUPnP',
+ nsversion : '1.0',
+ header : 'libgupnp/gupnp.h',
+ symbol_prefix : 'gupnp',
+ identifier_prefix : 'GUPnP',
+ export_packages : 'gupnp-1.0',
+ includes : ['GObject-2.0', 'Gio-2.0', 'Soup-2.4', 'GSSDP-1.0', 'libxml2-2.0'],
+ install : true,
+ extra_args : '-DGOBJECT_INTROSPECTION_SKIP'
+ )
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..733e16d
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,56 @@
+project('gupnp', 'c', version : '1.1.0')
+gnome = import('gnome')
+pkg = import('pkgconfig')
+
+cc = meson.get_compiler('c')
+
+conf = configuration_data()
+conf.set_quoted('VERSION', meson.project_version())
+
+netlink_test = '''#include <sys/socket.h>
+#include <linux/rtnetlink.h>
+'''
+netlink_available = cc.compiles(netlink_test, name : 'linux/rtnetlink.h availability')
+conf.set('HAVE_LINUX_RTNETLINK_H', netlink_available)
+
+ifaddrs_test = '#include <ifaddrs.h>'
+ifaddrs_available = cc.compiles(ifaddrs_test, name : 'ifaddrs.h availability')
+conf.set('HAVE_IFADDRS_H', ifaddrs_available)
+
+wireless_test ='''#include <sys/socket.h>
+#include <linux/wireless.h>
+'''
+conf.set('HAVE_LINUX_WIRELESS_H',
+ cc.compiles(wireless_test, name : 'linux/wireless.h availability'))
+
+config_h = configure_file(output : 'config.h', configuration : conf)
+add_global_arguments('-DHAVE_CONFIG_H=1', language : 'c')
+
+guul = subproject('guul', default_options : ['default_library=static'])
+
+dependencies = [
+ dependency('glib-2.0', version : '>= 2.44'),
+ dependency('gio-2.0', version : '>= 2.44'),
+ dependency('gmodule-2.0', version : '>= 2.44'),
+ dependency('gobject-2.0', version : '>= 2.44'),
+ dependency('gssdp-1.0', version : '>= 1.0'),
+ dependency('libsoup-2.4', version : '>= 2.48.0'),
+ dependency('libxml-2.0'),
+ guul.get_variable('guul')
+]
+
+subdir('libgupnp')
+subdir('tests')
+subdir('tools')
+
+if get_option('vapi') and get_option('introspection')
+ subdir('vala')
+endif
+
+if get_option('gtk_doc')
+ subdir('doc')
+endif
+
+if get_option('examples')
+ subdir('examples')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..3fa5392
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,5 @@
+option('context_manager', type : 'combo', choices : ['linux', 'network-manager', 'connman', 'system'], value
: 'system', description: 'Which context manager to use for detecting network interfaces')
+option('introspection', type : 'boolean', value : 'true', description : 'Enable / disable the
GObject-Introspection integration')
+option('vapi', type : 'boolean', value : 'true', description : ' Enable / disable VALA API file generation
(needs -Dintrospection=true)')
+option('gtk_doc', type : 'boolean', value : 'false', description : 'Enable generation of the API
documentation (needs GTK-Doc)')
+option('examples', type : 'boolean', value : 'true', description : 'Enable / disable building the examples')
diff --git a/subprojects/guul/guul.c b/subprojects/guul/guul.c
new file mode 120000
index 0000000..e6c6329
--- /dev/null
+++ b/subprojects/guul/guul.c
@@ -0,0 +1 @@
+../../libgupnp/guul.c
\ No newline at end of file
diff --git a/subprojects/guul/guul.h b/subprojects/guul/guul.h
new file mode 120000
index 0000000..bf690eb
--- /dev/null
+++ b/subprojects/guul/guul.h
@@ -0,0 +1 @@
+../../libgupnp/guul.h
\ No newline at end of file
diff --git a/subprojects/guul/meson.build b/subprojects/guul/meson.build
new file mode 100644
index 0000000..355f7a6
--- /dev/null
+++ b/subprojects/guul/meson.build
@@ -0,0 +1,40 @@
+project('guul', 'c', version : '0.1')
+
+cc = meson.get_compiler('c')
+dependencies = [
+ dependency('glib-2.0')
+]
+args = []
+
+if host_machine.system() == 'windows'
+ args += '-DGUUL_PLATFORM_WINDOWS'
+ dependencies += cc.find_library('rpcrt4')
+elif host_machine.system() == 'darwin'
+ args += '-DGUUL_PLATFORM_OSX'
+else
+ if not cc.has_function('uuid_to_string')
+ dependencies += dependency('uuid')
+ args += '-DGUUL_PLATFORM_GENERIC'
+ else
+ args += '-DGUUL_PLATFORM_BSD'
+ endif
+endif
+
+if meson.is_subproject()
+ include_dirs=include_directories('../..')
+else
+ include_dirs=[]
+endif
+
+guul_lib = static_library(
+ 'guul',
+ sources : 'guul.c',
+ c_args : args,
+ dependencies : dependencies,
+ include_directories: include_dirs
+)
+
+guul = declare_dependency (
+ link_with : guul_lib,
+ include_directories: include_directories('.')
+)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b47ea80..ab64a1b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -41,3 +41,4 @@ test_white_list_LDFLAGS = $(WARN_LDFLAGS)
CLEANFILES = $(BUILT_SOURCES)
DISTCLEANFILES = $(BUILT_SOURCES)
MAINTAINERCLEANFILES = Makefile.in $(BUILT_SOURCES)
+EXTRA_DIST = meson.build
diff --git a/tests/gtest/Makefile.am b/tests/gtest/Makefile.am
index 24f56a6..f9d7240 100644
--- a/tests/gtest/Makefile.am
+++ b/tests/gtest/Makefile.am
@@ -16,4 +16,4 @@ AM_CFLAGS = \
-I $(top_srcdir) \
-DDATA_PATH="\"$(srcdir)/data\""
-EXTRA_DIST=data/random4k.bin data/TestService.xml data/TestDevice.xml
+EXTRA_DIST=data/random4k.bin data/TestService.xml data/TestDevice.xml meson.build
diff --git a/tests/gtest/meson.build b/tests/gtest/meson.build
new file mode 100644
index 0000000..33637d7
--- /dev/null
+++ b/tests/gtest/meson.build
@@ -0,0 +1,12 @@
+foreach program : ['context', 'bugs']
+ test(
+ program,
+ executable(
+ 'test-' + program,
+ 'test-@0@.c'.format (program),
+ dependencies : gupnp,
+ c_args : '-DDATA_PATH="@0@/data"'.format(meson.current_source_dir())
+ ),
+ is_parallel : false
+ )
+endforeach
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..61b91bc
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,9 @@
+foreach program : ['browsing', 'proxy', 'server', 'introspection', 'white-list']
+ executable(
+ 'test-' + program,
+ sources : 'test-@0@.c'.format(program),
+ dependencies : gupnp
+ )
+endforeach
+
+subdir('gtest')
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 6de9db4..05308f3 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1 +1,2 @@
dist_bin_SCRIPTS = gupnp-binding-tool
+EXTRA_DIST = meson.build
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 0000000..5960fba
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1 @@
+install_data('gupnp-binding-tool', install_dir : 'bin')
diff --git a/vala/Makefile.am b/vala/Makefile.am
index d60fdbf..9fb2a21 100644
--- a/vala/Makefile.am
+++ b/vala/Makefile.am
@@ -1,3 +1,4 @@
+EXTRA_DIST = meson.build
if HAVE_INTROSPECTION
if HAVE_VAPIGEN
gupnp-1.0.vapi: gupnp-1.0.stamp
@@ -16,6 +17,6 @@ gupnp-1.0.stamp: $(top_builddir)/libgupnp/GUPnP-1.0.gir \
vapidir = $(datadir)/vala/vapi
vapi_DATA = gupnp-1.0.vapi $(srcdir)/gupnp-1.0.deps
CLEANFILES = gupnp-1.0.vapi gupnp-1.0.stamp
-EXTRA_DIST = gupnp-1.0.deps GUPnP-1.0.metadata gupnp-1.0-custom.vala gupnp-1.0.vapi gupnp-1.0.stamp
+EXTRA_DIST += gupnp-1.0.deps GUPnP-1.0.metadata gupnp-1.0-custom.vala gupnp-1.0.vapi gupnp-1.0.stamp
endif
endif
diff --git a/vala/meson.build b/vala/meson.build
new file mode 100644
index 0000000..4137796
--- /dev/null
+++ b/vala/meson.build
@@ -0,0 +1,5 @@
+
+gnome.generate_vapi('gupnp-1.0',
+ sources : [gir.get(0), 'gupnp-1.0-custom.vala'],
+ packages : ['gio-2.0', 'libsoup-2.4', 'libxml-2.0'],
+ install : true)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]