In one of the pieces of software that I wrote, I have been using
getopt_long and would like to continue using it. What is the
traditional way of dealing with the fact that it doesn't exist on some
platforms such as FreeBSD.

The information that I have is that:
getopt_long is found by default on Linux
it is in Solaris in the library named "iberty". 

My thought is that I should include getopt.h, getopt.c, getopt1.c with
the source code for my program (that is the nice thing about GPL'd
code).

What I would like to happen is that if there is a version on the
system, I use that but if there isn't I want it to use the one that
I included. 

What I have in my configure.in is:

AC_CHECK_FUNC(getopt_long,
    AC_MSG_RESULT(using libc's getopt_long),
    AC_CHECK_LIB(iberty, getopt_long))

This sort of works for linux and solaris but it doesn't work for
FreeBSD which doesn't have a "iberty" library but what do I put in my
Makefile.am to tell it to compile getopt.c getopt1.c and link with
them if both HAVE_GETOPT_LONG and HAVE_LIBIBERTY are defined.

Please tell me if this is not the right way to go about this
problem or if you know of a package which demonstrates how things like
this are done.

-ben

Reply via email to