summaryrefslogtreecommitdiff
path: root/config/confmacs.tlib
blob: 820ec54537d90f2af737ac8c706376e9b51688cd (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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
[=

AutoGen5 Template

## Time-stamp:        "2012-08-11 08:38:53 bkorb"
##
##  This file is part of AutoGen.
##
##  AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
##
##  AutoGen 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 3 of the License, or
##  (at your option) any later version.
##
##  AutoGen 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/>.

=][=

(define restore-flags "")
(define (protect-text t)
    (string-substitute t
        '("["     "]"     "$"     "#"     )
        '("@<:@"  "@:>@"  "@S|@"  "@%:@"  ))  )

(define test-name    "")
(define up-name      "")
(define down-name    "")
(define hyphen-name  "")
(define mac-name     "")
(define sub-name     "")
(define cv-name      "")
(define good-text    "")
(define bad-text     "")

(define set-ctx (lambda (my-name) (begin
  (set! test-name    (string->c-name! my-name))

  (set! good-text    "")
  (set! bad-text     "")

  (set! up-name      (string-upcase   test-name))
  (set! down-name    (string-downcase test-name))
  (set! hyphen-name  (string-tr       down-name "_" "-"))
  (set! mac-name     (string->c-name! (string-upcase! (string-append
                     group-pfx (get "type") "_" up-name))) )
  (set! cv-name      (string->c-name! (string-downcase! (string-append
                     group-pfx "cv_" (get "type") "_" down-name))) )
  (set! sub-name     (string-upcase!   (string-append group-pfx up-name)))
)))

=][=

# # # # # # # # # # EMIT MACRO # # # # # # # #  =][=

DEFINE  emit-macro                              =][=

  CASE    type                                  =][=
  ~~  compile|run|link|test                     =][=
      (define bad-define-name   "NEED_%s")
      (define good-define-name  "HAVE_%s")      =][=

  ~~  enable|disable                            =][=
      (define bad-define-name   "%s_DISABLED")
      (define good-define-name  "%s_ENABLED")   =][=

  ~~  with|without|with-group                   =][=
      (define bad-define-name   "WITHOUT_%s")
      (define good-define-name  "WITH_%s")      =][=
     
  ~~  withlib|withconf                          =][=
      (define lib-name          (string-append "lib" down-name))
      (define bad-define-name   "WITHOUT_LIB%s")
      (define good-define-name  "WITH_LIB%s")   =][=

  * =][= (error (string-append "unknown macro type: " (get "type"))) =][=
      
  ESAC                                          =][=

  IF  (. separate-macros)                       =][=

    INVOKE macro-header                         =][=

  ENDIF separate-macros

=]
AC_DEFUN([[=
  (define fcn-name (string-append "try-" (get "type")))
  (define c-text (get "code"))  =][=

  IF (= (get "code-mode") "body")               =][=
    (set! c-text (string-append "int main(int argc,char** argv) {\n"
          c-text "\nreturn 0; }" )) =][=
  ENDIF                         =][=

  (. mac-name)                  =]],[[=

  IF (ag-function? fcn-name)    =][=
    INVOKE (. fcn-name)         =][=
  ELSE                          =][=

    (error (string-append "invalid conftest function:   " fcn-name)) =][=

  ENDIF  =]
[=(prefix "  " (join "\n" (stack "always")))
=]
]) # end of AC_DEFUN of [=(. mac-name)=]
[=

ENDDEF  emit-macro

# # # # # # # # # # # macro file header # # # # # # # # # # =][=

DEFINE  macro-header                            =][=

(dne "dnl " "dnl ") =]
dnl
dnl @synopsis  [=(. mac-name)=]
dnl
dnl @success-result[=
    IF (<= (count "action") (count "action.no"))
      =]:  there is no output[=
    ELSE            =]
dnl[=
      FOR action    =][=
        IF (not (exist? "no"))  =][=
          CASE  act-type    =][=
          ==  define        =]
dnl   * [=(sprintf good-define-name up-name)
          =] is #defined as [=?% act-text "%s" "1"=][=
          ==  subst         =]
dnl   * @[=(.  sub-name)=]@ is replaced by [=act-text=][=
          ==  script        =]
dnl   * a short script is run[=
          ESAC              =][=
        ENDIF exist? "no"   =][=
      ENDFOR        =][=
    ENDIF (<= (count "action") (count "action.no")) =]
dnl
dnl @failure-result[=
    IF (= (count "action.no") 0)
      =]:  there is no output[=
    ELSE            =]
dnl[=
      FOR action    =][=
        IF (exist? "no")  =][=
          CASE  act-type  =][=
          ==  define      =]
dnl   * [=(sprintf bad-define-name up-name)
           =] is #defined as [=?% act-text "%s" "1"=][=
          ==  subst       =]
dnl   * @[=(. sub-name)=]@ is replaced by [=act-text=][=
          ==  script      =]
dnl   * a short script is run[=
          ESAC      =][=
        ENDIF       =][=
      ENDFOR        =][=
    ENDIF (= (count "action.no") 0) =][=

    IF   (define doc-text (get "doc"))
      (> (string-length doc-text) 0) =]
dnl
dnl @description
[=(prefix "dnl " doc-text) =][=
    ENDIF           =][=

    IF  (> (string-length author-name) 0) =]
dnl
dnl @version "[=

 (strftime "%d-%B-%Y at %H:%M"
           (localtime (current-time)) ) =]"
