~ubuntu-branches/ubuntu/feisty/kdetv/feisty

« back to all changes in this revision

Viewing changes to admin/cvs.sh

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-09-17 23:25:16 UTC
  • Revision ID: james.westby@ubuntu.com-20050917232516-9wdsn3ckagbqieh8
Tags: upstream-0.8.8
ImportĀ upstreamĀ versionĀ 0.8.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
#
 
3
# cvs.sh
 
4
#
 
5
# This file contains support code from Makefile.common
 
6
# It defines a shell function for each known target
 
7
# and then does a case to call the correct function.
 
8
 
 
9
unset MAKEFLAGS
 
10
 
 
11
call_and_fix_autoconf()
 
12
{
 
13
  $AUTOCONF || exit 1
 
14
  if test -r configure.in.in ; then
 
15
    perl -pi -e "print \"if test \\\"x\\\$with_fast_perl\\\" = \\\"xyes\\\"; then\
 
16
    \\n  perl -i.bak \\\$ac_aux_dir/conf.change.pl \\\$CONFIG_STATUS\
 
17
    \\\\\\n    || mv \\\$CONFIG_STATUS.bak \\\$CONFIG_STATUS\
 
18
    \\n  rm -f \\\$CONFIG_STATUS.bak\\nfi\
 
19
    \\n\" if /^\\s*chmod\\s+.*\\+x\\s+.*CONFIG_STATUS/; s,^#line.*LINENO.*\$,/* \$& */, ;" configure
 
20
  fi
 
21
}
 
22
 
 
23
strip_makefile()
 
24
{
 
25
  if test ! -f $makefile_wo; then
 
26
    perl -e '$in=0; while ( <> ) { $in = 1 if ($_ =~ m/^if / ); print $_ unless ($in || $_ =~ m/^include /); $in = 0 if ($_ =~ m/^endif/); }' < $makefile_am > $makefile_wo
 
27
  fi
 
28
}
 
29
 
 
30
check_autotool_versions()
 
31
{
 
32
required_autoconf_version="2.53 or newer"
 
33
AUTOCONF_VERSION=`$AUTOCONF --version | head -n 1`
 
34
case $AUTOCONF_VERSION in
 
35
  Autoconf*2.5* | autoconf*2.5* ) : ;;
 
36
  "" )
 
37
    echo "*** AUTOCONF NOT FOUND!."
 
38
    echo "*** KDE requires autoconf $required_autoconf_version"
 
39
    exit 1
 
40
    ;;
 
41
  * )
 
42
    echo "*** YOU'RE USING $AUTOCONF_VERSION."
 
43
    echo "*** KDE requires autoconf $required_autoconf_version"
 
44
    exit 1
 
45
    ;;
 
46
esac
 
47
 
 
48
AUTOHEADER_VERSION=`$AUTOHEADER --version | head -n 1`
 
49
case $AUTOHEADER_VERSION in
 
50
  Autoconf*2.5* | autoheader*2.5* ) : ;;
 
51
  "" )
 
52
    echo "*** AUTOHEADER NOT FOUND!."
 
53
    echo "*** KDE requires autoheader $required_autoconf_version"
 
54
    exit 1
 
55
    ;;
 
56
  * )
 
57
    echo "*** YOU'RE USING $AUTOHEADER_VERSION."
 
58
    echo "*** KDE requires autoheader $required_autoconf_version"
 
59
    exit 1
 
60
    ;;
 
61
esac
 
62
 
 
63
AUTOMAKE_STRING=`$AUTOMAKE --version | head -n 1`
 
64
required_automake_version="1.6.1 or newer"
 
65
case $AUTOMAKE_STRING in
 
66
  automake*1.5d* | automake*1.5* | automake*1.5-* )
 
67
    echo "*** YOU'RE USING $AUTOMAKE_STRING."
 
68
    echo "*** KDE requires automake $required_automake_version"
 
69
    exit 1
 
70
    ;;
 
71
  automake*1.6.* | automake*1.7* | automake*1.8* | automake*1.9*)
 
72
    echo "*** $AUTOMAKE_STRING found."
 
73
    UNSERMAKE=no
 
