~ubuntu-branches/ubuntu/precise/gtk-qt-engine/precise

« back to all changes in this revision

Viewing changes to admin/cvs.sh

  • Committer: Bazaar Package Importer
  • Author(s): Christoffer Sawicki
  • Date: 2005-01-02 22:24:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050102222409-2wsno0q9ywn0ac2e
Tags: upstream-0.60
ImportĀ upstreamĀ versionĀ 0.60

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