# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING. If not, write to
-# the Free Software Foundation, 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
+# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
# Always operate in the C locale.
LANG=C
package=$2
srcdir=$3
+case `$xgettext --version | sed -e 1q | sed -e 's/^\([^0-9]*\)//'` in
+ 0.14.[5-9]* | 0.14.[1-9][0-9]* | 0.1[5-9]* | 0.[2-9][0-9]* | [1-9].*) : ;;
+ *) echo "$xgettext is too old. GNU xgettext 0.14.5 is required"
+ exit 1 ;;
+esac
+
nl='
'
pwd=`${PWDCMD-pwd}`
kopt=$pwd/$T/keyword-options
+kopt2=$pwd/$T/keyword2-options
emsg=$pwd/$T/emsgids.c
posr=$pwd/$T/po-sources
-
-# Extra files to scan
-extra_files=$pwd/options.c
+pottmp1=$pwd/$T/tmp1.pot
+pottmp2=$pwd/$T/tmp2.pot
+pottmp=$pwd/$T/tmp.pot
# Locate files to scan, and generate the list. All .c, .h, and .def files
# in $srcdir are examined, likewise $srcdir/config and $srcdir/config/*
do eval echo $dir$glob
done
done;
- echo $extra_files;
} | tr ' ' "$nl" | grep -v '\*' |
- $AWK -v excl=po/EXCLUDES -v posr=$posr -v kopt=$kopt -v emsg=$emsg '
+ $AWK -v excl=po/EXCLUDES -v posr=$posr -v kopt=$kopt -v kopt2=$kopt2 -v emsg=$emsg '
function keyword_option(line) {
paren_index = index(line, "(")
name = substr(line, 1, paren_index - 1)
for (n = 1; sub(/^[^,]*,/, "", args); n++) {
continue
}
+ format=""
+ if (args ~ /g$/)
+ format="gcc-internal-format"
+ else if (args ~ /noc$/)
+ format="no-c-format"
+ else if (args ~ /c$/)
+ format="c-format"
+
+ if (n == 1) { keyword = "--keyword=" name }
+ else { keyword = "--keyword=" name ":" n }
+ if (format) {
+ keyword=keyword "\n--flag=" name ":" n ":" format
+ }
- if (n == 1) { keyword = name }
- else { keyword = name ":" n }
-
- if (! keyword_seen[keyword]++) {
- print "--keyword=" keyword > kopt
+ if (! keyword_seen[name]) {
+ if (format == "gcc-internal-format")
+ print keyword > kopt2
+ else
+ print keyword > kopt
+ keyword_seen[name] = keyword
+ } else if (keyword_seen[name] != keyword) {
+ printf("%s used incompatibly as both %s and %s\n",
+ name, keyword_seen[name], keyword)
+ exit (1)
}
}
}
print emsg > posr
}'
-)
+) || exit
+
+echo "scanning option files..." >&2
+
+( cd $srcdir; find . -name '*.opt' -print |
+ $AWK '{
+ file = $1
+ lineno = 1
+ field = 0
+ while (getline < file) {
+ if (/^[ \t]*(;|$)/ || !/^[^ \t]/) {
+ field = 0
+ } else {
+ if (field == 2) {
+ line = $0
+ gsub(".*\t", "", line)
+ printf("#line %d \"%s\"\n", lineno, file)
+ printf("_(\"%s\")\n", line)
+ }
+ field++;
+ }
+ lineno++;
+ }
+ }') >> $emsg
# Run the xgettext command, with temporary added as a file to scan.
echo "running xgettext..." >&2
--add-comments `cat $kopt` --files-from=$posr \
--copyright-holder="Free Software Foundation, Inc." \
--msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
- --language=c -o po/$package.pot.tmp
+ --language=c -o $pottmp1
+$xgettext --default-domain=$package --directory=$srcdir \
+ --add-comments --keyword= `cat $kopt2` --files-from=$posr \
+ --copyright-holder="Free Software Foundation, Inc." \
+ --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
+ --language=GCC-source -o $pottmp2
+$xgettext --default-domain=$package \
+ --add-comments $pottmp1 $pottmp2 \
+ --copyright-holder="Free Software Foundation, Inc." \
+ --msgid-bugs-address="http://gcc.gnu.org/bugs.html" \
+ --language=PO -o $pottmp
# Remove local paths from .pot file.
-sed "s:$srcdir/::g;s:$pwd/::g;" <po/$package.pot.tmp >po/$package.pot
-rm po/$package.pot.tmp
+sed "s:$srcdir/::g;s:$pwd/::g;" <$pottmp >po/$package.pot