74
    ;;
 
75
  "" )
 
76
    echo "*** AUTOMAKE NOT FOUND!."
 
77
    echo "*** KDE requires automake $required_automake_version"
 
78
    exit 1
 
79
    ;;
 
80
  *unsermake* ) :
 
81
    echo "*** YOU'RE USING UNSERMAKE."
 
82
    echo "*** GOOD LUCK!! :)"
 
83
    UNSERMAKE=unsermake
 
84
    ;;
 
85
  * )
 
86
    echo "*** YOU'RE USING $AUTOMAKE_STRING."
 
87
    echo "*** KDE requires automake $required_automake_version"
 
88
    exit 1
 
89
    ;;
 
90
esac
 
91
unset required_automake_version
 
92
}
 
93
 
 
94
cvs()
 
95
{
 
96
check_autotool_versions
 
97
acinclude_m4 
 
98
 
 
99
### Make new subdirs and configure.in.
 
100
### The make calls could be optimized away here,
 
101
### with a little thought.
 
102
if test -r configure.in.in; then
 
103
    rm -f configure.in
 
104
    echo "*** Creating list of subdirectories"
 
105
    create_subdirs
 
106
 
 
107
    if test -r Makefile.am.in; then
 
108
        echo "*** Creating Makefile.am"
 
109
        if grep '\$(top_srcdir)/Makefile.am:' $makefile_am >/dev/null; then 
 
110
            strip_makefile
 
111
            $MAKE -f $makefile_wo top_srcdir=. ./Makefile.am || exit 1
 
112
        else
 
113
            Makefile_am
 
114
        fi
 
115
     fi
 
116
     configure_files
 
117
     echo "*** Creating configure.in"
 
118
     if grep '\$(top_srcdir)/configure.in:' $makefile_am >/dev/null; then 
 
119
       strip_makefile
 
120
       $MAKE -f $makefile_wo top_srcdir=. ./configure.in || exit 1
 
121
     else
 
122
       configure_in
 
123
     fi
 
124
fi
 
125
 
 
126
echo "*** Creating aclocal.m4"
 
127
$ACLOCAL $ACLOCALFLAGS || exit 1
 
128
echo "*** Creating configure"
 
129
call_and_fix_autoconf
 
130
 
 
131
if egrep "^AM_CONFIG_HEADER" configure.in >/dev/null 2>&1; then
 
132
  echo "*** Creating config.h template"
 
133
  $AUTOHEADER || exit 1
 
134
fi
 
135
 
 
136
echo "*** Creating Makefile templates"
 
137
$AUTOMAKE || exit 1
 
138
 
 
139
if test "$UNSERMAKE" = no; then
 
140
  echo "*** Postprocessing Makefile templates"
 
141
  perl -w admin/am_edit || exit 1
 
142
fi
 
143
 
 
144
if egrep "^cvs-local:" $makefile_am >/dev/null; then \
 
145
  strip_makefile
 
146
  $MAKE -f $makefile_wo cvs-local top_srcdir=. || exit 1
 
147
fi
 
148
 
 
149
echo "*** Creating date/time stamp"
 
150
touch stamp-h.in
 
151
 
 
152
echo "*** Finished"
 
153
echo "    Don't forget to run ./configure"
 
154
echo "    If you haven't done so in a while, run ./configure --help"
 
155
}
 
156
 
 
157
dist()
 
