forked from matxin/matxin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatxin.m4
143 lines (131 loc) · 4.91 KB
/
matxin.m4
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# matxin.m4 - Macros to locate and utilise matxin libraries -*- Autoconf -*-
# serial 1 (matxin-3.4.0)
#
# Copyright (C) 2013--2016 Universitat d'Alacant / Universidad de Alicante
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
# MATXIN_CHECK_LING([ID], [MONOLINGUAL_PACKAGE])
#
# Check to see whether MONOLINGUAL_PACKAGE exists, and if so sets
# MATXIN_LIB[ID] and MATXIN_SRC[ID].
#
# As an example, MATXIN_CHECK_LING([1], [matxin-fie]) would check that
# matxin-fie exists, and set MATXIN_LIB1 and MATXIN_SRC1 to the paths
# containing the binaries and sources respectively of that monolingual
# language package.
#
# Also sets up options --with-lang[ID] (e.g. --with-lang1) if the user
# wants to use the source code checkout instead of installed files.
# ------------------------------------------
AC_DEFUN([MATXIN_CHECK_LING],
[
AC_ARG_VAR([MATXIN_SRC][$1], [Path to $2 sources, same as MATXIN_LIB$1 if --with-lang$1 set])
AC_ARG_VAR([MATXIN_LIB][$1], [Path to $2 binaries, same as MATXIN_SRC$1 if --with-lang$1 set])
AC_ARG_VAR([MATXIN_SUBDIRS], [List of all --with-lang dirs; add it to SUBDIRS to make configure-specified dependencies recursively])
AC_ARG_WITH([lang][$1],
[dnl
AS_HELP_STRING([--with-lang][$1],dnl
[Uninstalled source directory for $2, defines MATXIN_SRC$1 and MATXIN_LIB$1 for Makefile, otherwise these are set to paths of installed files.])
],
[
MATXIN_LIB$1=$withval
MATXIN_SRC$1=$withval
echo "Using $2 from $withval"
MATXIN_SUBDIRS="$MATXIN_SUBDIRS $withval"
],
[
# TODO: PKG_CHECK_MODULES sets useless variables, while _EXISTS
# doesn't error if not found, should make a PKG_CHECK macro that
# errors but does not set _CFLAGS/_LIBS
PKG_CHECK_MODULES(m4_toupper(m4_bpatsubst($2, [-], [_])), [$2])
MATXIN_LIB$1=`pkg-config --variable=dir $2`
MATXIN_SRC$1=`pkg-config --variable=srcdir $2`
])
if test -z "$MATXIN_SRC$1" || ! test -d "$MATXIN_SRC$1"; then
AC_MSG_ERROR([Could not find sources dir for $2 (MATXIN_SRC$1="$MATXIN_SRC$1")])
fi
])
# MATXIN_MKINCLUDE()
#
# Creates the file ap_include.am and sets the variable ap_include to
# point to this path. Now in your Makefile.am you can include
# ap_include.am by writing @ap_include@ on a line by itself.
#
# The file defines a pattern rule for making modes files, and a goal
# for installing the ones that have install="yes" in modes.xml. To
# generate modes, include a line like
#
# noinst_DATA=modes/$(PREFIX1).mode
#
# in your Makefile.am with _at most one mode_ (the others will be
# created even if you list only one, listing several will lead to
# trouble with parallell make).
#
# Install the modes by making install-data-local dependent on
# install-modes, ie.
#
# install-data-local: install-modes
#
# Also defined is a goal for making the .deps folder. If you want some
# file to be built in a folder named .deps, just make that goal
# dependent on .deps/.d, e.g.
#
# .deps/intermediate.dix: original.dix .deps/.d
#
# ------------------------------------------
AC_DEFUN([MATXIN_MKINCLUDE],
[
AC_SUBST_FILE(ap_include)
ap_include=$srcdir/ap_include.am
cat >$srcdir/ap_include.am <<EOF
modes/%.mode: modes.xml
matxin-validate-modes modes.xml
matxin-gen-modes modes.xml
modes=\`xmllint --xpath '//mode@<:@@install="yes"@:>@/@name' modes.xml | sed 's/ *name="\(@<:@^"@:>@*\)"/\1.mode /g'\`; \\
if test -n "\$\$modes"; then mv \$\$modes modes/; fi
matxin_modesdir=\$(prefix)/share/matxin/modes/
install-modes:
mv modes modes.bak
matxin-gen-modes modes.xml \$(BASENAME)
rm -rf modes
mv modes.bak modes
test -d \$(DESTDIR)\$(matxin_modesdir) || mkdir \$(DESTDIR)\$(matxin_modesdir)
modes=\`xmllint --xpath '//mode@<:@@install="yes"@:>@/@name' modes.xml | sed 's/ *name="\(@<:@^"@:>@*\)"/\1.mode /g'\`; \\
if test -n "\$\$modes"; then \\
\$(INSTALL_DATA) \$\$modes \$(DESTDIR)\$(matxin_modesdir); \\
rm \$\$modes; \\
fi
.deps/.d:
test -d .deps || mkdir .deps
touch \$[]@
.PRECIOUS: .deps/.d
langs:
@fail=; \
if \$(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
list='\$(MATXIN_SUBDIRS)'; \
for subdir in \$\$list; do \
echo "Making \$\$subdir"; \
(\$(am__cd) \$\$subdir && \$(MAKE) \$(AM_MAKEFLAGS) all-am) \
|| eval \$\$failcom; \
done; \
\$(MAKE) \$(AM_MAKEFLAGS) all-am || exit 1; \
test -z "\$\$fail"
.PHONY: langs
EOF
])