~ubuntu-branches/ubuntu/wily/knutclient/wily

« back to all changes in this revision

Viewing changes to admin/cvs.sh

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-12-15 01:56:29 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131215015629-kbtxdi17e1gmxb5e
Tags: 1.0.5-1
Re-packaged and re-introduced to Debian (Closes: #695840).

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* | autoconf*2.6* ) : ;;
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* | autoheader*2.6* ) : ;;
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* | automake*1.10* )
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
 
  touch config.h.in
135
 
fi
136
 
 
137
 
echo "*** Creating Makefile templates"
138
 
$AUTOMAKE || exit 1
139
 
 
140
 
if test "$UNSERMAKE" = no; then
141
 
  echo "*** Postprocessing Makefile templates"
142
 
  perl -w admin/am_edit || exit 1
143
 
fi
144
 
 
145
 
if egrep "^cvs-local:" $makefile_am >/dev/null; then \
146
 
  strip_makefile
147
 
  $MAKE -f $makefile_wo cvs-local top_srcdir=. || exit 1
148
 
fi
149
 
 
150
 
echo "*** Creating date/time stamp"
151
 
touch stamp-h.in
152
 
 
153
 
echo "*** Finished"
154
 
echo "    Don't forget to run ./configure"
155
 
echo "    If you haven't done so in a while, run ./configure --help"
156
 
}
157
 
 
158
 
dist()
159
 
{
160
 
check_autotool_versions
161
 
 
162
 
###
163
 
### First build all of the files necessary to do just "make"
164
 
###
165
 
acinclude_m4
166
 
if test -r configure.in.in; then
167
 
  rm -f configure.in
168
 
  create_subdirs
169
 
 
170
 
  if test -r Makefile.am.in; then
171
 
    if grep '\$(top_srcdir)/Makefile.am:' $makefile_am >/dev/null; then 
172
 
      strip_makefile
173
 
      $MAKE -f $makefile_wo top_srcdir=. ./Makefile.am || exit 1
174
 
    else
175
 
      Makefile_am
176
 
    fi
177
 
  fi
178
 
  configure_files
179
 
  if grep '\$(top_srcdir)/configure.in:' $makefile_am >/dev/null; then 
180
 
    strip_makefile
181
 
    $MAKE -f $makefile_wo top_srcdir=. ./configure.in || exit 1
182
 
  else
183
 
    configure_in
184
 
  fi
185
 
fi
186
 
$ACLOCAL $ACLOCALFLAGS
187
 
if egrep "^AM_CONFIG_HEADER" configure.in >/dev/null 2>&1; then
188
 
  echo "*** Creating config.h template"
189
 
  $AUTOHEADER || exit 1
190
 
  touch config.h.in
191
 
fi
192
 
$AUTOMAKE --foreign || exit 1
193
 
if test "$UNSERMAKE" = no; then
194
 
  echo "*** Postprocessing Makefile templates"
195
 
  perl -w admin/am_edit || exit 1
196
 
fi
197
 
call_and_fix_autoconf
198
 
touch stamp-h.in
199
 
if grep "^cvs-local:" $makefile_am >/dev/null; then
200
 
  strip_makefile
201
 
  $MAKE -f $makefile_wo cvs-local top_srcdir=.
202
 
fi
203
 
 
204
 
###
205
 
### Then make messages
206
 
###
207
 
if test -d po; then
208
 
 LIST=`find ./po -name "*.po"`
209
 
 for i in $LIST; do
210
 
  file2=`echo $i | sed -e "s#\.po#\.gmo#"`
211
 
  msgfmt -o $file2 $i || touch $file2
212
 
 done
213
 
fi
214
 
if grep "^cvs-dist-local:" $makefile_am >/dev/null; then
215
 
  strip_makefile
216
 
  $MAKE -f $makefile_wo cvs-dist-local top_srcdir=.
217
 
fi
218
 
}
219
 
 
220
 
subdir_dist()
221
 
{
222
 
$ACLOCAL $ACLOCALFLAGS
223
 
$AUTOHEADER
224
 
touch config.h.in
225
 
$AUTOMAKE
226
 
AUTOMAKE_STRING=`$AUTOMAKE --version | head -n 1`
227
 
case $AUTOMAKE_STRING in
228
 
  *unsermake* ) :
229
 
    ;;
230
 
  *)
231
 
     perl -w ../admin/am_edit --path=../admin
