File: make-macros-options

package info (click to toggle)
abinit 9.10.4-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 518,712 kB
  • sloc: xml: 877,568; f90: 577,240; python: 80,760; perl: 7,019; ansic: 4,585; sh: 1,925; javascript: 601; fortran: 557; cpp: 454; objc: 323; makefile: 77; csh: 42; pascal: 31
file content (738 lines) | stat: -rwxr-xr-x 18,173 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
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
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
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
737
738
#!/usr/bin/env python3
#
# Copyright (C) 2005-2022 ABINIT Group (Yann Pouillon)
#
# This file is part of the ABINIT software package. For license information,
# please see the COPYING file in the top-level directory of the ABINIT source
# distribution.
#
from __future__ import print_function, division, absolute_import #, unicode_literals

try:
    from ConfigParser import ConfigParser
except ImportError:
    from configparser import ConfigParser
from time import gmtime,strftime

try:
    from commands import getoutput
except:
    from subprocess import getoutput
import os
import re
import sys

class MyConfigParser(ConfigParser):

  def optionxform(self,option):
    return str(option)

# ---------------------------------------------------------------------------- #

#
# Subroutines
#

# Macro header
def macro_header(name,stamp):

  return """# Generated by %s on %s

#
# Command-line options for the "configure" script
#

#
# IMPORTANT NOTE
#
# This file has been automatically generated by the %s
# script. If you try to edit it, your changes will systematically be
# overwritten.
#
""" % (name,stamp,name)



# Define macro header
def macro_define_header():

  return """


# ABI_OPTIONS_DEFINE()
# --------------------
#
# Declares command-line arguments for the "configure" script.
#
AC_DEFUN([ABI_OPTIONS_DEFINE],[
  # Count use of deprecated options
  abi_opt_deprecated_count=0
  abi_opt_deprecated_used=""

"""



# Define macro footer
def macro_define_footer():

  return "]) # ABI_OPTIONS_DEFINE\n"



# Init macro header
def macro_setup_header():

  return """


# ABI_OPTIONS_SETUP()
# -------------------
#
# Sets the default values of command-line arguments.
#
AC_DEFUN([ABI_OPTIONS_SETUP],[
"""



# Init macro footer
def macro_setup_footer():

  return "]) # ABI_OPTIONS_SETUP\n"



# Backup macro header
def macro_backup_header():

  return """


# ABI_OPTIONS_BACKUP()
# --------------------
#
# Saves all command-line arguments.
#
AC_DEFUN([ABI_OPTIONS_BACKUP],[
"""



# Backup macro footer
def macro_backup_footer():

  return "]) # ABI_OPTIONS_BACKUP\n"



# Restore macro header
def macro_recall_header():

  return """


# ABI_OPTIONS_RECALL()
# --------------------
#
# Restores all previously-saved command-line arguments.
#
AC_DEFUN([ABI_OPTIONS_RECALL],[
"""



# Restore macro footer
def macro_recall_footer():

  return "]) # ABI_OPTIONS_RECALL\n"



# Changed options macro
def macro_changed_template():

  return """


# ABI_INFO_OPTIONS_CHANGED()
# --------------------------
#
# Display changes of user interface between versions and warns about
# obsolete uses.
#
AC_DEFUN([ABI_INFO_OPTIONS_CHANGED],[
@MACRO@
]) # ABI_INFO_OPTIONS_CHANGED
"""



# Parsing macro
def macro_parse_template():

  return """


# ABI_OPTIONS_PARSE()
# -------------------
#
# Parses command-line arguments.
#
AC_DEFUN([ABI_OPTIONS_PARSE],[
  AC_REQUIRE([AC_PROG_EGREP])
  AC_MSG_NOTICE([parsing command-line options])
@MACRO@
]) # ABI_OPTIONS_PARSE
"""



