summaryrefslogtreecommitdiffabout
path: root/src/getopt.m4
authorSergey Poznyakoff <gray@gnu.org.ua>2009-03-16 15:17:27 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2009-03-16 15:17:27 (GMT)
commit08057b45c5baad283f7132b64faa05018ff2f5f7 (patch) (side-by-side diff)
treebbeefaa36b0542a25cfdf29cc68c71b03afd4d2f /src/getopt.m4
parent4385b872616eba08c2b8c8b7f465e81ff379b43c (diff)
downloadidest-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') (more/less context) (ignore whitespace changes)
-rw-r--r--src/getopt.m451
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)
dnl Begin a named group of options
dnl
define([<GROUP>],[<dnl
-divert(3)
- { NULL, NULL, 0, N_("prep([<$1>])") },
+divert(3)ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
+ { NULL, NULL, 0, N_("prep([<$1>])") },dnl
+ifdef([<IFCOND>],[<
+#endif>])
divert(-1)>])
define([<__GATHER_OPTIONS>],[<
define([<KEY>],ifelse([<$2>],,[<OPTION_>]upcase(patsubst($1,-,_)),'$2'))
ifelse([<$2>],,[<
-divert(1)
- KEY,
+divert(1)ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
+ KEY,dnl
+ifdef([<IFCOND>],[<
+#endif>])
divert(-1)
>])
define([<SELECTOR>],ifdef([<SELECTOR>],SELECTOR) case KEY:)
ifelse([<$1>],,,[<
-divert(2)
- { "$1", ARGTYPE, 0, KEY },
+divert(2)ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
+ { "$1", ARGTYPE, 0, KEY },dnl
+ifdef([<IFCOND>],[<
+#endif>])
divert(-1)>])
dnl
define([<SHORT_OPTS>],SHORT_OPTS[<>]dnl
-ifelse([<$2>],,,$2[<>]ifelse(ARGTYPE,[<no_argument>],,ARGTYPE,[<required_argument>],:,ARGTYPE,[<optional_argument>],::)))
+ifelse([<$2>],,,dnl
+ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
+"$2[<>]ifelse(ARGTYPE,[<no_argument>],,ARGTYPE,[<required_argument>],:,ARGTYPE,[<optional_argument>],::)"dnl
+ifdef([<IFCOND>],[<
+#endif
+>])))
dnl
ifelse([<$1>],,,dnl
[<define([<LONG_TAG>],ifelse(LONG_TAG,,[<--$1>],[<LONG_TAG; --$1>]))>])
@@ -118,6 +133,12 @@ patsubst([<$3>],[<\[.*\]>]),,[<optional_argument>],dnl
__GATHER_OPTIONS($@)
>])
+define([<IFDEF>],[<
+pushdef([<IFCOND>],[<$1>])
+$2
+popdef([<IFCOND>])
+>])
+
dnl ALIAS(long-opt, short-opt)
dnl Declare aliases for the previous OPTION statement.
dnl long-opt Long option.
@@ -135,12 +156,16 @@ dnl statement, with optional ALIAS statements in between.
dnl
define([<BEGIN>],[<
ifelse([<DOCSTRING>],,,[<
-divert(3)
+divert(3)dnl
+ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
{ "translit(dnl
ifelse(SHORT_TAG,,LONG_TAG,[<SHORT_TAG[<>]ifelse(LONG_TAG,,,; LONG_TAG)>]),
[<;>],[<,>])", ifelse(ARGNAME,,[<NULL, 0>],
[<ifelse(ARGTYPE,[<optional_argument>],
-[<patsubst(ARGNAME,[<\[\(.*\)\]>],[<N_("\1"), 1>])>],[<N_("ARGNAME"), 0>])>]), N_("DOCSTRING") },
+[<patsubst(ARGNAME,[<\[\(.*\)\]>],[<N_("\1"), 1>])>],[<N_("ARGNAME"), 0>])>]), N_("DOCSTRING") },dnl
+ifdef([<IFCOND>],[<
+#endif>])
divert(-1)>])
popdef([<ARGTYPE>])
popdef([<ARGNAME>])
@@ -148,6 +173,8 @@ popdef([<DOCSTRING>])
divert(4)dnl
popdef([<LONG_TAG>])dnl
popdef([<SHORT_TAG>])dnl
+ifdef([<IFCOND>],[<
+#ifdef IFCOND>])
SELECTOR
{
>])
@@ -157,7 +184,9 @@ dnl Finish the associated action
dnl
define([<END>],[<
break;
- }
+ }dnl
+ifdef([<IFCOND>],[<
+#endif>])
divert(-1)
undefine([<SELECTOR>])>])
@@ -173,7 +202,7 @@ define([<GETOPT>],[<
int c;
ifelse([<$#>],3,opterr = 0;)
- while ((c = getopt_long($1, $2, "SHORT_OPTS",
+ while ((c = getopt_long($1, $2, SHORT_OPTS,
long_options, NULL)) != EOF)
{
switch (c)

Return to:

Send suggestions and report system problems to the System administrator.