diff --git a/configure b/configure
index bc319183190fc999b417eaf27466f25cb469a18b..4f020cf5ff012f0029e2e72e9f11b58a3d801b41 100755
--- a/configure
+++ b/configure
@@ -13017,7 +13017,7 @@ for ac_func in \
 	futimesat \
 	getattrlist \
 	getdirentries \
-	getopt_long \
+	getopt_long_only \
 	getpagesize \
 	getpwuid \
 	gettimeofday \
diff --git a/configure.ac b/configure.ac
index 1adb6fd18db20752095e046304775c4bb93c2ad6..b1e479d222e25b3dc64c2fd2c6b680ecb2e068fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2019,7 +2019,7 @@ AC_CHECK_FUNCS(\
 	futimesat \
 	getattrlist \
 	getdirentries \
-	getopt_long \
+	getopt_long_only \
 	getpagesize \
 	getpwuid \
 	gettimeofday \
diff --git a/include/config.h.in b/include/config.h.in
index 8dc812b0358b604af82c9c59375895296263aa0a..68220527e8c8919c080ac981c7e23797abbbfa79 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -206,8 +206,8 @@
 /* Define to 1 if you have the <getopt.h> header file. */
 #undef HAVE_GETOPT_H
 
-/* Define to 1 if you have the `getopt_long' function. */
-#undef HAVE_GETOPT_LONG
+/* Define to 1 if you have the `getopt_long_only' function. */
+#undef HAVE_GETOPT_LONG_ONLY
 
 /* Define to 1 if you have the `getpagesize' function. */
 #undef HAVE_GETPAGESIZE
diff --git a/libs/port/getopt.c b/libs/port/getopt.c
index eeb64a6e7d8eea1227a5ac367cfa1176f25f935e..e38d1370489668258a42397ed0be8ecea7d4704b 100644
--- a/libs/port/getopt.c
+++ b/libs/port/getopt.c
@@ -33,7 +33,7 @@
 # include <config.h>
 #endif
 
-#ifdef HAVE_GETOPT_LONG
+#ifdef HAVE_GETOPT_LONG_ONLY
 #define ELIDE_CODE
 #endif
 
@@ -218,26 +218,7 @@ static char *posixly_correct;
 #  include <strings.h>
 # endif
 
-/* Avoid depending on library functions or files
-   whose names are inconsistent.  */
-
-#ifndef getenv
-extern char *getenv ();
-#endif
-
-static char *
-my_index (str, chr)
-     const char *str;
-     int chr;
-{
-  while (*str)
-    {
-      if (*str == chr)
-	return (char *) str;
-      str++;
-    }
-  return 0;
-}
+# define my_index strchr
 
 /* If using GCC, we can safely declare strlen this way.
    If not using GCC, it is ok not to declare it.  */
@@ -1196,10 +1177,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
 }
 
 int
-getopt (argc, argv, optstring)
-     int argc;
-     char *const *argv;
-     const char *optstring;
+getopt (int argc, char * const *argv, const char *optstring)
 {
   return _getopt_internal (argc, argv, optstring,
 			   NULL,
diff --git a/libs/port/getopt1.c b/libs/port/getopt1.c
index 37249b616b181f736e94bc066aff72932e5f1904..5cf9f01d78e691e2e5213cec50767a39b17ea7ef 100644
--- a/libs/port/getopt1.c
+++ b/libs/port/getopt1.c
@@ -24,7 +24,7 @@
 #include <config.h>
 #endif
 
-#ifdef HAVE_GETOPT_LONG
+#ifdef HAVE_GETOPT_LONG_ONLY
 #define ELIDE_CODE
 #endif
 
@@ -74,12 +74,7 @@
 #endif
 
 int
-getopt_long (argc, argv, options, long_options, opt_index)
-     int argc;
-     char *const *argv;
-     const char *options;
-     const struct option *long_options;
-     int *opt_index;
+getopt_long (int argc, char * const *argv, const char *options, const struct option *long_options, int *opt_index)
 {
   return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
 }
@@ -90,12 +85,7 @@ getopt_long (argc, argv, options, long_options, opt_index)
    instead.  */
 
 int
-getopt_long_only (argc, argv, options, long_options, opt_index)
-     int argc;
-     char *const *argv;
-     const char *options;
-     const struct option *long_options;
-     int *opt_index;
+getopt_long_only (int argc, char * const *argv, const char *options, const struct option *long_options, int *opt_index)
 {
   return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
 }