232
 
esac
233
 
call_and_fix_autoconf
234
 
touch stamp-h.in
235
 
}
236
 
 
237
 
configure_in()
238
 
{
239
 
rm -f configure.in configure.in.new
240
 
kde_use_qt_param=
241
 
test -f configure.files || { echo "need configure.files for configure.in"; exit 1; }
242
 
list=`fgrep -v "configure.in.bot" < configure.files | fgrep -v "configure.in.mid"`
243
 
: > configure.in.new
244
 
for file in $list; do 
245
 
  echo "dnl =======================================================" >> configure.in.new
246
 
  echo "dnl FILE: $file" >> configure.in.new
247
 
  echo "dnl =======================================================" >> configure.in.new
248
 
  echo "" >> configure.in.new
249
 
  cat $file >> configure.in.new
250
 
done
251
 
echo "KDE_CREATE_SUBDIRSLIST" >> configure.in.new
252
 
if test -f Makefile.am.in; then
253
 
  subdirs=`cat subdirs`
254
 
  for dir in $subdirs; do
255
 
    vdir=`echo $dir | sed -e 's,[-+.@],_,g'`
256
 
    echo "AM_CONDITIONAL($vdir""_SUBDIR_included, test \"x\$$vdir""_SUBDIR_included\" = xyes)" >> configure.in.new
257
 
    if test -f "$dir/configure.in"; then
258
 
        echo "if test \"x\$$vdir""_SUBDIR_included\" = xyes; then " >> configure.in.new
259
 
        echo "  AC_CONFIG_SUBDIRS($dir)" >> configure.in.new
260
 
        echo "fi" >> configure.in.new
261
 
    fi
262
 
  done
263
 
fi
264
 
 
265
 
echo "AC_CONFIG_FILES([ Makefile ])" >> configure.in.new
266
 
 
267
 
if test -f inst-apps; then
268
 
    topleveldirs=`cat inst-apps`
269
 
else
270
 
    topleveldirs=
271
 
    for dir in `ls -1d * | sort`; do
272
 
        if test "$dir" != "debian" && test -d $dir; then
273
 
            topleveldirs="$topleveldirs $dir"
274
 
        fi
275
 
    done
276
 
fi
277
 
 
278
 
for topleveldir in $topleveldirs; do 
279
 
  if test -f $topleveldir/configure.in; then
280
 
        continue
281
 
  fi
282
 
  if test -f $topleveldir/Makefile.am; then :; else
283
 
        continue
284
 
  fi
285
 
 
286
 
  mfs=`find $topleveldir -follow -name Makefile.am -print | fgrep -v "/." | \
287
 
       sed -e 's#\./##; s#/Makefile.am$##' | sort | sed -e 's#$#/Makefile#'`
288
 
  for i in $mfs; do
289
 
     echo "AC_CONFIG_FILES([ $i ])" >> configure.in.new
290
 
  done
291
 
done
292
 
 
293
 
files=`cat configure.files`
294
 
list=`egrep '^dnl AC_OUTPUT\(.*\)' $files | sed -e "s#^.*dnl AC_OUTPUT(\(.*\))#\1#"`
295
 
for file in $list; do 
296
 
    echo "AC_CONFIG_FILES([ $file ])" >>  configure.in.new
297
 
done
298
 
 
299
 
midfiles=`cat configure.files | fgrep "configure.in.mid"`
300
 
test -n "$midfiles" && cat $midfiles >> configure.in.new
301
 
 
302
 
echo "AC_OUTPUT" >> configure.in.new
303
 
modulename=
304
 
if test -f configure.in.in; then
305
 
   if head -n 2 configure.in.in | egrep "^#MIN_CONFIG\(.*\)$" > /dev/null; then
306
 
      kde_use_qt_param=`cat configure.in.in | sed -n -e "s/#MIN_CONFIG(\(.*\))/\1/p"`
307
 
   fi
308
 
   if head -n 2 configure.in.in | egrep "^#MIN_CONFIG" > /dev/null; then
309
 
      line=`grep "^AM_INIT_AUTOMAKE(" configure.in.in`
310
 
      if test -n "$line"; then
311
 
          modulename=`echo $line | sed -e "s#AM_INIT_AUTOMAKE(\([^,]*\),.*#\1#"`
312
 
          VERSION=`echo $line | sed -e "s#AM_INIT_AUTOMAKE([^,]*, *\([^)]*\)).*#\1#"`
313
 
      fi
314
 
      sed -e "s#AM_INIT_AUTOMAKE([^@].*#dnl PACKAGE set before#" \
315
 
          configure.in.new > configure.in && mv configure.in configure.in.new
316
 
   fi
317
 
fi
318
 
if test -z "$VERSION" || test "$VERSION" = "@VERSION@"; then
319
 
     VERSION="\"3.5.5\""
320
 
fi
321
 
if test -z "$modulename" || test "$modulename" = "@MODULENAME@"; then
322
 
   modulename=`pwd`; 
323
 
   modulename=`basename $modulename`
324
 
   esc_VERSION=`echo $VERSION | sed -e "s#[^.0-9a-zA-Z]##g"`
325
 
   modulename=`echo $modulename | sed -e "s#-$esc_VERSION##"`   
326
 
 
327
 
fi
328
 
if test -n "$kde_use_qt_param"; then
329
 
      sed -e "s#^dnl KDE_USE_QT#KDE_USE_QT($kde_use_qt_param)#" \
330
 
        configure.in.new > configure.in && mv configure.in configure.in.new
331
 
fi
332
 
sed -e "s#@MODULENAME@#$modulename#" configure.in.new |
333
 
        sed -e "s#@VERSION@#$VERSION#" > configure.in
334
 
botfiles=`cat configure.files | egrep "configure.in.bot"`
335
 
test -n "$botfiles" && cat $botfiles >> configure.in
336
 
cat $admindir/configure.in.bot.end >> configure.in
337
 
rm -f configure.in.new
338
 
}
339
 
 
340
 