158
{
 
159
check_autotool_versions
 
160
 
 
161
###
 
162
### First build all of the files necessary to do just "make"
 
163
###
 
164
acinclude_m4
 
165
if test -r configure.in.in; then
 
166
  rm -f configure.in
 
167
  create_subdirs
 
168
 
 
169
  if test -r Makefile.am.in; then
 
170
    if grep '\$(top_srcdir)/Makefile.am:' $makefile_am >/dev/null; then 
 
171
      strip_makefile
 
172
      $MAKE -f $makefile_wo top_srcdir=. ./Makefile.am || exit 1
 
173
    else
 
174
      Makefile_am
 
175
    fi
 
176
  fi
 
177
  configure_files
 
178
  if grep '\$(top_srcdir)/configure.in:' $makefile_am >/dev/null; then 
 
179
    strip_makefile
 
180
    $MAKE -f $makefile_wo top_srcdir=. ./configure.in || exit 1
 
181
  else
 
182
    configure_in
 
183
  fi
 
184
fi
 
185
$ACLOCAL $ACLOCALFLAGS
 
186
if egrep "^AM_CONFIG_HEADER" configure.in >/dev/null 2>&1; then
 
187
  echo "*** Creating config.h template"
 
188
  $AUTOHEADER || exit 1
 
189
fi
 
190
$AUTOMAKE --foreign
 
191
if test "$UNSERMAKE" = no; then
 
192
  echo "*** Postprocessing Makefile templates"
 
193
  perl -w admin/am_edit || exit 1
 
194
fi
 
195
call_and_fix_autoconf
 
196
touch stamp-h.in
 
197
if grep "^cvs-local:" $makefile_am >/dev/null; then
 
198
  strip_makefile
 
199
  $MAKE -f $makefile_wo cvs-local top_srcdir=.
 
200
fi
 
201
 
 
202
###
 
203
### Then make messages
 
204
###
 
205
if test -d po; then
 
206
 LIST=`find ./po -name "*.po"`
 
207
 for i in $LIST; do
 
208
  file2=`echo $i | sed -e "s#\.po#\.gmo#"`
 
209
  msgfmt -o $file2 $i || touch $file2
 
210
 done
 
211
fi
 
212
if grep "^cvs-dist-local:" $makefile_am >/dev/null; then
 
213
  strip_makefile
 
214
  $MAKE -f $makefile_wo cvs-dist-local top_srcdir=.
 
215
fi
 
216
}
 
217
 
 
218
subdir_dist()
 
219
{
 
220
$ACLOCAL $ACLOCALFLAGS
 
221
$AUTOHEADER
 
222
$AUTOMAKE
 
223
AUTOMAKE_STRING=`$AUTOMAKE --version | head -n 1`
 
224
case $AUTOMAKE_STRING in
 
225
  *unsermake* ) :
 
226
    ;;
 
227
  *)
 
228
     perl -w ../admin/am_edit --path=../admin
 
229
esac
 
230
call_and_fix_autoconf
 
231
touch stamp-h.in
 
232
}
 
233
 
 
234
configure_in()
 
