Need help with autoconf/automake under cygwin

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Need help with autoconf/automake under cygwin

Johnathan Corgan
I've been furiously studying the autoconf/automake documentation to try
to create a automatic configuration for my FTDI patch for avrdude.

Success so far:

I've created an --enable-ftdi-support option for that
ultimately defines FTDI_SUPPORT in ac_cfg.h.  I've conditionalized the
ftbb.c file with this symbol to eliminate all but a stub for
init_ftbb_pgm if configure is invoked without the option. (The config
parser still needs to be able to link to this function, but it does
nothing.)  And so now normal builds without the option enabled still
work as expected, on either Linux or Cygwin.

With the option enabled, checks the target system for
cygwin or (anything else).  Under *nix, it sets things to check for
libftdi and ftdi.h, using AC_CHECK_LIB and AC_CHECK_HEADERS.  The
linking stage then includes -lftdi automagically (I assume because
AC_CHECK_LIB tells it to.)

Right now, I've enclosed all the calls to the FT_* functions for the
Windows DLL version in #ifdef WIN32NATIVE...#endif blocks.  So (for
now), when building under Linux, one gets non-functional stubs of all
the functions in ftbb.c, until I go write in all the calls to the
libftdi equivalents.  But the program compiles and links to libftdi ok.

So far so good--the build infrastructure appears to work under Linux and
I can now go in and start implementing libftdi replacement calls for the
FTD2XX calls.

However, I'm at my wits end trying to get this same build infrastructure
to work under cygwin/mingw32.  In the previously working patch, I had
hard coded in an avrdude_LDADD= line with pointed to the
.lib import library supplied by FTDI, and hard coded a "-I" include
search path for the header file.

But I want to do the "right thing", using AC_CHECK_LIB, etc.

It turns out that rather than add an import library to the list of
object files, recent versions of ld.exe can directly link against .dll
files, which is faster and simpler.  So, theoretically, I can use
AC_CHECK_LIB(FTD2XX, FT_Open) which will pass a -lFTD2XX to the linker
stage of the test (just as in the libftdi case under *nix.)  The only
minor inconvenience is that the dll file must be renamed to
libFTD2XX.dll.a in order for ld to see it.

I've done so, and from the cygwin bash prompt, i can manually invoke:

ld -lFTD2XX

and it will find the dll file (then complain because it can't find an
entry point, but that's cause there's not start up code linked in too.)

Now, when I add AC_CHECK_LIB to the, the autoconf test that
gets created does indeed invoke gcc with the -lFTD2XX option, but now ld
*can't* find it.  I verified this by looking in the config.log and
checking the command line for the test that configure records, and the
error message is from ld saying it cant find -lFTD2XX.  Remember, a
manual invocation of ld -lFTD2XX from the command line works.

I've only studied the autoconf documentation for a few hours, and I've
copied some from other files I've seen on Google, so I'm
probably doing something really dumb.  But it's frustrating--it all
worked so well the first time under Linux.

Here is the snippet I'm working from:

                [support serial programming via FTDI bit-bang mode]),
                [case "${enableval}" in
                yes) ftdi_support=yes ;;
                no)  ftdi_support=no ;;
                *)   AC_MSG_ERROR(bad value ${enableval} for option) ;;
AM_CONDITIONAL(FTDI_SUPPORT, [test "$ftdi_support" = "yes"])

# Determine appropriate FTDI library to link to
if test "$ftdi_support" = yes; then
        AC_DEFINE(FTDI_SUPPORT, 1, [Enable support for FTDI bit-bang.])
        AC_MSG_CHECKING([for FTDI support library])
        case $target in
                *-*-mingw32* | *-*-cygwin* | *-*-windows*)
        AC_CHECK_LIB([$ftdilib], [$ftdifunc])

I'm sort of stalled out at this point trying to do finish this.  Any
help is appreciated.


avrdude-dev mailing list
[hidden email]

signature.asc (196 bytes) Download Attachment