# Defines and conditionals
def macro_triggers_template():

  return """


# ABI_OPTIONS_CPP_DEFINES()
# -------------------------
#
# Set switches associated to 'enable_*' options (AC_DEFINE and
# AM_CONDTIONAL).
#
AC_DEFUN([ABI_OPTIONS_CPP_DEFINES],[
  AC_MSG_NOTICE([setting build switches associated to command-line options])
@MACRO@
]) # ABI_OPTIONS_CPP_DEFINES
"""



# Config file values
def macro_cfg_template():

  return """


# ABI_OPTIONS_CFG_TRANSFER()
# --------------------------
#
# Transfer options from the config file to internal variables.
#
AC_DEFUN([ABI_OPTIONS_CFG_TRANSFER],[
@MACRO@
]) # ABI_OPTIONS_CFG_TRANSFER
"""



# Option parser generator
def parse_opt(opt,opt_ivar,values):

  ret = "  # Parse %s\n" % (opt)

  if ( len(values.split()) > 1 ):
    ret += """  if test "${%s}" != ""; then
    for v in `echo "${%s}" | sed -e 's/+/ /g'`; do
      opt_ok="no"
      for r in %s; do
        if test "${v}" = "${r}";then
          opt_ok="yes"
          break
        fi
      done
      test "${opt_ok}" = "no" && break
    done
    if test "${opt_ok}" = "no"; then
      AC_MSG_WARN([%s = (%s)])
      AC_MSG_ERROR([invalid option: %s = ${v}])
    fi
  fi
""" % (opt_ivar,opt_ivar,values,opt,"|".join(values.split()),opt)

  else:

    if ( values == "@float" ):
      ret += """ if test "${%s}" != ""; then
    opt_ok="no"
    test "`echo "${%s}" | \\
      ${EGREP} -e '^-?[[0-9]]+\.[[0-9]]+$'`" != "" && opt_ok="yes"
    test "`echo "${%s}" | \\
      ${EGREP} -e '^-?[[0-9]]+\.[[0-9]]+[[Ee]]-?[[0-9]]+$'`" != "" && opt_ok="yes"
    if test "${opt_ok}" = "no"; then
      AC_MSG_ERROR([invalid float: %s = ${%s}])
    fi
  fi
""" % (opt,opt,opt,opt,opt)

    elif ( values == "@includes" ):
      ret += """ if test "${%s}" != ""; then
    opt_ok="yes"
    for v in ${%s}; do
      if test "`echo "${v}" | grep '^-I'`" = ""; then
        opt_ok="no"
        break
      fi
    done
    if test "${opt_ok}" = "no"; then
      AC_MSG_ERROR([invalid include statement in %s: ${v}])
    fi
  fi
""" % (opt,opt,opt)

    elif ( values == "@install" ):
      ret += """ if test "${%s}" != ""; then
    opt_ok="yes"
    if test "${%s}" != "no" -a "${%s}" != "yes"; then
      if test \! -d "${%s}" -o \! -r "${%s}"; then
        opt_ok="no"
        break
      fi
    fi
  fi
""" % (opt,opt,opt,opt,opt)

    elif ( values == "@integer" ):
      ret += """ if test "${%s}" != ""; then
    opt_ok="yes"
    test "`echo "${%s}" | ${EGREP} -e '^-?[[0-9]]+$'`" = "" && opt_ok="no"
    if test "${opt_ok}" = "no"; then
      AC_MSG_ERROR([invalid integer: %s = ${%s}])
    fi
  fi
""" % (opt,opt,opt,opt)

    elif ( values == "@libs" ):
      ret += """ if test "${%s}" != ""; then
    opt_ok="yes"
    for v in ${%s}; do
      if test "`echo "${v}" | grep '^-[[LloW]]'`" = ""; then
        opt_ok="no"
      fi
      if test "${opt_ok}" = "no"; then
        if test -s "${v}"; then
          opt_ok="yes"
        else
          break
        fi
      fi
    done
    if test "${opt_ok}" = "no"; then
      AC_MSG_WARN([possible invalid library statement in %s: ${v}])
    fi
  fi
""" % (opt,opt,opt)

    elif ( re.match("@profile", values) ):
      arg = " ".join(values.split()[1:])
      arg = re.sub("@VALUE@", "${%s}" % opt, arg)
      ret += """ if test "${%s}" != ""; then
    opt_ok="no"
    test -s "${%s}" && opt_ok="yes"
    if test "${opt_ok}" = "no"; then
      AC_MSG_ERROR([file for option %s not found:
                  %s])
    fi
  fi
""" % (opt,arg,opt,arg)

    elif ( values == "@readabledir" ):
      ret += """ if test "${%s}" != ""; then
    opt_ok="yes"
    if test \! -d "${%s}" -o \! -r "${%s}"; then
      opt_ok="no"
      break
    fi
  fi
""" % (opt,opt,opt)

    else:

      ret += """  # FIXME: NOT IMPLEMENTED!\n
  AC_MSG_WARN([parsing not implemented for value type '%s'])\n""" % values

  return ret