235
{
 
236
rm -f configure.in configure.in.new
 
237
kde_use_qt_param=
 
238
test -f configure.files || { echo "need configure.files for configure.in"; exit 1; }
 
239
list=`fgrep -v "configure.in.bot" < configure.files | fgrep -v "configure.in.mid"`
 
240
: > configure.in.new
 
241
for file in $list; do 
 
242
  echo "dnl =======================================================" >> configure.in.new
 
243
  echo "dnl FILE: $file" >> configure.in.new
 
244
  echo "dnl =======================================================" >> configure.in.new
 
245
  echo "" >> configure.in.new
 
246
  cat $file >> configure.in.new
 
247
done
 
248
echo "KDE_CREATE_SUBDIRSLIST" >> configure.in.new
 
249
if test -f Makefile.am.in; then
 
250
  subdirs=`cat subdirs`
 
251
  for dir in $subdirs; do
 
252
    vdir=`echo $dir | sed -e 's,[-+.@],_,g'`
 
253
    echo "AM_CONDITIONAL($vdir""_SUBDIR_included, test \"x\$$vdir""_SUBDIR_included\" = xyes)" >> configure.in.new
 
254
    if test -f "$dir/configure.in"; then
 
255
        echo "if test \"x\$$vdir""_SUBDIR_included\" = xyes; then " >> configure.in.new
 
256
        echo "  AC_CONFIG_SUBDIRS($dir)" >> configure.in.new
 
257
        echo "fi" >> configure.in.new
 
258
    fi
 
259
  done
 
260
fi
 
261
 
 
262
echo "AC_CONFIG_FILES([ Makefile ])" >> configure.in.new
 
263
 
 
264
if test -f inst-apps; then
 
265
    topleveldirs=`cat inst-apps`
 
266
else
 
267
    topleveldirs=
 
268
    for dir in `ls -1d * | sort`; do
 
269
        if test "$dir" != "debian" && test -d $dir; then
 
270
            topleveldirs="$topleveldirs $dir"
 
271
        fi
 
272
    done
 
273
fi
 
274
 
 
275
for topleveldir in $topleveldirs; do 
 
276
  if test -f $topleveldir/configure.in; then
 
277
        continue
 
278
  fi
 
279
  if test -f $topleveldir/Makefile.am; then :; else
 
280
        continue
 
281
  fi
 
282
 
 
283
  mfs=`find $topleveldir -follow -name Makefile.am -print | fgrep -v "/." | \
 
284
       sed -e 's#\./##; s#/Makefile.am$##' | sort | sed -e 's#$#/Makefile#'`
 
285
  for i in $mfs; do
 
286
     echo "AC_CONFIG_FILES([ $i ])" >> configure.in.new
 
287
  done
 
288
done
 
289
 
 
290
files=`cat configure.files`
 
291
list=`egrep '^dnl AC_OUTPUT\(.*\)' $files | sed -e "s#^.*dnl AC_OUTPUT(\(.*\))#\1#"`
 
292
for file in $list; do 
 
293
    echo "AC_CONFIG_FILES([ $file ])" >>  configure.in.new
 
294
done
 
295
 
 
296
midfiles=`cat configure.files | fgrep "configure.in.mid"`
 
297
test -n "$midfiles" && cat $midfiles >> configure.in.new
 
298
 
 
299
echo "AC_OUTPUT" >> configure.in.new
 
300
modulename=
 
301
if test -f configure.in.in; then
 
302
   if head -n 2 configure.in.in | egrep "^#MIN_CONFIG\(.*\)$" > /dev/null; then
 
303
      kde_use_qt_param=`cat configure.in.in | sed -n -e "s/#MIN_CONFIG(\(.*\))/\1/p"`
 
304
   fi
 
305
   if head -n 2 configure.in.in | egrep "^#MIN_CONFIG" > /dev/null; then
 
306
      line=`grep "^AM_INIT_AUTOMAKE(" configure.in.in`
 
307
      if test -n "$line"; then
 
308
          modulename=`echo $line | sed -e "s#AM_INIT_AUTOMAKE(\([^,]*\),.*#\1#"`
 
309
          VERSION=`echo $line | sed -e "s#AM_INIT_AUTOMAKE([^,]*, *\([^)]*\)).*#\1#"`
 
310
      fi
 
311
      sed -e "s#AM_INIT_AUTOMAKE([^@].*#dnl PACKAGE set before#" \
 
312
          configure.in.new > configure.in && mv configure.in configure.in.new
 
313
   fi
 
314
fi
 
315
if test -z "$VERSION" || test "$VERSION" = "@VERSION@"; then
 
316
     VERSION="\"3.4.0\""
 
317
fi
 
318
if test -z "$modulename" || test "$modulename" = "@MODULENAME@"; then
 
319
   modulename=`pwd`; 
 
320
   modulename=`basename $modulename`
 
321
   esc_VERSION=`echo $VERSION | sed -e "s#[^.0-9a-zA-Z]##g"`
 
322
   modulename=`echo $modulename | sed -e "s#-$esc_VERSION##"`   
 
323
 
 
324
fi
 
325
if test -n "$kde_use_qt_param"; then
 
326
      sed -e "s#^dnl KDE_USE_QT#KDE_USE_QT($kde_use_qt_param)#" \
 
327
        configure.in.new > configure.in && mv configure.in configure.in.new
 
328
fi
 
329
sed -e "s#@MODULENAME@#$modulename#" configure.in.new |
 
330
        sed -e "s#@VERSION@#$VERSION#" > configure.in
 
331
botfiles=`cat configure.files | egrep "configure.in.bot"`
 
332
test -n "$botfiles" && cat $botfiles >> configure.in
 
333
cat $admindir/configure.in.bot.end >> configure.in
 
334
rm -f configure.in.new
 
335
}
 
336
 
 
337
configure_files()
 
