[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

using system getopt_long instead of local version

From: Jeremy C. Reed
Subject: using system getopt_long instead of local version
Date: Thu, 29 Nov 2001 01:24:33 -0800 (PST)

My project included getopt1.c, getopt.c and getopt.h in the main
source directory. And the Makefile listed them and they were compiled and
link everytime.

I want it use the system's getopt_long() if available. I do not want to
compile and link in the local getopt.c if it is not needed. (In my tests,
I see it makes the executable binary a few kilobytes smaller.)

And I want to move the getopt* code to a getopt subdirectory. If the
system doesn't provide a getopt_long, then I want to use the locally
included code.

Currently, my has:

[LIBS="$LIBS -L./getopt" CFLAGS="$CFLAGS -I./getopt"])

And on my Debian Linux and NetBSD systems, it uses the system's
getopt_long (and works).

But on my FreeBSD system (without gnugetopt), it doesn't build. (I receive
"undefined reference to `getopt_long'".)

I want it to do the right thing for other systems too.

I have read several postings to the automake and autoconf mailing lists in
regards to this. But, I have only seen solutions that use the system
header file with the local code linked in. And a solution that uses
"AC_LIBOBJ(getopt1)". I don't see AC_LIBOBJ in the currently available autoconf book. (And it is not part of my autoconf 2.13.)

Can anyone share some advice on how to get my Makefile created so it will
only compile the local getopt as needed?

Also, feel free to point me to any good examples. (I have looked at
several examples of checking for getopt.h, but they don't do what I want.)


   Jeremy C. Reed

reply via email to

[Prev in Thread] Current Thread [Next in Thread]