# ---------------------------------------------------------------------------- #

#
# Main program
#

# Initial setup
my_name    = "make-macros-options"
my_configs = {
  "deps":"config/specs/dependencies.conf",
  "opts":"config/specs/options.conf",
}
my_output  = "config/m4/auto-options.m4"

# Check if we are in the top of the ABINIT source tree
if ( not os.path.exists("configure.ac") or
     not os.path.exists("src/98_main/abinit.F90") ):
  print("%s: You must be in the top of an ABINIT source tree." % my_name)
  print("%s: Aborting now." % my_name)
  sys.exit(1)

# Read config file(s)
cnf_deps = MyConfigParser()
cnf_opts = MyConfigParser()
for cnf_file in my_configs.values():
  if ( not os.path.exists(cnf_file) ):
    print("%s: Could not find config file (%s)." % (my_name,cnf_file))
    print("%s: Aborting now." % my_name)
    sys.exit(2)

# What time is it?
now = strftime("%Y/%m/%d %H:%M:%S +0000",gmtime())

# Init
cnf_deps.read(my_configs["deps"])
cnf_opts.read(my_configs["opts"])
re_en = re.compile("enable_")
re_wi = re.compile("with_")
all_args = cnf_opts.sections()
all_args.sort()
ac_args = { "enable":list(), "with":list() }
for arg in all_args:
  arg_stat = cnf_opts.get(arg,"status")
  if ( (arg_stat != "removed") and (arg_stat != "dropped") ):
    if ( arg.startswith("enable_") ):
      ac_args["enable"].append(arg)
    if ( arg.startswith("with_") ):
      ac_args["with"].append(arg)
ac_args["enable"].sort()
ac_args["with"].sort()

# Start writing macro
m4 = open(my_output, "wt")
m4.write(macro_header(my_name,now))

# Start writing define macro
m4.write(macro_define_header())

