Merge pull request #15 from wdlkmpx/patch1

improvements to the build system (autotools)
This commit is contained in:
Eugene Morozov 2021-07-13 19:10:20 +03:00 committed by GitHub
commit 3b2183777b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 265 additions and 51 deletions

7
.gitignore vendored
View File

@ -1,9 +1,9 @@
*.so
*.o
ar-lib
po/Makefile.in.in
po/POTFILES
po/*.gmo
*.gmo
*.mo
stamp-it
compile
config.guess
@ -21,9 +21,12 @@ libtool
ltmain.sh
Makefile
Makefile.in
!po/Makefile.in
m4
missing
stamp-h1
.deps
.libs
src/gtkballs
autoconf
autoconf-m4

View File

@ -16,4 +16,4 @@ install-data-hook:
if [ "${UID}" = 0 ]; then chgrp games $(DESTDIR)$(localstatedir)/gtkballs-scores; fi
chmod 0664 $(DESTDIR)$(localstatedir)/gtkballs-scores
ACLOCAL_AMFLAGS = -I m4
ACLOCAL_AMFLAGS = -I autoconf-m4

View File

@ -1,6 +1,54 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
# special params:
# - po update .pot & po files
# - linguas update LINGUAS and POTFILES.in
# - release create release tarball
#===========================================================================
if test "$1" = "po" ; then
# Before creating a release you might want to update the po files
test -d "po/" || exit
#git clean -dfx
test -f ./configure || ./autogen.sh
test -f ./po/Makefile || ./configure
find po -name '*.pot' -delete # updates don't happen if pot files already exist...
make -C po update-po
# cleanup
rm -f po/*.po~
#sed -i '/#~ /d' po/*.po
#git clean -dfx
exit
fi
if test "$1" = "linguas" ; then
./po/Makefile.in.gen
exit $?
fi
#===========================================================================
if test "$1" == "release" || test "$1" == "--release" ; then
pkg="$(grep -m 1 AC_INIT configure.ac | cut -f 2 -d '[' | cut -f 1 -d ']')"
ver="$(grep -m 1 AC_INIT configure.ac | cut -f 3 -d '[' | cut -f 1 -d ']')"
ver=$(echo $ver)
dir=${pkg}-${ver}
rm -rf ../$dir
mkdir -p ../$dir
cp -rf $PWD/* ../$dir
( cd ../$dir ; ./autogen.sh )
cd ..
tar -Jcf ${dir}.tar.xz $dir
exit
fi
#===========================================================================
# autogen.sh [--verbose]
#===========================================================================
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
cd $srcdir
@ -18,27 +66,30 @@ if test "$1" == "verbose" || test "$1" == "--verbose" ; then
verbose2='--debug'
fi
# pre-create some dirs / files
auxdir='.'
if grep -q "AC_CONFIG_AUX_DIR" configure.ac ; then
auxdir="$(grep AC_CONFIG_AUX_DIR configure.ac | cut -f 2 -d '[' | cut -f 1 -d ']')"
fi
mkdir -p ${auxdir}
touch ${auxdir}/config.rpath
m4dir="$(grep AC_CONFIG_MACRO_DIR configure.ac | cut -f 2 -d '[' | cut -f 1 -d ']')"
if test -n "$m4dir" ; then
mkdir -p ${m4dir}
fi
# Get all required m4 macros required for configure
$LIBTOOLIZE ${verbose} --copy --force || exit 1
$ACLOCAL ${verbose} -I m4 || exit 1
if grep -q LT_INIT configure.ac ; then
$LIBTOOLIZE ${verbose} --copy --force || exit 1
fi
$ACLOCAL ${verbose} || exit 1
# Generate config.h.in
$AUTOHEADER ${verbose} --force || exit 1
# Generate Makefile.in's
touch config.rpath
$AUTOMAKE ${verbose} --add-missing --copy --force || exit 1
if grep "IT_PROG_INTLTOOL" configure.ac >/dev/null ; then
intltoolize ${verbose2} -c --automake --force || exit 1
# po/Makefile.in.in has these lines:
# mostlyclean:
# rm -f *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp
# prevent $(GETTEXT_PACKAGE).pot from being deleted by `make clean`
sed 's/pox \$(GETTEXT_PACKAGE).pot/pox/' po/Makefile.in.in > po/Makefile.in.inx
mv -f po/Makefile.in.inx po/Makefile.in.in
fi
# generate configure
$AUTOCONF ${verbose} --force || exit 1

13
configure.ac vendored
View File

@ -2,19 +2,16 @@
# Process this file with autoconf to produce a configure script.
AC_INIT([gtkballs],[3.1.5],[])
AC_CONFIG_AUX_DIR([autoconf])
AC_CONFIG_MACRO_DIR([autoconf-m4])
AM_INIT_AUTOMAKE([-Wall foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_HEADER(config.h)
AC_CONFIG_MACRO_DIR([m4])
AM_GNU_GETTEXT([external])
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
m4_ifdef([AM_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
LT_INIT
# Init intltool
IT_PROG_INTLTOOL
#L#T_INIT
# Checks for programs.
AC_PROG_CC
@ -65,8 +62,6 @@ GETTEXT_PACKAGE=gtkballs
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
AM_GLIB_GNU_GETTEXT
case "$CC" in
gcc*) CPPFLAGS="$CPPFLAGS -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers" ;;
*) ;;
@ -79,7 +74,7 @@ AC_CONFIG_FILES([
src/Makefile
doc/Makefile
doc/gtkballs.6x
po/Makefile.in
po/Makefile
gtkballs.spec
gtkballs-data/Makefile
])

View File

@ -1,2 +0,0 @@
# Set of available languages.
ru fr de pl nl

88
po/Makefile.in Normal file
View File

@ -0,0 +1,88 @@
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
@SET_MAKE@
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
datadir = @datadir@
localedir = @localedir@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
GMSGFMT = @GMSGFMT@
MSGFMT = @MSGFMT@
#MSGFMT_OPTS = -c
XGETTEXT = @XGETTEXT@
MSGMERGE = msgmerge
MOFILES = de.mo fr.mo nl.mo pl.mo ru.mo
LINGUAS = de fr nl pl ru
POTFILES = ../src/about.c ../src/gtkballs.c ../src/gtkballs.h ../src/halloffame.c ../src/inputname.c ../src/mainmenu.c ../src/mainwin.c ../src/preferences.c ../src/prefs.c ../src/rules.c ../src/rulesdialog.c ../src/savedialog.c ../src/scoreboard.c
#.SUFFIXES: .po .gmo .mo
#.po.mo:
# $(GMSGFMT) $(MSGFMT_OPTS) -o `echo $* | sed "s,.*/,,"`.mo $<
all: all-@USE_NLS@
all-yes: $(MOFILES)
all-no:
$(GETTEXT_PACKAGE).pot: $(POTFILES)
$(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) \
--add-comments --keyword=_ --keyword=N_ --from-code=UTF-8 \
-o $(GETTEXT_PACKAGE).pot $(POTFILES)
install: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
catalogs="$(LINGUAS)"; \
for cat in $$catalogs; do \
dir=$(DESTDIR)$(localedir)/$$cat/LC_MESSAGES; \
mkdir -p $$dir; \
$(INSTALL_DATA) $$cat.mo $$dir/$(GETTEXT_PACKAGE).mo; \
echo "installing $$cat.mo as $$dir/$(GETTEXT_PACKAGE).mo"; \
done
uninstall:
catalogs="$(LINGUAS)"; \
for cat in $$catalogs; do \
echo "rm -f $(DESTDIR)$(localedir)/$$cat/LC_MESSAGES/$(GETTEXT_PACKAGE).mo"; \
rm -f $(DESTDIR)$(localedir)/$$cat/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \
done
mostlyclean:
rm -f *.pox *.old.po *.new.po *.mo *.gmo *.msg *.cat *.cat.m
clean: mostlyclean
distclean: clean
rm -f Makefile POTFILES
update-po: Makefile
rm -f $(GETTEXT_PACKAGE).pot
$(MAKE) $(GETTEXT_PACKAGE).pot
catalogs="$(LINGUAS)"; \
for lang in $$catalogs; do \
printf " %s " "$$lang"; \
if $(MSGMERGE) $$lang.po $(GETTEXT_PACKAGE).pot -o $$lang.new.po; then \
mv -f $$lang.new.po $$lang.po || exit 1; \
else \
echo "msgmerge for $$lang failed!"; \
rm -f $$lang.new.po; \
fi; \
done
de.mo:
$(GMSGFMT) $(MSGFMT_OPTS) -o de.mo de.po
fr.mo:
$(GMSGFMT) $(MSGFMT_OPTS) -o fr.mo fr.po
nl.mo:
$(GMSGFMT) $(MSGFMT_OPTS) -o nl.mo nl.po
pl.mo:
$(GMSGFMT) $(MSGFMT_OPTS) -o pl.mo pl.po
ru.mo:
$(GMSGFMT) $(MSGFMT_OPTS) -o ru.mo ru.po