338
{
 
339
echo "*** Creating configure.files"
 
340
admindir=NO
 
341
for i in . .. ../.. ../../..; do
 
342
  if test -x $i/admin; then admindir=$i/admin; break; fi
 
343
done
 
344
rm -f configure.files
 
345
touch configure.files
 
346
if test -f configure.in.in && head -n 2 configure.in.in | grep "^#MIN_CONFIG" > /dev/null; then
 
347
        echo $admindir/configure.in.min >> configure.files
 
348
fi
 
349
test -f configure.in.in && echo configure.in.in >> configure.files
 
350
# we collect files in the subdirs and do some sorting tricks, so subsubdirs come after subdirs
 
351
if test -f inst-apps; then
 
352
   inst=`cat inst-apps`
 
353
   list=""
 
354
   for i in $inst; do
 
355
      list="$list `find $i/ -follow -name "configure.in.in" -o -name "configure.in.bot" -o -name "configure.in.mid" | \
 
356
                sed -e "s,/configure,/aaaconfigure," | sort | sed -e "s,/aaaconfigure,/configure,"`"
 
357
   done
 
358
else
 
359
   list=`find . -follow -name "configure.in.in" -o -name "configure.in.bot" -o -name "configure.in.mid" | \
 
360
                sed -e "s,/configure,/aaaconfigure," | sort | sed -e "s,/aaaconfigure,/configure,"`
 
361
fi
 
362
for i in $list; do if test -f $i && test `dirname $i` != "." ; then
 
363
  echo $i >> configure.files
 
364
fi; done
 
365
test -f configure.in.mid && echo configure.in.mid >> configure.files
 
366
test -f configure.in.bot && echo configure.in.bot >> configure.files
 
367
if test ! -s configure.files; then
 
368
   echo "There are no files to build a configure. Please check your checkout."
 
369
   exit 1
 
370
fi
 
371
}
 
372
 
 
373
create_subdirs()
 
374
{
 
375
if grep '\$(top_srcdir)/subdirs:' $makefile_am >/dev/null; then 
 
376
    # as many modules contain rules to create subdirs without any
 
377
    # dependencies make won't create it unless there is no file.
 
378
    # so we check if that's a dummy rule or one that works
 
379
    rm -f subdirs.cvs.sh.$$
 
380
    if test -f subdirs; then
 
381
        mv subdirs subdirs.cvs.sh.$$
 
382
    fi
 
383
    strip_makefile
 
384
    $MAKE -f $makefile_wo top_srcdir=. ./subdirs || exit 1
 
385
    if test -f subdirs.cvs.sh.$$; then
 
386
        if test -s subdirs; then
 
387
            rm subdirs.cvs.sh.$$ 
 
388
        else
 
389
            mv subdirs.cvs.sh.$$ subdirs
 
390
        fi
 
391
    fi
 
392
else
 
393
    subdirs
 
394
fi
 
395
}
 
396
 
 
397
subdirs()
 
398
{
 
399
dirs=
 
400
idirs=
 
401
if test -f inst-apps; then
 
402
   idirs=`cat inst-apps`
 
403
else
 
404
   idirs=`ls -1 | sort`
 
405
fi
 
406
 
 
407
compilefirst=`sed -ne 's#^COMPILE_FIRST[ ]*=[ ]*##p' $makefile_am | head -n 1`
 
408
compilelast=`sed -ne 's#^COMPILE_LAST[ ]*=[ ]*##p' $makefile_am | head -n 1`
 
409
for i in $idirs; do
 
410
    if test -f $i/Makefile.am; then
 
411
       case " $compilefirst $compilelast " in
 
412
         *" $i "*) ;;
 
413
         *) dirs="$dirs $i"
 
414
       esac
 
415
    fi
 
416
done
 
417
 
 
418
: > ./_SUBDIRS
 
419
 
 
420
for d in $compilefirst; do
 
421
   echo $d >> ./_SUBDIRS
 
422
done
 
423
 
 
424
(for d in $dirs; do 
 
425
   list=`sed -ne "s#^COMPILE_BEFORE_$d""[ ]*=[ ]*##p" $makefile_am | head -n 1`
 
426
   for s in $list; do
 
427
      echo $s $d
 
428
   done
 
429
   list=`sed -ne "s#^COMPILE_AFTER_$d""[ ]*=[ ]*##p" $makefile_am | head -n 1`
 
430
   for s in $list; do
 
431
      echo $d $s
 
432
   done
 
433
   echo $d $d
 
434
done ) | tsort >> ./_SUBDIRS
 
435
 
 
436
for d in $compilelast; do
 
437
   echo $d >> ./_SUBDIRS
 
438
done
 
439
 
 
440
if test -r subdirs && cmp -s subdirs _SUBDIRS; then
 
441
    rm -f _SUBDIRS
 
442
fi
 
443
test -r _SUBDIRS && mv _SUBDIRS subdirs || true
 
444
}
 
445
 
 
446
Makefile_am()
 
447
{
 
448
if test -f Makefile.am.in; then
 
449
  compilefirst=`sed -ne 's#^COMPILE_FIRST[ ]*=[ ]*##p' $makefile_am | head -n 1`
 
450
  compilelast=`sed -ne 's#^COMPILE_LAST[ ]*=[ ]*##p' $makefile_am | head -n 1`
 
451
 
 
452
  idirs=
 
453
  dirs=
 
454
  if test -f inst-apps; then
 
455
     idirs=`cat inst-apps`
 
456
  else
 
457
     idirs=`cat subdirs`
 
458
  fi
 
459
  for i in $idirs; do
 
460
    case " $compilefirst $compilelast " in
 
461
      *" $i "*) ;;
 
462
      *) dirs="$dirs $i"
 
463
    esac
 
464
  done
 
465
 
 
466
  adds=`fgrep '$(top_srcdir)/acinclude.m4:' Makefile.am.in | sed -e 's,^[^:]*: *,,; s,\$(top_srcdir)/,,g'`
 
467
  if echo "$adds" | fgrep "*" >/dev/null ; then
 
468
    adds=`ls -d -1 $adds 2>/dev/null`
 
469
    fgrep -v  '$(top_srcdir)/acinclude.m4:' Makefile.am.in > Makefile.am.in.adds
 
470
    str='$(top_srcdir)/acinclude.m4:'
 
471
    for add in $adds; do 
 
472
        str="$str \$(top_srcdir)/$add"
 
473
    done
 
474
    echo $str >> Makefile.am.in.adds
 
475
  else
 
476
    cat Makefile.am.in > Makefile.am.in.adds
 
477
  fi
 
478
 
 
479
  cat Makefile.am.in.adds | \
 
480
      sed -e 's,^\s*\(COMPILE_BEFORE.*\),# \1,' | \
 
481
      sed -e 's,^\s*\(COMPILE_AFTER.*\),# \1,' > Makefile.am
 
482
    echo "SUBDIRS="'$(TOPSUBDIRS)' >> Makefile.am
 
483
  rm Makefile.am.in.adds
 
484
fi
 
485
}
 
486
 
 
487
acinclude_m4()
 
488
{
 
489
  echo "*** Creating acinclude.m4"
 
490
  adds=
 
491
  if grep '\$(top_srcdir)/acinclude.m4:' $makefile_am >/dev/null; then 
 
492
    strip_makefile
 
493
    rm -f acinclude.m4
 
494
    adds=`grep '\$(top_srcdir)/acinclude.m4:' $makefile_wo | sed -e 's,^[^:]*: *,,; s,\$(top_srcdir),.,g'`
 
495
    if echo $adds | fgrep "*" >/dev/null ; then
 
496
      adds=`ls -d -1 $adds 2>/dev/null`
 
497
    else
 
498
      $MAKE -f $makefile_wo top_srcdir=. ./acinclude.m4 || exit 1
 
499
    fi
 
500
  else
 
501
    rm -f acinclude.m4
 
502
  fi
 
503
  # if it wasn't created up to now, then we do it better
 
504
  if test ! -f acinclude.m4; then
 
505
     cat admin/acinclude.m4.in admin/libtool.m4.in admin/pkg.m4.in $adds > acinclude.m4
 
506
  fi
 
507
}
 
508
 
 
509
cvs_clean()
 
510
{
 
511
if test -d CVS; then :; else
 
512
  echo "You don't have a toplevel CVS directory."
 
513
  echo "You most certainly didn't use cvs to get these sources."
 
514
  echo "But this function depends on cvs's information."
 
515
  exit 1
 
516
fi
 
517
perl $admindir/cvs-clean.pl
 
518
}
 
519
 
 
520
package_merge()
 
521
{
 
522
catalogs=$POFILES
 
523
for cat in $catalogs; do
 
524
  msgmerge -o $cat.new $cat $PACKAGE.pot
 
525
  if test -s $cat.new; then
 
526
    grep -v "\"POT-Creation" $cat.new > $cat.new.2
 
527
    grep -v "\"POT-Creation" $cat >> $cat.new.1
 
528
    if diff $cat.new.1 $cat.new.2; then
 
529
        rm $cat.new
 
530
    else
 
531
        mv $cat.new $cat
 
532
    fi
 
533
    rm -f $cat.new.1 $cat.new.2
 
534
  fi
 
535
done
 
536
}
 
537
 
 
538
extract_messages()
 
539
{
 
540
podir=${podir:-$PWD/po}
 
541
files=`find . -name Makefile.am | xargs egrep -l '^messages:' `
 
542
dirs=`for i in $files; do echo \`dirname $i\`; done`
 
543
tmpname="$PWD/messages.log"
 
544
if test -z "$EXTRACTRC"; then EXTRACTRC=extractrc ; fi
 
545
if test -z "$PREPARETIPS"; then PREPARETIPS=preparetips ; fi
 
546
export EXTRACTRC PREPARETIPS
 
547
 
 
548
for subdir in $dirs; do
 
549
  test -z "$VERBOSE" || echo "Making messages in $subdir"
 
550
  (cd $subdir
 
551
   if test -n "`grep -e '^messages:.*rc.cpp' Makefile.am`"; then
 
552
        $EXTRACTRC *.rc *.ui *.kcfg > rc.cpp
 
553
   else
 
554
        candidates=`ls -1 *.rc *.ui *.kcfg 2>/dev/null`
 
555
        if test -n "$candidates"; then
 
556
            echo "$subdir has *.rc, *.ui or *.kcfg files, but not correct messages line"
 
557
        fi
 
558
   fi
 
559
   if find . -name \*.c\* -o -name \*.h\* | xargs fgrep -s -q KAboutData ; then
 
560
        echo -e 'i18n("_: NAME OF TRANSLATORS\\n"\n"Your names")\ni18n("_: EMAIL OF TRANSLATORS\\n"\n"Your emails")' > _translatorinfo.cpp
 
561
   else echo " " > _translatorinfo.cpp
 
562
   fi
 
563
   perl -e '$mes=0; while (<STDIN>) { next if (/^(if\s|else\s|endif)/); if (/^messages:/) { $mes=1; print $_; next; } if ($mes) { if (/$\\(XGETTEXT\)/ && / -o/) { s/ -o \$\(podir\)/ _translatorinfo.cpp -o \$\(podir\)/ } print $_; } else { print $_; } }' < Makefile.am | egrep -v '^include ' > _transMakefile
 
564
 
 
565
   kdepotpath=${includedir:-`kde-config --expandvars --install include`}/kde.pot
 
566
 
 
567
   $MAKE -s -f _transMakefile podir=$podir EXTRACTRC="$EXTRACTRC" PREPARETIPS="$PREPARETIPS" srcdir=. \
 
568
        XGETTEXT="${XGETTEXT:-xgettext} --foreign-user -C -ci18n -ki18n -ktr2i18n -kI18N_NOOP -kI18N_NOOP2 -kaliasLocale -x $kdepotpath" messages
 
569
   exit_code=$?
 
570
   if test "$exit_code" != 0; then
 
571
       echo "make exit code: $exit_code"
 
572
   fi
 
573
   ) 2>&1 | grep -v '^make\[1\]' > $tmpname
 
574
   test -s $tmpname && { echo $subdir ; cat "$tmpname"; }
 
575
   test -f $subdir/rc.cpp && rm -f $subdir/rc.cpp
 
576
   rm -f $subdir/_translatorinfo.cpp
 
577
   rm -f $subdir/_transMakefile
 
578
done
 
579
rm -f $tmpname
 
580
}
 
