Blame view

aclocal.m4 22.4 KB
ec859a60   samuel thibault   New upstream vers...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
###############################################################################
# libbrlapi - A library providing access to braille terminals for applications.
#
# Copyright (C) 1995-2018 by Dave Mielke <dave@mielke.cc>
#
# libbrlapi comes with ABSOLUTELY NO WARRANTY.
#
# This is free software, placed under the terms of the
# GNU Lesser General Public License, as published by the Free Software
# Foundation; either version 2.1 of the License, or (at your option) any
# later version. Please see the file LICENSE-LGPL for details.
#
# Web Page: http://brltty.com/
#
# This software is maintained by Dave Mielke <dave@mielke.cc>.
###############################################################################

c100d13a   Mario Lang   Imported Upstream...
18
19
20
AC_DEFUN([BRLTTY_UPPERCASE_TRANSLATE], [translit([$1], [a-z], [A-Z])])

AC_DEFUN([BRLTTY_TRANSLATE_ASSIGN], [$1=`echo "$2" | sed -e 'y%$3%$4%'`])
67e7bfbc   samuel thibault   New upstream vers...
21
AC_DEFUN([BRLTTY_UPPERCASE_ASSIGN], BRLTTY_TRANSLATE_ASSIGN([$1], [$2], [abcdefghijklmnopqrstuvwxyz$3], [ABCDEFGHIJKLMNOPQRSTUVWXYZ$4]))
c100d13a   Mario Lang   Imported Upstream...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
AC_DEFUN([BRLTTY_LOWERCASE_ASSIGN], [BRLTTY_TRANSLATE_ASSIGN([$1], [$2], [ABCDEFGHIJKLMNOPQRSTUVWXYZ$3], [abcdefghijklmnopqrstuvwxyz$4])])

