Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlfaultinjection / repo / third_party / nlbuild-autotools / repo / autoconf / m4 / nl_with_package.m4
1 #
2 #    Copyright 2015-2016 Nest Labs Inc. All Rights Reserved.
3 #
4 #    Licensed under the Apache License, Version 2.0 (the "License");
5 #    you may not use this file except in compliance with the License.
6 #    You may obtain a copy of the License at
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #    Unless required by applicable law or agreed to in writing, software
11 #    distributed under the License is distributed on an "AS IS" BASIS,
12 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #    See the License for the specific language governing permissions and
14 #    limitations under the License.
15 #
16
17 #
18 #    Description:
19 #      This file defines a GNU autoconf M4-style macro for checking
20 #      the presence and viability of both required and optional
21 #      dependent packages, which may be internal or external to the
22 #      current package.
23 #
24 #      Five (5) macros are made available:
25 #
26 #        * NL_WITH_REQUIRED_EXTERNAL_PACKAGE
27 #        * NL_WITH_OPTIONAL_EXTERNAL_PACKAGE
28 #        * NL_WITH_REQUIRED_INTERNAL_PACKAGE
29 #        * NL_WITH_OPTIONAL_INTERNAL_PACKAGE
30 #        * NL_WITH_PACKAGE
31 #
32 #      Note, however, that NL_WITH_PACKAGE is deprecated and maps to
33 #      NL_WITH_REQUIRED_INTERNAL_PACKAGE.
34 #
35
36 # _NL_ARG_WITH_INCLUDES_OR_LIBS(PACKAGE-DISPOSITION,
37 #                               PACKAGE-SOURCE,
38 #                               PACKAGE-PRETTY-NAME,
39 #                               PACKAGE-VARIABLE-PREFIX,
40 #                               PACKAGE-SUCCINCT-NAME,
41 #                               PACKAGE-WITH-OPTION,
42 #                               PLURAL-WITH-OPTION-HELP-WORD,
43 #                               WITH-DIR-VARIABLE-MODIFIER)
44 # ----------------------------------------------------------------------------
45 # This is a wrapper around AC_ARG_WITH that provides the ability to
46 # optionally specify a dependent package include and link library
47 # directories independently as
48 # --with-<PACKAGE-SUCCINCT-NAME>-<PACKAGE-WITH-OPTION>=<DIR>.
49 #
50 # If the package is specified as required, the use of
51 # --without-<PACKAGE-SUCCINCT-NAME> or the use of
52 # --with-<PACKAGE-SUCCINCT-NAME>=no will result in a fatal error.
53 #
54 # At the successful conclusion of the execution of the macro, 
55 # two variables will be defined:
56 #
57 #   * nl_with_<PACKAGE-SUCCINCT-NAME>
58 #   * <PACKAGE-SUCCINT-NAME>_<WITH-DIR-VARIABLE-MODIFIER>_dir
59 #
60 # The package disposition and source are specified by:
61 #
62 #   PACKAGE-DISPOSITION     : This may be either 'required' if the dependent
63 #                             package is required or 'optional' if
64 #                             not.
65 #   PACKAGE-SOURCE          : This may be either 'internal' if the dependent
66 #                             package may be provided either
67 #                             internally or externally to the current
68 #                             package or 'external' if the dependent
69 #                             package may only be provided outside of
70 #                             the current package. This also serves as
71 #                             the default value for where the
72 #                             configuration script expects to find the
73 #                             package.
74 #
75 # The dependent package is specified in three forms:
76 #
77 #   PACKAGE-PRETTY-NAME     : The human-readable name by which the package
78 #                             will be referred for any diagnostic output. For
79 #                             example, "My Great Software Package".
80 #   PACKAGE-VARIABLE-PREFIX : The package-specific prefix applied to variables
81 #                             defined as a result of running this macro for the
82 #                             packages. For example, "MGSP" here is transformed
83 #                             into MGSP_CPPFLAGS.
84 #   PACKAGE-SUCCINCT-NAME   : The package-specific name used for pkg-config,
85 #                             in temporary variables and on the
86 #                             configure command line.  For example,
87 #                             "mgsp" here is used for --with-mgsp=DIR
88 #                             or 'pkg-config --cflags mgsp'.
89 # ----------------------------------------------------------------------------
90 AC_DEFUN([_NL_ARG_WITH_INCLUDES_OR_LIBS],
91 [
92     dnl Check whether or not the package is required
93
94     m4_case([$1],
95         [required],[],
96         [optional],[],
97         [m4_fatal([$0: invalid disposition value '$1'; must be 'required' or 'optional'])])
98
99     dnl Check whether or not the package is internal
100
101     m4_case([$2],
102         [internal],[],
103         [external],[],
104         [m4_fatal([$0: invalid source value '$2'; must be 'internal' or 'external'])])
105
106     AC_ARG_WITH($5-$6,
107         AS_HELP_STRING([--with-$5-$6=DIR],
108                    [Specify location of $1 $3 $7 @<:@default=$2@:>@.]),
109         [
110             if test "${withval}" = "no"; then
111                 m4_if([$1],
112                       [required],
113                       [AC_MSG_ERROR([${PACKAGE_NAME} requires the $3 package.])],
114                       [nl_with_$5=${withval}])
115             fi
116         
117             if test "x${$5_dir}" != "x"; then
118                 AC_MSG_WARN([overriding --with-$5=${$5_dir}])
119             fi
120
121             if test "${withval}" = "internal"; then
122                 $5_$8_dir=${withval}
123                 nl_with_$5=${withval}
124             else
125                 $5_$8_dir=${withval}
126                 nl_with_$5=external
127             fi
128         ],
129         [
130             $5_$8_dir=;
131             if test "x${nl_with_$5}" = "x"; then
132                 nl_with_$5=$2
133             fi
134         ])
135 ])
136
137 # _NL_ARG_WITH_INCLUDES(PACKAGE-DISPOSITION,
138 #                       PACKAGE-SOURCE,
139 #                       PACKAGE-PRETTY-NAME,
140 #                       PACKAGE-VARIABLE-PREFIX,
141 #                       PACKAGE-SUCCINCT-NAME)
142 # ----------------------------------------------------------------------------
143 # This is a wrapper around AC_ARG_WITH that provides the ability to
144 # optionally specify a dependent package include directory
145 # independently as --with-<PACKAGE-SUCCINCT-NAME>-includes=<DIR>.
146 #
147 # If the package is specified as required, the use of
148 # --without-<PACKAGE-SUCCINCT-NAME>-includes or the use of
149 # --with-<PACKAGE-SUCCINCT-NAME>-includes=no will result in a fatal error.
150 #
151 # At the successful conclusion of the execution of the macro, 
152 # two variables will be defined:
153 #
154 #   * nl_with_<PACKAGE-SUCCINCT-NAME>
155 #   * <PACKAGE-SUCCINT-NAME>_header_dir
156 #
157 # The package disposition and source are specified by:
158 #
159 #   PACKAGE-DISPOSITION     : This may be either 'required' if the dependent
160 #                             package is required or 'optional' if
161 #                             not.
162 #   PACKAGE-SOURCE          : This may be either 'internal' if the dependent
163 #                             package may be provided either
164 #                             internally or externally to the current
165 #                             package or 'external' if the dependent
166 #                             package may only be provided outside of
167 #                             the current package. This also serves as
168 #                             the default value for where the
169 #                             configuration script expects to find the
170 #                             package.
171 #
172 # The dependent package is specified in three forms:
173 #
174 #   PACKAGE-PRETTY-NAME     : The human-readable name by which the package
175 #                             will be referred for any diagnostic output. For
176 #                             example, "My Great Software Package".
177 #   PACKAGE-VARIABLE-PREFIX : The package-specific prefix applied to variables
178 #                             defined as a result of running this macro for the
179 #                             packages. For example, "MGSP" here is transformed
180 #                             into MGSP_CPPFLAGS.
181 #   PACKAGE-SUCCINCT-NAME   : The package-specific name used for pkg-config,
182 #                             in temporary variables and on the
183 #                             configure command line.  For example,
184 #                             "mgsp" here is used for --with-mgsp=DIR
185 #                             or 'pkg-config --cflags mgsp'.
186 # ----------------------------------------------------------------------------
187 AC_DEFUN([_NL_ARG_WITH_INCLUDES],
188 [
189     _NL_ARG_WITH_INCLUDES_OR_LIBS([$1], [$2], [$3], [$4], [$5], [includes], [headers], [header])dnl
190 ])
191
192 # _NL_ARG_WITH_LIBS(PACKAGE-DISPOSITION,
193 #                   PACKAGE-SOURCE,
194 #                   PACKAGE-PRETTY-NAME,
195 #                   PACKAGE-VARIABLE-PREFIX,
196 #                   PACKAGE-SUCCINCT-NAME)
197 # ----------------------------------------------------------------------------
198 # This is a wrapper around AC_ARG_WITH that provides the ability to
199 # optionally specify a dependent package link library directory
200 # independently as --with-<PACKAGE-SUCCINCT-NAME>-libs=<DIR>.
201 #
202 # If the package is specified as required, the use of
203 # --without-<PACKAGE-SUCCINCT-NAME>-libs or the use of
204 # --with-<PACKAGE-SUCCINCT-NAME>-libs=no will result in a fatal error.
205 #
206 # At the successful conclusion of the execution of the macro, 
207 # two variables will be defined:
208 #
209 #   * nl_with_<PACKAGE-SUCCINCT-NAME>
210 #   * <PACKAGE-SUCCINT-NAME>_library_dir
211 #
212 # The package disposition and source are specified by:
213 #
214 #   PACKAGE-DISPOSITION     : This may be either 'required' if the dependent
215 #                             package is required or 'optional' if
216 #                             not.
217 #   PACKAGE-SOURCE          : This may be either 'internal' if the dependent
218 #                             package may be provided either
219 #                             internally or externally to the current
220 #                             package or 'external' if the dependent
221 #                             package may only be provided outside of
222 #                             the current package. This also serves as
223 #                             the default value for where the
224 #                             configuration script expects to find the
225 #                             package.
226 #
227 # The dependent package is specified in three forms:
228 #
229 #   PACKAGE-PRETTY-NAME     : The human-readable name by which the package
230 #                             will be referred for any diagnostic output. For
231 #                             example, "My Great Software Package".
232 #   PACKAGE-VARIABLE-PREFIX : The package-specific prefix applied to variables
233 #                             defined as a result of running this macro for the
234 #                             packages. For example, "MGSP" here is transformed
235 #                             into MGSP_CPPFLAGS.
236 #   PACKAGE-SUCCINCT-NAME   : The package-specific name used for pkg-config,
237 #                             in temporary variables and on the
238 #                             configure command line.  For example,
239 #                             "mgsp" here is used for --with-mgsp=DIR
240 #                             or 'pkg-config --cflags mgsp'.
241 # ----------------------------------------------------------------------------
242 AC_DEFUN([_NL_ARG_WITH_LIBS],
243 [
244     _NL_ARG_WITH_INCLUDES_OR_LIBS([$1], [$2], [$3], [$4], [$5], [libs], [libraries], [library])dnl
245 ])
246
247 # _NL_ARG_WITH_PACKAGE(PACKAGE-DISPOSITION,
248 #                      PACKAGE-SOURCE,
249 #                      PACKAGE-PRETTY-NAME,
250 #                      PACKAGE-VARIABLE-PREFIX,
251 #                      PACKAGE-SUCCINCT-NAME)
252 # ----------------------------------------------------------------------------
253 # This is a wrapper around AC_ARG_WITH that provides the ability to
254 # optionally specify a dependent package as
255 # --with-<PACKAGE-SUCCINCT-NAME>=<DIR> or to independently specify the
256 # include and link library directories independently as
257 # --with-<PACKAGE-SUCCINCT-NAME>-includes=<DIR> and
258 # --with-<PACKAGE-SUCCINCT-NAME>-libs=<DIR>.
259 #
260 # If the package is specified as required, the use of
261 # --without-<PACKAGE-SUCCINCT-NAME>* or the use of
262 # --with-<PACKAGE-SUCCINCT-NAME>*=no will result in a fatal error.
263 #
264 # At the successful conclusion of the execution of the macro, 
265 # two or more variables will be defined:
266 #
267 #   * nl_with_<PACKAGE-SUCCINCT-NAME>
268 #   * <PACKAGE-SUCCINT-NAME>_dir
269 #   * <PACKAGE-SUCCINT-NAME>_header_dir
270 #   * <PACKAGE-SUCCINT-NAME>_library_dir
271 #
272 # The package disposition and source are specified by:
273 #
274 #   PACKAGE-DISPOSITION     : This may be either 'required' if the dependent
275 #                             package is required or 'optional' if
276 #                             not.
277 #   PACKAGE-SOURCE          : This may be either 'internal' if the dependent
278 #                             package may be provided either
279 #                             internally or externally to the current
280 #                             package or 'external' if the dependent
281 #                             package may only be provided outside of
282 #                             the current package. This also serves as
283 #                             the default value for where the
284 #                             configuration script expects to find the
285 #                             package.
286 #
287 # The dependent package is specified in three forms:
288 #
289 #   PACKAGE-PRETTY-NAME     : The human-readable name by which the package
290 #                             will be referred for any diagnostic output. For
291 #                             example, "My Great Software Package".
292 #   PACKAGE-VARIABLE-PREFIX : The package-specific prefix applied to variables
293 #                             defined as a result of running this macro for the
294 #                             packages. For example, "MGSP" here is transformed
295 #                             into MGSP_CPPFLAGS.
296 #   PACKAGE-SUCCINCT-NAME   : The package-specific name used for pkg-config,
297 #                             in temporary variables and on the
298 #                             configure command line.  For example,
299 #                             "mgsp" here is used for --with-mgsp=DIR
300 #                             or 'pkg-config --cflags mgsp'.
301 # ----------------------------------------------------------------------------
302 AC_DEFUN([_NL_ARG_WITH_PACKAGE],
303 [
304     AC_ARG_WITH($5,
305         AS_HELP_STRING([--with-$5=DIR],
306                    [Specify location of the $1 $3 headers and libraries @<:@default=$2@:>@.]),
307         [
308             if test "${withval}" = "no"; then
309                 m4_if([$1],
310                       [required],
311                       [AC_MSG_ERROR([${PACKAGE_NAME} requires the $3 package.])],
312                       [nl_with_$5=${withval}])
313             elif test "${withval}" = "internal"; then
314                 $5_dir=${withval}
315                 nl_with_$5=${withval}
316             else
317                 $5_dir=${withval}
318                 nl_with_$5=external
319             fi
320         ],
321         [$5_dir=; nl_with_$5=$2])
322
323     # Allow users to specify external headers and libraries independently.
324
325     _NL_ARG_WITH_INCLUDES([$1], [$2], [$3], [$4], [$5])dnl
326
327     _NL_ARG_WITH_LIBS([$1], [$2], [$3], [$4], [$5])dnl
328 ])
329
330 # _NL_WITH_PACKAGE(PACKAGE-DISPOSITION,
331 #                  PACKAGE-SOURCE,
332 #                  PACKAGE-PRETTY-NAME,
333 #                  PACKAGE-VARIABLE-PREFIX,
334 #                  PACKAGE-SUCCINCT-NAME,
335 #                  [DEFAULT-PACKAGE-LIBS],
336 #                  [ACTIONS-TO-RUN-IF-NOT-EXTERNAL],
337 #                  [ACTIONS-TO-RUN-IF-NOT-INTERNAL])
338 # ----------------------------------------------------------------------------
339 # This macro is used to test for the presence, with pkg-config if it
340 # is available, of the specified, optional or required dependent
341 # package. The dependent package may be provided externally or may
342 # exist within the current package itself.
343 #
344 # If the package is specified as required, failure to find the
345 # dependent package will result in a fatal error.
346 #
347 # At the successful conclusion of the execution of the macro, three
348 # variables will be defined:
349 #
350 #   * <PACKAGE-VARIABLE-PREFIX>_CPPFLAGS
351 #   * <PACKAGE-VARIABLE-PREFIX>_LDFLAGS
352 #   * <PACKAGE-VARIABLE-PREFIX>_LIBS
353 #
354 # In addition, the variable:
355 #
356 #   * nl_with_<PACKAGE-SUCCINCT-NAME>
357 #
358 # will unconditionally be set to the source of the package if it is to
359 # be used and is found; otherwise, 'no' if it is not to be used.
360 #
361 # The package disposition and source are specified by:
362 #
363 #   PACKAGE-DISPOSITION     : This may be either 'required' if the dependent
364 #                             package is required or 'optional' if
365 #                             not.
366 #   PACKAGE-SOURCE          : This may be either 'internal' if the dependent
367 #                             package may be provided either
368 #                             internally or externally to the current
369 #                             package or 'external' if the dependent
370 #                             package may only be provided outside of
371 #                             the current package. This also serves as
372 #                             the default value for where the
373 #                             configuration script expects to find the
374 #                             package.
375 #
376 # The dependent package is specified in three forms:
377 #
378 #   PACKAGE-PRETTY-NAME     : The human-readable name by which the package
379 #                             will be referred for any diagnostic output. For
380 #                             example, "My Great Software Package".
381 #   PACKAGE-VARIABLE-PREFIX : The package-specific prefix applied to variables
382 #                             defined as a result of running this macro for the
383 #                             packages. For example, "MGSP" here is transformed
384 #                             into MGSP_CPPFLAGS.
385 #   PACKAGE-SUCCINCT-NAME   : The package-specific name used for pkg-config,
386 #                             in temporary variables and on the
387 #                             configure command line.  For example,
388 #                             "mgsp" here is used for --with-mgsp=DIR
389 #                             or 'pkg-config --cflags mgsp'.
390 #
391 # In addition, if any additional, default link libraries are required
392 # for use with the package, these are specified as:
393 #
394 #   DEFAULT-PACKAGE-LIBS    : Default link libraries required for use with
395 #                             the package. These are used if pkg-config is
396 #                             not available or cannot identify any
397 #                             such libraries. For example, '-lmgsp'.
398 #
399 # If the package is specified, either internally or externally, optional
400 # actions are run.
401 #
402 #   ACTIONS-TO-RUN-IF-NOT-EXTERNAL : Optional actions to run if the package
403 #                                    is not external.
404 #   ACTIONS-TO-RUN-IF-NOT-INTERNAL : Optional actions to run if the package
405 #                                    is not internal.
406 # ----------------------------------------------------------------------------
407 AC_DEFUN([_NL_WITH_PACKAGE],
408 [
409     # Influential external variables for the package support
410
411     AC_ARG_VAR($4_CPPFLAGS, [$3 C preprocessor flags])
412     AC_ARG_VAR($4_LDFLAGS,  [$3 linker flags])
413     AC_ARG_VAR($4_LIBS,     [$3 linker libraries])
414
415     # Allow the user to specify both external headers and libraries
416     # together (or internal).
417
418     _NL_ARG_WITH_PACKAGE([$1], [$2], [$3], [$4], [$5])dnl
419
420     if test "${nl_with_$5}" == "no"; then
421         AC_MSG_CHECKING([whether to use the $3 package])
422         AC_MSG_RESULT([${nl_with_$5}])
423
424     else
425         AC_MSG_CHECKING([source of the $3 package])
426         AC_MSG_RESULT([${nl_with_$5}])
427
428         # If the user has selected or has defaulted into the internal $3
429         # package, set the values appropriately. Otherwise, run through the
430         # usual routine.
431
432         if test "${nl_with_$5}" = "internal"; then
433             $7
434
435         else
436             # We always prefer checking the values of the various '--with-$5-...' 
437             # options first to using pkg-config because the former might be used
438             # in a cross-compilation environment on a system that also contains
439             # pkg-config. In such a case, the user wants what he/she specified
440             # rather than what pkg-config indicates.
441
442             if test "x${$5_dir}" != "x" -o "x${$5_header_dir}" != "x" -o "x${$5_library_dir}" != "x"; then
443                         if test "x${$5_dir}" != "x"; then
444                     if test -d "${$5_dir}"; then
445                         if test -d "${$5_dir}/include"; then
446                             $4_CPPFLAGS="-I${$5_dir}/include"
447                         else
448                             $4_CPPFLAGS="-I${$5_dir}"
449                         fi
450
451                         if test -d "${$5_dir}/lib"; then
452                             $4_LDFLAGS="-L${$5_dir}/lib"
453                         else
454                             $4_LDFLAGS="-L${$5_dir}"
455                         fi
456                     else
457                         AC_MSG_ERROR([No such directory ${$5_dir}])
458                     fi
459                 fi
460
461                 if test "x${$5_header_dir}" != "x"; then
462                     if test -d "${$5_header_dir}"; then
463                         $4_CPPFLAGS="-I${$5_header_dir}"
464                     else
465                         AC_MSG_ERROR([No such directory ${$5_header_dir}])
466                     fi
467                 fi
468
469                 if test "x${$5_library_dir}" != "x"; then
470                     if test -d "${$5_library_dir}"; then
471                         $4_LDFLAGS="-L${$5_library_dir}"
472                     else
473                         AC_MSG_ERROR([No such directory ${$5_library_dir}])
474                     fi
475                 fi
476
477                 $4_LIBS="${$4_LDFLAGS} $6"
478
479             elif test "x${PKG_CONFIG}" != "x"; then
480                 if ${PKG_CONFIG} --exists "$5"; then
481                     $4_CPPFLAGS="`${PKG_CONFIG} --cflags $5`"
482                     $4_LDFLAGS="`${PKG_CONFIG} --libs-only-L $5`"
483                     $4_LIBS="`${PKG_CONFIG} --libs-only-l $5`"
484                 else
485                     m4_if([$1],
486                           [required],
487                           [AC_MSG_ERROR([Cannot find the $5 package with ${PKG_CONFIG}. ${PACKAGE_NAME} requires the $5 package. Try installing the package or use the relevant --with options to configure.])],
488                           [nl_with_$5="no"])
489                 fi
490
491             else
492                 m4_if([$1],
493                       [required],
494                       [AC_MSG_ERROR([Cannot find the $3 package. ${PACKAGE_NAME} requires the $3 package.])],
495                       [nl_with_$5="no"])
496             fi
497         fi
498
499         AC_SUBST($4_CPPFLAGS)
500         AC_SUBST($4_LDFLAGS)
501         AC_SUBST($4_LIBS)
502
503         if test "${nl_with_$5}" != "internal" -a "${nl_with_$5}" != "no"; then
504             nl_saved_CPPFLAGS="${CPPFLAGS}"
505             nl_saved_LDFLAGS="${LDFLAGS}"
506             nl_saved_LIBS="${LIBS}"
507
508             CPPFLAGS="${CPPFLAGS} ${$4_CPPFLAGS}"
509             LDFLAGS="${LDFLAGS} ${$4_LDFLAGS}"
510             LIBS="${LIBS} ${$4_LIBS}"
511
512                 $8
513
514             CPPFLAGS="${nl_saved_CPPFLAGS}"
515             LDFLAGS="${nl_saved_LDFLAGS}"
516             LIBS="${nl_saved_LIBS}"
517         fi
518     fi
519 ])
520
521 # NL_WITH_REQUIRED_EXTERNAL_PACKAGE(PACKAGE-PRETTY-NAME,
522 #                                   PACKAGE-VARIABLE-PREFIX,
523 #                                   PACKAGE-SUCCINCT-NAME,
524 #                                   [DEFAULT-PACKAGE-LIBS],
525 #                                   [ACTIONS-TO-RUN])
526 # ----------------------------------------------------------------------------
527 # This macro is used to test for the presence, with pkg-config if it
528 # is available, of the specified, required external dependent package.
529 #
530 # Failure to find the dependent package will result in a fatal error.
531 #
532 # The dependent package is specified in three forms:
533 #
534 #   PACKAGE-PRETTY-NAME     : The human-readable name by which the package
535 #                             will be referred for any diagnostic output. For
536 #                             example, "My Great Software Package".
537 #   PACKAGE-VARIABLE-PREFIX : The package-specific prefix applied to variables
538 #                             defined as a result of running this macro for the
539 #                             packages. For example, "MGSP" here is transformed
540 #                             into MGSP_CPPFLAGS.
541 #   PACKAGE-SUCCINCT-NAME   : The package-specific name used for pkg-config,
542 #                             in temporary variables and on the
543 #                             configure command line.  For example,
544 #                             "mgsp" here is used for --with-mgsp=DIR
545 #                             or 'pkg-config --cflags mgsp'.
546 #
547 # In addition, if any additional, default link libraries are required
548 # for use with the package, these are specified as:
549 #
550 #   DEFAULT-PACKAGE-LIBS    : Default link libraries required for use with
551 #                             the package. These are used if pkg-config is
552 #                             not available or cannot identify any
553 #                             such libraries. For example, '-lmgsp'.
554 #
555 # If the package is specified, optional actions are run.
556 #
557 #   ACTIONS-TO-RUN-IF-FOUND : Optional actions to run if the package is found.
558 # ----------------------------------------------------------------------------
559 AC_DEFUN([NL_WITH_REQUIRED_EXTERNAL_PACKAGE],
560 [
561     _NL_WITH_PACKAGE([required], [external], [$1], [$2], [$3], [$4], [:], [$5])dnl
562 ])
563
564 # NL_WITH_OPTIONAL_EXTERNAL_PACKAGE(PACKAGE-PRETTY-NAME,
565 #                                   PACKAGE-VARIABLE-PREFIX,
566 #                                   PACKAGE-SUCCINCT-NAME,
567 #                                   [DEFAULT-PACKAGE-LIBS],
568 #                                   [ACTIONS-TO-RUN])
569 # ----------------------------------------------------------------------------
570 # This macro is used to test for the presence, with pkg-config if it
571 # is available, of the specified, optional external dependent package.
572 #
573 # Failure to find the dependent package will NOT result in a fatal error.
574 #
575 # The dependent package is specified in three forms:
576 #
577 #   PACKAGE-PRETTY-NAME     : The human-readable name by which the package
578 #                             will be referred for any diagnostic output. For
579 #                             example, "My Great Software Package".
580 #   PACKAGE-VARIABLE-PREFIX : The package-specific prefix applied to variables
581 #                             defined as a result of running this macro for the
582 #                             packages. For example, "MGSP" here is transformed
583 #                             into MGSP_CPPFLAGS.
584 #   PACKAGE-SUCCINCT-NAME   : The package-specific name used for pkg-config,
585 #                             in temporary variables and on the
586 #                             configure command line.  For example,
587 #                             "mgsp" here is used for --with-mgsp=DIR
588 #                             or 'pkg-config --cflags mgsp'.
589 #
590 # In addition, if any additional, default link libraries are required
591 # for use with the package, these are specified as:
592 #
593 #   DEFAULT-PACKAGE-LIBS    : Default link libraries required for use with
594 #                             the package. These are used if pkg-config is
595 #                             not available or cannot identify any
596 #                             such libraries. For example, '-lmgsp'.
597 #
598 # If the package is specified, optional actions are run.
599 #
600 #   ACTIONS-TO-RUN-IF-FOUND : Optional actions to run if the package is found.
601 # ----------------------------------------------------------------------------
602 AC_DEFUN([NL_WITH_OPTIONAL_EXTERNAL_PACKAGE],
603 [
604     _NL_WITH_PACKAGE([optional], [external], [$1], [$2], [$3], [$4], [:], [$5])dnl
605 ])
606
607 # NL_WITH_REQUIRED_INTERNAL_PACKAGE(PACKAGE-PRETTY-NAME,
608 #                                   PACKAGE-VARIABLE-PREFIX,
609 #                                   PACKAGE-SUCCINCT-NAME,
610 #                                   [DEFAULT-PACKAGE-LIBS],
611 #                                   [ACTIONS-TO-RUN-IF-NOT-EXTERNAL],
612 #                                   [ACTIONS-TO-RUN-IF-NOT-INTERNAL])
613 # ----------------------------------------------------------------------------
614 # This macro is used to test for the presence, with pkg-config if it
615 # is available, of the specified, required dependent package. The dependent
616 # package may be provided externally or may exist within the current
617 # package itself.
618 #
619 # Failure to find the dependent package will result in a fatal error.
620 #
621 # The dependent package is specified in three forms:
622 #
623 #   PACKAGE-PRETTY-NAME     : The human-readable name by which the package
624 #                             will be referred for any diagnostic output. For
625 #                             example, "My Great Software Package".
626 #   PACKAGE-VARIABLE-PREFIX : The package-specific prefix applied to variables
627 #                             defined as a result of running this macro for the
628 #                             packages. For example, "MGSP" here is transformed
629 #                             into MGSP_CPPFLAGS.
630 #   PACKAGE-SUCCINCT-NAME   : The package-specific name used for pkg-config,
631 #                             in temporary variables and on the
632 #                             configure command line.  For example,
633 #                             "mgsp" here is used for --with-mgsp=DIR
634 #                             or 'pkg-config --cflags mgsp'.
635 #
636 # In addition, if any additional, default link libraries are required
637 # for use with the package, these are specified as:
638 #
639 #   DEFAULT-PACKAGE-LIBS    : Default link libraries required for use with
640 #                             the package. These are used if pkg-config is
641 #                             not available or cannot identify any
642 #                             such libraries. For example, '-lmgsp'.
643 #
644 # If the package is specified, either internally or externally, optional
645 # actions are run.
646 #
647 #   ACTIONS-TO-RUN-IF-NOT-EXTERNAL : Optional actions to run if the package
648 #                                    is not external.
649 #   ACTIONS-TO-RUN-IF-NOT-INTERNAL : Optional actions to run if the package
650 #                                    is not internal.
651 # ----------------------------------------------------------------------------
652 AC_DEFUN([NL_WITH_REQUIRED_INTERNAL_PACKAGE],
653 [
654     _NL_WITH_PACKAGE([required], [internal], [$1], [$2], [$3], [$4], [$5], [$6])dnl
655 ])
656
657 # NL_WITH_OPTIONAL_INTERNAL_PACKAGE(PACKAGE-PRETTY-NAME,
658 #                                   PACKAGE-VARIABLE-PREFIX,
659 #                                   PACKAGE-SUCCINCT-NAME,
660 #                                   [DEFAULT-PACKAGE-LIBS],
661 #                                   [ACTIONS-TO-RUN-IF-NOT-EXTERNAL],
662 #                                   [ACTIONS-TO-RUN-IF-NOT-INTERNAL])
663 # ----------------------------------------------------------------------------
664 # This macro is used to test for the presence, with pkg-config if it
665 # is available, of the specified, optional dependent package. The dependent
666 # package may be provided externally or may exist within the current
667 # package itself.
668 #
669 # Failure to find the dependent package will NOT result in a fatal error.
670 #
671 # The dependent package is specified in three forms:
672 #
673 #   PACKAGE-PRETTY-NAME     : The human-readable name by which the package
674 #                             will be referred for any diagnostic output. For
675 #                             example, "My Great Software Package".
676 #   PACKAGE-VARIABLE-PREFIX : The package-specific prefix applied to variables
677 #                             defined as a result of running this macro for the
678 #                             packages. For example, "MGSP" here is transformed
679 #                             into MGSP_CPPFLAGS.
680 #   PACKAGE-SUCCINCT-NAME   : The package-specific name used for pkg-config,
681 #                             in temporary variables and on the
682 #                             configure command line.  For example,
683 #                             "mgsp" here is used for --with-mgsp=DIR
684 #                             or 'pkg-config --cflags mgsp'.
685 #
686 # In addition, if any additional, default link libraries are required
687 # for use with the package, these are specified as:
688 #
689 #   DEFAULT-PACKAGE-LIBS    : Default link libraries required for use with
690 #                             the package. These are used if pkg-config is
691 #                             not available or cannot identify any
692 #                             such libraries. For example, '-lmgsp'.
693 #
694 # If the package is specified, either internally or externally, optional
695 # actions are run.
696 #
697 #   ACTIONS-TO-RUN-IF-NOT-EXTERNAL : Optional actions to run if the package
698 #                                    is not external.
699 #   ACTIONS-TO-RUN-IF-NOT-INTERNAL : Optional actions to run if the package
700 #                                    is not internal.
701 # ----------------------------------------------------------------------------
702 AC_DEFUN([NL_WITH_OPTIONAL_INTERNAL_PACKAGE],
703 [
704     _NL_WITH_PACKAGE([optional], [internal], [$1], [$2], [$3], [$4], [$5], [$6])dnl
705 ])
706
707 # NL_WITH_PACKAGE(PACKAGE-PRETTY-NAME, PACKAGE-VARIABLE-PREFIX,
708 #                 PACKAGE-SUCCINCT-NAME, [DEFAULT-PACKAGE-LIBS],
709 #                 [ACTIONS-TO-RUN-IF-NOT-EXTERNAL],
710 #                 [ACTIONS-TO-RUN-IF-NOT-INTERNAL])
711 # ----------------------------------------------------------------------------
712 # This macro is used to test for the presence, with pkg-config if it
713 # is available, of the specified dependent package. The dependent
714 # package may be provided externally or may exist within the current
715 # package itself.
716 #
717 # The dependent package is specified in three forms:
718 #
719 #   PACKAGE-PRETTY-NAME     : The human-readable name by which the package
720 #                             will be referred for any diagnostic output. For
721 #                             example, "My Great Software Package".
722 #   PACKAGE-VARIABLE-PREFIX : The package-specific prefix applied to variables
723 #                             defined as a result of running this macro for the
724 #                             packages. For example, "MGSP" here is transformed
725 #                             into MGSP_CPPFLAGS.
726 #   PACKAGE-SUCCINCT-NAME   : The package-specific name used for pkg-config,
727 #                             in temporary variables and on the
728 #                             configure command line.  For example,
729 #                             "mgsp" here is used for --with-mgsp=DIR
730 #                             or 'pkg-config --cflags mgsp'.
731 #
732 # In addition, if any additional, default link libraries are required
733 # for use with the package, these are specified as:
734 #
735 #   DEFAULT-PACKAGE-LIBS    : Default link libraries required for use with
736 #                             the package. These are used if pkg-config is
737 #                             not available or cannot identify any
738 #                             such libraries. For example, '-lmgsp'.
739 #
740 # If the package is specified, either internally or externally, optional
741 # actions are run.
742 #
743 #   ACTIONS-TO-RUN-IF-NOT-EXTERNAL : Optional actions to run if the package
744 #                                    is not external.
745 #   ACTIONS-TO-RUN-IF-NOT-INTERNAL : Optional actions to run if the package
746 #                                    is not internal.
747 # ----------------------------------------------------------------------------
748 AC_DEFUN([NL_WITH_PACKAGE],
749 [
750     m4_warn(obsolete, [$0: this macro has been deprecated. Consider using NL_WITH_REQUIRED_INTERNAL_PACKAGE instead.])
751
752     NL_WITH_REQUIRED_INTERNAL_PACKAGE([$1], [$2], [$3], [$4], [$5], [$6])dnl
753 ])
754
755