summaryrefslogtreecommitdiff
path: root/libc/unistd
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2014-12-12 16:18:12 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2014-12-12 16:18:12 +0100
commit067637375658047d70c296606ae17ef0bc86499d (patch)
tree3310aa2ed1489274cae928e0e9ab350ecf3af3c6 /libc/unistd
parentd6da534cbf05dc4d09221881afd49b275ca7cd29 (diff)
unistd: allow to turn off getopt_long
The GNU variant of getopt() previously had no way to turn off getopt_long() support.
Diffstat (limited to 'libc/unistd')
-rw-r--r--libc/unistd/Makefile.in14
-rw-r--r--libc/unistd/getopt.c2
2 files changed, 12 insertions, 4 deletions
diff --git a/libc/unistd/Makefile.in b/libc/unistd/Makefile.in
index b15d60a16..659008d4d 100644
--- a/libc/unistd/Makefile.in
+++ b/libc/unistd/Makefile.in
@@ -16,10 +16,16 @@ OMIT-$(ARCH_USE_MMU) += __exec_alloc.c
OMIT-$(if $(UCLIBC_SUSV3_LEGACY),,y) += ualarm.c usleep.c
#OMIT-$(UCLIBC_HAS_THREADS_NATIVE) += sleep.c
-# XXX: GNU_GETOPT comes with getopt_long unconditionally, which is wrong
-GO_LONG := $(if $(UCLIBC_HAS_GNU_GETOPT),getopt_long-simple.c)
-OMIT-y += $(if $(UCLIBC_HAS_GNU_GETOPT),getopt-susv3.c $(GO_LONG),getopt.c)
-OMIT-y += $(if $(UCLIBC_HAS_GNU_GETSUBOPT),getsubopt-susv3.c,getsubopt.c)
+ifeq ($(UCLIBC_HAS_GNU_GETOPT),y)
+# GNU getopt family
+OMIT-y += getopt-susv3.c getopt_long-simple.c getsubopt-susv3.c
+OMIT-y += $(if $(UCLIBC_HAS_GNU_GETSUBOPT),,getsubopt.c)
+else
+# SuS getopt family
+OMIT-y += getopt.c getsubopt.c
+OMIT-y += $(if $(UCLIBC_HAS_GETOPT_LONG),,getopt_long-simple.c)
+OMIT-y += $(if $(UCLIBC_HAS_GNU_GETSUBOPT),,getsubopt-susv3.c)
+endif
CSRC-y := $(filter-out $(OMIT-y),$(CSRC-y))
diff --git a/libc/unistd/getopt.c b/libc/unistd/getopt.c
index 3944c7c1f..f63482bc8 100644
--- a/libc/unistd/getopt.c
+++ b/libc/unistd/getopt.c
@@ -1162,6 +1162,7 @@ getopt (int argc, char *const *argv, const char *optstring)
}
libc_hidden_def(getopt)
+#if defined __UCLIBC_HAS_GETOPT_LONG__
int
getopt_long (int argc, char *const *argv, const char *options,
const struct option *long_options, int *opt_index)
@@ -1180,5 +1181,6 @@ getopt_long_only (int argc, char *const *argv, const char *options,
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
+#endif /* __UCLIBC_HAS_GETOPT_LONG__ */
#endif /* Not ELIDE_CODE. */