gst-project-maker: set up a meson project instead of an autotools one

Now that autotools has been removed generate a meson project template in
gst-project-maker.

There are some differences with the autotools project

  1. gstreamer-controller-1.0 is not added to the default dependencies.
  2. The '-Wall' option is not set explicitly, meson can handle that.
  3. The flags in GST_PLUGIN_LDFLAGS have not been ported to meson as
     they are not necessary anymore.

The generated project requires meson 0.53.0 for the 'fs' module. It's up
to the user to remove that part in case compatibility with older
versions of meson is desired.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/184>
This commit is contained in:
Antonio Ospite 2020-01-17 17:49:47 +01:00 committed by GStreamer Merge Bot
parent 6ac6831ae7
commit 7f1d3e252f

View file

@ -93,144 +93,107 @@ EOF
cat >$basedir/README <<EOF cat >$basedir/README <<EOF
README for your project. README for your project.
NOTE:
plugins can be installed locally by using "\$HOME" as prefix:
$ meson --prefix="\$HOME" build/
$ ninja -C build/ install
However be advised that the automatic scan of plugins in the user home
directory won't work under gst-build devenv.
EOF EOF
cat >$basedir/autogen.sh <<EOF cat >$basedir/meson.build <<EOF
#!/bin/sh project('${gst__replace}', 'c',
# you can either set the environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, version : '0.1.0',
# ACLOCAL, AUTOPOINT and/or LIBTOOLIZE to the right versions, or leave them default_options : [ 'warning_level=1',
# unset and get the defaults 'buildtype=debugoptimized' ])
autoreconf --verbose --force --install --make || { core_conf = configuration_data()
echo 'autogen.sh failed'; core_conf.set('PACKAGE', '"@0@"'.format(meson.project_name()))
exit 1; core_conf.set('VERSION', '"@0@"'.format(meson.project_version()))
}
./configure || { configure_file(output : 'config.h', configuration : core_conf)
echo 'configure failed';
exit 1;
}
echo configinc = include_directories('.')
echo "Now type 'make' to compile this module."
echo
EOF
chmod 755 $basedir/autogen.sh
cat >$basedir/configure.ac <<EOF common_args = ['-DHAVE_CONFIG_H']
dnl required version of autoconf
AC_PREREQ([2.53])
dnl TODO: fill in your package name and package version here gst_req = '>= 1.0.0'
AC_INIT([${gst__replace}],[1.0.0])
dnl required versions of gstreamer and plugins-base # Check for the required version of GStreamer core (and gst-plugins-base)
GST_REQUIRED=1.0.0 #
GSTPB_REQUIRED=1.0.0 # If you need libraries from gst-plugins-base here, also add:
# for libgstaudio-1.0: gstreamer-audio-1.0
# for libgstvideo-1.0: gstreamer-video-1.0
# for libgsttag-1.0: gstreamer-tag-1.0
# for libgstpbutils-1.0: gstreamer-pbutils-1.0
# for libgstfft-1.0: gstreamer-fft-1.0
# for libgstinterfaces-1.0: gstreamer-interfaces-1.0
# for libgstrtp-1.0: gstreamer-rtp-1.0
# for libgstrtsp-1.0: gstreamer-rtsp-1.0
# etc.
gst_dep = dependency('gstreamer-1.0', version : gst_req,
fallback : ['gstreamer', 'gst_dep'])
gst_base_dep = dependency('gstreamer-base-1.0', version : gst_req,
fallback : ['gstreamer', 'gst_base_dep'])
AC_CONFIG_SRCDIR([plugins/${gstreplace}.c]) # Set the directory where plugins should be installed.
AC_CONFIG_HEADERS([config.h]) #
# If the prefix is the user home directory, adjust the plugin installation
dnl required version of automake # path so that GStreamer can find it. Requires meson >= 0.53.0
AM_INIT_AUTOMAKE([1.10]) fs = import('fs')
AC_CONFIG_MACRO_DIR([m4]) if fs.is_samepath(get_option('prefix'), '~')
plugins_install_dir = '@0@/.local/share/gstreamer-1.0/plugins'.format(get_option('prefix'))
dnl enable mainainer mode by default
AM_MAINTAINER_MODE([enable])
dnl check for tools (compiler etc.)
AC_PROG_CC
AM_PROG_CC_C_O
dnl required version of libtool
LT_PREREQ([2.2.6])
LT_INIT
dnl give error and exit if we don't have pkgconfig
AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, [ ], [
AC_MSG_ERROR([You need to have pkg-config installed!])
])
dnl Check for the required version of GStreamer core (and gst-plugins-base)
dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am
dnl
dnl If you need libraries from gst-plugins-base here, also add:
dnl for libgstaudio-1.0: gstreamer-audio-1.0 >= \$GST_REQUIRED
dnl for libgstvideo-1.0: gstreamer-video-1.0 >= \$GST_REQUIRED
dnl for libgsttag-1.0: gstreamer-tag-1.0 >= \$GST_REQUIRED
dnl for libgstpbutils-1.0: gstreamer-pbutils-1.0 >= \$GST_REQUIRED
dnl for libgstfft-1.0: gstreamer-fft-1.0 >= \$GST_REQUIRED
dnl for libgstinterfaces-1.0: gstreamer-interfaces-1.0 >= \$GST_REQUIRED
dnl for libgstrtp-1.0: gstreamer-rtp-1.0 >= \$GST_REQUIRED
dnl for libgstrtsp-1.0: gstreamer-rtsp-1.0 >= \$GST_REQUIRED
dnl etc.
PKG_CHECK_MODULES(GST, [
gstreamer-1.0 >= \$GST_REQUIRED
gstreamer-base-1.0 >= \$GST_REQUIRED
gstreamer-controller-1.0 >= \$GST_REQUIRED
], [
AC_SUBST(GST_CFLAGS)
AC_SUBST(GST_LIBS)
], [
AC_MSG_ERROR([
You need to install or upgrade the GStreamer development
packages on your system. On debian-based systems these are
libgstreamer1.0-dev and libgstreamer-plugins-base1.0-dev.
on RPM-based systems gstreamer1.0-devel, libgstreamer1.0-devel
or similar. The minimum version required is \$GST_REQUIRED.
])
])
dnl check if compiler understands -Wall (if yes, add -Wall to GST_CFLAGS)
AC_MSG_CHECKING([to see if compiler understands -Wall])
save_CFLAGS="\$CFLAGS"
CFLAGS="\$CFLAGS -Wall"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ], [ ])], [
GST_CFLAGS="\$GST_CFLAGS -Wall"
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
])
dnl set the plugindir where plugins should be installed (for plugins/Makefile.am)
if test "x\${prefix}" = "x\$HOME"; then
plugindir="\$HOME/.gstreamer-1.0/plugins"
else else
plugindir="\\\$(libdir)/gstreamer-1.0" plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
fi endif
AC_SUBST(plugindir)
dnl set proper LDFLAGS for plugins plugin_deps = [gst_dep, gst_base_dep]
GST_PLUGIN_LDFLAGS='-module -avoid-version -export-symbols-regex [_]*\(gst_\|Gst\|GST_\).*' tool_deps = [gst_dep]
AC_SUBST(GST_PLUGIN_LDFLAGS)
AC_CONFIG_FILES([Makefile plugins/Makefile tools/Makefile]) subdir('plugins')
AC_OUTPUT subdir('tools')
EOF EOF
cat >$basedir/Makefile.am <<EOF
SUBDIRS = plugins tools
EXTRA_DIST = autogen.sh
ACLOCAL_AMFLAGS = -I m4
EOF
mkdir -p $basedir/m4
mkdir -p $basedir/plugins mkdir -p $basedir/plugins
cat >$basedir/plugins/Makefile.am <<EOF cat >$basedir/plugins/meson.build <<EOF
plugin_LTLIBRARIES = lib$gstreplace.la lib_args = common_args + []
# sources used to compile this plug-in # sources used to compile this plug-in
lib${gstreplace}_la_SOURCES = ${gstreplace}plugin.c ${gstreplace}.c ${gstreplace}.h plugin_sources = [
'${gstreplace}plugin.c',
'${gstreplace}.c',
'${gstreplace}.h'
]
# compiler and linker flags used to compile this plugin, set in configure.ac shlib = shared_library('${gstreplace}',
lib${gstreplace}_la_CFLAGS = \$(GST_CFLAGS) plugin_sources,
lib${gstreplace}_la_LIBADD = \$(GST_LIBS) c_args : lib_args,
lib${gstreplace}_la_LDFLAGS = \$(GST_PLUGIN_LDFLAGS) include_directories: [configinc],
dependencies : plugin_deps,
gnu_symbol_visibility : 'hidden',
install : true,
install_dir : plugins_install_dir,
)
# Make this library usable as a Meson subproject.
gst_${replace}_dep = declare_dependency(
include_directories: include_directories('.'),
link_with : shlib)
pkg_mod = import('pkgconfig')
pkg_mod.generate(
name : '${gst__replace}',
filebase : '${gst__replace}',
description : 'Meson sample project.',
subdirs : 'src',
libraries : shlib,
version : '"@0@"'.format(meson.project_version()),
)
EOF EOF
@ -323,7 +286,7 @@ generate | sed \
-e "s/gstreplace/$gstreplace/g" \ -e "s/gstreplace/$gstreplace/g" \
-e "s/replace/$replace/g" >$basedir/plugins/${gstreplace}plugin.c -e "s/replace/$replace/g" >$basedir/plugins/${gstreplace}plugin.c
gst-indent $basedir/plugins/${gstreplace}plugin.c gst-indent $basedir/plugins/${gstreplace}plugin.c || echo "Warning: could not run gst-indent on the generated code." 1>&2
rm -f $basedir/plugins/${gstreplace}plugin.c~ rm -f $basedir/plugins/${gstreplace}plugin.c~
cat >$basedir/plugins/${gstreplace}.c <<EOF cat >$basedir/plugins/${gstreplace}.c <<EOF
@ -360,16 +323,21 @@ EOF
mkdir -p $basedir/tools mkdir -p $basedir/tools
cat >$basedir/tools/Makefile.am <<EOF cat >$basedir/tools/meson.build <<EOF
bin_PROGRAMS = ${gst__replace} exe_args = common_args + []
# sources used to compile this program # sources used to compile this program
${gst_replace}_SOURCES = ${gstreplace}.c tool_sources = [
'${gstreplace}.c',
# compiler and linker flags used to compile the program, set in configure.ac ]
${gst_replace}_CFLAGS = \$(GST_CFLAGS)
${gst_replace}_LDADD = \$(GST_LIBS)
executable('${gstreplace}',
tool_sources,
install: true,
c_args : exe_args,
include_directories: [configinc],
dependencies : tool_deps,
)
EOF EOF
cat >$basedir/tools/${gstreplace}.c <<EOF cat >$basedir/tools/${gstreplace}.c <<EOF
@ -385,5 +353,3 @@ cat >$basedir/tools/${gstreplace}.c <<EOF
#include <stdio.h> #include <stdio.h>
int main (void) { printf ("FIXME\n"); return 0; } int main (void) { printf ("FIXME\n"); return 0; }
EOF EOF