diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-03-16 17:17:27 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-03-16 17:17:27 +0200 |
commit | 08057b45c5baad283f7132b64faa05018ff2f5f7 (patch) | |
tree | bbeefaa36b0542a25cfdf29cc68c71b03afd4d2f /src/getopt.m4 | |
parent | 4385b872616eba08c2b8c8b7f465e81ff379b43c (diff) | |
download | idest-08057b45c5baad283f7132b64faa05018ff2f5f7.tar.gz idest-08057b45c5baad283f7132b64faa05018ff2f5f7.tar.bz2 |
Add framework for Guile scripting.
* am/guile.m4: New file.
* Makefile.am (ACLOCAL_AMFLAGS): Add -I am
* configure.ac: Check for Guile.
* src/Makefile.am (idest_SOURCES): guile.c
(INCLUDES,LDADD): Add guile variables.
* src/cmdline.opt: New options: --script and --function.
* src/getopt.m4: Support conditional compilation.
* src/idest.h (guile_debug, guile_script, guile_function): New externs.
* src/guile.c: New file.
Diffstat (limited to 'src/getopt.m4')
-rw-r--r-- | src/getopt.m4 | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/src/getopt.m4 b/src/getopt.m4 index a086c76..44e2408 100644 --- a/src/getopt.m4 +++ b/src/getopt.m4 | |||
@@ -64,25 +64,40 @@ dnl GROUP(STRING) | |||
64 | dnl Begin a named group of options | 64 | dnl Begin a named group of options |
65 | dnl | 65 | dnl |
66 | define([<GROUP>],[<dnl | 66 | define([<GROUP>],[<dnl |
67 | divert(3) | 67 | divert(3)ifdef([<IFCOND>],[< |
68 | { NULL, NULL, 0, N_("prep([<$1>])") }, | 68 | #ifdef IFCOND>]) |
69 | { NULL, NULL, 0, N_("prep([<$1>])") },dnl | ||
70 | ifdef([<IFCOND>],[< | ||
71 | #endif>]) | ||
69 | divert(-1)>]) | 72 | divert(-1)>]) |
70 | 73 | ||
71 | define([<__GATHER_OPTIONS>],[< | 74 | define([<__GATHER_OPTIONS>],[< |
72 | define([<KEY>],ifelse([<$2>],,[<OPTION_>]upcase(patsubst($1,-,_)),'$2')) | 75 | define([<KEY>],ifelse([<$2>],,[<OPTION_>]upcase(patsubst($1,-,_)),'$2')) |
73 | ifelse([<$2>],,[< | 76 | ifelse([<$2>],,[< |
74 | divert(1) | 77 | divert(1)ifdef([<IFCOND>],[< |
75 | KEY, | 78 | #ifdef IFCOND>]) |
79 | KEY,dnl | ||
80 | ifdef([<IFCOND>],[< | ||
81 | #endif>]) | ||
76 | divert(-1) | 82 | divert(-1) |
77 | >]) | 83 | >]) |
78 | define([<SELECTOR>],ifdef([<SELECTOR>],SELECTOR) case KEY:) | 84 | define([<SELECTOR>],ifdef([<SELECTOR>],SELECTOR) case KEY:) |
79 | ifelse([<$1>],,,[< | 85 | ifelse([<$1>],,,[< |
80 | divert(2) | 86 | divert(2)ifdef([<IFCOND>],[< |
81 | { "$1", ARGTYPE, 0, KEY }, | 87 | #ifdef IFCOND>]) |
88 | { "$1", ARGTYPE, 0, KEY },dnl | ||
89 | ifdef([<IFCOND>],[< | ||
90 | #endif>]) | ||
82 | divert(-1)>]) | 91 | divert(-1)>]) |
83 | dnl | 92 | dnl |
84 | define([<SHORT_OPTS>],SHORT_OPTS[<>]dnl | 93 | define([<SHORT_OPTS>],SHORT_OPTS[<>]dnl |
85 | ifelse([<$2>],,,$2[<>]ifelse(ARGTYPE,[<no_argument>],,ARGTYPE,[<required_argument>],:,ARGTYPE,[<optional_argument>],::))) | 94 | ifelse([<$2>],,,dnl |
95 | ifdef([<IFCOND>],[< | ||
96 | #ifdef IFCOND>]) | ||
97 | "$2[<>]ifelse(ARGTYPE,[<no_argument>],,ARGTYPE,[<required_argument>],:,ARGTYPE,[<optional_argument>],::)"dnl | ||
98 | ifdef([<IFCOND>],[< | ||
99 | #endif | ||
100 | >]))) | ||
86 | dnl | 101 | dnl |
87 | ifelse([<$1>],,,dnl | 102 | ifelse([<$1>],,,dnl |
88 | [<define([<LONG_TAG>],ifelse(LONG_TAG,,[<--$1>],[<LONG_TAG; --$1>]))>]) | 103 | [<define([<LONG_TAG>],ifelse(LONG_TAG,,[<--$1>],[<LONG_TAG; --$1>]))>]) |
@@ -118,6 +133,12 @@ patsubst([<$3>],[<\[.*\]>]),,[<optional_argument>],dnl | |||
118 | __GATHER_OPTIONS($@) | 133 | __GATHER_OPTIONS($@) |
119 | >]) | 134 | >]) |
120 | 135 | ||
136 | define([<IFDEF>],[< | ||
137 | pushdef([<IFCOND>],[<$1>]) | ||
138 | $2 | ||
139 | popdef([<IFCOND>]) | ||
140 | >]) | ||
141 | |||
121 | dnl ALIAS(long-opt, short-opt) | 142 | dnl ALIAS(long-opt, short-opt) |
122 | dnl Declare aliases for the previous OPTION statement. | 143 | dnl Declare aliases for the previous OPTION statement. |
123 | dnl long-opt Long option. | 144 | dnl long-opt Long option. |
@@ -135,12 +156,16 @@ dnl statement, with optional ALIAS statements in between. | |||
135 | dnl | 156 | dnl |
136 | define([<BEGIN>],[< | 157 | define([<BEGIN>],[< |
137 | ifelse([<DOCSTRING>],,,[< | 158 | ifelse([<DOCSTRING>],,,[< |
138 | divert(3) | 159 | divert(3)dnl |
160 | ifdef([<IFCOND>],[< | ||
161 | #ifdef IFCOND>]) | ||
139 | { "translit(dnl | 162 | { "translit(dnl |
140 | ifelse(SHORT_TAG,,LONG_TAG,[<SHORT_TAG[<>]ifelse(LONG_TAG,,,; LONG_TAG)>]), | 163 | ifelse(SHORT_TAG,,LONG_TAG,[<SHORT_TAG[<>]ifelse(LONG_TAG,,,; LONG_TAG)>]), |
141 | [<;>],[<,>])", ifelse(ARGNAME,,[<NULL, 0>], | 164 | [<;>],[<,>])", ifelse(ARGNAME,,[<NULL, 0>], |
142 | [<ifelse(ARGTYPE,[<optional_argument>], | 165 | [<ifelse(ARGTYPE,[<optional_argument>], |
143 | [<patsubst(ARGNAME,[<\[\(.*\)\]>],[<N_("\1"), 1>])>],[<N_("ARGNAME"), 0>])>]), N_("DOCSTRING") }, | 166 | [<patsubst(ARGNAME,[<\[\(.*\)\]>],[<N_("\1"), 1>])>],[<N_("ARGNAME"), 0>])>]), N_("DOCSTRING") },dnl |
167 | ifdef([<IFCOND>],[< | ||
168 | #endif>]) | ||
144 | divert(-1)>]) | 169 | divert(-1)>]) |
145 | popdef([<ARGTYPE>]) | 170 | popdef([<ARGTYPE>]) |
146 | popdef([<ARGNAME>]) | 171 | popdef([<ARGNAME>]) |
@@ -148,6 +173,8 @@ popdef([<DOCSTRING>]) | |||
148 | divert(4)dnl | 173 | divert(4)dnl |
149 | popdef([<LONG_TAG>])dnl | 174 | popdef([<LONG_TAG>])dnl |
150 | popdef([<SHORT_TAG>])dnl | 175 | popdef([<SHORT_TAG>])dnl |
176 | ifdef([<IFCOND>],[< | ||
177 | #ifdef IFCOND>]) | ||
151 | SELECTOR | 178 | SELECTOR |
152 | { | 179 | { |
153 | >]) | 180 | >]) |
@@ -157,7 +184,9 @@ dnl Finish the associated action | |||
157 | dnl | 184 | dnl |
158 | define([<END>],[< | 185 | define([<END>],[< |
159 | break; | 186 | break; |
160 | } | 187 | }dnl |
188 | ifdef([<IFCOND>],[< | ||
189 | #endif>]) | ||
161 | divert(-1) | 190 | divert(-1) |
162 | undefine([<SELECTOR>])>]) | 191 | undefine([<SELECTOR>])>]) |
163 | 192 | ||
@@ -173,7 +202,7 @@ define([<GETOPT>],[< | |||
173 | int c; | 202 | int c; |
174 | 203 | ||
175 | ifelse([<$#>],3,opterr = 0;) | 204 | ifelse([<$#>],3,opterr = 0;) |
176 | while ((c = getopt_long($1, $2, "SHORT_OPTS", | 205 | while ((c = getopt_long($1, $2, SHORT_OPTS, |
177 | long_options, NULL)) != EOF) | 206 | long_options, NULL)) != EOF) |
178 | { | 207 | { |
179 | switch (c) | 208 | switch (c) |