configure_files()
341
 
{
342
 
echo "*** Creating configure.files"
343
 
admindir=NO
344
 
for i in . .. ../.. ../../..; do
345
 
  if test -x $i/admin; then admindir=$i/admin; break; fi
346
 
done
347
 
rm -f configure.files
348
 
touch configure.files
349
 
if test -f configure.in.in && head -n 2 configure.in.in | grep "^#MIN_CONFIG" > /dev/null; then
350
 
        echo $admindir/configure.in.min >> configure.files
351
 
fi
352
 
test -f configure.in.in && echo configure.in.in >> configure.files
353
 
# we collect files in the subdirs and do some sorting tricks, so subsubdirs come after subdirs
354
 
if test -f inst-apps; then
355
 
   inst=`cat inst-apps`
356
 
   list=""
357
 
   for i in $inst; do
358
 
      list="$list `find $i/ -follow -name "configure.in.in" -o -name "configure.in.bot" -o -name "configure.in.mid" | \
359
 
                sed -e "s,/configure,/aaaconfigure," | sort | sed -e "s,/aaaconfigure,/configure,"`"
360
 
   done
361
 
else
362
 
   list=`find . -follow -name "configure.in.in" -o -name "configure.in.bot" -o -name "configure.in.mid" | \
363
 
                sed -e "s,/configure,/aaaconfigure," | sort | sed -e "s,/aaaconfigure,/configure,"`
364
 
fi
365
 
for i in $list; do if test -f $i && test `dirname $i` != "." ; then
366
 
  echo $i >> configure.files
367
 
fi; done
368
 
test -f configure.in.mid && echo configure.in.mid >> configure.files
369
 
test -f configure.in.bot && echo configure.in.bot >> configure.files
370
 
if test ! -s configure.files; then
371
 
   echo "There are no files to build a configure. Please check your checkout."
372
 
   exit 1
373
 
fi
374
 
}
375
 
 
376
 
create_subdirs()
377
 
{
378
 
if grep '\$(top_srcdir)/subdirs:' $makefile_am >/dev/null; then 
379
 
    # as many modules contain rules to create subdirs without any
380
 
    # dependencies make won't create it unless there is no file.
381
 
    # so we check if that's a dummy rule or one that works
382
 
    rm -f subdirs.cvs.sh.$$
383
 
    if test -f subdirs; then
384
 
        mv subdirs subdirs.cvs.sh.$$
385
 
    fi
386
 
    strip_makefile
387
 
    $MAKE -f $makefile_wo top_srcdir=. ./subdirs || exit 1
388
 
    if test -f subdirs.cvs.sh.$$; then
389
 
        if test -s subdirs; then
390
 
            rm subdirs.cvs.sh.$$ 
391
 
        else
392
 
            mv subdirs.cvs.sh.$$ subdirs
393
 
        fi
394
 
    fi
395
 
else
396
 
    subdirs
397
 
fi
398
 
}
399
 
 
400
 
subdirs()
401
 
{
402
 
dirs=
403
 
idirs=
404
 
if test -f inst-apps; then
405
 
   idirs=`cat inst-apps`
406
 
else
407
 
   idirs=`ls -1 | sort`
408
 
fi
409
 
 
410
 
compilefirst=`sed -ne 's#^COMPILE_FIRST[ ]*=[ ]*##p' $makefile_am | head -n 1`
411
 
compilelast=`sed -ne 's#^COMPILE_LAST[ ]*=[ ]*##p' $makefile_am | head -n 1`
412
 
for i in $idirs; do
413
 
    if test -f $i/Makefile.am; then
414
 
       case " $compilefirst $compilelast " in
415
 
         *" $i "*) ;;
416
 
         *) dirs="$dirs $i"
417
 
       esac
418
 
    fi
419
 
done
420
 
 
421
 
: > ./_SUBDIRS
422
 
 
423
 
for d in $compilefirst; do
424
 
   echo $d >> ./_SUBDIRS
425
 
done
426
 
 
427
 
(for d in $dirs; do 
428
 
   list=`sed -ne "s#^COMPILE_BEFORE_$d""[ ]*=[ ]*##p" $makefile_am | head -n 1`
429
 
   for s in $list; do
430
 
      echo $s $d
431
 
   done
432
 
   list=`sed -ne "s#^COMPILE_AFTER_$d""[ ]*=[ ]*##p" $makefile_am | head -n 1`
433
 
   for s in $list; do
434
 
      echo $d $s
435
 
   done
436
 
   echo $d $d
437
 
done ) | tsort >> ./_SUBDIRS
438
 
 
439
 
for d in $compilelast; do
440
 
   echo $d >> ./_SUBDIRS
441
 
done
442
 
 
443
 
if test -r subdirs && cmp -s subdirs _SUBDIRS; then
444
 
    rm -f _SUBDIRS
445
 
fi
446
 
test -r _SUBDIRS && mv _SUBDIRS subdirs || true
447
 
}
448
 
 
449
 
Makefile_am()
450
 
{
451
 
if test -f Makefile.am.in; then
452
 
  compilefirst=`sed -ne 's#^COMPILE_FIRST[ ]*=[ ]*##p' $makefile_am | head -n 1`
453
 
  compilelast=`sed -ne 's#^COMPILE_LAST[ ]*=[ ]*##p' $makefile_am | head -n 1`
454
 
 
455
 
  idirs=
456
 
  dirs=
457
 
  if test -f inst-apps; then
458
 
     idirs=`cat inst-apps`
459
 
  else
460
 
     idirs=`cat subdirs`
461
 
  fi
462
 
  for i in $idirs; do
463
 
    case " $compilefirst $compilelast " in
464
 
      *" $i "*) ;;
465
 
      *) dirs="$dirs $i"
466
 
    esac
467
 
  done
468
 
 
469
 
  adds=`fgrep '$(top_srcdir)/acinclude.m4:' Makefile.am.in | sed -e 's,^[^:]*: *,,; s,\$(top_srcdir)/,,g'`
470
 
  if echo "$adds" | fgrep "*" >/dev/null ; then
471
 
    adds=`ls -d -1 $adds 2>/dev/null`
472
 
    fgrep -v  '$(top_srcdir)/acinclude.m4:' Makefile.am.in > Makefile.am.in.adds
473
 
    str='$(top_srcdir)/acinclude.m4:'
474
 
    for add in $adds; do 
475
 
        str="$str \$(top_srcdir)/$add"
476
 
    done
477
 
    echo $str >> Makefile.am.in.adds
478
 
  else
479
 
    cat Makefile.am.in > Makefile.am.in.adds
480
 
  fi
481
 
 
482
 
  cat Makefile.am.in.adds | \
483
 
      sed -e 's,^\s*\(COMPILE_BEFORE.*\),# \1,' | \
484
 
      sed -e 's,^\s*\(COMPILE_AFTER.*\),# \1,' > Makefile.am
485
 
    echo "SUBDIRS="'$(TOPSUBDIRS)' >> Makefile.am
486
 
  rm Makefile.am.in.adds
487
 
fi
488
 
}
489
 
 
490
 
acinclude_m4()
491
 
{
492
 
  echo "*** Creating acinclude.m4"
493
 
  adds=
494
 
  if grep '\$(top_srcdir)/acinclude.m4:' $makefile_am >/dev/null; then 
495
 
    strip_makefile
496
 
    rm -f acinclude.m4
497
 
    adds=`grep '\$(top_srcdir)/acinclude.m4:' $makefile_wo | sed -e 's,^[^:]*: *,,; s,\$(top_srcdir),.,g'`
498
 
    if echo $adds | fgrep "*" >/dev/null ; then
499
 
      adds=`ls -d -1 $adds 2>/dev/null`
500
 
    else
501
 
      $MAKE -f $makefile_wo top_srcdir=. ./acinclude.m4 || exit 1
502
 
    fi
503
 
  else
504
 
    rm -f acinclude.m4
505
 
  fi
506
 
  # if it wasn't created up to now, then we do it better
507
 
  if test ! -f acinclude.m4; then
508
 
     cat admin/acinclude.m4.in admin/libtool.m4.in admin/pkg.m4.in $adds > acinclude.m4
509
 
  fi
510
 
}
511
 
 
512
 
package_merge()
513
 
{
514
 
catalogs=$POFILES
515
 
for cat in $catalogs; do
516
 
  msgmerge -o $cat.new $cat $PACKAGE.pot
517
 
  if test -s $cat.new; then
518
 
    grep -v "\"POT-Creation" $cat.new > $cat.new.2
519
 
    grep -v "\"POT-Creation" $cat >> $cat.new.1
520
 
    if diff $cat.new.1 $cat.new.2; then
521
 
        rm $cat.new
522
 
    else
523
 
        mv $cat.new $cat
524
 
    fi
525
 
    rm -f $cat.new.1 $cat.new.2
526
 
  fi
527
 
done
528
 
}
529
 
 
530
 
extract_messages()
531
 
{
532
 
podir=${podir:-$PWD/po}
533
 
files=`find . -name Makefile.am | xargs egrep -l '^messages:' `
534
 
dirs=`for i in $files; do echo \`dirname $i\`; done`
535
 
tmpname="$PWD/messages.log"
536
 
if test -z "$EXTRACTRC"; then EXTRACTRC=extractrc ; fi
537
 
if test -z "$PREPARETIPS"; then PREPARETIPS=preparetips ; fi
538
 
export EXTRACTRC PREPARETIPS
539
 
 
540
 
for subdir in $dirs; do
541
 
  test -z "$VERBOSE" || echo "Making messages in $subdir"
542
 
  (cd $subdir
543
 
   if test -n "`grep -e '^messages:.*rc.cpp' Makefile.am`"; then
544
 
        $EXTRACTRC *.rc *.ui *.kcfg > rc.cpp
545
 
   else
546
 
        candidates=`ls -1 *.rc *.ui *.kcfg 2>/dev/null`
547
 
        if test -n "$candidates"; then
548
 
            echo "$subdir has *.rc, *.ui or *.kcfg files, but not correct messages line"
549
 
        fi
550
 
   fi
551
 
   if find . -name \*.c\* -o -name \*.h\* | fgrep -v ".svn" | xargs fgrep -s -q KAboutData ; then
552
 
        echo -e 'i18n("_: NAME OF TRANSLATORS\\n"\n"Your names")\ni18n("_: EMAIL OF TRANSLATORS\\n"\n"Your emails")' > _translatorinfo.cpp
553
 
   else echo " " > _translatorinfo.cpp
554
 
   fi
555
 
   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
556
 
 
557
 
   kdepotpath=${includedir:-`kde-config --expandvars --install include`}/kde.pot
558
 
   if ! test -f $kdepotpath; then
559
 
        kdepotpath=`kde-config --expandvars --prefix`/include/kde.pot
560
 
   fi
561
 
 
562
 
   $MAKE -s -f _transMakefile podir=$podir EXTRACTRC="$EXTRACTRC" PREPARETIPS="$PREPARETIPS" srcdir=. \
563
 
        XGETTEXT="${XGETTEXT:-xgettext} --foreign-user -C -ci18n -ki18n -ktr2i18n -kI18N_NOOP -kI18N_NOOP2 -kaliasLocale -x $kdepotpath" messages
564
 
   exit_code=$?
565
 
   if test "$exit_code" != 0; then
566
 
       echo "make exit code: $exit_code"
567
 
   fi
568
 
   ) 2>&1 | grep -v '^make\[1\]' > $tmpname
569
 
   test -s $tmpname && { echo $subdir ; cat "$tmpname"; }
570
 
   test -f $subdir/rc.cpp && rm -f $subdir/rc.cpp
571
 
   rm -f $subdir/_translatorinfo.cpp
572
 
   rm -f $subdir/_transMakefile
573
 
done
574
 
rm -f $tmpname
575
 
}
576
 
 
577
 
