summaryrefslogtreecommitdiff
path: root/libgphoto2_port/gphoto-m4/gp-gettext-setup.m4
blob: 49b8c7af26599b0052297771e088a8d65d5c05b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# gp-gettext-setup.m4 - set up gettext with some checks        -*- Autoconf -*-
# serial 13
dnl | Increment the above serial number every time you edit this file.
dnl | When it finds multiple m4 files with the same name,
dnl | aclocal will use the one with the highest serial.
dnl
dnl ####################################################################
dnl GP_GETTEXT_SETUP(...)
dnl    Gettext setup with e.g. consistency checks for value of DOMAIN.
dnl ####################################################################
dnl
dnl Usage:
dnl     GP_GETTEXT_SETUP([DOMAIN_LIBGPHOTO2],
dnl                      [libgphoto2-${LIBGPHOTO2_CURRENT_MIN}],
dnl                      [po])
dnl     GP_GETTEXT_SETUP([DOMAIN_LIBGPHOTO2_PORT],
dnl                      [libgphoto2_port-${LIBGPHOTO2_PORT_CURRENT_MIN}],
dnl                      [libgphoto2_port/po])
dnl
dnl with the corresponding top level Makefile.am containing
dnl
dnl     @GP_GETTEXT_SETUP_MK@
dnl
dnl     # Dummy target to force Automake to make the "all" target depend on it
dnl     all-local:
dnl     	@:
dnl
dnl     # Dummy target to force Automake to make the "distclean" target depend on it
dnl     distclean-local:
dnl     	@:
dnl
dnl ####################################################################
dnl
AC_DEFUN([GP_GETTEXT_SETUP], [dnl
AC_REQUIRE([AC_PROG_GREP])dnl
AC_REQUIRE([GP_GETTEXT_SETUP_INIT])dnl
dnl
AC_MSG_CHECKING([translation text domain symbol])
AC_MSG_RESULT([$1])
AC_MSG_CHECKING([translation text domain value])
AC_MSG_RESULT([$2])
AC_MSG_CHECKING([translation subdirectory])
AC_MSG_RESULT([$3])
dnl
dnl The text domain can be evaluated as a shell variable, no need for
dnl recursive make variable evaluation, so we can put the text domain
dnl into the include file and do not need to define it from a make
dnl rule on the compiler command line.
AC_DEFINE_UNQUOTED([$1], ["$2"], [text domain for string translations])
dnl AM_CPPFLAGS="$AM_CPPFLAGS -D$1=\\\""'$2'"\\\""
AC_SUBST([$1], [$2])
dnl
dnl
dnl The following check will have "make all" print something like
dnl     DOMAIN = libgphoto2-6
dnl if the consistency check has been successful, and have "make all" abort
dnl     Error: Inconsistent values for GETTEXT_PACKAGE_LIBGPHOTO2 and po/Makevars DOMAIN.
dnl if the consistency check has failed.
dnl
cat >>${GP_GETTEXT_SETUP_MK} <<EOF
	@set -ex; \\
	MAKEVARS_FILE="\$\$(test -f '$3/Makevars' || echo '\$(srcdir)/')$3/Makevars"; \\
	MAKEVARS_DOMAIN="\$\$(\$(SED) -n 's/^DOMAIN \\{0,\\}= \\{0,\\}//p' "\$\$MAKEVARS_FILE")"; \\
	MAKE_TIME_DOMAIN="\$($1)"; \\
	echo "  MAKEVARS_DOMAIN=\$\$MAKEVARS_DOMAIN"; \\
	echo "  $1=\$($1)"; \\
	if test "x\$\$MAKEVARS_DOMAIN" = "x\$($1)"; then \\
	     echo "Good: Matching gettext domain values (\$($1))"; \\
	     true; \\
	elif test "x\$\$USE_NLS" = xyes; then \\
	     echo "Error: Mismatching gettext domain values (\$($1) vs \$\${MAKEVARS_DOMAIN})"; \\
	     false; \\
	else \\
	     echo "Warning: Mismatching gettext domain values (\$($1) vs \$\${MAKEVARS_DOMAIN})"; \\
	     true; \\
	fi
EOF
dnl
])dnl
dnl
dnl
dnl ####################################################################
dnl Setup for the po subdir specific setup
dnl ####################################################################
dnl
AC_DEFUN_ONCE([GP_GETTEXT_SETUP_INIT], [dnl
AC_BEFORE([$0], [GP_GETTEXT_SETUP])dnl
dnl
dnl The LOCALEDIR definition contains too many levels of recursive
dnl make variable definitions to evaluate via shell, so we have make
dnl resolve that instead of the shell configure script.
AM_CPPFLAGS="$AM_CPPFLAGS -DLOCALEDIR=\\\""'${localedir}'"\\\""
dnl
dnl
AC_SUBST_FILE([GP_GETTEXT_SETUP_MK])
GP_GETTEXT_SETUP_MK="gp-gettext-setup.mk"
dnl
dnl
cat >${GP_GETTEXT_SETUP_MK} <<EOF

# ${GP_GETTEXT_SETUP_MK} autogenerated by $0

distclean-local: distclean-local-gp-gettext-setup
.PHONY: distclean-local-gp-gettext-setup
distclean-local-gp-gettext-setup:
	-rm -f ${GP_GETTEXT_SETUP_MK}

all-local: all-local-gp-gettext-setup
.PHONY: all-local-gp-gettext-setup
all-local-gp-gettext-setup:
	@:
EOF
dnl
dnl
])dnl
dnl
dnl
dnl ####################################################################
dnl
dnl Local Variables:
dnl mode: autoconf
dnl End: