File: create_plugin.sh

package info (click to toggle)
modlogan 0.8.13-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 7,120 kB
  • ctags: 3,684
  • sloc: ansic: 38,972; sh: 10,853; makefile: 491; perl: 220; sed: 16
file content (107 lines) | stat: -rwxr-xr-x 2,503 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh

# $Id: create_plugin.sh,v 1.6 2001/08/29 12:44:55 jk Exp $

if [ $# = 0 ]; then
	echo "Usage:"
	echo "  $0 <name> [<type>]"
	exit
fi


## getting the vars
name=$1

if [ $# > 1 ]; then
	type=$2
fi

if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
    ac_n= ac_c='
' ac_t='	'
  else
    ac_n=-n ac_c= ac_t=
  fi
else
  ac_n= ac_c='\c' ac_t=
fi

echo $ac_n "Detecting basedir... $ac_c" 
basedir=`pwd | sed "s/src.*//;s/doc.*//;s/po.*//;s/intl.*//"`

if [ ! -e $basedir/modlogan.spec.in ]; then
	echo "Couldn't detect modlogan basedir - aborting"
	exit
fi

echo "$basedir"

echo $ac_n "Detecting type of plugin... $ac_c" 
if [ x$type = x ]; then
	_bd=`echo $basedir | sed "s/\///g"`
	_t=`pwd | sed "s/\///g;s/$_bd//;s/src//;"`
	case $_t in
		input) type=$_t ;;
		output) type=$_t ;;
		processor)  type=$_t ;;
	esac
fi

if [ x$type = x ]; then
	echo "none specified"
	echo "Couldn't detect type of plugin - aborting"
	exit
fi

case $type in
	input) ;;
	output) ;;
	processor) ;;
	*) 	echo "Unknown type of plugin - aborting"
		;;
esac
echo "$type"

workdir="$basedir/src/$type"

if [ ! -d $workdir/skeleton ]; then
	echo "skeleton not found - aborting"
	exit
fi

if [ -e $workdir/$name ]; then
	echo "plugin '$name' already exists - aborting"
	exit
fi

echo $ac_n "Creating subdirectory... $ac_c" 
mkdir $workdir/$name
echo "done"

echo $ac_n "Copying skeleton code... $ac_c" 
for i in $workdir/skeleton/*.[ch]; do
	cat $i | sed "s/skeleton/$name/g" > $workdir/$name/`basename $i`
done
echo "done"

echo $ac_n "Preparing infrastructure... $ac_c" 
cat $workdir/skeleton/Makefile.am | grep "^#" | sed "s/^#//;s/skeleton/$name/" > $workdir/$name/Makefile.am
cat $workdir/skeleton/.cvsignore | sed "s/skeleton/$name/" > $workdir/$name/.cvsignore
cat $workdir/skeleton/STATUS | sed "s/skeleton/$name/" > $workdir/$name/STATUS
echo "done"

echo $ac_n "Updating $workdir/Makefile.am... $ac_c" 
cp $workdir/Makefile.am $workdir/Makefile.am.orig
cat $workdir/Makefile.am.orig | sed "/SUBDIRS/s/\(\\\\\)*$/ $name\\1/;" > $workdir/Makefile.am
echo "done"

echo $ac_n "Updating $basedir/configure.in... $ac_c" 
cp $basedir/configure.in $basedir/configure.in.orig
cat $basedir/configure.in.orig | sed "/AC_CONFIG_FILES(/,/)/{/src\/$type\/Makefile/a\\
	src\/$type\/$name\/Makefile
}" > $basedir/configure.in
echo "done"

echo "--> successfully finished"