581
 
 
582
package_messages()
 
583
{
 
584
rm -rf po.backup
 
585
mkdir po.backup
 
586
 
 
587
for i in `ls -1 po/*.pot 2>/dev/null | sed -e "s#po/##"`; do
 
588
  egrep -v '^#[^,]' po/$i | egrep '^.*[^ ]+.*$' | grep -v "\"POT-Creation" > po.backup/$i
 
589
  cat po/$i > po.backup/backup_$i
 
590
  touch -r po/$i po.backup/backup_$i
 
591
  rm po/$i
 
592
done
 
593
 
 
594
extract_messages
 
595
 
 
596
for i in `ls -1 po.backup/*.pot 2>/dev/null | sed -e "s#po.backup/##" | egrep -v '^backup_'`; do
 
597
  test -f po/$i || echo "disappeared: $i"
 
598
done
 
599
for i in `ls -1 po/*.pot 2>/dev/null | sed -e "s#po/##"`; do
 
600
  sed -e 's,^"Content-Type: text/plain; charset=CHARSET\\n"$,"Content-Type: text/plain; charset=UTF-8\\n",' po/$i > po/$i.new && mv po/$i.new po/$i
 
601
  #msgmerge -q -o po/$i po/$i po/$i
 
602
  egrep -v '^#[^,]' po/$i | egrep '^.*[^ ]+.*$' | grep -v "\"POT-Creation" > temp.pot
 
603
  if test -f po.backup/$i && ! cmp -s temp.pot po.backup/$i; then
 
604
    echo "will update $i"
 
605
  else
 
606
    if test -f po.backup/backup_$i; then
 
607
      test -z "$VERBOSE" || echo "I'm restoring $i"
 
608
      mv po.backup/backup_$i po/$i
 
609
      rm po.backup/$i
 
610
    else
 
611
      echo "will add $i"
 
612
    fi
 
613
  fi
 
614
done
 
615
rm -f temp.pot
 
616
rm -rf po.backup
 
617
}
 
