[gcab] Include support for the Meson buildsystem



commit c8ff6fe71707f7735923d13280f866acc8b8617d
Author: Richard Hughes <richard hughsie com>
Date:   Thu Nov 16 21:00:38 2017 +0000

    Include support for the Meson buildsystem
    
    The automake build system is still the default, and will be used for releases
    going forward.
    
    Adding meson as an option allows us to build on s390x and other unusual
    architectures easily.

 docs/meson.build           |    1 +
 docs/reference/meson.build |   15 ++++++
 libgcab/meson.build        |   99 +++++++++++++++++++++++++++++++++++++++
 meson.build                |  111 ++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt          |    3 +
 po/meson.build             |    6 ++
 src/gcab.1.in              |    2 +-
 src/meson.build            |   27 +++++++++++
 8 files changed, 263 insertions(+), 1 deletions(-)
---
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..ead14c4
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1 @@
+subdir('reference')
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
new file mode 100644
index 0000000..4099e21
--- /dev/null
+++ b/docs/reference/meson.build
@@ -0,0 +1,15 @@
+gcab_docs = configure_file(
+  input : 'gcab-docs.sgml.in',
+  output : 'gcab-docs.sgml',
+  configuration : conf,
+)
+
+gnome.gtkdoc(
+  'gcab',
+  src_dir : [
+    join_paths(meson.source_root(), 'libgcab'),
+    join_paths(meson.build_root(), 'libgcab'),
+  ],
+  main_sgml : 'gcab-docs.sgml',
+  install : true
+)
diff --git a/libgcab/meson.build b/libgcab/meson.build
new file mode 100644
index 0000000..2da074a
--- /dev/null
+++ b/libgcab/meson.build
@@ -0,0 +1,99 @@
+cargs = [
+  '-DG_LOG_DOMAIN="gcab"',
+]
+
+enum_headers = ['gcab-folder.h', 'gcab-file.h']
+enums = gnome.mkenums(
+  'gcab-enums',
+  sources : enum_headers,
+  c_template : 'gcab-enums.c.etemplate',
+  h_template : 'gcab-enums.h.etemplate',
+  install_header : true,
+  install_dir : 'include/libgcab-1.0/libgcab',
+  symbol_prefix : 'gcab',
+  identifier_prefix : 'GCab',
+)
+
+install_headers(
+  'libgcab.h',
+  subdir : 'libgcab-1.0',
+)
+
+install_headers([
+    'gcab-cabinet.h',
+    'gcab-file.h',
+    'gcab-folder.h',
+  ],
+  subdir : 'libgcab-1.0/libgcab',
+)
+
+mapfile = 'libgcab.syms'
+vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
+libgcab = shared_library(
+  'gcab-1.0',
+  enums,
+  sources : [
+    'gcab-cabinet.c',
+    'gcab-folder.c',
+    'gcab-file.c',
+    'cabinet.c',
+    'decomp.c',
+    'glib-compat.c',
+  ],
+  soversion : lt_current,
+  version : lt_version,
+  dependencies : [
+    gio,
+    libz,
+  ],
+  c_args : cargs,
+  include_directories : [
+    include_directories('.'),
+    include_directories('..'),
+  ],
+  link_args : vflag,
+  link_depends : mapfile,
+  install : true
+)
+
+pkgg = import('pkgconfig')
+pkgg.generate(
+  libraries : libgcab,
+  requires : [ 'gio-2.0' ],
+  subdirs : 'libgcab-1.0',
+  version : meson.project_version(),
+  name : 'libgcab',
+  filebase : 'libgcab-1.0',
+  description : 'Cabinet file library',
+)
+
+if get_option('introspection')
+  gir = gnome.generate_gir(libgcab,
+    sources : [
+      'gcab-cabinet.c',
+      'gcab-cabinet.h',
+      'gcab-folder.c',
+      'gcab-folder.h',
+      'gcab-file.c',
+      'gcab-file.h',
+    ],
+    nsversion : '1.0',
+    namespace : 'GCab',
+    symbol_prefix : 'gcab',
+    identifier_prefix : 'GCab',
+    export_packages : 'libgcab',
+    dependencies : [
+      gio,
+    ],
+    includes : [
+      'Gio-2.0',
+      'GObject-2.0',
+    ],
+    install : true
+  )
+  gnome.generate_vapi('libgcab-1.0',
+    sources: gir[0],
+    packages : ['gio-2.0'],
+    install : true,
+  )
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..1d669f1
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,111 @@
+project('gcab', 'c',
+  version : '1.0',
+  license : 'LGPL-2.1+',
+  meson_version : '>=0.37.0',
+  default_options : ['warning_level=2', 'c_std=c99'],
+)
+
+# libtool versioning
+lt_current = '0'
+lt_revision = '0'
+lt_age = '0'
+lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision)
+
+# get suported warning flags
+test_args = [
+  '-fstack-protector-strong',
+  '-Waggregate-return',
+  '-Wunused',
+  '-Warray-bounds',
+  '-Wcast-align',
+  '-Wclobbered',
+  '-Wduplicated-branches',
+  '-Wduplicated-cond',
+  '-Wempty-body',
+  '-Wformat=2',
+  '-Wformat-nonliteral',
+  '-Wformat-security',
+  '-Wformat-signedness',
+  '-Wignored-qualifiers',
+  '-Wimplicit-function-declaration',
+  '-Winit-self',
+  '-Wlogical-op',
+  '-Wmissing-declarations',
+  '-Wmissing-format-attribute',
+  '-Wmissing-include-dirs',
+  '-Wmissing-noreturn',
+  '-Wmissing-parameter-type',
+  '-Wmissing-prototypes',
+  '-Wnested-externs',
+  '-Wno-discarded-qualifiers',
+  '-Wno-missing-field-initializers',
+  '-Wno-strict-aliasing',
+  '-Wno-suggest-attribute=format',
+  '-Wno-unused-parameter',
+  '-Wnull-dereference',
+  '-Wold-style-definition',
+  '-Woverride-init',
+  '-Wpointer-arith',
+  '-Wredundant-decls',
+  '-Wreturn-type',
+  '-Wshadow',
+  '-Wsign-compare',
+  '-Wstrict-aliasing',
+  '-Wstrict-prototypes',
+  '-Wswitch-default',
+  '-Wtype-limits',
+  '-Wundef',
+  '-Wuninitialized',
+  '-Wunused-but-set-variable',
+  '-Wunused-variable',
+  '-Wwrite-strings'
+]
+cc = meson.get_compiler('c')
+foreach arg: test_args
+  if cc.has_argument(arg)
+    add_project_arguments(arg, language : 'c')
+  endif
+endforeach
+
+# enable full RELRO where possible
+# FIXME: until https://github.com/mesonbuild/meson/issues/1140 is fixed
+global_link_args = []
+test_link_args = [
+  '-Wl,-z,relro',
+  '-Wl,-z,now',
+]
+foreach arg: test_link_args
+  if cc.has_argument(arg)
+    global_link_args += arg
+  endif
+endforeach
+add_global_link_arguments(
+  global_link_args,
+  language: 'c'
+)
+
+gio = dependency('gio-2.0', version : '>= 2.32.0')
+libz = dependency('zlib')
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+conf = configuration_data()
+conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+conf.set_quoted('PACKAGE_NAME', meson.project_name())
+conf.set_quoted('PACKAGE_STRING', meson.project_name())
+conf.set_quoted('VERSION', meson.project_version())
+conf.set_quoted('LOCALEDIR', get_option('localedir'))
+conf.set_quoted('PACKAGE_BUGREPORT', 'https://bugzilla.gnome.org/enter_bug.cgi?product=msitools')
+configure_file(
+  output : 'config.h',
+  configuration : conf
+)
+
+subdir('libgcab')
+subdir('po')
+subdir('src')
+
+if get_option('docs')
+subdir('docs')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..bbcbbea
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,3 @@
+option('docs', type : 'boolean', value : true, description : 'enable developer documentation')
+option('introspection', type : 'boolean', value : true, description : 'generate GObject Introspection data')
+option('tests', type : 'boolean', value : true, description : 'enable tests')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..6b9a7bc
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,6 @@
+i18n.gettext(meson.project_name(),
+  preset : 'glib',
+  args: [
+  '--default-domain=' + meson.project_name(),
+  ]
+)
diff --git a/src/gcab.1.in b/src/gcab.1.in
index 3f0e7f0..9be70e8 100644
--- a/src/gcab.1.in
+++ b/src/gcab.1.in
@@ -1,4 +1,4 @@
-.TH GCAB "1" "December 2012" "@PACKAGE@ @VERSION@"
+.TH GCAB "1" "December 2012" "@PACKAGE_NAME@ @VERSION@"
 .SH NAME
 gcab \- Program to create Microsoft cabinet (.cab) archives
 .SH SYNOPSIS
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..79962ab
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,27 @@
+configure_file(
+  input : 'gcab.1.in',
+  output : 'gcab.1',
+  configuration : conf,
+  install : true,
+  install_dir : join_paths(get_option('mandir'), 'man1'),
+)
+
+executable(
+  'gcab',
+  sources : [
+    'gcab.c',
+  ],
+  include_directories : [
+    include_directories('..'),
+    include_directories('../libgcab'),
+  ],
+  dependencies : [
+    gio,
+  ],
+  link_with : [
+    libgcab,
+  ],
+  c_args : cargs,
+  install : true,
+  install_dir : get_option('bindir')
+)


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