• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3
4prefix=gst
5templatedir=element-templates
6
7while [ "$1" ] ; do
8  case $1 in
9    --help)
10      cat <<-EOF
11Usage: gst-project-maker [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: 'gst-project-maker 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: gst-project-maker [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.
96EOF
97
98cat >$basedir/autogen.sh <<EOF
99#!/bin/sh
100# you can either set the environment variables AUTOCONF, AUTOHEADER, AUTOMAKE,
101# ACLOCAL, AUTOPOINT and/or LIBTOOLIZE to the right versions, or leave them
102# unset and get the defaults
103
104autoreconf --verbose --force --install --make || {
105 echo 'autogen.sh failed';
106 exit 1;
107}
108
109./configure || {
110 echo 'configure failed';
111 exit 1;
112}
113
114echo
115echo "Now type 'make' to compile this module."
116echo
117EOF
118chmod 755 $basedir/autogen.sh
119
120cat >$basedir/configure.ac <<EOF
121dnl required version of autoconf
122AC_PREREQ([2.53])
123
124dnl TODO: fill in your package name and package version here
125AC_INIT([${gst__replace}],[1.0.0])
126
127dnl required versions of gstreamer and plugins-base
128GST_REQUIRED=1.0.0
129GSTPB_REQUIRED=1.0.0
130
131AC_CONFIG_SRCDIR([plugins/${gstreplace}.c])
132AC_CONFIG_HEADERS([config.h])
133
134dnl required version of automake
135AM_INIT_AUTOMAKE([1.10])
136AC_CONFIG_MACRO_DIR([m4])
137
138dnl enable mainainer mode by default
139AM_MAINTAINER_MODE([enable])
140
141dnl check for tools (compiler etc.)
142AC_PROG_CC
143AM_PROG_CC_C_O
144
145dnl required version of libtool
146LT_PREREQ([2.2.6])
147LT_INIT
148
149dnl give error and exit if we don't have pkgconfig
150AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, [ ], [
151  AC_MSG_ERROR([You need to have pkg-config installed!])
152])
153
154dnl Check for the required version of GStreamer core (and gst-plugins-base)
155dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am
156dnl
157dnl If you need libraries from gst-plugins-base here, also add:
158dnl for libgstaudio-1.0: gstreamer-audio-1.0 >= \$GST_REQUIRED
159dnl for libgstvideo-1.0: gstreamer-video-1.0 >= \$GST_REQUIRED
160dnl for libgsttag-1.0: gstreamer-tag-1.0 >= \$GST_REQUIRED
161dnl for libgstpbutils-1.0: gstreamer-pbutils-1.0 >= \$GST_REQUIRED
162dnl for libgstfft-1.0: gstreamer-fft-1.0 >= \$GST_REQUIRED
163dnl for libgstinterfaces-1.0: gstreamer-interfaces-1.0 >= \$GST_REQUIRED
164dnl for libgstrtp-1.0: gstreamer-rtp-1.0 >= \$GST_REQUIRED
165dnl for libgstrtsp-1.0: gstreamer-rtsp-1.0 >= \$GST_REQUIRED
166dnl etc.
167PKG_CHECK_MODULES(GST, [
168  gstreamer-1.0 >= \$GST_REQUIRED
169  gstreamer-base-1.0 >= \$GST_REQUIRED
170  gstreamer-controller-1.0 >= \$GST_REQUIRED
171], [
172  AC_SUBST(GST_CFLAGS)
173  AC_SUBST(GST_LIBS)
174], [
175  AC_MSG_ERROR([
176      You need to install or upgrade the GStreamer development
177      packages on your system. On debian-based systems these are
178      libgstreamer1.0-dev and libgstreamer-plugins-base1.0-dev.
179      on RPM-based systems gstreamer1.0-devel, libgstreamer1.0-devel
180      or similar. The minimum version required is \$GST_REQUIRED.
181  ])
182])
183
184dnl check if compiler understands -Wall (if yes, add -Wall to GST_CFLAGS)
185AC_MSG_CHECKING([to see if compiler understands -Wall])
186save_CFLAGS="\$CFLAGS"
187CFLAGS="\$CFLAGS -Wall"
188AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ], [ ])], [
189  GST_CFLAGS="\$GST_CFLAGS -Wall"
190  AC_MSG_RESULT([yes])
191], [
192  AC_MSG_RESULT([no])
193])
194
195dnl set the plugindir where plugins should be installed (for plugins/Makefile.am)
196if test "x\${prefix}" = "x\$HOME"; then
197  plugindir="\$HOME/.gstreamer-1.0/plugins"
198else
199  plugindir="\\\$(libdir)/gstreamer-1.0"
200fi
201AC_SUBST(plugindir)
202
203dnl set proper LDFLAGS for plugins
204GST_PLUGIN_LDFLAGS='-module -avoid-version -export-symbols-regex [_]*\(gst_\|Gst\|GST_\).*'
205AC_SUBST(GST_PLUGIN_LDFLAGS)
206
207AC_CONFIG_FILES([Makefile plugins/Makefile tools/Makefile])
208AC_OUTPUT
209EOF
210
211cat >$basedir/Makefile.am <<EOF
212SUBDIRS = plugins tools
213
214EXTRA_DIST = autogen.sh
215
216ACLOCAL_AMFLAGS = -I m4
217EOF
218
219mkdir -p $basedir/m4
220
221mkdir -p $basedir/plugins
222
223cat >$basedir/plugins/Makefile.am <<EOF
224plugin_LTLIBRARIES = lib$gstreplace.la
225
226# sources used to compile this plug-in
227lib${gstreplace}_la_SOURCES = ${gstreplace}plugin.c ${gstreplace}.c ${gstreplace}.h
228
229# compiler and linker flags used to compile this plugin, set in configure.ac
230lib${gstreplace}_la_CFLAGS = \$(GST_CFLAGS)
231lib${gstreplace}_la_LIBADD = \$(GST_LIBS)
232lib${gstreplace}_la_LDFLAGS = \$(GST_PLUGIN_LDFLAGS)
233
234EOF
235
236
237generate()
238{
239cat <<EOF
240/*
241 * GStreamer
242 * Copyright (C) $(date +%Y) $REAL_NAME <$EMAIL_ADDRESS>
243 * 
244 * Permission is hereby granted, free of charge, to any person obtaining a
245 * copy of this software and associated documentation files (the "Software"),
246 * to deal in the Software without restriction, including without limitation
247 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
248 * and/or sell copies of the Software, and to permit persons to whom the
249 * Software is furnished to do so, subject to the following conditions:
250 *
251 * The above copyright notice and this permission notice shall be included in
252 * all copies or substantial portions of the Software.
253 *
254 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
255 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
256 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
257 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
258 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
259 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
260 * DEALINGS IN THE SOFTWARE.
261 *
262 * Alternatively, the contents of this file may be used under the
263 * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
264 * which case the following provisions apply instead of the ones
265 * mentioned above:
266 *
267 * This library is free software; you can redistribute it and/or
268 * modify it under the terms of the GNU Library General Public
269 * License as published by the Free Software Foundation; either
270 * version 2 of the License, or (at your option) any later version.
271 *
272 * This library is distributed in the hope that it will be useful,
273 * but WITHOUT ANY WARRANTY; without even the implied warranty of
274 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
275 * Library General Public License for more details.
276 *
277 * You should have received a copy of the GNU Library General Public
278 * License along with this library; if not, write to the
279 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
280 * Boston, MA 02110-1301, USA.
281 */
282
283#ifdef HAVE_CONFIG_H
284#include <config.h>
285#endif
286
287#include <gst/gst.h>
288#include "gstreplace.h"
289
290static gboolean
291plugin_init (GstPlugin * plugin)
292{
293  gst_element_register (plugin, "replace", GST_RANK_NONE,
294      GST_TYPE_REPLACE);
295
296  return TRUE;
297}
298
299GST_PLUGIN_DEFINE (
300    GST_VERSION_MAJOR,
301    GST_VERSION_MINOR,
302    replace,
303    "FIXME Template plugin",
304    plugin_init,
305    VERSION,
306    "LGPL", /* FIXME */
307    "GStreamer",
308    "http://gstreamer.net/"
309)
310EOF
311}
312
313
314generate | sed \
315  -e "s/GST_BASE_REPLACE/$GST_BASE_REPLACE/g" \
316  -e "s/GST_TYPE_BASE_REPLACE/$GST_TYPE_BASE_REPLACE/g" \
317  -e "s/GstBaseReplace/$GstBaseReplace/g" \
318  -e "s/GST_IS_REPLACE/$GST_IS_REPLACE/g" \
319  -e "s/GST_REPLACE/$GST_REPLACE/g" \
320  -e "s/GST_TYPE_REPLACE/$GST_TYPE_REPLACE/g" \
321  -e "s/GstReplace/$GstReplace/g" \
322  -e "s/gst_replace/$gst_replace/g" \
323  -e "s/gstreplace/$gstreplace/g" \
324  -e "s/replace/$replace/g" >$basedir/plugins/${gstreplace}plugin.c
325
326gst-indent $basedir/plugins/${gstreplace}plugin.c
327rm -f $basedir/plugins/${gstreplace}plugin.c~
328
329cat >$basedir/plugins/${gstreplace}.c <<EOF
330/* This file should be replaced by element source generated by
331 * gst-element-maker, or by your own source code.  To generate suitable
332 * element source using gst-element-maker, run:
333 *
334 *   gst-element-maker $cmdline_prefix $replace BASE_CLASS
335 *
336 * Where BASE_CLASS is replaced by one of the base class templates,
337 * such as basesrc, basetransform, audiofilter, videofilter2, etc.
338 * Then copy the resulting $gstreplace.c file over this file, and
339 * $gstreplace.h over $gstreplace.h.
340 */
341/* The rest of this file is shim code to allow the project to compile */
342EOF
343
344cat >$basedir/plugins/${gstreplace}.h <<EOF
345/* This file should be replaced by element header generated by
346 * gst-element-maker, or by your own source code.  To generate suitable
347 * element header using gst-element-maker, run:
348 *
349 *   gst-element-maker $cmdline_prefix $replace BASE_CLASS
350 *
351 * Where BASE_CLASS is replaced by one of the base class templates,
352 * such as basesrc, basetransform, audiofilter, videofilter2, etc.
353 * Then copy the resulting $gstreplace.h file over this file, and
354 * $gstreplace.c over $gstreplace.c.
355 */
356/* The rest of this file is shim code to allow the project to compile */
357#define ${GST_TYPE_REPLACE} G_TYPE_NONE
358EOF
359
360
361mkdir -p $basedir/tools
362
363cat >$basedir/tools/Makefile.am <<EOF
364bin_PROGRAMS = ${gst__replace}
365
366# sources used to compile this plug-in
367${gst_replace}_SOURCES = ${gstreplace}.c
368
369# compiler and linker flags used to compile the program, set in configure.ac
370${gst_replace}_CFLAGS = \$(GST_CFLAGS)
371${gst_replace}_LDADD = \$(GST_LIBS)
372
373EOF
374
375cat >$basedir/tools/${gstreplace}.c <<EOF
376/* This file should be replaced by application source generated by
377 * gst-app-maker, or by your own source code.  To generate suitable
378 * app source using gst-app-maker, run:
379 *
380 *   gst-app-maker $cmdline_prefix $replace
381 *
382 * Then copy the resulting $gstreplace.c file over this file.
383 */
384/* The rest of this file is shim code to allow the project to compile */
385#include <stdio.h>
386int main (void) { printf ("FIXME\n"); return 0; }
387EOF
388
389
390