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