618
 
 
619
# Make sure that sorting is always done the same way
 
620
LC_ALL=C
 
621
export LC_ALL
 
622
unset LANG || :
 
623
unset LC_CTYPE || :
 
624
unset LANGUAGE || :
 
625
 
 
626
unset CDPATH || :
 
627
admindir=`echo "$0" | sed 's%[\\/][^\\/][^\\/]*$%%'`
 
628
test "x$admindir" = "x$0" && admindir=.
 
629
 
 
630
test "x$MAKE" = x && MAKE=make
 
631
makefile_am=Makefile.am
 
632
makefile_wo=Makefile.am.wo
 
633
if test -f Makefile.am.in; then
 
634
  makefile_am=Makefile.am.in
 
635
  makefile_wo=Makefile.am.in.wo
 
636
  rm -f $makefile_wo
 
637
fi
 
638
 
 
639
# Suck in the AUTOCONF detection code
 
640
. $admindir/detect-autoconf.sh
 
641
 
 
642
###
 
643
### Main
 
644
###
 
645
 
 
646
arg=`echo $1 | tr .- __`
 
647
case $arg in
 
648
  cvs | dist | subdir_dist | configure_in | configure_files | subdirs | \
 
649
  cvs_clean | package_merge | package_messages | Makefile_am | acinclude_m4 | extract_messages ) $arg ;;
 
650
  configure ) call_and_fix_autoconf ;;
 
651
  * ) echo "Usage: cvs.sh <target>"
 
652
      echo "Target can be one of:"
 
653
      echo "    cvs cvs-clean dist"
 
654
      echo "    configure.in configure.files"
 
655
      echo "    package-merge package-messages"
 
656
      echo ""
 
657
      echo "Usage: anything but $1"
 
658
      exit 1 ;;
 
659
esac
 
660
 
 
661
if test -f $makefile_wo; then
 
662
  rm $makefile_wo
 
663
fi
 
664
 
 
665
exit 0