97
po/Makefile.in.gen Executable file
View File

@ -0,0 +1,97 @@
#!/bin/sh
# https://unlicense.org
cd $(dirname "$0")
POFILES="$(ls *.po)"
MOFILES="$(echo "$POFILES" | sed 's/\.po$/.mo/')"
LINGUAS="$(echo "$POFILES" | sed 's/\.po$//')"
filez=$(find .. -type f -name '*.h' -or -name '*.c' -or -name '*.cc' -or -name '*.cpp' -or -name '*.hh')
POTFILES="$(grep '_(' $filez | sed -e 's%^\./%%' -e 's%:.*%%' | sort -u)"
echo '
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
@SET_MAKE@
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
datadir = @datadir@
localedir = @localedir@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
GMSGFMT = @GMSGFMT@
MSGFMT = @MSGFMT@
#MSGFMT_OPTS = -c
XGETTEXT = @XGETTEXT@
MSGMERGE = msgmerge
MOFILES = '${MOFILES}'
LINGUAS = '${LINGUAS}'
POTFILES = '${POTFILES}'
#.SUFFIXES: .po .gmo .mo
#.po.mo:
# $(GMSGFMT) $(MSGFMT_OPTS) -o `echo $* | sed "s,.*/,,"`.mo $<
all: all-@USE_NLS@
all-yes: $(MOFILES)
all-no:
$(GETTEXT_PACKAGE).pot: $(POTFILES)
$(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) \
--add-comments --keyword=_ --keyword=N_ --from-code=UTF-8 \
-o $(GETTEXT_PACKAGE).pot $(POTFILES)
install: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
catalogs="$(LINGUAS)"; \
for cat in $$catalogs; do \
dir=$(DESTDIR)$(localedir)/$$cat/LC_MESSAGES; \
mkdir -p $$dir; \
$(INSTALL_DATA) $$cat.mo $$dir/$(GETTEXT_PACKAGE).mo; \
echo "installing $$cat.mo as $$dir/$(GETTEXT_PACKAGE).mo"; \
done
uninstall:
catalogs="$(LINGUAS)"; \
for cat in $$catalogs; do \
echo "rm -f $(DESTDIR)$(localedir)/$$cat/LC_MESSAGES/$(GETTEXT_PACKAGE).mo"; \
rm -f $(DESTDIR)$(localedir)/$$cat/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \
done
mostlyclean:
rm -f *.pox *.old.po *.new.po *.mo *.gmo *.msg *.cat *.cat.m
clean: mostlyclean
distclean: clean
rm -f Makefile POTFILES
update-po: Makefile
rm -f $(GETTEXT_PACKAGE).pot
$(MAKE) $(GETTEXT_PACKAGE).pot
catalogs="$(LINGUAS)"; \
for lang in $$catalogs; do \
printf " %s " "$$lang"; \
if $(MSGMERGE) $$lang.po $(GETTEXT_PACKAGE).pot -o $$lang.new.po; then \
mv -f $$lang.new.po $$lang.po || exit 1; \
else \
echo "msgmerge for $$lang failed!"; \
rm -f $$lang.new.po; \
fi; \
done
' > Makefile.in
(
for i in ${LINGUAS}
do
echo "${i}.mo:"
echo " \$(GMSGFMT) \$(MSGFMT_OPTS) -o ${i}.mo ${i}.po"
done
) >> Makefile.in

View File

@ -1,24 +0,0 @@
# List of files which containing translatable strings.
# Package source files
src/about.c
src/child.c
src/gfx.c
src/gtkballs.c
src/gtkutils.c
src/license.c
src/mainmenu.c
src/mainwin.c
src/path.c
src/preferences.c
src/prefs.c
src/rules.c
src/scoreboard.c
src/themerc.c
src/theme.c
src/savegame.c
src/savedialog.c
src/halloffame.c
src/inputname.c
src/rulesdialog.c
src/game.c

6
po/readme.txt Normal file
View File

@ -0,0 +1,6 @@
There's no LINGUAS file..
Just run ./Makefile.in.gen whenever a .po file is added or removed..
and when you want to update the $(POTFILES) (source files that contain translatable strings)