AC_DEFUN([BRLTTY_INCLUDE_HEADERS], [dnl
ifelse(len([$1]), 0, [], [
[#]include <$1>
])ifelse($#, 1, [], [BRLTTY_INCLUDE_HEADERS(m4_shift($@))])])

AC_DEFUN([BRLTTY_CHECK_FUNCTION], [dnl
   AC_CHECK_DECL([$1], [dnl
      AC_SEARCH_LIBS([$1], [$3], [dnl
         BRLTTY_UPPERCASE_ASSIGN([brltty_define], [have_$1])
         AC_DEFINE_UNQUOTED(${brltty_define}, [1], [Define this if the function $1 is available.])
      ])
   ], [], [BRLTTY_INCLUDE_HEADERS(m4_translit([$2], [ ], [,]))])
])
72c536f8   Mario Lang   Imported Upstream...
37
38

AC_DEFUN([BRLTTY_SEARCH_LIBS], [dnl
c100d13a   Mario Lang   Imported Upstream...
39
BRLTTY_UPPERCASE_ASSIGN([brltty_uc], [$1])
be26d4ea   Mario Lang   Imported Upstream...
40
AC_SEARCH_LIBS([$1], [$2], [AC_DEFINE_UNQUOTED(HAVE_${brltty_uc}, [1], [Define this if the function $1 is available.])])])
72c536f8   Mario Lang   Imported Upstream...
41
42

AC_DEFUN([BRLTTY_VAR_TRIM], [dnl
72c536f8   Mario Lang   Imported Upstream...
43
$1="`echo "${$1}" | sed -e 's/^ *//' -e 's/ *$//'`"
be26d4ea   Mario Lang   Imported Upstream...
44
])
72c536f8   Mario Lang   Imported Upstream...
45
46
47
48

AC_DEFUN([BRLTTY_VAR_EXPAND], [dnl
eval '$1="'"$2"'"'])

67e7bfbc   samuel thibault   New upstream vers...
49
50
51
52
AC_DEFUN([BRLTTY_SUBST_EXPANDED], [dnl
BRLTTY_VAR_EXPAND([brltty_expanded], [$2])
AC_SUBST([$1], ["${brltty_expanded}"])])

d8488191   samuel thibault   Imported Upstream...
53
54
55
56
57
AC_DEFUN([BRLTTY_DEFINE_STRING], [dnl
   AC_SUBST([$1], [$2])
   AC_DEFINE([$1], ["$2"], [Define this to be a string containing $3.])
])

72c536f8   Mario Lang   Imported Upstream...
58
59
AC_DEFUN([BRLTTY_DEFINE_EXPANDED], [dnl
BRLTTY_VAR_EXPAND([brltty_expanded], [$2])
be26d4ea   Mario Lang   Imported Upstream...
60
61
62
63
64
AC_DEFINE_UNQUOTED([$1], ["${brltty_expanded}"], [$3])])

AC_DEFUN([BRLTTY_RELATIVE_PATH], [dnl
AC_REQUIRE([AC_PROG_AWK])
eval '$1="`"${AWK}" -v path="'"$2"'" -v reference="'"$3"'" -f "${srcdir}/relpath.awk"`"'])
72c536f8   Mario Lang   Imported Upstream...
65
66
67
68

AC_DEFUN([BRLTTY_DEFINE_DIRECTORY], [dnl
BRLTTY_VAR_EXPAND([$1], [$2])
AC_SUBST([$1])
be26d4ea   Mario Lang   Imported Upstream...
69
70
71
72
73
74
75
if test "${brltty_enabled_relocatable_install}" = "yes"
then
   BRLTTY_RELATIVE_PATH([brltty_path], [${$1}], [${brltty_reference_directory}])
else
   brltty_path="${$1}"
fi
BRLTTY_DEFINE_EXPANDED([$1], [${brltty_path}], [$3])])
72c536f8   Mario Lang   Imported Upstream...
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

AC_DEFUN([BRLTTY_ARG_WITH], [dnl
AC_ARG_WITH([$1], BRLTTY_HELP_STRING([--with-$1=$2], [$3]), [$4="${withval}"], [$4=$5])])

AC_DEFUN([BRLTTY_ARG_REQUIRED], [dnl
BRLTTY_ARG_WITH([$1], [$2], [$3], [$4], ["yes"])
if test "${$4}" = "no"
then
   AC_MSG_ERROR([$1 not specified])
elif test "${$4}" = "yes"
then
   $4=$5
fi
AC_SUBST([$4])
BRLTTY_SUMMARY_ITEM([$1], [$4])])

AC_DEFUN([BRLTTY_ARG_TABLE], [dnl
brltty_default_table="$2"
BRLTTY_ARG_WITH(
   [$1-table], [FILE],
cb3fa58f   Mario Lang   Imported Upstream...
96
   [built-in (fallback) $1 table]brltty_tables_$1,
72c536f8   Mario Lang   Imported Upstream...
97
98
99
100
101
102
103
104
105
106
107
108
   [$1_table], ["${brltty_default_table}"]
)
install_$1_tables=install-$1-tables
if test "${$1_table}" = "no"
then
   install_$1_tables=
   $1_table="${brltty_default_table}"
elif test "${$1_table}" = "yes"
then
   $1_table="${brltty_default_table}"
fi
AC_SUBST([install_$1_tables])
72c536f8   Mario Lang   Imported Upstream...
109
BRLTTY_SUMMARY_ITEM([$1-table], [$1_table])
c100d13a   Mario Lang   Imported Upstream...
110
AC_DEFINE_UNQUOTED(BRLTTY_UPPERCASE_TRANSLATE([$1_table]), ["${$1_table}"],
be26d4ea   Mario Lang   Imported Upstream...
111
                   [Define this to be a string containing the path to the default $1 table.])
72c536f8   Mario Lang   Imported Upstream...
112
113
114
115
AC_SUBST([$1_table])])

AC_DEFUN([BRLTTY_ARG_PARAMETERS], [dnl
BRLTTY_ARG_WITH(
ec859a60   samuel thibault   New upstream vers...
116
117
   [$1-parameters], [$3PARAMETER=SETTING... (comma-separated)],
   [default parameters for the $2],
72c536f8   Mario Lang   Imported Upstream...
118
119
120
121
122
123
124
125
126
   [$1_parameters], [""]
)
if test "${$1_parameters}" = "no"
then
   $1_parameters=""
elif test "${$1_parameters}" = "yes"
then
   $1_parameters=""
fi
c100d13a   Mario Lang   Imported Upstream...
127
AC_DEFINE_UNQUOTED(BRLTTY_UPPERCASE_TRANSLATE([$1_parameters]), ["${$1_parameters}"],
ec859a60   samuel thibault   New upstream vers...
128
                   [Define this to be a string containing the default parameters for the $2.])
72c536f8   Mario Lang   Imported Upstream...
129
130
BRLTTY_SUMMARY_ITEM([$1-parameters], [$1_parameters])])

12927b0c   Mario Lang   Imported Upstream...
131
132
AC_DEFUN([BRLTTY_ARG_PACKAGE], [dnl
$1_package=""
90c515c4   Mario Lang   Imported Upstream...
133
$1_includes=""
12927b0c   Mario Lang   Imported Upstream...
134
135
136
137
138
139
140
141
142
143
$1_libs=""

BRLTTY_ARG_WITH(
   [$1-package], [PACKAGE],
   [which $2 package to use],
   [packages], ["yes"]
)

if test "${packages}" = "no"
then
a80ccd3b   samuel thibault   Imported Upstream...
144
   $1_package="none"
12927b0c   Mario Lang   Imported Upstream...
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
elif test "${packages}" = "yes"
then
   packages="$3"
   ifelse(len([$4]), 0, [], [dnl
      case "${host_os}"
      in
         $4
         *);;
      esac
   ])
else
   packages=`echo "${packages}" | sed -e 'y/,/ /'`
fi

test -z "${$1_package}" && {
   test -n "${packages}" && {
      for package in ${packages}
      do
67e7bfbc   samuel thibault   New upstream vers...
163
         BRLTTY_HAVE_PACKAGE([$1], [${package}], [break], [])
12927b0c   Mario Lang   Imported Upstream...
164
165
166
167
168
169
170
171
172
173
174
175
176

         ifelse(len([$5]), 0, [], [dnl
            case "${package}"
            in
               $5
               *);;
            esac

            test -n "${$1_package}" && break
         ])

         AC_MSG_NOTICE([$2 package not available: ${package}])
      done
12927b0c   Mario Lang   Imported Upstream...
177
178
179
180
181
   }
}

test -z "${$1_package}" && {
   $1_package="none"
a80ccd3b   samuel thibault   Imported Upstream...
182
   AC_MSG_WARN([$2 support not available on this platform])
12927b0c   Mario Lang   Imported Upstream...
183
184
185
}

AC_SUBST([$1_package])
90c515c4   Mario Lang   Imported Upstream...
186
AC_SUBST([$1_includes])
12927b0c   Mario Lang   Imported Upstream...
187
AC_SUBST([$1_libs])
c100d13a   Mario Lang   Imported Upstream...
188
AC_DEFINE_UNQUOTED(BRLTTY_UPPERCASE_TRANSLATE([$1_package]), [${$1_package}], [Define this to the name of the selected $2 package.])
90c515c4   Mario Lang   Imported Upstream...
189
BRLTTY_UPPERCASE_ASSIGN([brltty_uc], [use_pkg_$1_${$1_package}], [-.], [__])
c100d13a   Mario Lang   Imported Upstream...
190
AC_DEFINE_UNQUOTED([${brltty_uc}])
12927b0c   Mario Lang   Imported Upstream...
191
192
BRLTTY_SUMMARY_ITEM([$1-package], [$1_package])])

72c536f8   Mario Lang   Imported Upstream...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
AC_DEFUN([BRLTTY_ARG_ENABLE], [dnl
BRLTTY_ARG_FEATURE([$1], [$2], [enable], [no], [$3], [$4], [$5])])

AC_DEFUN([BRLTTY_ARG_DISABLE], [dnl
BRLTTY_ARG_FEATURE([$1], [$2], [disable], [yes], [$3], [$4], [$5])])

AC_DEFUN([BRLTTY_ARG_FEATURE], [dnl
AC_ARG_ENABLE([$1], BRLTTY_HELP_STRING([--$3-$1], [$2]), [], [enableval="$4"])

pushdef([var], brltty_enabled_[]translit([$1], [-], [_]))dnl
var="${enableval}"
BRLTTY_SUMMARY_ITEM([$1], var)dnl
popdef([var])

if test "${enableval}" = "no"
then
   ifelse(len([$7]), 0, [:], [$7])
else
ifelse(len([$5]), 0, [], [dnl
   set -- [$5]
])dnl
   if test "${enableval}" = "yes"
   then
      brltty_ok=true
ifelse(len([$5]), 0, [], [dnl
      test "${#}" -gt 0 && enableval="${1}"
])dnl
   else
      brltty_ok=false
ifelse(len([$5]), 0, [], [dnl
      test "${#}" -gt 0 && {
         for brltty_selection
         do
            test "${brltty_selection}" = "${enableval}" && {
               brltty_ok=true
               break
            }
         done
      }
])dnl
   fi

   if "${brltty_ok}"
   then
ifelse(len([$5]), 0, [], [dnl
      test "${#}" -gt 0 && {
c100d13a   Mario Lang   Imported Upstream...
239
         BRLTTY_UPPERCASE_ASSIGN([brltty_uc], [use_$1_${enableval}], [-], [_])
72c536f8   Mario Lang   Imported Upstream...
240
241
242
243
244
245
246
247
248
249
250
         AC_DEFINE_UNQUOTED([${brltty_uc}])
      }
])dnl
      ifelse(len([$6]), 0, [:], [$6])
   else
      AC_MSG_ERROR([invalid selection: --enable-$1=${enableval}])
   fi
fi])

AC_DEFUN([BRLTTY_HELP_STRING], [dnl
AC_HELP_STRING([$1], patsubst([$2], [
6a26ecf7   Mario Lang   Imported Upstream...
251
.*$]), m4_defn([brltty_help_prefix]))dnl
be26d4ea   Mario Lang   Imported Upstream...
252
253
254
patsubst(patsubst([$2], [\`[^
]*]), [
], [\&brltty_help_prefix])[]dnl
72c536f8   Mario Lang   Imported Upstream...
255
256
257
258
259
260
261
262
263
264
265
])
m4_define([brltty_help_indent], 32)
m4_define([brltty_help_prefix], m4_format([%]brltty_help_indent[s], []))
m4_define([brltty_help_width], m4_eval(79-brltty_help_indent))

AC_DEFUN([BRLTTY_ITEM], [dnl
define([brltty_item_list_$1], ifdef([brltty_item_list_$1], [brltty_item_list_$1])[
m4_text_wrap([$3], [      ], [- $2  ], brltty_help_width)])dnl
brltty_item_entries_$1="${brltty_item_entries_$1} $2-$3"
brltty_item_codes_$1="${brltty_item_codes_$1} $2"
brltty_item_names_$1="${brltty_item_names_$1} $3"
be26d4ea   Mario Lang   Imported Upstream...
266
AC_SUBST([$1_libraries_$2], ['$4'])])
72c536f8   Mario Lang   Imported Upstream...
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292

AC_DEFUN([BRLTTY_BRAILLE_DRIVER], [dnl
BRLTTY_ITEM([braille], [$1], [$2], [$3])])

AC_DEFUN([BRLTTY_SPEECH_DRIVER], [dnl
BRLTTY_ITEM([speech], [$1], [$2], [$3])])

AC_DEFUN([BRLTTY_SCREEN_DRIVER], [dnl
BRLTTY_ITEM([screen], [$1], [$2], [$3])])

AC_DEFUN([BRLTTY_ARG_ITEM], [dnl
BRLTTY_VAR_TRIM([brltty_item_codes_$1])
AC_SUBST([brltty_item_codes_$1])

BRLTTY_VAR_TRIM([brltty_item_names_$1])
AC_SUBST([brltty_item_names_$1])

case "${host_os}"
in
   cygwin*|mingw*)
      brltty_default="all"
      ;;
   *)
      brltty_default="yes"
      ;;
esac
12927b0c   Mario Lang   Imported Upstream...
293

72c536f8   Mario Lang   Imported Upstream...
294
BRLTTY_ARG_WITH(
c100d13a   Mario Lang   Imported Upstream...
295
   [$1-$2], BRLTTY_UPPERCASE_TRANSLATE([$2]),
72c536f8   Mario Lang   Imported Upstream...
296
297
298
   [$1 $2(s) to build in]brltty_item_list_$1,
   [brltty_items], ["${brltty_default}"]
)
12927b0c   Mario Lang   Imported Upstream...
299

72c536f8   Mario Lang   Imported Upstream...
300
301
302
303
304
305
306
if test "${brltty_items}" = "no"
then
   brltty_external_codes_$1=""
   brltty_external_names_$1=""
   brltty_internal_codes_$1=""
   brltty_internal_names_$1=""
else
12927b0c   Mario Lang   Imported Upstream...
307
   brltty_items_left_$1=" ${brltty_item_entries_$1} "
72c536f8   Mario Lang   Imported Upstream...
308
309
310
311
   brltty_external_codes_$1=" ${brltty_item_codes_$1} "
   brltty_external_names_$1=" ${brltty_item_names_$1} "
   brltty_internal_codes_$1=""
   brltty_internal_names_$1=""
be26d4ea   Mario Lang   Imported Upstream...
312

72c536f8   Mario Lang   Imported Upstream...
313
314
315
316
   if test "${brltty_items}" != "yes"
   then
      while :
      do
be26d4ea   Mario Lang   Imported Upstream...
317
         [brltty_delimiter="`expr "${brltty_items}" : '[^,]*,'`"]
72c536f8   Mario Lang   Imported Upstream...
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
         if test "${brltty_delimiter}" -eq 0
         then
            brltty_item="${brltty_items}"
            brltty_items=""
            if test "${brltty_item}" = "all"
            then
               brltty_item_all=true
               brltty_item_include=true
            elif test "${brltty_item}" = "-all"
            then
               brltty_item_all=true
               brltty_item_include=false
            else
               brltty_item_all=false
            fi
            if "${brltty_item_all}"
            then
               if "${brltty_item_include}"
               then
                  brltty_internal_codes_$1="${brltty_internal_codes_$1}${brltty_external_codes_$1}"
                  brltty_internal_names_$1="${brltty_internal_names_$1}${brltty_external_names_$1}"
               fi
               brltty_external_codes_$1=""
               brltty_external_names_$1=""
               break
            fi
         else
be26d4ea   Mario Lang   Imported Upstream...
345
346
            [brltty_item="`expr "${brltty_items}" : '\([^,]*\)'`"]
            [brltty_items="`expr "${brltty_items}" : '[^,]*,\(.*\)'`"]
72c536f8   Mario Lang   Imported Upstream...
347
348
349
350
351
352
353
354
355
         fi
         brltty_item_suffix="${brltty_item#-}"
         if test "${brltty_item}" = "${brltty_item_suffix}"
         then
            brltty_item_include=true
         else
            brltty_item_include=false
            brltty_item="${brltty_item_suffix}"
         fi
12927b0c   Mario Lang   Imported Upstream...
356
357
358

         BRLTTY_ITEM_RESOLVE([$1])
         "${brltty_item_unknown}" && {
72c536f8   Mario Lang   Imported Upstream...
359
            AC_MSG_ERROR([unknown $1 $2: ${brltty_item}])
12927b0c   Mario Lang   Imported Upstream...
360
361
         }

72c536f8   Mario Lang   Imported Upstream...
362
         brltty_item_found="`expr "${brltty_external_codes_$1}" : ".* ${brltty_item_code} "`"
12927b0c   Mario Lang   Imported Upstream...
363
         test "${brltty_item_found}" -eq 0 && {
72c536f8   Mario Lang   Imported Upstream...
364
            AC_MSG_ERROR([duplicate $1 $2: ${brltty_item}])
12927b0c   Mario Lang   Imported Upstream...
365
366
367
         }

         brltty_items_left_$1="`echo "${brltty_items_left_$1}" | sed -e "s% ${brltty_item_entry} % %"`"
72c536f8   Mario Lang   Imported Upstream...
368
369
         brltty_external_codes_$1="`echo "${brltty_external_codes_$1}" | sed -e "s% ${brltty_item_code} % %"`"
         brltty_external_names_$1="`echo "${brltty_external_names_$1}" | sed -e "s% ${brltty_item_name} % %"`"
12927b0c   Mario Lang   Imported Upstream...
370
371

         "${brltty_item_include}" && {
72c536f8   Mario Lang   Imported Upstream...
372
373
            brltty_internal_codes_$1="${brltty_internal_codes_$1} ${brltty_item_code}"
            brltty_internal_names_$1="${brltty_internal_names_$1} ${brltty_item_name}"
12927b0c   Mario Lang   Imported Upstream...
374
375
376
377
378
379
380
         }

         BRLTTY_ITEM_RESOLVE([$1])
         "${brltty_item_unknown}" || {
            AC_MSG_ERROR([ambiguous $1 $2: ${brltty_item}])
         }

72c536f8   Mario Lang   Imported Upstream...
381
382
383
         test "${brltty_delimiter}" -eq 0 && break
      done
   fi
be26d4ea   Mario Lang   Imported Upstream...
384

72c536f8   Mario Lang   Imported Upstream...
385
386
387
388
389
   BRLTTY_VAR_TRIM([brltty_external_codes_$1])
   BRLTTY_VAR_TRIM([brltty_external_names_$1])
   BRLTTY_VAR_TRIM([brltty_internal_codes_$1])
   BRLTTY_VAR_TRIM([brltty_internal_names_$1])
fi
be26d4ea   Mario Lang   Imported Upstream...
390

72c536f8   Mario Lang   Imported Upstream...
391
392
393
394
AC_SUBST([brltty_external_codes_$1])
AC_SUBST([brltty_external_names_$1])
AC_SUBST([brltty_internal_codes_$1])
AC_SUBST([brltty_internal_names_$1])
be26d4ea   Mario Lang   Imported Upstream...
395
396

set -- ${brltty_internal_codes_$1} ${brltty_external_codes_$1}
c100d13a   Mario Lang   Imported Upstream...
397
AC_DEFINE_UNQUOTED(BRLTTY_UPPERCASE_TRANSLATE([$1_$2_codes]), ["${*}"], 
be26d4ea   Mario Lang   Imported Upstream...
398
                   [Define this to be a string containing a list of the $1 $2 codes.])
72c536f8   Mario Lang   Imported Upstream...
399

d8488191   samuel thibault   Imported Upstream...
400
401
402
403
AC_SUBST([default_$1_$2], ["${1}"])
AC_DEFINE_UNQUOTED(BRLTTY_UPPERCASE_TRANSLATE([default_$1_$2]), ["${1}"], 
                   [Define this to be a string containing the default $1 $2 code.])

72c536f8   Mario Lang   Imported Upstream...
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
$1_driver_libraries=""
if test -n "${brltty_internal_codes_$1}"
then
   for brltty_driver in ${brltty_internal_codes_$1}
   do
      eval 'brltty_libraries="${$1_libraries_'"${brltty_driver}"'}"'
      if test -n "${brltty_libraries}"
      then
         $1_driver_libraries="${$1_driver_libraries} ${brltty_libraries}"
      fi
   done
fi
BRLTTY_VAR_TRIM([$1_driver_libraries])
AC_SUBST([$1_driver_libraries])
])

12927b0c   Mario Lang   Imported Upstream...
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
AC_DEFUN([BRLTTY_ITEM_RESOLVE], [dnl
brltty_item_unknown=true
brltty_item_length=`expr length "${brltty_item}"`

if test "${brltty_item_length}" -eq 2
then
   [brltty_item_entry=`expr "${brltty_items_left_$1}" : '.* \('"${brltty_item}"'-[^ ]*\)'`]
   if test -n "${brltty_item_entry}"
   then
      brltty_item_code="${brltty_item}"
      [brltty_item_name=`expr "${brltty_item_entry}" : '[^[.-.]]*-\(.*\)$'`]
      brltty_item_unknown=false
   fi
elif test "${brltty_item_length}" -gt 2
then
   [brltty_item_entry=`expr "${brltty_items_left_$1}" : '.* \([^- ]*-'"${brltty_item}"'[^ ]*\)'`]
   if test -z "${brltty_item_entry}"
   then
c100d13a   Mario Lang   Imported Upstream...
438
      BRLTTY_LOWERCASE_ASSIGN([brltty_lowercase], [${brltty_items_left_$1}])
12927b0c   Mario Lang   Imported Upstream...
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
      [brltty_item_code=`expr "${brltty_lowercase}" : '.* \([^- ]*\)-'"${brltty_item}"`]
      if test -n "${brltty_item_code}"
      then
         [brltty_item_entry=`expr "${brltty_items_left_$1}" : '.* \('"${brltty_item_code}"'-[^ ]*\)'`]
      fi
   fi

   if test -n "${brltty_item_entry}"
   then
      [brltty_item_code=`expr "${brltty_item_entry}" : '\([^[.-.]]*\)'`]
      [brltty_item_name=`expr "${brltty_item_entry}" : '[^[.-.]]*-\(.*\)$'`]
      brltty_item_unknown=false
   fi
fi
])

72c536f8   Mario Lang   Imported Upstream...
455
456
457
458
459
460
AC_DEFUN([BRLTTY_ARG_DRIVER], [dnl
BRLTTY_ARG_ITEM([$1], [driver])
if test "${brltty_enabled_$1_support}" != "no"
then
   if test -n "${brltty_internal_codes_$1}"
   then
6a26ecf7   Mario Lang   Imported Upstream...
461
      [$1_driver_objects="`echo "${brltty_internal_names_$1}" | sed -e 's%\([^ ][^ ]*\)%$(BLD_TOP)Drivers/$2/\1/$1.$O%g'`"]
72c536f8   Mario Lang   Imported Upstream...
462
463
464
465
466
467
468
469
470
471
472
473
474
475
      $1_help="$1-help"
   fi

   if test "${brltty_standalone_programs}" != "yes"
   then
      if test -n "${brltty_external_codes_$1}"
      then
         $1_drivers="$1-drivers"
         install_drivers="install-drivers"
      fi
      BRLTTY_SUMMARY_ITEM([external-$1-drivers], [brltty_external_codes_$1])
   fi

   BRLTTY_SUMMARY_ITEM([internal-$1-drivers], [brltty_internal_codes_$1])
ec859a60   samuel thibault   New upstream vers...
476
   BRLTTY_ARG_PARAMETERS([$1], [$1 driver(s)], [DRIVER:])
72c536f8   Mario Lang   Imported Upstream...
477
478
fi

72c536f8   Mario Lang   Imported Upstream...
479
480
for brltty_driver in ${brltty_item_names_$1}
do
6a26ecf7   Mario Lang   Imported Upstream...
481
   brltty_build_directories="${brltty_build_directories} Drivers/$2/${brltty_driver}"
72c536f8   Mario Lang   Imported Upstream...
482
483
484
485
486
487
488
done

AC_SUBST([$1_driver_objects])
AC_SUBST([$1_drivers])
AC_SUBST([$1_help])
])

72c536f8   Mario Lang   Imported Upstream...
489
490
AC_DEFUN([BRLTTY_TEXT_TABLE], [dnl
define([brltty_tables_text], ifdef([brltty_tables_text], [brltty_tables_text])[
6a26ecf7   Mario Lang   Imported Upstream...
491
m4_text_wrap([$2], [           ], [- ]m4_format([%-8s ], [$1]), brltty_help_width)])])
72c536f8   Mario Lang   Imported Upstream...
492
493
494

AC_DEFUN([BRLTTY_ATTRIBUTES_TABLE], [dnl
define([brltty_tables_attributes], ifdef([brltty_tables_attributes], [brltty_tables_attributes])[
6a26ecf7   Mario Lang   Imported Upstream...
495
m4_text_wrap([$2], [             ], [- ]m4_format([%-10s ], [$1]), brltty_help_width)])])
72c536f8   Mario Lang   Imported Upstream...
496
497
498
499
500
501

AC_DEFUN([BRLTTY_SUMMARY_BEGIN], [dnl
brltty_summary_lines="Options Summary:"
])

AC_DEFUN([BRLTTY_SUMMARY_END], [dnl
c100d13a   Mario Lang   Imported Upstream...
502
AC_CONFIG_COMMANDS([item-summary],
72c536f8   Mario Lang   Imported Upstream...
503
   [AC_MSG_NOTICE([${brltty_summary_lines}])],
c100d13a   Mario Lang   Imported Upstream...
504
   [brltty_summary_lines='${brltty_summary_lines}']
72c536f8   Mario Lang   Imported Upstream...
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
)])

AC_DEFUN([BRLTTY_SUMMARY_ITEM], [dnl
brltty_summary_lines="${brltty_summary_lines}
   $1: ${$2}"])

AC_DEFUN([BRLTTY_PORTABLE_DIRECTORY], [dnl
   BRLTTY_TOPLEVEL_DIRECTORY([$1], [$2], [prefix])])

AC_DEFUN([BRLTTY_ARCHITECTURE_DIRECTORY], [dnl
if test "${exec_prefix}" = "NONE"
then
   BRLTTY_TOPLEVEL_DIRECTORY([$1], [$2], [exec_prefix])
fi])

AC_DEFUN([BRLTTY_TOPLEVEL_DIRECTORY], [dnl
if test "${prefix}" = "NONE"
then
   if test -z "${execute_root}"
   then
be26d4ea   Mario Lang   Imported Upstream...
525
      [if test `expr "${$1} " : '\${$3}/[^/]*$'` -gt 0]
72c536f8   Mario Lang   Imported Upstream...
526
527
528
529
530
531
532
      then
         $1="`echo ${$1} | sed -e 's%/%$2/%'`"
      fi
   fi
fi])

AC_DEFUN([BRLTTY_EXECUTABLE_PATH], [dnl
be26d4ea   Mario Lang   Imported Upstream...
533
[if test `expr "${$1} " : '[^/ ][^/ ]*/'` -gt 0]
72c536f8   Mario Lang   Imported Upstream...
534
535
536
537
538
539
540
541
542
543
then
   $1="`pwd`/${$1}"
fi])

AC_DEFUN([BRLTTY_IF_PACKAGE], [dnl
BRLTTY_ARG_WITH(
   [$2], [DIRECTORY],
   [where the $1 package is installed],
   [$2_root], ["yes"]
)
67e7bfbc   samuel thibault   New upstream vers...
544
545
546
547
548

$2_found=false
m4_define([$2_find], ifelse(m4_eval($# > 4), 1, [true], [false]))
ifelse($2_find, [true], [BRLTTY_HAVE_PACKAGE([$2], [$1], [$2_found=true], [])])

72c536f8   Mario Lang   Imported Upstream...
549
550
551
552
553
if test "${$2_root}" = "no"
then
   $2_root=""
elif test "${$2_root}" = "yes"
then
67e7bfbc   samuel thibault   New upstream vers...
554
555
556
557
558
559
560
561
562
563
564
565
566
567
   "${$2_found}" || {
      $2_root=""
      roots="/usr /usr/local /usr/local/$1 /usr/local/$2 /opt/$1 /opt/$2 /mingw /mingw/$1 /mingw/$2"

      for root in ${roots}
      do
         test -f "${root}/$3" && {
            $2_root="${root}"
            AC_MSG_NOTICE([$1 root: ${$2_root}])
            break
         }
      done

      if test -z "${$2_root}"
72c536f8   Mario Lang   Imported Upstream...
568
      then
67e7bfbc   samuel thibault   New upstream vers...
569
         AC_MSG_WARN([$1 package not found: ${roots}])
72c536f8   Mario Lang   Imported Upstream...
570
      fi
67e7bfbc   samuel thibault   New upstream vers...
571
   }
72c536f8   Mario Lang   Imported Upstream...
572
fi
67e7bfbc   samuel thibault   New upstream vers...
573

72c536f8   Mario Lang   Imported Upstream...
574
575
AC_SUBST([$2_root])
BRLTTY_SUMMARY_ITEM([$2-root], [$2_root])
67e7bfbc   samuel thibault   New upstream vers...
576
577

test -n "${$2_root}" && {
c100d13a   Mario Lang   Imported Upstream...
578
   AC_DEFINE_UNQUOTED(BRLTTY_UPPERCASE_TRANSLATE([$2_root]), ["${$2_root}"],
be26d4ea   Mario Lang   Imported Upstream...
579
                      [Define this to be a string containing the path to the root of the $1 package.])
67e7bfbc   samuel thibault   New upstream vers...
580
581
582
583
584
585
586
587

   ifelse($2_find, [true], [dnl
      test "${$2_root}" = "yes" || {
         $2_includes="BRLTTY_WORDS_PREPEND([$5], [-I${$2_root}/])"
         $2_libs="BRLTTY_WORDS_PREPEND([$6], [-L${$2_root}/]) BRLTTY_WORDS_PREPEND([$7], [-l])"
      }
   ])

72c536f8   Mario Lang   Imported Upstream...
588
   $4
67e7bfbc   samuel thibault   New upstream vers...
589
590
591
592
593
}
])

AC_DEFUN([BRLTTY_WORDS_PREPEND], [dnl
patsubst([$1], [\(\S+\)], [$2\1])])
72c536f8   Mario Lang   Imported Upstream...
594

12927b0c   Mario Lang   Imported Upstream...
595
AC_DEFUN([BRLTTY_HAVE_PACKAGE], [dnl
d8488191   samuel thibault   Imported Upstream...
596
$1_package=""
12927b0c   Mario Lang   Imported Upstream...
597
598
$1_includes=""
$1_libs=""
d8488191   samuel thibault   Imported Upstream...
599

12927b0c   Mario Lang   Imported Upstream...
600
601
for package_specification in $2
do
d8488191   samuel thibault   Imported Upstream...
602
   ${PKG_CONFIG} --exists "${package_specification}" && {
67e7bfbc   samuel thibault   New upstream vers...
603
604
      AC_DEFINE(BRLTTY_UPPERCASE_TRANSLATE([HAVE_PKG_$1]))

d8488191   samuel thibault   Imported Upstream...
605
      $1_package="${package_specification%% *}"
67e7bfbc   samuel thibault   New upstream vers...
606
607
      AC_MSG_NOTICE([$1 package: ${$1_package}])

d8488191   samuel thibault   Imported Upstream...
608
      $1_includes=`${PKG_CONFIG} --cflags-only-I "${$1_package}"`
67e7bfbc   samuel thibault   New upstream vers...
609
610
      AC_MSG_NOTICE([$1 includes: ${$1_includes}])

d8488191   samuel thibault   Imported Upstream...
611
      $1_libs=`${PKG_CONFIG} ${pkgconfig_flags_libs} "${$1_package}"`
67e7bfbc   samuel thibault   New upstream vers...
612
613
      AC_MSG_NOTICE([$1 libs: ${$1_libs}])

12927b0c   Mario Lang   Imported Upstream...
614
615
616
617
      $3
      break
   }
done
d8488191   samuel thibault   Imported Upstream...
618

67e7bfbc   samuel thibault   New upstream vers...
619
620
621
622
test -n "${$1_package}" || {
   ifelse([$#], 4, [:], AC_MSG_WARN([$1 support not available]))
}

d8488191   samuel thibault   Imported Upstream...
623
AC_SUBST([$1_package])
12927b0c   Mario Lang   Imported Upstream...
624
625
626
627
AC_SUBST([$1_includes])
AC_SUBST([$1_libs])
])

be26d4ea   Mario Lang   Imported Upstream...
628
629
AC_DEFUN([BRLTTY_HAVE_PTHREADS], [dnl
   AC_CACHE_CHECK([if pthreads are available], [brltty_cv_have_pthreads], [dnl
6a26ecf7   Mario Lang   Imported Upstream...
630
      SYSCFLAGS="${SYSCFLAGS} -D_REENTRANT"
72c536f8   Mario Lang   Imported Upstream...
631
632
633
      case "${host_os}"
      in
         mingw32*)
be26d4ea   Mario Lang   Imported Upstream...
634
            brltty_cv_have_pthreads=yes
72c536f8   Mario Lang   Imported Upstream...
635
636
            ;;
         *)
be26d4ea   Mario Lang   Imported Upstream...
637
            brltty_cv_have_pthreads=no
72c536f8   Mario Lang   Imported Upstream...
638
            AC_CHECK_HEADER([pthread.h], [dnl
72c536f8   Mario Lang   Imported Upstream...
639
640
               case "${host_os}"
               in
be26d4ea   Mario Lang   Imported Upstream...
641
642
643
                  solaris*) AC_SEARCH_LIBS([_getfp], [pthread], [brltty_cv_have_pthreads=yes]);;
                  hpux*) AC_SEARCH_LIBS([__pthread_cancel_stack], [pthread], [brltty_cv_have_pthreads=yes]);;
                  *) AC_SEARCH_LIBS([pthread_create], [pthread c_r], [brltty_cv_have_pthreads=yes]);;
72c536f8   Mario Lang   Imported Upstream...
644
               esac
72c536f8   Mario Lang   Imported Upstream...
645
646
647
648
            ])
            ;;
      esac
   ])
72c536f8   Mario Lang   Imported Upstream...
649
650
])

be26d4ea   Mario Lang   Imported Upstream...
651
652
653
654
655
656
AC_DEFUN([BRLTTY_IF_PTHREADS], [dnl
AC_REQUIRE([BRLTTY_HAVE_PTHREADS])
test "${brltty_cv_have_pthreads}" = "yes" && {
   $1
}])

72c536f8   Mario Lang   Imported Upstream...
657
658
659
660
AC_DEFUN([BRLTTY_PACKAGE_CHOOSE], [dnl
BRLTTY_ARG_WITH(
   [translit([$1], [_], [-])], [PACKAGE],
   [which translit([$1], [_], [ ]) package to use (BRLTTY_PACKAGE_LIST(m4_shift($@)))],
90c515c4   Mario Lang   Imported Upstream...
661
   [$1_package], ["yes"]
72c536f8   Mario Lang   Imported Upstream...
662
)
90c515c4   Mario Lang   Imported Upstream...
663
if test "${$1_package}" = "no"
72c536f8   Mario Lang   Imported Upstream...
664
then
90c515c4   Mario Lang   Imported Upstream...
665
666
   $1_package=""
elif test "${$1_package}" = "yes"
72c536f8   Mario Lang   Imported Upstream...
667
668
669
670
671
672
673
674
675
676
677
678
679
then
AC_CACHE_CHECK([which translit([$1], [_], [ ]) package to use], [brltty_cv_package_$1], [dnl
   brltty_cv_package_$1=""
   brltty_packages=""
   BRLTTY_PACKAGE_DEFINE(m4_shift($@))

   for brltty_package in ${brltty_packages}
   do
      eval 'brltty_headers="${brltty_headers_'"${brltty_package}"'}"'
      test -n "${brltty_headers}" && {
         brltty_found=true
         for brltty_header in ${brltty_headers}
         do
90c515c4   Mario Lang   Imported Upstream...
680
            AC_CHECK_HEADER([${brltty_header}], [], [brltty_found=false], [-])
72c536f8   Mario Lang   Imported Upstream...
681
682
683
684
685
686
687
688
689
690
            "${brltty_found}" || break
         done
         "${brltty_found}" || continue
      }

      AC_CHECK_LIB([${brltty_package}], [main], [], [continue])
      brltty_cv_package_$1="${brltty_package}"
      break
   done
])
90c515c4   Mario Lang   Imported Upstream...
691
   $1_package="${brltty_cv_package_$1}"
72c536f8   Mario Lang   Imported Upstream...
692
else
90c515c4   Mario Lang   Imported Upstream...
693
   AC_HAVE_LIBRARY([${$1_package}], [], [$1_package=""])
72c536f8   Mario Lang   Imported Upstream...
694
fi
90c515c4   Mario Lang   Imported Upstream...
695
696
697
AC_SUBST([$1_package])
test -n "${$1_package}" && {
   BRLTTY_UPPERCASE_ASSIGN([brltty_uc], [${$1_package}])
72c536f8   Mario Lang   Imported Upstream...
698
   AC_DEFINE_UNQUOTED([HAVE_PKG_${brltty_uc}])
90c515c4   Mario Lang   Imported Upstream...
699
   BRLTTY_SUMMARY_ITEM([translit([$1], [_], [-])-package], [$1_package])
72c536f8   Mario Lang   Imported Upstream...
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
}])
AC_DEFUN([BRLTTY_PACKAGE_DEFINE], [dnl
ifelse($#, 0, [], [dnl

set -- [$1]
brltty_package="${1}"
shift 1
eval "brltty_headers_${brltty_package}"'="${*}"'
brltty_packages="${brltty_packages} ${brltty_package}"
ifelse($#, 1, [], [BRLTTY_PACKAGE_DEFINE(m4_shift($@))])])])
AC_DEFUN([BRLTTY_PACKAGE_LIST], [dnl
ifelse($#, 0, [], $#, 1, [BRLTTY_PACKAGE_NAME([$1])], [BRLTTY_PACKAGE_NAME([$1]) BRLTTY_PACKAGE_LIST(m4_shift($@))])])
AC_DEFUN([BRLTTY_PACKAGE_NAME], [patsubst([$1], [^ *\(\w+\).*], [\1])])

AC_DEFUN([BRLTTY_OPTIONS_LD2CC], [dnl
`echo "$1" | sed -e '
/^$/d
s/^ */-Wl /
s/ *$//
s/  */,/g
'`])

AC_DEFUN([BRLTTY_HAVE_WINDOWS_LIBRARY], [dnl
AC_CACHE_CHECK(
   [if DLL $1 can be loaded],
   [brltty_cv_dll_$1],
   [AC_TRY_RUN([
#include <windows.h>
int main () {
   return !LoadLibrary("$1.DLL");
}
],
[brltty_cv_dll_$1=yes],
[brltty_cv_dll_$1=no])])
if test "${brltty_cv_dll_$1}" = "yes"
then
   AC_HAVE_LIBRARY([$1])
be26d4ea   Mario Lang   Imported Upstream...
737
738
739
740
   $2
else
   :
   $3
72c536f8   Mario Lang   Imported Upstream...
741
742
743
744
745
746
747
748
749
750
751
752
753
754
fi])

AC_DEFUN([BRLTTY_HAVE_WINDOWS_FUNCTION], [dnl
AC_CACHE_CHECK(
   [if function $1 in DLL $2 exists],
   [brltty_cv_function_$1],
   [AC_TRY_RUN([
#include <windows.h>
#include <stdio.h>
#include <errno.h>

int
main (void) {
  HMODULE module;
be26d4ea   Mario Lang   Imported Upstream...
755
756
757
758
  HINSTANCE instance;
  if (!(instance = LoadLibrary("$2.dll"))) return 1;
  if (!(module = GetModuleHandle("$2.dll"))) return 2;
  if (!(GetProcAddress(module, "$1"))) return 3;
72c536f8   Mario Lang   Imported Upstream...
759
760
761
762
763
764
765
  return 0;
}
],
   [brltty_cv_function_$1=yes],
   [brltty_cv_function_$1=no])])
if test "${brltty_cv_function_$1}" = "yes"
then
c100d13a   Mario Lang   Imported Upstream...
766
   AC_DEFINE(BRLTTY_UPPERCASE_TRANSLATE([HAVE_$1]), [1],
be26d4ea   Mario Lang   Imported Upstream...
767
768
769
770
771
             [Define this if the function $1 is available.])
   $3
else
   :
   $4
72c536f8   Mario Lang   Imported Upstream...
772
773
fi
])
be26d4ea   Mario Lang   Imported Upstream...
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794

AC_DEFUN([BRLTTY_BINDINGS], [dnl
ifelse($#, 1, [dnl
BRLTTY_BINDINGS([$1], m4_tolower([$1]), m4_toupper([$1]))dnl
], [dnl
BRLTTY_ARG_DISABLE(
   [$2-bindings],
   [$1 bindings for BrlAPI],
   [],
   [
      m4_include([Bindings/$1/bindings.m4])
      BRLTTY_$3_BINDINGS
      if "${$3_OK}"
      then
         api_bindings="${api_bindings} $1"
      else
         AC_MSG_WARN([$1 BrlAPI bindings not included])
      fi
   ]
)dnl
])])