Wow. Good call! It seems so obvious now that you mention it =)O|
I was thinking that it might be better to note in the autoconf manual
(or perhaps add the functionality to `automake --add-missing') to
use a project local gnugetopt.h and change getopt.c and getopt1.c to
#include the renamed header.
configure.in would need:
AC_CHECK_FUNC(getopt_long, [],
[AC_DEFINE(HAVE_GETOPT_H, 1,
[Define this if there is a system getopt.h header])
])
The file the makes use of getopt would have:
#if HAVE_CONFIG_H
# include <config.h>
#endif
.
.
.
#if HAVE_GETOPT_H
# include <getopt.h>
#else
# include "gnugetopt.h"
#endif
getopt.c and getopt1.c would still be compiled in unconditionally.
Cheers,
Gary.
On Wed, Sep 13, 2000 at 07:19:55AM -0700, [EMAIL PROTECTED] wrote:
> > packages I've seen that have local copies of getopt.h use that copy
> > when compiling their files, regardless of whether or not the system or
> > the package supplies the actual getopt functions. On some systems
>
> BTW, in the past I've fixed this by moving getopt.h to getopt.h.in,
> replacing getopt.o in the objects list with LIBOBJS, putting something
> like the following in configure.in, and regenerating configure:
>
> # We use our own version of getopt (including our own header file) if
> # the system libs don't have getopt. The problem we have is that we
> # can't just arbitrarily use the one in libs. Some systems, notably
> # those that use the Microsoft style of shared library linkage,
> # require special "cruft" in the declarations (__declspec(dllimport))
> # to properly import global variables set by the shared library
> # functions. Thus we not only have to use the version of getopt
> # supplied by the system, but we must also ensure that we use the
> # getopt.h supplied by the system. On the other hand, if we use our
> # replacement getopt, then we must ensure that we also use the
> # corresponding replacement getopt.h. Using the system getopt() with
> # our getopt.h or vice versa, is a sure recipe for disaster if there
> # is any mismatch.
>
> private_getopt=
> AC_CHECK_FUNC(getopt, :, private_getopt=yes)
> AC_CHECK_HEADER(getopt.h, AC_DEFINE(HAVE_GETOPT_H), private_getopt=yes)
> if test -n "$private_getopt"; then
> getopt_dist=getopt.h.in
> getopt_used=getopt.h
> LIBOBJS="$LIBOBJS getopt.o"
> fi
>
> AC_LINK_FILES($getopt_dist,$getopt_used)
> AC_SUBST(LIBOBJS)
>
> -Fred
--
___ _ ___ __ _ mailto: [EMAIL PROTECTED]
/ __|__ _ _ ___ _| | / / | / /_ _ _ _ __ _| |_ __ _ ___ [EMAIL PROTECTED]
| (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \
\___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/
home page: /___/ /___/ gpg public key:
http://www.oranda.demon.co.uk http://www.oranda.demon.co.uk/key.asc