# Process arguments
defaults = ""
parse = ""
for arg in ("enable","with"):
  m4.write("\n  #\n  # --%s arguments\n  #\n" % (arg))
  defaults += "\n  #\n  # --%s arguments\n  #\n\n" % (arg)
  for opt in ac_args[arg]:
    var = re.sub(arg+"_","",opt)
    opt_name = re.sub("_","-",var)
    opt_desc = cnf_opts.get(opt,"description")
    opt_stat = cnf_opts.get(opt,"status")
    if ( arg == "enable" ):
      opt_ivar = "abi_%s_enable" % var
    else:
      opt_ivar = "abi_%s" % var
    try:
      opt_dflt = cnf_opts.get(opt,"default")
    except:
      opt_dflt = None
    try:
      opt_nega = cnf_opts.get(opt,"negative")
    except:
      opt_nega = ""
    try:
      opt_vals = cnf_opts.get(opt,"values")
    except:
      opt_vals = None

    if ( arg == "enable" ):
      m4.write("\n  AC_ARG_%s(%s,\n" % (arg.upper(),opt_name) \
        + "    AS_HELP_STRING([--%s-%s],\n      [%s (default: %s)]),\n" % \
          (arg,opt_name,opt_desc,opt_dflt) \
        + "    [abi_%s_enable=\"${enableval}\"; abi_%s_init=\"yon\"],\n" % (var,var) \
        + "    [abi_%s_enable=\"%s\"; abi_%s_init=\"def\"])\n" % (var, opt_dflt, var))
    else:
      tmp_dflt = ""
      if ( not opt_dflt is None ):
        tmp_dflt = opt_dflt
      tmp_init = "kwd"
      if ( opt_vals == "@install" ):
        tmp_init = "dir"
      tmp_decl = """
  AC_ARG_WITH({name},
    AS_HELP_STRING([--with-{cmd}],
      [{help} (default: '{default}')]),
    [ abi_{name}="${{withval}}"
      case "${{withval}}" in
        no|yes)
          abi_{name}_init="yon"
          ;;
        *)
          abi_{name}_init="{init}"
          ;;
      esac],
    [ abi_{name}_init="def"; abi_{name}="{default}"])
""".format(cmd=opt_name, name=var, help=opt_desc, default=tmp_dflt, init=tmp_init)
      m4.write(tmp_decl)

    if ( opt_dflt is not None ):
      if ( arg == "enable" ):
        defaults += "  if test \"${%s_%s}\" = \"\"; then\n    abi_%s_%s=\"%s\"\n  fi\n" % \
          (arg,var,var,arg,opt_dflt)
      else:
        defaults += "  if test \"${%s_%s}\" = \"\"; then\n    abi_%s=\"%s\"\n  fi\n" % \
          (arg,var,var,opt_dflt)

    if ( arg == "with" ):
      defaults += "  if test \"${%s_%s}\" = \"no\"; then\n    abi_%s=\"%s\"\n  fi\n" % \
        (arg,var,var,opt_nega)

    if ( opt_vals is not None ):
      parse += "\n"+parse_opt(opt,opt_ivar,opt_vals)
    elif ( arg == "enable" ):
      parse += "\n"+parse_opt(opt,opt_ivar,"no yes")

    m4.write("  AC_SUBST(%s_%s)\n" % (arg,var))
    if ( arg == "enable" ):
      m4.write("  AC_SUBST(abi_%s_%s)\n" % (var,arg))

# Finish writing define macro
m4.write(macro_define_footer())

# Start writing setup macro
m4.write(macro_setup_header())

# Process arguments
m4.write(defaults)

# Finish writing setup macro
m4.write(macro_setup_footer())

# Start writing backup macro
m4.write(macro_backup_header())

# Process arguments
for arg in ("enable","with"):
  m4.write("\n  #\n  # --%s arguments\n  #\n" % (arg))
  for opt in ac_args[arg]:
    var = re.sub(arg+"_","",opt)
    m4.write("  cmd_%s_%s=\"${%s_%s}\"\n" % (arg,var,arg,var))
for dep in sorted(cnf_deps.sections()):
  if (cnf_deps.get(dep, "detector") == "steredeg" ):
    m4.write("  cmd_with_%s=\"${with_%s}\"\n" % (dep,dep))
    if ( cnf_deps.has_option(dep, "flavors") ):
      m4.write("  cmd_with_%s_flavor=\"${with_%s_flavor}\"\n" % (dep,dep))

# Do not forget "prefix"
m4.write("""
  #
  # Prefix
  #
  if test "${prefix}" != "NONE"; then
    cmd_prefix="${prefix}"
  fi
""")

# Finish writing backup macro
m4.write(macro_backup_footer())

# Write transfer-from-config-file macro
transfer = ""
for arg in ("enable","with"):
  transfer += "\n  #\n  # --%s arguments\n  #\n" % (arg)
  for opt in ac_args[arg]:
    var = re.sub(arg+"_","",opt)
    if ( arg == "enable" ):
      transfer += "\n  if test \"${%s_%s}\" != \"\"; then\n    abi_%s_%s=\"${%s_%s}\"\n  fi\n" % \
        (arg,var,var,arg,arg,var)
    else:
      transfer += "\n  if test \"${%s_%s}\" != \"\"; then\n    abi_%s=\"${%s_%s}\"\n  fi\n" % \
        (arg,var,var,arg,var)
