m3u8: remove unreachable code
[platform/upstream/gstreamer.git] / tools / gst-project-maker
1 #!/bin/sh
2
3
4 prefix=gst
5 templatedir=element-templates
6
7 while [ "$1" ] ; do
8   case $1 in
9     --help)
10       cat <<-EOF
11 Usage: gst-project-maker [OPTIONS] PROJECT_NAME
12 Create an autotools project based on GStreamer from a template.
13 Options:
14   --help             Print this information
15   --prefix PREFIX    Use PREFIX instead of "gst"
16 Example: 'gst-project-maker my_project' will create the project gst-my-project.
17 EOF
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
36 done
37
38 if [ "$name" = "" ] ; then
39   echo "Usage: gst-project-maker [OPTIONS] PROJECT_NAME"
40   exit 1
41 fi
42
43
44 PREFIX=$(echo $prefix | sed -e 's/\(.*\)/\U\1/')
45 NAME=$(echo $name | sed -e 's/\(.*\)/\U\1/')
46 Prefix=$(echo $prefix | sed -e 's/_\(.\)/\U\1/g' -e 's/^\(.\)/\U\1/')
47 Name=$(echo $name | sed -e 's/_\(.\)/\U\1/g' -e 's/^\(.\)/\U\1/')
48
49 if [ "$prefix" != "gst" ] ; then
50   cmdline_prefix="--prefix $prefix"
51 else
52   cmdline_prefix=""
53 fi
54
55 GST_IS_REPLACE=${PREFIX}_IS_${NAME}
56 GST_REPLACE=${PREFIX}_${NAME}
57 GST_TYPE_REPLACE=${PREFIX}_TYPE_${NAME}
58 GstReplace=${Prefix}${Name}
59 gst_replace=${prefix}_${name}
60 gst__replace=${prefix}-${name}
61 gstreplace=${prefix}$(echo $name | sed -e 's/_//g')
62 replace=$(echo $name | sed -e 's/_//g')
63
64 if [ "$REAL_NAME" = "" ] ; then
65   REAL_NAME=FIXME
66 fi
67 if [ "$EMAIL_ADDRESS" = "" ] ; then
68   EMAIL_ADDRESS=fixme@example.com
69 fi
70
71
72
73 basedir=`pwd`/$gst__replace
74
75 rm -rf $basedir
76 mkdir $basedir
77
78 cat >$basedir/AUTHORS <<EOF
79 $REAL_NAME <$EMAIL_ADDRESS>
80 EOF
81
82 cat >$basedir/COPYING <<EOF
83 Put your license here.
84 EOF
85
86 cat >$basedir/ChangeLog <<EOF
87 Put your changelog here.
88 EOF
89
90 cat >$basedir/NEWS <<EOF
91 News about your project.
92 EOF
93
94 cat >$basedir/README <<EOF
95 README for your project.
96 EOF
97
98 cat >$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
104 autoreconf --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
114 echo
115 echo "Now type 'make' to compile this module."
116 echo
117 EOF
118 chmod 755 $basedir/autogen.sh
119
120 cat >$basedir/configure.ac <<EOF
121 dnl required version of autoconf
122 AC_PREREQ([2.53])
123
124 dnl TODO: fill in your package name and package version here
125 AC_INIT([${gst__replace}],[1.0.0])
126
127 dnl required versions of gstreamer and plugins-base
128 GST_REQUIRED=1.0.0
129 GSTPB_REQUIRED=1.0.0
130
131 AC_CONFIG_SRCDIR([plugins/${gstreplace}.c])
132 AC_CONFIG_HEADERS([config.h])
133
134 dnl required version of automake
135 AM_INIT_AUTOMAKE([1.10])
136 AC_CONFIG_MACRO_DIR([m4])
137
138 dnl enable mainainer mode by default
139 AM_MAINTAINER_MODE([enable])
140
141 dnl check for tools (compiler etc.)
142 AC_PROG_CC
143 AM_PROG_CC_C_O
144
145 dnl required version of libtool
146 LT_PREREQ([2.2.6])
147 LT_INIT
148
149 dnl give error and exit if we don't have pkgconfig
150 AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, [ ], [
151   AC_MSG_ERROR([You need to have pkg-config installed!])
152 ])
153
154 dnl Check for the required version of GStreamer core (and gst-plugins-base)
155 dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am
156 dnl
157 dnl If you need libraries from gst-plugins-base here, also add:
158 dnl for libgstaudio-1.0: gstreamer-audio-1.0 >= \$GST_REQUIRED
159 dnl for libgstvideo-1.0: gstreamer-video-1.0 >= \$GST_REQUIRED
160 dnl for libgsttag-1.0: gstreamer-tag-1.0 >= \$GST_REQUIRED
161 dnl for libgstpbutils-1.0: gstreamer-pbutils-1.0 >= \$GST_REQUIRED
162 dnl for libgstfft-1.0: gstreamer-fft-1.0 >= \$GST_REQUIRED
163 dnl for libgstinterfaces-1.0: gstreamer-interfaces-1.0 >= \$GST_REQUIRED
164 dnl for libgstrtp-1.0: gstreamer-rtp-1.0 >= \$GST_REQUIRED
165 dnl for libgstrtsp-1.0: gstreamer-rtsp-1.0 >= \$GST_REQUIRED
166 dnl etc.
167 PKG_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
184 dnl check if compiler understands -Wall (if yes, add -Wall to GST_CFLAGS)
185 AC_MSG_CHECKING([to see if compiler understands -Wall])
186 save_CFLAGS="\$CFLAGS"
187 CFLAGS="\$CFLAGS -Wall"
188 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ], [ ])], [
189   GST_CFLAGS="\$GST_CFLAGS -Wall"
190   AC_MSG_RESULT([yes])
191 ], [
192   AC_MSG_RESULT([no])
193 ])
194
195 dnl set the plugindir where plugins should be installed (for plugins/Makefile.am)
196 if test "x\${prefix}" = "x\$HOME"; then
197   plugindir="\$HOME/.gstreamer-1.0/plugins"
198 else
199   plugindir="\\\$(libdir)/gstreamer-1.0"
200 fi
201 AC_SUBST(plugindir)
202
203 dnl set proper LDFLAGS for plugins
204 GST_PLUGIN_LDFLAGS='-module -avoid-version -export-symbols-regex [_]*\(gst_\|Gst\|GST_\).*'
205 AC_SUBST(GST_PLUGIN_LDFLAGS)
206
207 AC_CONFIG_FILES([Makefile plugins/Makefile tools/Makefile])
208 AC_OUTPUT
209 EOF
210
211 cat >$basedir/Makefile.am <<EOF
212 SUBDIRS = plugins tools
213
214 EXTRA_DIST = autogen.sh
215
216 ACLOCAL_AMFLAGS = -I m4
217 EOF
218
219 mkdir -p $basedir/m4
220
221 mkdir -p $basedir/plugins
222
223 cat >$basedir/plugins/Makefile.am <<EOF
224 plugin_LTLIBRARIES = lib$gstreplace.la
225
226 # sources used to compile this plug-in
227 lib${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
230 lib${gstreplace}_la_CFLAGS = \$(GST_CFLAGS)
231 lib${gstreplace}_la_LIBADD = \$(GST_LIBS)
232 lib${gstreplace}_la_LDFLAGS = \$(GST_PLUGIN_LDFLAGS)
233
234 EOF
235
236
237 generate()
238 {
239 cat <<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
290 static gboolean
291 plugin_init (GstPlugin * plugin)
292 {
293   gst_element_register (plugin, "replace", GST_RANK_NONE,
294       GST_TYPE_REPLACE);
295
296   return TRUE;
297 }
298
299 GST_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 )
310 EOF
311 }
312
313
314 generate | 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
326 gst-indent $basedir/plugins/${gstreplace}plugin.c
327 rm -f $basedir/plugins/${gstreplace}plugin.c~
328
329 cat >$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 */
342 EOF
343
344 cat >$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
358 EOF
359
360
361 mkdir -p $basedir/tools
362
363 cat >$basedir/tools/Makefile.am <<EOF
364 bin_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
373 EOF
374
375 cat >$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>
386 int main (void) { printf ("FIXME\n"); return 0; }
387 EOF
388
389