package_messages()
578
 
{
579
 
rm -rf po.backup
580
 
mkdir po.backup
581
 
 
582
 
for i in `ls -1 po/*.pot 2>/dev/null | sed -e "s#po/##"`; do
583
 
  egrep -v '^#[^,]' po/$i | egrep '^.*[^ ]+.*$' | grep -v "\"POT-Creation" > po.backup/$i
584
 
  cat po/$i > po.backup/backup_$i
585
 
  touch -r po/$i po.backup/backup_$i
586
 
  rm po/$i
587
 
done
588
 
 
589
 
extract_messages
590
 
 
591
 
for i in `ls -1 po.backup/*.pot 2>/dev/null | sed -e "s#po.backup/##" | egrep -v '^backup_'`; do
592
 
  test -f po/$i || echo "disappeared: $i"
593
 
done
594
 
for i in `ls -1 po/*.pot 2>/dev/null | sed -e "s#po/##"`; do
595
 
  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
596
 
  #msgmerge -q -o po/$i po/$i po/$i
597
 
  egrep -v '^#[^,]' po/$i | egrep '^.*[^ ]+.*$' | grep -v "\"POT-Creation" > temp.pot
598
 
  if test -f po.backup/$i && ! cmp -s temp.pot po.backup/$i; then
599
 
    echo "will update $i"
600
 
  else
601
 
    if test -f po.backup/backup_$i; then
602
 
      test -z "$VERBOSE" || echo "I'm restoring $i"
603
 
      mv po.backup/backup_$i po/$i
604
 
      rm po.backup/$i
605
 
    else
606
 
      echo "will add $i"
607
 
    fi
608
 
  fi
609
 
done
610
 
rm -f temp.pot
611
 
rm -rf po.backup
612
 
}
613
 
 
614
 
