File: apertium.m4

package info (click to toggle)
apertium 3.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,908 kB
  • sloc: cpp: 27,401; ansic: 5,231; xml: 2,457; sh: 1,554; lex: 1,141; makefile: 591; python: 434; awk: 24
file content (164 lines) | stat: -rw-r--r-- 6,879 bytes parent folder | download
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# apertium.m4 - Macros to locate and utilise apertium libraries -*- Autoconf -*-
# serial 1 (apertium-3.4.2)
#
# 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/>.


# AP_CHECK_LING([ID], [MONOLINGUAL_PACKAGE])
#
# Check to see whether MONOLINGUAL_PACKAGE exists, and if so sets
# AP_LIB[ID] and AP_SRC[ID].
#
# As an example, AP_CHECK_LING([1], [apertium-fie]) would check that
# apertium-fie exists, and set AP_LIB1 and AP_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([AP_CHECK_LING],
[
  AC_ARG_VAR([AP_SRC][$1], [Path to $2 sources, same as AP_LIB$1 if --with-lang$1 set])
  AC_ARG_VAR([AP_LIB][$1], [Path to $2 binaries, same as AP_SRC$1 if --with-lang$1 set])
  AC_ARG_VAR([AP_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 AP_SRC$1 and AP_LIB$1 for Makefile, otherwise these are set to paths of installed files.])
    ],
    [
      AP_LIB$1=$withval
      AP_SRC$1=$withval
      echo "Using $2 from $withval"
      AP_SUBDIRS="$AP_SUBDIRS $withval"
      module="$2"
      if test "${module%%-*}" = apertium && ! test -f "$withval/$2.pc.in"; then
          AC_MSG_WARN([$2 looks like an apertium dependency, but couldn't find $withval/$2.pc.in -- wrong directory, or not compiled yet?])
      elif test "${module%%-*}" = giella && ! grep -x -q "PACKAGE = $2" "$withval/Makefile"; then
          AC_MSG_WARN([$2 looks like a giella dependency, but couldn't find PACKAGE = $2 in $withval/Makefile -- wrong directory, or not compiled yet?])
      elif test "${module%%-*}" = giella && ! grep -x -q "subdir = tools/mt/apertium" "$withval/Makefile"; then
          AC_MSG_WARN([$2 looks like a giella dependency, but couldn't find subdir = tools/mt/apertium in $withval/Makefile -- wrong directory, or not compiled yet?])
      fi
    ],
    [
      # 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])
      AP_LIB$1=`pkg-config --variable=dir $2`
      AP_SRC$1=`pkg-config --variable=srcdir $2`
    ])
  if test -z "$AP_SRC$1" || ! test -d "$AP_SRC$1"; then
    AC_MSG_ERROR([Could not find sources dir for $2 (AP_SRC$1="$AP_SRC$1")])
  fi
])


# AP_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([AP_MKINCLUDE],
[
  AC_SUBST_FILE(ap_include)
  AC_PROG_MKDIR_P
  ap_include=$srcdir/ap_include.am

  cat >$srcdir/ap_include.am <<EOF

modes/%.mode: modes.xml
	apertium-validate-modes modes.xml
	apertium-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

apertium_modesdir=\$(prefix)/share/apertium/modes/
install-modes:
	mv modes modes.bak
	apertium-gen-modes -f modes.xml \$(prefix)/share/apertium/\$(BASENAME)
	rm -rf modes
	mv modes.bak modes
	\$(MKDIR_P) \$(DESTDIR)\$(apertium_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)\$(apertium_modesdir); \\
			rm \$\$modes; \\
		fi

.deps/.d:
	\$(MKDIR_P) .deps
	touch \$[]@

.PRECIOUS: .deps/.d

langs:
	@fail=; \
	if \$(am__make_keepgoing); then \
	  failcom='fail=yes'; \
	else \
	  failcom='exit 1'; \
	fi; \
	dot_seen=no; \
	list='\$(AP_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


.deps/%.autobil.prefixes: %.autobil.bin .deps/.d
	lt-print $< | sed 's/ /@_SPACE_@/g' > .deps/\@S|@*.autobil.att
	hfst-txt2fst -e ε <  .deps/\@S|@*.autobil.att > .deps/\@S|@*.autobil.hfst
	hfst-project -p upper .deps/\@S|@*.autobil.hfst > .deps/\@S|@*.autobil.upper                                   # bidix
	echo ' @<:@ ? - %+ @:>@* ' | hfst-regexp2fst > .deps/\@S|@*.any-nonplus.hfst                                                        # [^+]*
	hfst-concatenate -1 .deps/\@S|@*.autobil.upper -2 .deps/\@S|@*.any-nonplus.hfst -o .deps/\@S|@*.autobil.nonplussed    # bidix [^+]*
	echo ' %+ ' | hfst-regexp2fst > .deps/\@S|@*.single-plus.hfst                                                                 # +
	hfst-concatenate -1 .deps/\@S|@*.single-plus.hfst -2 .deps/\@S|@*.autobil.nonplussed -o .deps/\@S|@*.autobil.postplus # + bidix [^+]*
	hfst-repeat -f0 -t3 -i .deps/\@S|@*.autobil.postplus -o .deps/\@S|@*.autobil.postplus.0,3                      # (+ bidix [^+]*){0,3} -- gives at most three +
	hfst-concatenate -1 .deps/\@S|@*.autobil.nonplussed -2 .deps/\@S|@*.autobil.postplus.0,3 -o \@S|@@                 # bidix [^+]* (+ bidix [^+]*){0,3}

EOF

])