m4.write(re.sub("@MACRO@", transfer, macro_cfg_template()))

# Start writing recall macro
m4.write(macro_recall_header())

# Process arguments
for arg in ("enable","with"):
  m4.write("\n  #\n  # --%s arguments\n  #\n" % (arg))
  for opt in ac_args[arg]:
    var = re.sub(arg+"_","",opt)
    if ( arg == "enable" ):
      m4.write("  if test \"${cmd_%s_%s}\" != \"\"; then\n    abi_%s_%s=\"${cmd_%s_%s}\"\n  fi\n" % \
        (arg,var,var,arg,arg,var))
    else:
      m4.write("  if test \"${cmd_%s_%s}\" != \"\"; then\n    %s_%s=\"${cmd_%s_%s}\"\n  fi\n" % \
        (arg,var,arg,var,arg,var))
for dep in sorted(cnf_deps.sections()):
  if (cnf_deps.get(dep, "detector") == "steredeg" ):
    m4.write("  if test \"${cmd_with_%s}\" != \"\"; then\n    with_%s=\"${cmd_with_%s}\"\n  fi\n" % \
      (dep,dep,dep))
    if ( cnf_deps.has_option(dep, "flavors") ):
      m4.write("  if test \"${cmd_with_%s_flavor}\" != \"\"; then\n    with_%s_flavor=\"${cmd_with_%s_flavor}\"\n  fi\n" % \
      (dep,dep,dep))


# Do not forget "prefix"
m4.write("""
  #
  # Prefix
  #
  if test "${cmd_prefix}" != ""; then
    prefix="${cmd_prefix}"
  fi
""")

# Finish writing recall macro
m4.write(macro_recall_footer())

# Build changed macro
changed = ""
chg_dep = ""
chg_mod = ""
chg_new = ""
chg_rem = ""
chg_ren = ""

for arg in all_args:

  # Init
  arg_stat = cnf_opts.get(arg,"status")
  try:
    arg_repl = cnf_opts.get(arg,"use_instead")
  except:
    arg_repl = ""

  # Removed options
  if ( (arg_stat == "removed") or (arg_stat == "dropped") ):
    arg1 = re.sub("_","-",arg)
    chg_rem += "\n  # Removed --%s option" % (arg1)
    if ( arg_stat == "removed" ):
      chg_rem += "\n  AC_MSG_NOTICE([  * removed option --%s])" % (arg1)
      if ( arg_repl != "" ):
        if ( arg_repl.upper() == arg_repl ):
          chg_rem += "\n  AC_MSG_NOTICE([    >>> use %s instead])" % arg_repl
        else:
          chg_rem += "\n  AC_MSG_NOTICE([    >>> use --%s instead])" % \
            (re.sub("_","-",arg_repl))
    chg_rem += """
  if test "${%s}" != ""; then
    AC_MSG_ERROR([removed option --%s has been used])
  fi
""" % (re.sub("-","_",arg1),arg1)

  # New options
  elif ( arg_stat.startswith("new") ):
    arg2 = re.sub("_","-",arg.split()[0])
    chg_new += "\n  # New --%s option\n" % (arg2)
    chg_new += "  AC_MSG_NOTICE([  * new option --%s is available])\n" % (arg2)
    if ( len(arg.split()) > 1 ):
      chg_new += "  AC_MSG_NOTICE([    (%s)])\n" % (" ".join(arg.split()[1:]))

  # Changed UIs
  elif ( re.match("changed",arg_stat) ):
    arg1 = re.sub("_","-",arg)
    chg_mod += """
  # UI change for --%s option
  AC_MSG_NOTICE([  * modified option --%s])
  AC_MSG_NOTICE([    (%s)])
  AC_MSG_NOTICE([    please check that --%s="${%s}" is OK for you])
""" % (arg1,arg1,arg_stat,arg1,re.sub("-","_",arg1))

  # Deprecated options
  elif ( re.match("deprecated",arg_stat) ):
    arg2 = re.sub("_","-",arg)
    chg_dep += """
  # --%s deprecated
  AC_MSG_NOTICE([  * deprecated option --%s])
  if test "${%s}" != ""; then
    AC_MSG_NOTICE([    >>> --%s = '${%s}' will soon be forbidden!])
    abi_opt_deprecated_count=`expr ${abi_opt_deprecated_count} + 1`
    abi_opt_deprecated_used="${abi_opt_deprecated_used} %s"
  fi
""" % (arg2,arg2,arg,arg2,arg,arg)

