Skip to content

Commit

Permalink
build: remove doc/locale language auto-detection, simplify
Browse files Browse the repository at this point in the history
This removes the rather complicated configure and Makefile parts
related to auto-detecting available languages for manpages and locales.
We don't have non-English manpages or any locales, so this is
pointless. It didn't even work: configure --language=all created an
invalid config.mak that would cause "make install" to fail.

Remove installation of locales. There are no translations at all which
could be installed. Should there ever be someone who is interested in
adding translations, this can be added back in a simpler way.

Rename the --enable-translation configure option to --enable-gettext.
This is what this option really does: enable gettext() use. This may
be interesting for people who want to experiment with localizing mpv,
but is entirely useless for normal use.

Remove detection of the binary codecs directory in configure.
  • Loading branch information
wm4 committed Nov 14, 2012
1 parent a209832 commit 97efafe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 167 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
/core/input/input_conf.h
/tags
/TAGS
/locale
/po
/video/out/vo_opengl_shaders.h
/video/out/vdpau_template.c
/demux/ebml_defs.c
Expand Down
46 changes: 7 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,9 @@ ALL_PRG += mpv$(EXESUF)

INSTALL_TARGETS += check_rst2man \
install-mpv \
install-mpv-man \
install-mpv-msg
install-mpv-man

INSTALL_NO_MAN_TARGETS += install-mpv \
install-mpv-msg
INSTALL_NO_MAN_TARGETS += install-mpv

DIRS = . \
audio \
Expand All @@ -309,8 +307,6 @@ DIRS = . \
video/filter \
video/out

MOFILES := $(MSG_LANGS:%=locale/%/LC_MESSAGES/mpv.mo)


ADDSUFFIXES = $(foreach suf,$(1),$(addsuffix $(suf),$(2)))
ADD_ALL_DIRS = $(call ADDSUFFIXES,$(1),$(DIRS))
Expand All @@ -325,7 +321,7 @@ endif

###### generic rules #######

all: $(ALL_PRG) locales
all: $(ALL_PRG)

%.1: %.rst
$(RST2MAN) $< $@
Expand Down Expand Up @@ -392,16 +388,9 @@ version.h .version: version.sh
%$(EXESUF): %.c
$(CC) $(CFLAGS) -o $@ $^

locales: $(MOFILES)

locale/%/LC_MESSAGES/mpv.mo: po/%.po
mkdir -p $(dir $@)
msgfmt -c -o $@ $<

%.ho: %.h
$(CC) $(CFLAGS) -Wno-unused -c -o $@ -x c $<


###### dependency declarations / specific CFLAGS ######

core/version.c osdep/mpv-rc.o: version.h
Expand All @@ -421,46 +410,26 @@ install-no-man: $(INSTALL_NO_MAN_TARGETS)
install-dirs:
if test ! -d $(BINDIR) ; then $(INSTALL) -d $(BINDIR) ; fi
if test ! -d $(CONFDIR) ; then $(INSTALL) -d $(CONFDIR) ; fi
if test ! -d $(LIBDIR) ; then $(INSTALL) -d $(LIBDIR) ; fi

install-%: %$(EXESUF) install-dirs
$(INSTALL) -m 755 $(INSTALLSTRIP) $< $(BINDIR)

install-mpv-man: $(foreach lang,$(MAN_LANGS),install-mpv-man-$(lang))
install-mpv-msg: $(foreach lang,$(MSG_LANGS),install-mpv-msg-$(lang))
install-mpv-man: install-mpv-man-en

install-mpv-man-en: DOCS/man/en/mpv.1
if test ! -d $(MANDIR)/man1 ; then $(INSTALL) -d $(MANDIR)/man1 ; fi
$(INSTALL) -m 644 DOCS/man/en/mpv.1 $(MANDIR)/man1/

define MPLAYER_MAN_RULE
install-mpv-man-$(lang): DOCS/man/$(lang)/mpv.1
if test ! -d $(MANDIR)/$(lang)/man1 ; then $(INSTALL) -d $(MANDIR)/$(lang)/man1 ; fi
$(INSTALL) -m 644 DOCS/man/$(lang)/mpv.1 $(MANDIR)/$(lang)/man1/
endef

$(foreach lang,$(filter-out en,$(MAN_LANG_ALL)),$(eval $(MPLAYER_MAN_RULE)))