dnl
dnl @author [=(. author-name)=][=

    ENDIF           =]
dnl[=

ENDDEF  macro-header

# # # # # # # # # # # C-Feature # # # # # # # # # #

Stash the result of a C/C++ feature test =][=

DEFINE start-feat-test =][=
  (if (exist? "preamble") (prefix "  " (get "preamble"))) =]
  AC_MSG_CHECKING([whether [=(protect-text (get "check"))=]])[=
ENDDEF start-feat-test =][=

DEFINE  end-feat-test  =][=

  (. pop-language)     =]
  ]) # end of AC_CACHE_VAL for [=(. cv-name)=]
  AC_MSG_RESULT([${[=(. cv-name)=]}])[=
  emit-results         =][=

ENDDEF  end-feat-test

# # # # # # # # # # COLLECT ACTIONS # # # # # # # # # # =][=

DEFINE  collect-act   =][=

  CASE
       (set! tmp-text (get "act-text"))
       (set! TMP-text (string-upcase tmp-text))
       (string-append
         (if (exist? "no") "no-" "yes-")
         (get "act-type"))
    =][=

  == yes-define        =][=
    (set! good-text (string-append good-text
          "\n    AC_DEFINE" (if (exist? "unquoted") "_UNQUOTED" "")
          "([" (sprintf good-define-name up-name) "],["
          (if (> (string-length tmp-text) 0) tmp-text "1")
          "],\n        [Define this if " (protect-text (get "check")) "])" ))
    =][=

  == yes-subst         =][=
    (set! good-subst 1)
    (set! good-text (string-append good-text
                 "\n    " sub-name "=" (protect-text (shell-str tmp-text)) ))
    =][=

  == yes-script        =][=
    (set! good-text (string-append good-text "\n    "
          (if (exist? "asis") tmp-text (protect-text tmp-text))  ))
    =][=

  ==  no-define        =][=
    (set! bad-text (string-append bad-text
          "\n    AC_DEFINE" (if (exist? "unquoted") "_UNQUOTED" "")
          "([" (sprintf bad-define-name up-name) "],["
          (if (> (string-length tmp-text) 0) tmp-text "1")
          "],\n        [Define this if '" (protect-text (get "check"))
                                     "' is not true])" ))
    =][=

  ==  no-subst         =][=
    (set! bad-subst  1)
    (set! bad-text (string-append bad-text
                 "\n    " sub-name "=" (protect-text (shell-str tmp-text)) ))
    =][=

  ==  no-script        =][=
    (set! bad-text (string-append bad-text "\n    "
          (if (exist? "asis") tmp-text (protect-text tmp-text))  ))
    =][=

  ESAC                 =][=

ENDDEF  collect-act

# # # # # # # # # # EMIT RESULTS # # # # # # # # # # =][=

DEFINE  emit-results   =][=

  (define good-subst 0 )
  (define bad-subst  0 )
  (define TMP-text   "")
  (define tmp-text   "") =][=

  IF (and (= (get "type") "withlib") (exist? "config")) =]
    AC_SUBST([LIB[=(. up-name)=]_CFLAGS])
    AC_SUBST([LIB[=(. up-name)=]_LIBS])
    AC_SUBST([LIB[=(. up-name)=]_PATH])[=

    (define good-subst 1)
    (define bad-subst  1)
    (set! good-text (string-append good-text (sprintf "[
      LIB%1$s_CFLAGS=\"${%2$s_cflags}\"
      LIB%1$s_LIBS=\"${%2$s_libs}\"
      case \"${LIB%1$s_LIBS}\" in *-L* )
        LIB%1$s_PATH=`echo ,${LIB%1$s_LIBS} | \
          sed 's/.*[, ]-L[ \t]*//;s/[ \t].*//'`
      ;; * ) LIB%1$s_PATH='' ;; esac]"
       up-name cv-name )))

    (set! bad-text (string-append bad-text (sprintf "
      LIB%1$s_CFLAGS=''
      LIB%1$s_LIBS=''
      LIB%1$s_PATH=''"  up-name )))  =][=

  ENDIF  type is withlib =][=

  FOR     action         =][=
    INVOKE collect-act   =][=
  ENDFOR  action         =][=

  (if (> good-subst 0)
      (if (< bad-subst 1)
          (set! bad-text (string-append bad-text "\n    "
                         sub-name "=''" ))  )
      (if (> bad-subst 0)
          (set! good-text (string-append good-text "\n    "
                         sub-name "=''" ))  )
  )

=]
  if test "X${[=(. cv-name)=]}" [=

  IF (> (string-length good-text) 0)

    =]!= Xno
  then[=
    (. good-text) =][=

    IF (> (string-length bad-text) 0) =]
  else[=
    ENDIF         =][=
  ELSE            =]= Xno
  then[=
  ENDIF           =][=
    (. bad-text)  =]
  fi[=

  (if (> (+ good-subst bad-subst) 0)
     (string-append "\n  AC_SUBST([" sub-name "])" ))  =][=

  FOR conditional =]
  AM_CONDITIONAL([[= conditional =]],[test "X${[=(. cv-name)=]}" != Xno])[=
  ENDFOR          =][=

  FOR affirmed    =]
  AM_CONDITIONAL([[= conditional =]],[test "X${[=(. cv-name)=]}" = Xyes])[=
  ENDFOR          =][=

ENDDEF  emit-results

# # # # # # # # # # ENABLEMENT # # # # # # # # # # =][=

DEFINE  emit-enablement

  =]
  AC_ARG_[=arg-name=]([[=(. hyphen-name)=]],
    AS_HELP_STRING([--[=type=]-[=(. hyphen-name)=]], [[=check=]]),
    [[=(. cv-name)=]=${[=(string-downcase! (get "arg-name"))
      =]_[=(. down-name)=]}],
    AC_CACHE_CHECK([whether [=check=]], [=(. cv-name)=],
      [=(. cv-name)=]=[=
         (if (~~ (get "type") "with|enable") "no" "yes") =])
  ) # end of AC_ARG_[=arg-name=][=

  INVOKE emit-results =][=

ENDDEF  emit-enablement

# # # # # # # # # SET-LANGUAGE # # # # # # # # =][=

DEFINE  set-language

=]
  AC_CACHE_VAL([[=(. cv-name)=]],[[=
  CASE language  =][=
  ==   ""        =][=(define pop-language "")=][=
  ==   default   =][=(define pop-language "")=][=
  *              =]
  AC_LANG_PUSH([=language=])[=
    (define pop-language (sprintf "
  AC_LANG_POP(%s)" (get "language"))) =][=

  ESAC  =][=

  IF (exist? "cflags")

=]
    [=(. group-pfx)=]save_CPPFLAGS="${CPPFLAGS}"
    CPPFLAGS="[= cflags =] ${CPPFLAGS}"[=
    (set! pop-language (string-append pop-language
          "\n    CPPFLAGS=\"${" group-pfx "save_CPPFLAGS}\"" )) =][=

  ENDIF   cflags exists         =][=

  IF (exist? "libs")

=]
    [=(. group-pfx)=]save_LIBS="${LIBS}"
    LIBS="[= libs =] ${LIBS}"[=
    (set! pop-language (string-append pop-language
          "\n    LIBS=\"${" group-pfx "save_LIBS}\"" )) =][=

  ENDIF   libs exists           =][=

ENDDEF  set-language

# # # # # # # # # # WITH # # # # # # # # # =][=

DEFINE  try-with                =][=
  INVOKE emit-enablement
       arg-name  = WITH         =][=
ENDDEF  try-with                =][=

# # # # # # # # # # WITHOUT # # # # # # # =][=

DEFINE  try-without             =][=
  (set! cv-name (string-append group-pfx "cv_with_" down-name)) =][=
  INVOKE emit-enablement
       arg-name  = WITH         =][=
ENDDEF  try-without             =][=

# # # # # # # WITH-GROUP # # # # # #  =][=

DEFINE  try-with-group          =][=
  (define group-name (string-downcase (string->c-name! (get "name"))))
  =][=

  INVOKE emit-enablement
       type      = with
       arg-name  = WITH         =][=
  (define save-mname mac-name)  =][=

  FOR  subgroup                 =][=
    (set-ctx (string-append group-name "_" (get "subtype")))
    =][=
    INVOKE emit-enablement
       type      = with
       arg-name  = WITH
       check     = (get "subtext")
    =][=
  ENDFOR subgroup               =][=

  (set! mac-name   save-mname)
  (set! good-subst 0)
  (set! bad-subst  0)
  (set! good-text  "")
  (set! bad-text   "")          =][=

  FOR  grp-valid                =]
  if [= (get "grp-test")       =]
  then[=
    FOR  grp-action             =][=
      INVOKE collect-act        =][=
    ENDFOR grp-action           =][=
    (emit (if (> (string-length good-text) 1)
        (string-append "\n" good-text)
        " :"))
    (if (> (string-length bad-text) 1)
        (string-append "\n  else\n" bad-text) "")
    =]
  fi[=
  ENDFOR  grp-valid             =][=

ENDDEF  try-with-group          =][=

# # # # # # # # # # ENABLE # # # # # # # # # =][=

DEFINE  try-enable              =][=
  INVOKE emit-enablement
       arg-name  = ENABLE       =][=
ENDDEF  try-enable              =][=

# # # # # # # # # # DISABLE # # # # # # # # # =][=

DEFINE  try-disable             =][=
  (set! cv-name (string-append group-pfx "cv_enable_" down-name)) =][=
  INVOKE emit-enablement
       arg-name  = ENABLE       =][=
ENDDEF  try-disable             =][=

# # # # # # # # # # WITHLIB # # # # # # # =][=

DEFINE  try-withlib             =][=

  # # # # # # # # options # # # # # # #

=]
  AC_ARG_WITH([[=
    (set! cv-name  (string-append group-pfx "cv_with_lib" down-name))
    (set! lib-name (string-append "lib" down-name))
    lib-name =]],
    AS_HELP_STRING([--with-lib[=(string-tr down-name "_" "-")
        =]], [[=(. lib-name)=] installation prefix]),
    [[=(. cv-name)=]_root=${with_lib[=(string-tr down-name "-" "_")=]}],
    AC_CACHE_CHECK([whether with-[=(. lib-name)=] was specified], [=
        (. cv-name)=]_root,
      [=(. cv-name)=]_root=no)
  ) # end of AC_ARG_WITH [=(. lib-name)=]

  if test "${with_[=(. lib-name)=]+set}" = set && \
     test "X${withval}" = Xno
  then ## disabled by request
    [=(. cv-name)=]_root=no
    [=(. cv-name)=]_cflags=no
    [=(. cv-name)=]_libs=no
  else

  AC_ARG_WITH([[=(. lib-name)=]-cflags],
    AS_HELP_STRING([--with-lib[=(string-tr down-name "_A-Z" "-a-z")
        =]-cflags], [[=(. lib-name)=] compile flags]),
    [[=(. cv-name)=]_cflags=${with_[=(. lib-name)=]_cflags}],
    AC_CACHE_CHECK([whether with-[=(. lib-name)=]-cflags was specified], [=
        (. cv-name)=]_cflags,
      [=(. cv-name)=]_cflags=no)
  ) # end of AC_ARG_WITH [=(. lib-name)=]-cflags

  AC_ARG_WITH([[=(. lib-name)=]-libs],
    AS_HELP_STRING([--with-lib[=(string-tr down-name "_A-Z" "-a-z")
        =]-libs], [[=(. lib-name)=] link command arguments]),
    [[=(. cv-name)=]_libs=${with_[=(. lib-name)=]_libs}],
    AC_CACHE_CHECK([whether with-[=(. lib-name)=]-libs was specified], [=
        (. cv-name)=]_libs,
      [=(. cv-name)=]_libs=no)
  ) # end of AC_ARG_WITH [=(. lib-name)=]-libs
[=

  # # # # # # set cflags/libs # # # # # #

=]
  case "X${[=(. cv-name)=]_cflags}" in
  Xyes|Xno|X )
    case "X${[=(. cv-name)=]_root}" in
    Xyes|Xno|X ) [=(. cv-name)=]_cflags=no ;;
    * )        [=(. cv-name)=]_cflags=-I${[=(. cv-name)=]_root}/include ;;
    esac
  esac
  case "X${[=(. cv-name)=]_libs}" in
  Xyes|Xno|X )
    case "X${[=(. cv-name)=]_root}" in
    Xyes|Xno|X ) [=(. cv-name)=]_libs=no ;;
    * )        [=(. cv-name)=]_libs="-L${[=(. cv-name)
               =]_root}/lib -l[=(. down-name)=]";;
    esac
  esac
  [=(. group-pfx)=]save_CPPFLAGS="${CPPFLAGS}"
  [=(. group-pfx)=]save_LIBS="${LIBS}"[=
  (set! bad-text (sprintf
    "\n    CPPFLAGS=\"${%1$ssave_CPPFLAGS}\"
    LIBS=\"${%1$ssave_LIBS}\"" group-pfx )) =][=

  # # # # # # check config script # # # # # =][=

  IF (exist? "config")

=]
  case "X${[=

  (define tmp-text (if (exist? "config.script") (get "config.script")
                       (string-append down-name "-config")  ))

  cv-name =]_cflags}" in
  Xyes|Xno|X )
    f=`[=(. tmp-text)=] [= config.cflags-arg =] 2>/dev/null` || f=''
    test -n "${f}" && [=(. cv-name)=]_cflags="${f}" && \
      AC_MSG_NOTICE([[=(. tmp-text)=] used for CFLAGS: $f]) ;;
  esac
  case "X${[=(. cv-name)=]_libs}" in
  Xyes|Xno|X )
    f=`[=(. tmp-text)=] [= config.libs-arg =] 2>/dev/null` || f=''
    test -n "${f}" && [=(. cv-name)=]_libs="${f}" && \
      AC_MSG_NOTICE([[=(. tmp-text)=] used for LIBS: $f]) ;;
  esac[=

  ENDIF (exist? "config")

  =][= # # # # set cflags/libs # # # #

=]
  fi ## disabled by request

  case "X${[=(. cv-name)=]_cflags}" in
  Xyes|Xno|X )
    [=(. cv-name)=]_cflags="" ;;
  * ) CPPFLAGS="${CPPFLAGS} ${[=(. cv-name)=]_cflags}" ;;
  esac
  case "X${[=(. cv-name)=]_libs}" in
  Xyes|Xno|X )[=
    IF (not (exist? "libname")) =]
    LIBS="${LIBS} -l[=(. down-name)=]"
    [=(. cv-name)=]_libs="-l[=(. down-name)=]"[=

    ELIF (> (string-length (get "libname")) 0) =]
    LIBS="${LIBS} -l[=(get "libname")=]"
    [=(. cv-name)=]_libs="-l[=(get "libname")=]"[=
    ELSE   =]
    [=(. cv-name)=]_libs=""[=
    ENDIF  =] ;;
  * )
    LIBS="${LIBS} ${[=(. cv-name)=]_libs}" ;;
  esac[=

  # # # # # # # # testing # # # # # # #

  =]
  LIB[=(. up-name)=]_CFLAGS=""
  LIB[=(. up-name)=]_LIBS=""[=

  CASE run-mode                 =][=

  ==   link                     =]
  AC_MSG_CHECKING([whether [=(. lib-name)=] can be linked with])[=
  set-language                  =]
  AC_LINK_IFELSE(
    [AC_LANG_SOURCE([[[=(protect-text c-text)=]]])],
    [[=(. cv-name)=]=yes],
    [[=(. cv-name)=]=no]) # end of AC_LINK_IFELSE [=

  ==   run                      =]
  AC_MSG_CHECKING([whether [=(. lib-name)=] functions properly])[=
  set-language                  =]
  AC_RUN_IFELSE([[=(protect-text c-text)=]],
    [[=(. cv-name)=]=yes], [[=(. cv-name)=]=no],
    [[=(. cv-name)=]=no]) # end of AC_RUN_IFELSE [=

  ESAC                          =][=

  end-feat-test                 =][=

ENDDEF  try-withlib             =][=

# # # # # # # # # # TEST # # # # # # # # # =][=

DEFINE  try-test                =][=

  start-feat-test               =]
  AC_CACHE_VAL([[=(. cv-name)=]],[
    [=(. cv-name)=]=[= (sub-shell-str
      (string-append "exec 2> /dev/null\n" (get "code")) ) =]
    if test $? -ne 0 || test -z "$[=(. cv-name)=]"
    then [=(. cv-name)=]=no
    fi
  ]) # end of CACHE_VAL of [=(. cv-name)=]
  AC_MSG_RESULT([${[=(. cv-name)=]}])[=
  emit-results                  =][=

ENDDEF  try-test                =][=

# # # # # # # # # # RUN # # # # # # # # # =][=

DEFINE  try-run                 =][=

  start-feat-test               =][=
  set-language                  =]
  AC_RUN_IFELSE([[=(protect-text c-text)=]],
    [[=(. cv-name)=]=yes],[[=(. cv-name)=]=no],[[=
        (. cv-name)=]=no]
  ) # end of RUN_IFELSE[=
  end-feat-test                 =][=

ENDDEF  try-run                 =][=

# # # # # # # # # # LINK # # # # # # # # # =][=

DEFINE  try-link                =][=

  start-feat-test               =][=
  set-language                  =]
  AC_TRY_LINK([[= (protect-text (shellf
    "egrep '^#' <<_EOF_\n%s\n_EOF_" c-text )) =]],
    [[= (protect-text (shellf
    "egrep -v '^#' <<_EOF_\n%s\n_EOF_" c-text )) =]],
    [[=(. cv-name)=]=yes],[[=(. cv-name)=]=no]
  ) # end of TRY_LINK[=
  end-feat-test                 =][=

ENDDEF  try-link                =][=

# # # # # # # # # # COMPILE # # # # # # # # # # =][=

DEFINE  try-compile             =][=

  start-feat-test               =][=
  set-language                  =]
  AC_TRY_COMPILE([= % includes "[%s]" =],[[=(protect-text c-text)=]],
    [[=(. cv-name)=]=yes],[[=(. cv-name)=]=no]
  ) # end of TRY_COMPILE[=
  end-feat-test                 =][=

ENDDEF  try-compile             =]