Ticket #4619: (autogen.sh) - improve creation of POTFILES.in

- current POTFILES.in file detection can output wrong filename
     xgettext output
     #: src/background.c:221 src/filemanager/file.c:858 src/filemanager/file.c:952
     result in
     src/background.csrc/filemanager/file.csrc/filemanager/file.c
- simplify POTFILES.in file detection by using grep only
- find command search files only
- find/grep option should be Solaris OS friendly
- move POTFILES.in creating to configure.ac (more BUILD friendly and future autogen.sh get rid possibility)
- autoconf AC_CONFIG_COMMANDS_POST support since <2.64
- comparing current vs simplify grep file detection result in additional files:
    lib/search/regex.c
    lib/widget/history.c
    lib/widget/quick.h
    src/diffviewer/internal.h
    src/diffviewer/search.c
    src/editor/editdraw.c
    src/editor/etags.c
    src/filemanager/command.c
    src/vfs/tar/tar.c
    src/viewer/lib.c
    tests/src/execute__common.c
    tests/src/execute__execute_with_vfs_arg.c

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
Andreas Mohr 2024-12-17 15:00:00 +00:00 committed by Yury V. Zaytsev
parent 17c2a65cd5
commit fe9e468296
3 changed files with 16 additions and 11 deletions

View File

@ -13,17 +13,6 @@ ${AUTORECONF:-autoreconf} --verbose --install --force -I m4 ${AUTORECONF_FLAGS}
# Customize the INSTALL file
rm -f INSTALL && ln -s doc/INSTALL .
# Generate po/POTFILES.in
if ! xgettext -h 2>&1 | grep -- '--keyword' >/dev/null ; then
echo "gettext is unable to extract translations, set XGETTEXT to GNU gettext!" >&2
touch po/POTFILES.in
else
${XGETTEXT:-xgettext} --keyword=_ --keyword=N_ --keyword=Q_ --output=- \
`find . -name '*.[ch]'` | ${SED-sed} -ne '/^#:/{s/#://;s/:[0-9]*/\
/g;s/ //g;p;}' | \
grep -v '^$' | sort | uniq >po/POTFILES.in
fi
"$srcdir/version.sh" "$srcdir"
if test -x "$srcdir/configure.mc"; then

View File

@ -733,6 +733,10 @@ tests/src/vfs/extfs/helpers-list/misc/Makefile
tests/src/vfs/ftpfs/Makefile
])
AC_CONFIG_COMMANDS_POST([
"${srcdir}"/po/create-potfiles_in.sh "${srcdir}"
])
AC_OUTPUT
AC_MSG_NOTICE([

12
po/create-potfiles_in.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
set -e
if [ -z "$1" ] ;then
echo "usage: $0 <toplevel-source-dir>"
exit 1
fi
cd "$1" && \
"${FIND:-find}" . -type f -name '*.[ch]' -exec \
"${GREP:-grep}" -l '_\s*(\s*"' {} + | \
"${SORT:-sort}" | "${UNIQ:-uniq}" > po/POTFILES.in