define MPLAYER_MSG_RULE
install-mpv-msg-$(lang):
if test ! -d $(LOCALEDIR)/$(lang)/LC_MESSAGES ; then $(INSTALL) -d $(LOCALEDIR)/$(lang)/LC_MESSAGES ; fi
$(INSTALL) -m 644 locale/$(lang)/LC_MESSAGES/mpv.mo $(LOCALEDIR)/$(lang)/LC_MESSAGES/
endef

$(foreach lang,$(MSG_LANG_ALL),$(eval $(MPLAYER_MSG_RULE)))

uninstall:
$(RM) $(BINDIR)/mpv$(EXESUF)
$(RM) $(MANDIR)/man1/mpv.1
$(RM) $(foreach lang,$(MAN_LANGS),$(foreach man,mpv.1,$(MANDIR)/$(lang)/man1/$(man)))
$(RM) $(foreach lang,$(MSG_LANGS),$(LOCALEDIR)/$(lang)/LC_MESSAGES/mpv.1)
$(RM) $(MANDIR)/en/man1/mpv.1

clean:
-$(RM) $(call ADD_ALL_DIRS,/*.o /*.d /*.a /*.ho /*~)
-$(RM) $(foreach lang,$(MAN_LANGS),$(foreach man,mpv.1,DOCS/man/$(lang)/$(man)))
-$(RM) $(call ADD_ALL_DIRS,/*.o /*.a /*.ho /*~)
-$(RM) $(call ADD_ALL_EXESUFS,mpv)
-$(RM) $(MOFILES)
-$(RM) DOCS/man/en/mpv.1
-$(RM) version.h
-$(RM) core/codecs.conf.h
-$(RM) core/input/input_conf.h
Expand All @@ -470,7 +439,6 @@ clean:
-$(RM) sub/osd_font.h

distclean: clean
-$(RM) -r locale
-$(RM) config.log config.mak config.h TAGS tags

TAGS:
Expand All @@ -484,7 +452,7 @@ osxbundle:

-include $(DEP_FILES)

.PHONY: all locales *install*
.PHONY: all *install*
.PHONY: checkheaders *clean .version

# Disable suffix rules. Most of the builtin rules are suffix rules,
Expand Down
135 changes: 12 additions & 123 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,6 @@ case $(echo -n) in
*) _echo_n='-n ' _echo_c= ;; # BSD echo
esac

msg_lang_all=''
ls po/*.po >/dev/null 2>&1 && msg_lang_all=$(echo po/*.po | sed -e 's:po/\([^[:space:]]*\)\.po:\1:g')
man_lang_all=$(echo DOCS/man/??/mpv.1 DOCS/man/??_??/mpv.1 | sed -e "s:DOCS/man/\(..\)/mpv.1:\1:g" -e "s:DOCS/man/\(.._..\)/mpv.1:\1:g")
doc_lang_all=$(echo DOCS/xml/??/ DOCS/xml/??_??/ | sed -e "s:DOCS/xml/\(..\)/:\1:g" -e "s:DOCS/xml/\(.._..\)/:\1:g")

show_help(){
cat << EOF
Expand All @@ -292,12 +288,9 @@ Installation directories:
--mandir=DIR directory for installing man pages [PREFIX/share/man]
--confdir=DIR directory for installing configuration files
[PREFIX/etc/mpv]
--localedir=DIR directory for locale tree [PREFIX/share/locale]
--libdir=DIR directory for object code libraries [PREFIX/lib]
--codecsdir=DIR directory for binary codecs [LIBDIR/codecs]
--localedir=DIR directory for gettext locales [PREFIX/share/locale]
Optional features:
--disable-mpv disable mpv compilation [enable]
--disable-encoding disable encoding functionality [enable]
--enable-termcap use termcap database for key codes [autodetect]
--enable-termios use termios database for key codes [autodetect]
Expand Down Expand Up @@ -378,22 +371,8 @@ Audio output:
--disable-dsound disable DirectSound audio output [autodetect]
--disable-select disable using select() on the audio device [enable]
Language options:
--enable-translation enable support for translated output [disable]
--language-doc=lang language to use for the documentation [en]
--language-man=lang language to use for the man pages [en]
--language-msg=lang extra languages for program messages [all]
--language=lang default language to use [en]
Specific options override --language. You can pass a list of languages separated
by whitespace or commas instead of a single language. Nonexisting translations
will be dropped from each list. All translations available in the list will be
installed. The value "all" will activate all translations. The LINGUAS
environment variable is honored. In all cases the fallback is English.
The program always supports English-language output; additional message
languages are only installed if --enable-translation is also specified.
Available values for --language-doc are: all $doc_lang_all
Available values for --language-man are: all $man_lang_all
Available values for --language-msg are: all $msg_lang_all
Localization options:
--enable-gettext enable gettext() usage [disable]
Miscellaneous options:
--enable-cross-compile enable cross-compilation [disable]
Expand Down Expand Up @@ -492,9 +471,8 @@ _apple_remote=auto
_apple_ir=auto
_termcap=auto
_termios=auto
#language=en
_shm=auto
_translation=no
_gettext=no
_cdda=auto
_cddb=auto
_coreaudio=auto
Expand Down Expand Up @@ -541,12 +519,6 @@ for ac_option do
--confdir=*)
_confdir=$(echo $ac_option | cut -d '=' -f 2)
;;
--libdir=*)
_libdir=$(echo $ac_option | cut -d '=' -f 2)
;;
--codecsdir=*)
_codecsdir=$(echo $ac_option | cut -d '=' -f 2)
;;
--localedir=*)
_localedir=$(echo $ac_option | cut -d '=' -f 2)
;;
Expand Down Expand Up @@ -580,18 +552,6 @@ for ac_option do
--windres=*)
_windres=$(echo $ac_option | cut -d '=' -f 2)
;;
--language-doc=*)
language_doc=$(echo $ac_option | cut -d '=' -f 2)
;;
--language-man=*)
language_man=$(echo $ac_option | cut -d '=' -f 2)
;;
--language-msg=*)
language_msg=$(echo $ac_option | cut -d '=' -f 2)
;;
--language=*)
language=$(echo $ac_option | cut -d '=' -f 2)
;;

--enable-static)
_ld_static='-static'
Expand All @@ -616,8 +576,8 @@ for ac_option do
--disable-debug)
_debug=
;;
--enable-translation) _translation=yes ;;
--disable-translation) _translation=no ;;
--enable-gettext) _gettext=yes ;;
--disable-gettext) _gettext=no ;;
--enable-cross-compile) _cross_compile=yes ;;
--disable-cross-compile) _cross_compile=no ;;
--enable-encoding) _encoding=yes ;;
Expand Down Expand Up @@ -785,7 +745,6 @@ test -z "$_bindir" && _bindir="$_prefix/bin"
test -z "$_datadir" && _datadir="$_prefix/share/mpv"
test -z "$_mandir" && _mandir="$_prefix/share/man"
test -z "$_confdir" && _confdir="$_prefix/etc/mpv"
test -z "$_libdir" && _libdir="$_prefix/lib"
test -z "$_localedir" && _localedir="$_prefix/share/locale"

for tmpdir in "$TMPDIR" "$TEMPDIR" "/tmp" ; do
Expand Down Expand Up @@ -1271,54 +1230,13 @@ else
fi


echocheck "translation support"
if test "$_translation" = yes; then
def_translation="#define CONFIG_TRANSLATION 1"
echocheck "gettext support"
if test "$_gettext" = yes; then
def_gettext="#define CONFIG_GETTEXT 1"
else
def_translation="#undef CONFIG_TRANSLATION"
def_gettext="#undef CONFIG_GETTEXT"
fi
echores "$_translation"

echocheck "language"
# Set preferred languages, "all" uses English as main language.
test -z "$language" && language=$LINGUAS
test -z "$language_doc" && language_doc=$language
test -z "$language_man" && language_man=$language
test -z "$language_msg" && language_msg=$language
test -z "$language_msg" && language_msg="all"
language_doc=$(echo $language_doc | tr , " ")
language_man=$(echo $language_man | tr , " ")
language_msg=$(echo $language_msg | tr , " ")

test "$language_doc" = "all" && language_doc=$doc_lang_all
test "$language_man" = "all" && language_man=$man_lang_all
test "$language_msg" = "all" && language_msg=$msg_lang_all

if test "$_translation" != yes ; then
language_msg=""
fi

# Prune non-existing translations from language lists.
# Set message translation to the first available language.
# Fall back on English.
for lang in $language_doc ; do
test -d DOCS/xml/$lang && tmp_language_doc="$tmp_language_doc $lang"
done
language_doc=$tmp_language_doc
test -z "$language_doc" && language_doc=en

for lang in $language_man ; do
test -d DOCS/man/$lang && tmp_language_man="$tmp_language_man $lang"
done
language_man=$tmp_language_man
test -z "$language_man" && language_man=en

for lang in $language_msg ; do
test -f po/$lang.po && tmp_language_msg="$tmp_language_msg $lang"
done
language_msg=$tmp_language_msg

echores "messages (en+): $language_msg - man pages: $language_man - documentation: $language_doc"
echores "$_gettext"


echocheck "__builtin_expect"
Expand Down Expand Up @@ -2910,22 +2828,6 @@ test "$_libbs2b" = yes && def_libbs2b="#define CONFIG_LIBBS2B 1"
echores "$_libbs2b"


if test -z "$_codecsdir" ; then
for dir in "$_libdir/codecs" "$_libdir/win32" /usr/local/lib/codecs \
/usr/lib/codecs /usr/local/lib/win32 /usr/lib/win32 ; do
if test -d "$dir" ; then
_codecsdir="$dir"
break;
fi;
done
fi
# Fall back on default directory.
if test -z "$_codecsdir" ; then
_codecsdir="$_libdir/codecs"
mingw32 && _codecsdir="codecs"
fi


echocheck "LCMS2 support"
if test "$_lcms2" = auto ; then
_lcms2=no
Expand Down Expand Up @@ -3304,17 +3206,9 @@ export LC_ALL = C
CONFIGURATION = $configuration
DOC_LANGS = $language_doc
DOC_LANG_ALL = $doc_lang_all
MAN_LANGS = $language_man
MAN_LANG_ALL = $man_lang_all
MSG_LANGS = $language_msg
MSG_LANG_ALL = $msg_lang_all
prefix = \$(DESTDIR)$_prefix
BINDIR = \$(DESTDIR)$_bindir
DATADIR = \$(DESTDIR)$_datadir
LIBDIR = \$(DESTDIR)$_libdir
MANDIR = \$(DESTDIR)$_mandir
CONFDIR = \$(DESTDIR)$_confdir
LOCALEDIR = \$(DESTDIR)$_localedir
Expand Down Expand Up @@ -3457,7 +3351,7 @@ cat > $TMPH << EOF
#define MPLAYER_CONFDIR "$_confdir"
#define MPLAYER_LOCALEDIR "$_localedir"
$def_translation
$def_gettext
/* system headers */
Expand Down Expand Up @@ -3659,11 +3553,6 @@ Config files successfully generated by ./configure $configuration !
Data directory: $_datadir
Config direct.: $_confdir
Languages:
Messages (in addition to English): $language_msg
Manual pages: $language_man
Documentation: $language_doc
Enabled optional drivers:
Input: $inputmodules
Codecs: libavcodecs $codecmodules
Expand Down
6 changes: 3 additions & 3 deletions core/mp_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "osdep/getch2.h"
#include "osdep/io.h"

#ifdef CONFIG_TRANSLATION
#ifdef CONFIG_GETTEXT
#include <locale.h>
#include <libintl.h>
#endif
Expand Down Expand Up @@ -86,7 +86,7 @@ void mp_msg_init(void){
for(i=0;i<MSGT_MAX;i++) mp_msg_levels[i] = -2;
mp_msg_cancolor = isatty(fileno(stdout));
mp_msg_levels[MSGT_IDENTIFY] = -1; // no -identify output by default
#ifdef CONFIG_TRANSLATION
#ifdef CONFIG_GETTEXT
textdomain("mpv");
char *localedir = getenv("MPV_LOCALEDIR");
if (localedir == NULL && strlen(MPLAYER_LOCALEDIR))
Expand Down Expand Up @@ -249,7 +249,7 @@ void mp_msg(int mod, int lev, const char *format, ...)

char *mp_gtext(const char *string)
{
#ifdef CONFIG_TRANSLATION
#ifdef CONFIG_GETTEXT
/* gettext expects the global locale to be set with
* setlocale(LC_ALL, ""). However doing that would suck for a
* couple of reasons (locale stuff is badly designed and sucks in
Expand Down

0 comments on commit 97efafe

Please sign in to comment.