# Make sure that sorting is always done the same way
615
 
LC_ALL=C
616
 
export LC_ALL
617
 
unset LANG || :
618
 
unset LC_CTYPE || :
619
 
unset LANGUAGE || :
620
 
 
621
 
unset CDPATH || :
622
 
admindir=`echo "$0" | sed 's%[\\/][^\\/][^\\/]*$%%'`
623
 
test "x$admindir" = "x$0" && admindir=.
624
 
 
625
 
test "x$MAKE" = x && MAKE=make
626
 
makefile_am=Makefile.am
627
 
makefile_wo=Makefile.am.wo
628
 
if test -f Makefile.am.in; then
629
 
  makefile_am=Makefile.am.in
630
 
  makefile_wo=Makefile.am.in.wo
631
 
  rm -f $makefile_wo
632
 
fi
633
 
 
634
 
# Call script to find autoconf and friends.  Uses eval since the script outputs
635
 
# sh-compatible code.
636
 
eval `$admindir/detect-autoconf.pl`
637
 
 
638
 
###
639
 
### Main
640
 
###
641
 
 
642
 
arg=`echo $1 | tr .- __`
643
 
case $arg in
644
 
  cvs | dist | subdir_dist | configure_in | configure_files | subdirs | \
645
 
  cvs_clean | package_merge | package_messages | Makefile_am | acinclude_m4 | extract_messages ) $arg ;;
646
 
  configure ) call_and_fix_autoconf ;;
647
 
  * ) echo "Usage: cvs.sh <target>"
648
 
      echo "Target can be one of:"
649
 
      echo "    cvs svn dist"
650
 
      echo "    configure.in configure.files"
651
 
      echo "    package-merge package-messages"
652
 
      echo ""
653
 
      echo "Usage: anything but $1"
654
 
      exit 1 ;;
655
 
esac
656
 
 
657
 
if test -f $makefile_wo; then
658
 
  rm $makefile_wo
659
 
fi
660
 
 
661
 
exit 0