[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnulib] Re: getopt trouble on uClibc systems
From: |
Simon Josefsson |
Subject: |
[Bug-gnulib] Re: getopt trouble on uClibc systems |
Date: |
Fri, 02 Jul 2004 20:53:38 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux) |
* getopt.h has to be renamed to getopt_.h.
* This still check for getopt.h. I reckoned it is conceivable that a
system has all getopt symbols (getopt_long etc) but not getopt.h,
and in that case it is cheap to provide getopt.h, instead of let the
build fail.
* The test for a GNU getopt implementation is presence of
getopt_long_only. I feel this is simpler than writing a full blown
test case, which probably would amount to mostly the same thing as
testing whether getopt_long_only links successfully anyway. It
might turn out to be insufficient, but then at least getopt.m4 is
short and simple to understand, and it is easy to extend the test.
* Tested on native builds for Linux x86/IA64/Alpha, NetBSD1.6, OSF5.1,
HP-UX, and cross compiled to uClibc/uClinux Motorola Coldfire M5200.
Thanks!
PS. Savannah CVS seem down, so I rolled this against my local copy of
Savannah gnulib CVS. Shouldn't cause a problem, but you never know.
PPS. FYI, with this patch, all of GNU Libidn/SASL/Shishi/GSS cross
compile without problem, and at least the latter two projects use many
gnulib files, so that means many modules are in good shape.
Index: ChangeLog
===================================================================
RCS file: /home/cvs/shadow-cvs/gnulib/gnulib/ChangeLog,v
retrieving revision 1.157
diff -u -p -r1.157 ChangeLog
--- ChangeLog 22 Jun 2004 18:28:11 -0000 1.157
+++ ChangeLog 2 Jul 2004 18:50:46 -0000
@@ -1,3 +1,9 @@
+2004-07-01 Simon Josefsson <address@hidden>
+
+ * modules/getopt (Files): Rename getopt.h to getopt_.h.
+ (Makefile.am): Rewrite, use logic from argz.
+ (Include): Use <getopt.h> instead of "getopt.h".
+
2004-06-22 Paul Eggert <address@hidden>
* modules/argz: Omit "#include".
Index: lib/ChangeLog
===================================================================
RCS file: /home/cvs/shadow-cvs/gnulib/gnulib/lib/ChangeLog,v
retrieving revision 1.672
diff -u -p -r1.672 ChangeLog
--- lib/ChangeLog 24 Jun 2004 06:05:19 -0000 1.672
+++ lib/ChangeLog 2 Jul 2004 18:50:52 -0000
@@ -1,3 +1,7 @@
+2004-07-01 Simon Josefsson <address@hidden>
+
+ * getopt.c, getopt1.c: Remove ELIDE_CODE hack.
+
2004-06-24 Jim Meyering <address@hidden>
* obstack.h (obstack_base): Cast to (void *), per documentation.
Index: lib/getopt.c
===================================================================
RCS file: /home/cvs/shadow-cvs/gnulib/gnulib/lib/getopt.c,v
retrieving revision 1.42
diff -u -p -r1.42 getopt.c
--- lib/getopt.c 11 Mar 2004 13:04:48 -0000 1.42
+++ lib/getopt.c 2 Jul 2004 18:50:54 -0000
@@ -32,25 +32,6 @@
#include <stdio.h>
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-# include <gnu-versions.h>
-# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-# define ELIDE_CODE
-# endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
@@ -1181,7 +1162,6 @@ getopt (int argc, char *const *argv, con
0);
}
-#endif /* Not ELIDE_CODE. */
#ifdef TEST
Index: lib/getopt1.c
===================================================================
RCS file: /home/cvs/shadow-cvs/gnulib/gnulib/lib/getopt1.c,v
retrieving revision 1.16
diff -u -p -r1.16 getopt1.c
--- lib/getopt1.c 9 Mar 2004 19:42:23 -0000 1.16
+++ lib/getopt1.c 2 Jul 2004 18:50:54 -0000
@@ -30,25 +30,6 @@
#include <stdio.h>
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-#include <gnu-versions.h>
-#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-#define ELIDE_CODE
-#endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
@@ -96,7 +77,6 @@ _getopt_long_only_r (int argc, char *con
1, d);
}
-#endif /* Not ELIDE_CODE. */
#ifdef TEST
Index: m4/ChangeLog
===================================================================
RCS file: /home/cvs/shadow-cvs/gnulib/gnulib/m4/ChangeLog,v
retrieving revision 1.560
diff -u -p -r1.560 ChangeLog
--- m4/ChangeLog 22 Jun 2004 18:28:27 -0000 1.560
+++ m4/ChangeLog 2 Jul 2004 18:50:58 -0000
@@ -1,3 +1,13 @@
+2004-07-01 Simon Josefsson <address@hidden>
+
+ * getopt.m4: Implement it, as discussed with Paul Eggert
+ <address@hidden> in threads rooted at
+ <http://lists.gnu.org/archive/html/bug-gnulib/2004-06/msg00039.html>
+ and
+ <http://lists.gnu.org/archive/html/bug-gnulib/2004-07/msg00001.html>.
+ Before, the test was empty, and relied on ELIDE_CODE in source
+ code.)
+
2004-06-22 Paul Eggert <address@hidden>
* argz.m4: New file, which is autoupdated from libtool.
Index: m4/getopt.m4
===================================================================
RCS file: /home/cvs/shadow-cvs/gnulib/gnulib/m4/getopt.m4,v
retrieving revision 1.2
diff -u -p -r1.2 getopt.m4
--- m4/getopt.m4 9 Sep 2003 18:36:53 -0000 1.2
+++ m4/getopt.m4 2 Jul 2004 18:50:58 -0000
@@ -1,13 +1,39 @@
-# getopt.m4 serial 2
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# getopt.m4 serial 3
+dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
+# The getopt module assume you want GNU getopt, with getopt_long etc,
+# rather than vanilla POSIX getopt. This means your your code should
+# always include <getopt.h> for the getopt prototypes.
+
AC_DEFUN([gl_GETOPT],
[
- dnl Prerequisites of lib/getopt.c.
- :
+ gl_PREREQ_GETOPT
+
+ GETOPT_H=
+ AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
+ AC_CHECK_FUNCS([getopt_long_only], [],
+ [GETOPT_H=getopt.h
+ AC_LIBOBJ([getopt])
+ AC_LIBOBJ([getopt1])
+ AC_DEFINE([optarg], [rpl_optarg],
+ [Define to rpl_optarg if the replacement variable should be used.])
+ AC_DEFINE([optind], [rpl_optind],
+ [Define to rpl_optind if the replacement variable should be used.])
+ AC_DEFINE([optopt], [rpl_optopt],
+ [Define to rpl_optopt if the replacement variable should be used.])
+ AC_DEFINE([getopt], [rpl_getopt],
+ [Define to rpl_getopt if the replacement function should be used.])
+ AC_DEFINE([getopt_long], [rpl_getopt_long],
+ [Define to rpl_getopt_long if the replacement function should be used.])
+ AC_DEFINE([getopt_long_only], [rpl_getopt_long_only],
+ [Define to rpl_getopt_long_only if the replacement function should be
used.])])
+ AC_SUBST([GETOPT_H])
])
+
+# Prerequisites of lib/getopt*.
+AC_DEFUN([gl_PREREQ_GETOPT], [:])
Index: modules/getopt
===================================================================
RCS file: /home/cvs/shadow-cvs/gnulib/gnulib/modules/getopt,v
retrieving revision 1.5
diff -u -p -r1.5 getopt
--- modules/getopt 12 Apr 2004 20:12:33 -0000 1.5
+++ modules/getopt 2 Jul 2004 18:50:58 -0000
@@ -2,7 +2,7 @@ Description:
Process command line arguments.
Files:
-lib/getopt.h
+lib/getopt_.h
lib/getopt.c
lib/getopt1.c
lib/getopt_int.h
@@ -15,10 +15,19 @@ configure.ac:
gl_GETOPT
Makefile.am:
-lib_SOURCES += getopt.h getopt.c getopt1.c getopt_int.h
+BUILT_SOURCES += $(GETOPT_H)
+EXTRA_DIST += getopt_.h getopt_int.h
+
+# We need the following in order to create an <getopt.h> when the system
+# doesn't have one that works with the given compiler.
+all-local $(lib_OBJECTS): $(GETOPT_H)
+getopt.h: getopt_.h
+ cp $(srcdir)/getopt_.h address@hidden
+ mv address@hidden $@
+MOSTLYCLEANFILES += getopt.h getopt.h-t
Include:
-"getopt.h"
+<getopt.h>
Maintainer:
all, glibc
- [Bug-gnulib] Re: getopt trouble on uClibc systems, Simon Josefsson, 2004/07/01
- [Bug-gnulib] config.h (was: Re: getopt trouble on uClibc systems), Simon Josefsson, 2004/07/01
- [Bug-gnulib] Re: getopt trouble on uClibc systems, Simon Josefsson, 2004/07/01
- [Bug-gnulib] Re: getopt trouble on uClibc systems, Paul Eggert, 2004/07/01
- [Bug-gnulib] Re: getopt trouble on uClibc systems, Simon Josefsson, 2004/07/02
- [Bug-gnulib] Re: getopt trouble on uClibc systems, Paul Eggert, 2004/07/02
- [Bug-gnulib] Re: getopt trouble on uClibc systems,
Simon Josefsson <=
- [Bug-gnulib] Re: getopt trouble on uClibc systems, Simon Josefsson, 2004/07/02
- Re: [Bug-gnulib] Re: getopt trouble on uClibc systems, Karl Berry, 2004/07/02
- [Bug-gnulib] Re: getopt trouble on uClibc systems, Simon Josefsson, 2004/07/06
- [Bug-gnulib] Re: getopt trouble on uClibc systems, Paul Eggert, 2004/07/10
- [Bug-gnulib] Re: getopt trouble on uClibc systems, Simon Josefsson, 2004/07/13
- Re: [Bug-gnulib] Re: getopt trouble on uClibc systems, Paul Eggert, 2004/07/13
- [Bug-gnulib] Re: getopt trouble on uClibc systems, Simon Josefsson, 2004/07/13