File: create_plugin.sh

package info (click to toggle)
crossfire 1.71.0%2Bdfsg1-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 28,076 kB
  • sloc: ansic: 85,126; sh: 11,978; perl: 2,659; lex: 2,044; makefile: 1,271
file content (88 lines) | stat: -rwxr-xr-x 2,923 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
#
#    CrossFire, A Multiplayer game for X-windows
#    Copyright (C) 2007 Nicolas Weeger
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#    The authors can be reached via e-mail at crossfire-devel@real-time.com
#
# This script creates a plugin from the template directory.
# The plugin will have for id (slaying field in events) the first argument,
# and for name an optional second argument, or the id.
#
# Running multiple times this script will erase generated/modified
# plugin, but should not mess too much with building process.
#
# Note that some Crossfire files are affected.
# Ensure everything works before committing :)
#
# Also, modified files (/configure.ac) may have extra new lines.

if test  "x$1" = "x"  ; then
	echo "This script creates a plugin from the template directory."
	echo "Usage: $0 plugin_id [plugin_name]"
	exit
fi

ID=$1
NAME=$ID
if test "x$2" != "x" ; then
	NAME=$2
fi

echo "Creating plugin $NAME ($ID)"

DIR=$1
FIC_INC=$DIR/include/$ID.h
FIC_C=$DIR/$ID.c
FIC_MAK=$DIR/Makefile.am

echo "Copying files..."
cd ..
mkdir $1
cp template/plugin_template.c $FIC_C
mkdir $1/include
cp template/include/plugin_template.h $FIC_INC
cp template/Makefile.am $FIC_MAK

echo "Altering plugin's include"
sed -i -e "s/PLUGIN_NAME\s\+\"Template\"/PLUGIN_NAME \"$ID\"/g" $FIC_INC
sed -i -e "s/PLUGIN_VERSION\s\+\"Template Plugin 2.0\"/PLUGIN_VERSION \"$NAME plugin version 1.0\"/" $FIC_INC
sed -i -e "s/PLUGIN_TEMPLATE_H/PLUGIN_$ID\_H/" $FIC_INC
sed -i -e "s/plugin_template.h/$ID.h/" $FIC_INC
sed -i -e "s/plugin_template_proto.h/${ID}_proto.h/" $FIC_INC

echo "Altering plugin's c"
sed -i -e "s/plugin_template.h/$ID.h/" $FIC_C

echo "Altering plugin's Makefile.am"
sed -i -e "s/plugin_template/$ID/g" $FIC_MAK

PLUGINS=Makefile.am
echo "Adding plugin to build list in /plugins/Makefile.am"
sed -i -e "s/ $ID / /" $PLUGINS
sed -i -e "s/SUBDIRS =/SUBDIRS = $ID/" $PLUGINS

echo "Adding plugin to configure.ac"
CONF=../configure.ac
sed -i -e "s/plugins\/$ID\/Makefile/ /" $CONF
sed -i -e "s/devel\/Makefile/plugins\/$ID\/Makefile\n\tdevel\/Makefile/" $CONF

echo "Running auto* tools"
( cd .. && automake && autoconf )

echo
echo
echo "Done. Please run configure in the top-level directory to correctly generate Makefiles."