1 #!/bin/sh
   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License, Version 1.0 only
   7 # (the "License").  You may not use this file except in compliance
   8 # with the License.
   9 #
  10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11 # or http://www.opensolaris.org/os/licensing.
  12 # See the License for the specific language governing permissions
  13 # and limitations under the License.
  14 #
  15 # When distributing Covered Code, include this CDDL HEADER in each
  16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17 # If applicable, add the following below this CDDL HEADER, with the
  18 # fields enclosed by brackets "[]" replaced with your own identifying
  19 # information: Portions Copyright [yyyy] [name of copyright owner]
  20 #
  21 # CDDL HEADER END
  22 #
  23 #
  24 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 
  28 #
  29 # Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  30 #
  31 
  32 XGETTEXT=${XGETTEXT:-xgettext}
  33 GETTEXT=${GETTEXT:-gettext}
  34 MSGDIR=$1
  35 
  36 #
  37 # Change Directory
  38 #
  39         cd ./port/gen
  40         rm -f *.po
  41 
  42 #
  43 #       get list of files
  44 #
  45 FILES=`grep ${GETTEXT} *.c | sed "s/:.*//" | sort | sed "s/\.c//" | uniq`
  46 
  47 
  48 #
  49 #       Create po files
  50 #               No need for options for xgettext
  51 #
  52 for     i in ${FILES}
  53 do
  54         cat ${i}.c | sed "s/_libc_gettext/gettext/" > ${i}.i
  55         ${XGETTEXT} ${i}.i
  56         cat messages.po | sed "/^domain/d" > ${i}.po
  57         rm -f ${i}.i messages.po
  58 done
  59 
  60 #
  61 #       Create po files
  62 #               Use -a
  63 #
  64 
  65 # First, create errlst.c, if it doesn't exist.
  66 # new_list.c is created as a side effect
  67 if [ ! -f errlst.c ]; then
  68         awk -f errlist.awk errlist
  69         rmerr="errlst.c new_list.c"
  70 else
  71         rmerr=
  72 fi
  73 
  74 for     i in siglist errlst
  75 do
  76         cat ${i}.c | sed "s/_libc_gettext/gettext/" > ${i}.i
  77         ${XGETTEXT} -a  ${i}.i
  78         cat messages.po | sed "/^domain/d" > ${i}.po
  79         rm -f ${i}.i messages.po
  80 done
  81 
  82 #
  83 #       Copy .po files
  84 #
  85         cp *.po         ${MSGDIR}
  86 
  87 #
  88 #       And remove them
  89 #
  90         rm -f *.po ${rmerr}
  91 
  92 #
  93 # Change Directory
  94 #
  95         cd ../locale
  96         rm -f messages.po regerror.po
  97 
  98         ${XGETTEXT} -a regerror.c
  99         cat messages.po | sed "/^domain/d" > regerror.po
 100         rm -f regerror.i messages.po
 101         
 102 #
 103 # Copy .po file
 104 #
 105         cp regerror.po ${MSGDIR}
 106 
 107 # And remove it         
 108 
 109         rm -f regerror.po