changed = chg_rem + chg_new + chg_mod + chg_ren + chg_dep
if ( changed == "" ):
  changed = "AC_MSG_NOTICE([no change in user interface to report])"
else:
  changed = """\
  AC_MSG_NOTICE([])
  AC_MSG_NOTICE([reporting user interface changes:])
  AC_MSG_NOTICE([])\n""" + changed

# Write changed macro
m4.write(re.sub("@MACRO@",changed,macro_changed_template()))

# Write parse macro
m4.write(re.sub("@MACRO@",parse,macro_parse_template()))

# Build triggers macro
triggers = ""

for opt in ac_args["enable"]:
  opt_desc = cnf_opts.get(opt,"description")
  opt_desc = opt_desc[0].lower() + opt_desc[1:]
  opt_ivar = "abi_" + opt.replace("enable_", "") + "_enable"
  try:
    opt_cnds = cnf_opts.get(opt,"conditionals").split()
  except:
    opt_cnds = list()
  try:
    opt_defs = cnf_opts.get(opt,"defines").split()
  except:
    opt_defs = list()

  if ( len(opt_cnds) + len(opt_defs) > 0 ):
    triggers += """

  # Triggers for %s
  AC_MSG_CHECKING([whether to %s])
  AC_MSG_RESULT([${%s}])
""" % (opt,opt_desc,opt_ivar)

  if ( len(opt_cnds) > 0 ):
    for cnd in opt_cnds:
      if ( cnd[0] == "!" ):
        val = "no"
        cnd = cnd[1:]
      else:
        val = "yes"
      triggers += """
  if test "${%s}" = "%s"; then
    AC_MSG_NOTICE([triggering the '%s' conditional])
  fi
  AM_CONDITIONAL([%s],[test "${%s}" = "%s"])""" % (opt_ivar,val,cnd,cnd,opt_ivar,val)

  if ( len(opt_defs) > 0 ):
    for cpp in opt_defs:
      if ( cpp[0] == "!" ):
        val = "no"
        cpp = cpp[1:]
      else:
        val = "yes"
      triggers += """
  if test "${%s}" = "%s"; then
    AC_MSG_NOTICE([defining the '%s' preprocessing macro])
    AC_DEFINE([%s], 1,
      [Define to 1 if you want to %s.])
  fi""" % (opt_ivar,val,cpp,cpp,opt_desc)

# Write triggers macro
m4.write(re.sub("@MACRO@",triggers,macro_triggers_template()))

# Finish
m4.close()

tmp = getoutput("./config/scripts/add-header-typed Autoconf %s" % (my_output))
if ( tmp != "" ):
  print(tmp)

# Write option dumper (for debugging)
dumper = open("config.dump.in","a")
dumper.write("# Command-line options (script: %s)\n" % (my_name))
for arg in all_args:
  arg_stat = cnf_opts.get(arg,"status")
  if ( (arg_stat != "removed") and \
       (arg_stat != "dropped") and \
       (not re.match("group", arg)) ):
    var = re.sub("-","_",opt_name)
    dumper.write("%s=\"@%s@\"\n" % (arg,arg))
dumper.write("\n")
dumper.close()