1#!/bin/sh 2 3 4prefix=gst 5templatedir=element-templates 6 7while [ "$1" ] ; do 8 case $1 in 9 --help) 10 cat <<-EOF 11Usage: $(basename "$0") [OPTIONS] PROJECT_NAME 12Create an autotools project based on GStreamer from a template. 13Options: 14 --help Print this information 15 --prefix PREFIX Use PREFIX instead of "gst" 16Example: '$(basename "$0") my_project' will create the project gst-my-project. 17EOF 18 exit 0 19 ;; 20 --prefix) 21 shift 22 prefix=$1 23 ;; 24 -*) 25 echo Unknown option: $1 26 exit 1 27 ;; 28 *) 29 if [ "$name" = "" ]; then 30 name=$1 31 else 32 echo Ignored: $1 33 fi 34 esac 35 shift 36done 37 38if [ "$name" = "" ] ; then 39 echo "Usage: $(basename "$0") [OPTIONS] PROJECT_NAME" 40 exit 1 41fi 42 43 44PREFIX=$(echo $prefix | sed -e 's/\(.*\)/\U\1/') 45NAME=$(echo $name | sed -e 's/\(.*\)/\U\1/') 46Prefix=$(echo $prefix | sed -e 's/_\(.\)/\U\1/g' -e 's/^\(.\)/\U\1/') 47Name=$(echo $name | sed -e 's/_\(.\)/\U\1/g' -e 's/^\(.\)/\U\1/') 48 49if [ "$prefix" != "gst" ] ; then 50 cmdline_prefix="--prefix $prefix" 51else 52 cmdline_prefix="" 53fi 54 55GST_IS_REPLACE=${PREFIX}_IS_${NAME} 56GST_REPLACE=${PREFIX}_${NAME} 57GST_TYPE_REPLACE=${PREFIX}_TYPE_${NAME} 58GstReplace=${Prefix}${Name} 59gst_replace=${prefix}_${name} 60gst__replace=${prefix}-${name} 61gstreplace=${prefix}$(echo $name | sed -e 's/_//g') 62replace=$(echo $name | sed -e 's/_//g') 63 64if [ "$REAL_NAME" = "" ] ; then 65 REAL_NAME=FIXME 66fi 67if [ "$EMAIL_ADDRESS" = "" ] ; then 68 EMAIL_ADDRESS=fixme@example.com 69fi 70 71 72 73basedir=`pwd`/$gst__replace 74 75rm -rf $basedir 76mkdir $basedir 77 78cat >$basedir/AUTHORS <<EOF 79$REAL_NAME <$EMAIL_ADDRESS> 80EOF 81 82cat >$basedir/COPYING <<EOF 83Put your license here. 84EOF 85 86cat >$basedir/ChangeLog <<EOF 87Put your changelog here. 88EOF 89 90cat >$basedir/NEWS <<EOF 91News about your project. 92EOF 93 94cat >$basedir/README <<EOF 95README for your project. 96 97NOTE: 98plugins can be installed locally by using "\$HOME" as prefix: 99 100 $ meson --prefix="\$HOME" build/ 101 $ ninja -C build/ install 102 103However be advised that the automatic scan of plugins in the user home 104directory won't work under gst-build devenv. 105EOF 106 107cat >$basedir/meson.build <<EOF 108project('${gst__replace}', 'c', 109 version : '0.1.0', 110 default_options : [ 'warning_level=1', 111 'buildtype=debugoptimized' ]) 112 113core_conf = configuration_data() 114core_conf.set('PACKAGE', '"@0@"'.format(meson.project_name())) 115core_conf.set('VERSION', '"@0@"'.format(meson.project_version())) 116 117configure_file(output : 'config.h', configuration : core_conf) 118 119configinc = include_directories('.') 120 121common_args = ['-DHAVE_CONFIG_H'] 122 123gst_req = '>= 1.0.0' 124 125# Check for the required version of GStreamer core (and gst-plugins-base) 126# 127# If you need libraries from gst-plugins-base here, also add: 128# for libgstaudio-1.0: gstreamer-audio-1.0 129# for libgstvideo-1.0: gstreamer-video-1.0 130# for libgsttag-1.0: gstreamer-tag-1.0 131# for libgstpbutils-1.0: gstreamer-pbutils-1.0 132# for libgstfft-1.0: gstreamer-fft-1.0 133# for libgstinterfaces-1.0: gstreamer-interfaces-1.0 134# for libgstrtp-1.0: gstreamer-rtp-1.0 135# for libgstrtsp-1.0: gstreamer-rtsp-1.0 136# etc. 137gst_dep = dependency('gstreamer-1.0', version : gst_req, 138 fallback : ['gstreamer', 'gst_dep']) 139gst_base_dep = dependency('gstreamer-base-1.0', version : gst_req, 140 fallback : ['gstreamer', 'gst_base_dep']) 141 142# Set the directory where plugins should be installed. 143# 144# If the prefix is the user home directory, adjust the plugin installation 145# path so that GStreamer can find it. Requires meson >= 0.53.0 146fs = import('fs') 147if fs.is_samepath(get_option('prefix'), '~') 148 plugins_install_dir = '@0@/.local/share/gstreamer-1.0/plugins'.format(get_option('prefix')) 149else 150 plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir')) 151endif 152 153plugin_deps = [gst_dep, gst_base_dep] 154tool_deps = [gst_dep] 155 156subdir('plugins') 157subdir('tools') 158EOF 159 160 161mkdir -p $basedir/plugins 162 163cat >$basedir/plugins/meson.build <<EOF 164lib_args = common_args + [] 165 166# sources used to compile this plug-in 167plugin_sources = [ 168 '${gstreplace}plugin.c', 169 '${gstreplace}.c', 170 '${gstreplace}.h' 171] 172 173shlib = shared_library('${gstreplace}', 174 plugin_sources, 175 c_args : lib_args, 176 include_directories: [configinc], 177 dependencies : plugin_deps, 178 gnu_symbol_visibility : 'hidden', 179 install : true, 180 install_dir : plugins_install_dir, 181) 182 183# Make this library usable as a Meson subproject. 184gst_${replace}_dep = declare_dependency( 185 include_directories: include_directories('.'), 186 link_with : shlib) 187 188pkg_mod = import('pkgconfig') 189pkg_mod.generate( 190 name : '${gst__replace}', 191 filebase : '${gst__replace}', 192 description : 'Meson sample project.', 193 subdirs : 'src', 194 libraries : shlib, 195 version : '"@0@"'.format(meson.project_version()), 196) 197EOF 198 199 200generate() 201{ 202cat <<EOF 203/* 204 * GStreamer 205 * Copyright (C) $(date +%Y) $REAL_NAME <$EMAIL_ADDRESS> 206 * 207 * Permission is hereby granted, free of charge, to any person obtaining a 208 * copy of this software and associated documentation files (the "Software"), 209 * to deal in the Software without restriction, including without limitation 210 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 211 * and/or sell copies of the Software, and to permit persons to whom the 212 * Software is furnished to do so, subject to the following conditions: 213 * 214 * The above copyright notice and this permission notice shall be included in 215 * all copies or substantial portions of the Software. 216 * 217 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 218 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 219 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 220 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 221 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 222 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 223 * DEALINGS IN THE SOFTWARE. 224 * 225 * Alternatively, the contents of this file may be used under the 226 * GNU Lesser General Public License Version 2.1 (the "LGPL"), in 227 * which case the following provisions apply instead of the ones 228 * mentioned above: 229 * 230 * This library is free software; you can redistribute it and/or 231 * modify it under the terms of the GNU Library General Public 232 * License as published by the Free Software Foundation; either 233 * version 2 of the License, or (at your option) any later version. 234 * 235 * This library is distributed in the hope that it will be useful, 236 * but WITHOUT ANY WARRANTY; without even the implied warranty of 237 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 238 * Library General Public License for more details. 239 * 240 * You should have received a copy of the GNU Library General Public 241 * License along with this library; if not, write to the 242 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 243 * Boston, MA 02110-1301, USA. 244 */ 245 246#ifdef HAVE_CONFIG_H 247#include <config.h> 248#endif 249 250#include <gst/gst.h> 251#include "gstreplace.h" 252 253static gboolean 254plugin_init (GstPlugin * plugin) 255{ 256 gst_element_register (plugin, "replace", GST_RANK_NONE, 257 GST_TYPE_REPLACE); 258 259 return TRUE; 260} 261 262GST_PLUGIN_DEFINE ( 263 GST_VERSION_MAJOR, 264 GST_VERSION_MINOR, 265 replace, 266 "FIXME Template plugin", 267 plugin_init, 268 VERSION, 269 "LGPL", /* FIXME */ 270 "GStreamer", 271 "http://gstreamer.net/" 272) 273EOF 274} 275 276 277generate | sed \ 278 -e "s/GST_BASE_REPLACE/$GST_BASE_REPLACE/g" \ 279 -e "s/GST_TYPE_BASE_REPLACE/$GST_TYPE_BASE_REPLACE/g" \ 280 -e "s/GstBaseReplace/$GstBaseReplace/g" \ 281 -e "s/GST_IS_REPLACE/$GST_IS_REPLACE/g" \ 282 -e "s/GST_REPLACE/$GST_REPLACE/g" \ 283 -e "s/GST_TYPE_REPLACE/$GST_TYPE_REPLACE/g" \ 284 -e "s/GstReplace/$GstReplace/g" \ 285 -e "s/gst_replace/$gst_replace/g" \ 286 -e "s/gstreplace/$gstreplace/g" \ 287 -e "s/replace/$replace/g" >$basedir/plugins/${gstreplace}plugin.c 288 289gst-indent $basedir/plugins/${gstreplace}plugin.c || echo "Warning: could not run gst-indent on the generated code." 1>&2 290rm -f $basedir/plugins/${gstreplace}plugin.c~ 291 292cat >$basedir/plugins/${gstreplace}.c <<EOF 293/* This file should be replaced by element source generated by 294 * gst-element-maker, or by your own source code. To generate suitable 295 * element source using gst-element-maker, run: 296 * 297 * gst-element-maker $cmdline_prefix $replace BASE_CLASS 298 * 299 * Where BASE_CLASS is replaced by one of the base class templates, 300 * such as basesrc, basetransform, audiofilter, videofilter2, etc. 301 * Then copy the resulting $gstreplace.c file over this file, and 302 * $gstreplace.h over $gstreplace.h. 303 */ 304/* The rest of this file is shim code to allow the project to compile */ 305EOF 306 307cat >$basedir/plugins/${gstreplace}.h <<EOF 308/* This file should be replaced by element header generated by 309 * gst-element-maker, or by your own source code. To generate suitable 310 * element header using gst-element-maker, run: 311 * 312 * gst-element-maker $cmdline_prefix $replace BASE_CLASS 313 * 314 * Where BASE_CLASS is replaced by one of the base class templates, 315 * such as basesrc, basetransform, audiofilter, videofilter2, etc. 316 * Then copy the resulting $gstreplace.h file over this file, and 317 * $gstreplace.c over $gstreplace.c. 318 */ 319/* The rest of this file is shim code to allow the project to compile */ 320#define ${GST_TYPE_REPLACE} G_TYPE_NONE 321EOF 322 323 324mkdir -p $basedir/tools 325 326cat >$basedir/tools/meson.build <<EOF 327exe_args = common_args + [] 328 329# sources used to compile this program 330tool_sources = [ 331 '${gstreplace}.c', 332] 333 334executable('${gstreplace}', 335 tool_sources, 336 install: true, 337 c_args : exe_args, 338 include_directories: [configinc], 339 dependencies : tool_deps, 340) 341EOF 342 343cat >$basedir/tools/${gstreplace}.c <<EOF 344/* This file should be replaced by application source generated by 345 * gst-app-maker, or by your own source code. To generate suitable 346 * app source using gst-app-maker, run: 347 * 348 * gst-app-maker $cmdline_prefix $replace 349 * 350 * Then copy the resulting $gstreplace.c file over this file. 351 */ 352/* The rest of this file is shim code to allow the project to compile */ 353#include <stdio.h> 354int main (void) { printf ("FIXME\n"); return 0; } 355EOF 356