Replace unsigned INT with UINT (fixes #4)
[rofl0r-motor.git] / misc / motorsync
blob91357c81dd2af8b756e8e2c3e66a12f0c4876a29
1 #!/bin/sh
4 # This script can be used to for checking out and updating
5 # a program with anonymous r/o CVS access.
7 # by Konstantin Klyagin <konst@konst.org.ua>
9 # $Id: motorsync,v 1.19 2004/07/08 14:39:39 konst Exp $
12 CROOT=":pserver:anonymous@cvs.thekonst.net:/home/konst/cvs/root"
14 PROG="motor"
15 MODULES="kktoolbox/kkstrtext kktoolbox/kksystr kktoolbox/kkconsui parser"
16 MAKEUPDATE=""
17 MONOLITE="1"
19 RETVAL=0
20 CVS="cvs -z9 -d $CROOT"
22 moduledir=""
24 checkutils() {
25 for i in automake autoconf aclocal autoheader gettextize; do
26 r=`which $i 2>&1`
27 if test ! -f "$r"; then
28 echo "error: you must have $i installed to be able to use $0"
29 exit 1
31 done
33 vcvs=`cvs --version | grep System | gawk '{print $5}' | gawk -F . '{print $1 " " $2}'`
34 if test "$vcvs" = "1 10"; then
35 echo "CVS version 1.11 or later is needed in order to use $0"
36 exit 1
39 ver=1.4
40 for i in automake aclocal; do
41 r=`which $i-$ver 2>&1`
42 eval $i=$i
43 if test -f "$r"; then eval $i=$i-$ver; fi
44 done
46 ver=2.13
47 for i in autoconf autoheader; do
48 r=`which $i-$ver 2>&1`
49 eval $i=$i
50 if test -f "$r"; then eval $i=$i-$ver; fi
51 done
54 preparedirs() {
55 if test ! -d ${DEST}; then
56 mkdir -p ${DEST};
60 getmoduledirname() {
61 moduledir=`echo $1 | sed 's@^..*/\(..*\)$@\1@g'`
64 progsync() {
65 preparedirs
66 codir=$PROG
67 dir=$prefix
69 for module in $PROG $MODULES
71 if test $module != $PROG; then
72 getmoduledirname $module
73 dir=$DEST/$moduledir
74 codir="orig"
77 mkdir -p $dir
79 if test -d $dir; then
80 cd $dir
82 if test $1 = "checkout"; then
83 $CVS co -d $codir $module
84 else
85 cd $codir
86 $CVS update -C -P -d
89 RETVAL=$?
90 [ $RETVAL != 0 ] && return
92 done
94 find $DEST -name ".#*" -exec rm -f {} \;
97 makelinks() {
98 echo -n "Creating symbolic links for sources of libraries.. "
100 for module in $MODULES
102 getmoduledirname $module
103 dir=$DEST/$moduledir/orig
105 if test -d $dir; then
106 cd $dir
108 for fn in `find $dir -name "*.h" -o -name "*.cc" -o -name "*.c" -o -name "*.cpp" -o -name "*.C" -o -name "Makefile.am" -o -name "*.in"`
110 srcfname=`echo $fn | sed 's@^..*/\(orig/..*\)$@\1@'`
111 destdir=`dirname $fn | sed 's@/orig@@'`
112 updirs=`echo $srcfname | sed 's/ /_/g;s/\// /g' | wc -w`
113 updirs=`expr $updirs - 2`
116 while test $i -lt $updirs; do
117 srcfname="../"$srcfname
118 i=`expr $i + 1`
119 done
121 if test ! -d $destdir; then
122 mkdir -p $destdir
125 if test ! -f $destdir/`basename $srcfname`; then
126 ln -sf $srcfname $destdir/
128 done
130 done
132 echo "ok"
135 updatemakepaths() {
136 if test ! -z "$MAKEUPDATE"; then
137 for fn in `find $DEST -name "Makefile.am"`
139 sed $MAKEUPDATE $fn >.makefile.am
140 mv .makefile.am $fn
141 done
144 for m in $MODULES
146 getmoduledirname $m
147 for fn in `find $DEST -name "configure.in"`
149 smask="s/${moduledir}-[[:digit:].-][[:digit:].-]*/${moduledir}/g"
151 sed $smask $fn >.configure.in
152 mv .configure.in $fn
153 done
154 done
156 MSUBDIRS=`cat $DEST/Makefile.am | egrep "^SUBDIRS" | sed 's/SUBDIRS[ =][ =]*//g'`
158 for m in $MODULES
160 getmoduledirname $m
161 onlist=`echo $MSUBDIRS | grep $moduledir`
162 if test -z "$onlist"; then
163 MSUBDIRS="$moduledir $MSUBDIRS"
165 done
167 echo "SUBDIRS = $MSUBDIRS" >.makefile.am
168 egrep -v "^SUBDIRS" $DEST/Makefile.am >>.makefile.am
169 mv .makefile.am $DEST/Makefile.am
172 runautomake() {
173 if test "$MONOLITE" != "0"
174 then
175 traverse="${DEST}/configure.in"
176 else
177 traverse=`find $DEST -name "configure.in" -print`
180 for i in $traverse
182 cd `dirname $i`
184 $aclocal
185 headneeded=`grep AM_CONFIG_HEADER configure.in`
186 if test ! -z "$headneeded"; then $autoheader; fi
187 $autoconf
188 $automake -a -c
189 done
191 cd $DEST
192 if test ! -f intl/Makefile.in; then
193 p="--no-changelog"
194 while true; do
195 gettextize -f --intl $p
196 if test ! -z "$p"; then p=""; else break; fi
197 done
199 if test -f po/Makevars.template -a ! -f po/Makevars; then
200 mv po/Makevars.template po/Makevars
203 if test -d m4; then
204 sed 's/^\s*SUBDIRS[ =]*m4[ =]*\(.*\)$/SUBDIRS = \1/g' <Makefile.am >11
205 grep -v "ACLOCAL_AMFLAGS = -I m4" 11 >Makefile.am
206 rm -rf m4 11
207 sed 's@intl/Makefile@@;s@po/Makefile.in@@;s@m4/Makefile @@' <configure.in >11
208 mv 11 configure.in
211 aclocal
215 usage() {
216 echo "
217 This is a script which can checkout and update $PROG from an
218 anonymous CVS repository.
220 script usage:
221 $0 {update|checkout} <pathname>
225 finishmsg() {
226 echo "
227 CVS operations finished sucessfully.
229 To build the updated stuff go to the ${DEST} directory
230 and issue the following commands:
232 ./configure
233 make
234 make install
238 if test $# -lt 2; then
239 usage
240 else
241 checkutils
243 if test ! -d $2; then
244 echo "the location you specified does not exist: $2"
245 exit
246 else
247 cd $2
248 prefix=`pwd`
249 DEST=${prefix}/$PROG
252 if test $1 = "checkout" -o $1 = "update"; then
253 progsync $1
254 else
255 usage
256 exit
259 if test $RETVAL != 0; then
260 echo "$0 aborted, exit code = $RETVAL"
261 else
262 updatemakepaths
263 makelinks
264 runautomake
265 finishmsg
269 exit $RETVAL