[frogr/meson: 3/4] Add initial bits to provide support for the meson build system



commit 26f360de2b7d0669bc86eec369fe2d89edd0a590
Author: Mario Sanchez Prada <msanchez gnome org>
Date:   Tue May 23 13:01:23 2017 +0100

    Add initial bits to provide support for the meson build system
    
    For now, this just includes a basic version of the meson.build
    script, the meson_options.txt file and the configure script adapter
    to comply with the build API (https://github.com/cgwalters/build-api).
    
    Still lacks all the actual bits to compile things, plus some code
    to properly check for libgcrypt when no .pc file is available.

 .gitignore        |    1 -
 configure         |  156 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 meson.build       |   76 ++++++++++++++++++++++++++
 meson_options.txt |    2 +
 4 files changed, 234 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 15db01e..f94f2bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,7 +28,6 @@ Makefile.in
 aclocal.m4
 compile
 config.*
-configure
 depcomp
 frogr-*.tar*
 install-sh
diff --git a/configure b/configure
new file mode 100755
index 0000000..fd6046d
--- /dev/null
+++ b/configure
@@ -0,0 +1,156 @@
+#!/bin/bash
+# configure script adapter for Meson
+# Based on build-api: https://github.com/cgwalters/build-api
+# Copyright 2010, 2011, 2013 Colin Walters <walters verbum org>
+# Copyright 2016, 2017 Emmanuele Bassi
+# Copyright 2017 Mario Sanchez Prada
+# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
+
+# Build API variables:
+
+# Little helper function for reading args from the commandline.
+# it automatically handles -a b and -a=b variants, and returns 1 if
+# we need to shift $3.
+read_arg() {
+    # $1 = arg name
+    # $2 = arg value
+    # $3 = arg parameter
+    local rematch='^[^=]*=(.*)$'
+    if [[ $2 =~ $rematch ]]; then
+       read "$1" <<< "${BASH_REMATCH[1]}"
+    else
+       read "$1" <<< "$3"
+       # There is no way to shift our callers args, so
+       # return 1 to indicate they should do it instead.
+       return 1
+    fi
+}
+
+sanitycheck() {
+    # $1 = arg name
+    # $1 = arg command
+    # $2 = arg alternates
+    local cmd=$( which $2 2>/dev/null )
+
+    if [ -x "$cmd" ]; then
+        read "$1" <<< "$cmd"
+        return 0
+    fi
+
+    test -z $3 || {
+        for alt in $3; do
+            cmd=$( which $alt 2>/dev/null )
+
+            if [ -x "$cmd" ]; then
+                read "$1" <<< "$cmd"
+                return 0
+            fi
+        done
+    }
+
+    echo -e "\e[1;31mERROR\e[0m: Command '$2' not found"
+    exit 1
+}
+
+sanitycheck MESON 'meson'
+sanitycheck MESONTEST 'mesontest'
+sanitycheck NINJA 'ninja' 'ninja-build'
+
+enable_header_bar='-Denable-header-bar=true'
+enable_video='-Denable-video=true'
+
+while (($# > 0)); do
+    case "${1%%=*}" in
+       --prefix) read_arg prefix "$@" || shift;;
+       --bindir) read_arg bindir "$@" || shift;;
+       --sbindir) read_arg sbindir "$@" || shift;;
+       --libexecdir) read_arg libexecdir "$@" || shift;;
+       --datarootdir) read_arg datarootdir "$@" || shift;;
+       --datadir) read_arg datadir "$@" || shift;;
+       --sysconfdir) read_arg sysconfdir "$@" || shift;;
+       --libdir) read_arg libdir "$@" || shift;;
+       --mandir) read_arg mandir "$@" || shift;;
+       --includedir) read_arg includedir "$@" || shift;;
+       --enable-header-bar) enable_header_bar='-Denable-header-bar=true';;
+       --disable-header-bar) enable_header_bar='-Denable-header-bar=false';;
+       --enable-video) enable_video='-Denable-video=true';;
+       --disable-video) enable_video='-Denable-video=false';;
+       *) echo -e "\e[1;33mINFO\e[0m: Ignoring unknown option '$1'";;
+    esac
+    shift
+done
+
+# Defaults
+test -z ${prefix} && prefix="/usr/local"
+test -z ${bindir} && bindir=${prefix}/bin
+test -z ${sbindir} && sbindir=${prefix}/sbin
+test -z ${libexecdir} && libexecdir=${prefix}/bin
+test -z ${datarootdir} && datarootdir=${prefix}/share
+test -z ${datadir} && datadir=${datarootdir}
+test -z ${sysconfdir} && sysconfdir=${prefix}/etc
+test -z ${libdir} && libdir=${prefix}/lib
+test -z ${mandir} && mandir=${prefix}/share/man
+test -z ${includedir} && includedir=${prefix}/include
+
+# The source directory is the location of this file
+srcdir=$(dirname $0)
+
+# The build directory is the current location
+builddir=`pwd`
+
+# If we're calling this file from the source directory then
+# we automatically create a build directory and ensure that
+# both Meson and Ninja invocations are relative to that
+# location
+if [[ -f "${builddir}/meson.build" ]]; then
+  mkdir -p _build
+  builddir="${builddir}/_build"
+  NINJA_OPT="-C ${builddir}"
+fi
+
+# Wrapper Makefile for Ninja
+cat > Makefile <<END
+# Generated by configure; do not edit
+
+all:
+       CC="\$(CC)" CXX="\$(CXX)" ${NINJA} ${NINJA_OPT}
+
+install:
+       DESTDIR="\$(DESTDIR)" ${NINJA} ${NINJA_OPT} install
+
+check:
+       ${MESONTEST} ${NINJA_OPT}
+END
+
+echo "Summary:"
+echo "  meson:....... ${MESON}"
+echo "  ninja:....... ${NINJA}"
+echo "  prefix:...... ${prefix}"
+echo "  bindir:...... ${bindir}"
+echo "  sbindir:..... ${sbindir}"
+echo "  libexecdir:.. ${libexecdir}"
+echo "  datarootdir:. ${datarootdir}"
+echo "  datadir:..... ${datadir}"
+echo "  sysconfdir:.. ${sysconfdir}"
+echo "  libdir:...... ${libdir}"
+echo "  mandir:...... ${mandir}"
+echo "  includedir:.. ${includedir}"
+echo "  additional:.."
+echo "    - ${enable_header_bar} ${enable_video}"
+
+exec ${MESON} \
+       --prefix=${prefix} \
+       --libdir=${libdir} \
+       --libexecdir=${libexecdir} \
+       --datadir=${datadir} \
+       --sysconfdir=${sysconfdir} \
+       --bindir=${bindir} \
+       --includedir=${includedir} \
+       --mandir=${mandir} \
+       --default-library shared \
+       ${enable_header_bar} \
+       ${enable_video} \
+       ${builddir} \
+       ${srcdir}
+
+# vim: ai ts=8 noet sts=2 ft=sh
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..2c704fb
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,76 @@
+project('frogr', 'c',
+        version: '1.4',
+        license: 'GPL3')
+
+add_global_arguments ('-Wno-deprecated-declarations', language:'c')
+
+frogr_version = meson.project_version()
+prefix = get_option ('prefix')
+datadir = get_option ('datadir')
+localedir = get_option ('localedir')
+
+gtk_ver = '>= 3.4'
+glib_ver = '>= 2.44'
+soup_ver = '>= 2.34'
+exif_ver = '>= 0.6.14'
+xml2_ver = '>= 2.6.8'
+json_glib_ver = '>= 0.12'
+gcrypt_ver = '>= 1.5.0'
+
+conf = configuration_data()
+conf.set_quoted('VERSION', frogr_version)
+conf.set_quoted ('PACKAGE_VERSION', frogr_version)
+conf.set_quoted ('PACKAGE_NAME', meson.project_name())
+conf.set_quoted ('DATADIR', join_paths (prefix, datadir))
+conf.set_quoted ('LOCALEDIR', join_paths (prefix, localedir))
+
+glib = dependency ('glib-2.0', version: glib_ver)
+soup = dependency('libsoup-2.4', version: soup_ver)
+exif = dependency('libexif', version: exif_ver)
+xml2 = dependency('libxml-2.0', version: xml2_ver)
+json_glib = dependency('json-glib-1.0', version: json_glib_ver)
+
+# gcrypt might not provide a .pc file
+gcrypt = dependency('libgcrypt', version: gcrypt_ver, required: false)
+if gcrypt.found()
+    conf.set('LIBGCRYPT_MIN_VERSION', gcrypt_ver)
+else
+    message('libgcrypt could not be found using pkg-config')
+    # TODO: Use alternative way of checking for gcrypt in case
+    # it's not found, and fail with error() otherwise
+endif
+
+# Optional GtkHeaderBar
+if get_option('enable-header-bar')
+    gtk_3_12 = dependency('gtk+-3.0', version: '>=3.12', required: false)
+    if gtk_3_12.found()
+        gtk = gtk_3_12
+        has_header_bar = true
+    endif
+endif
+
+# Fallback to GTK+ minimum version if not using GtkHeaderBar
+if not get_variable('has_header_bar', false)
+     gtk = dependency('gtk+-3.0', version: gtk_ver)
+endif
+
+conf.set10('USE_HEADER_BAR', get_variable('has_header_bar', false))
+
+# Optional video support
+if get_option('enable-video')
+    gst_1 = dependency('gstreamer-1.0', version: '>=1.0', required: false)
+    if gst_1.found()
+        conf.set('HAVE_GSTREAMER_1_0', 1)
+        gst = gst_1
+    else
+        # Fallback to gstreamer 0.10 if 1.0 is not available
+        gst = dependency('gstreamer-0.10', version: '>=0.10')
+    endif
+
+    has_video = true
+endif
+
+conf.set10('HAVE_GSTREAMER', get_variable('has_video', false))
+
+configure_file(output: 'config.h',
+               configuration: conf)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..4499d54
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+option('enable-header-bar', type: 'boolean', value: true, description: 'Enable GtkHeaderBar')
+option('enable-video', type: 'boolean', value: true, description: 'Enable video uploads')


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