automake
[Top][All Lists]
Advanced

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

conditionally linking to mingw32 library


From: Mark Brand
Subject: conditionally linking to mingw32 library
Date: Wed, 01 Jun 2005 14:41:58 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511

I'm not very experienced with the GNU build tools, but I've managed to
get a couple simple autoconf/automake configurations to work. My goal
now is to build for Linux or Mingw32 starting with the same configure.ac
and Makefile.am files. My generate/configure/make steps are:

    autoheader
    touch NEWS README AUTHORS ChangeLog
    touch stamp-h
    aclocal
    autoconf
    automake -a
    ./configure
    make

For Mingw32, the configure step looks like this:

    ./configure --with-msw --target=i586-mingw32msvc
--host=i586-mingw32msvc --build=i386-linux

The good news is that this works well. However, for a program that uses
the sockets interface, the Mingw32 version needs to link to the winsock
library ws2_32. If I add to Makefile.am the line:

    myprogram_LDADD = -lws2_32

then the Ming32 version can build, but the Linux version gets a link
error. So, obviously it would be nice to make this LDADD line conditional.

To reach this lofty goal, I've been trying to apply the example in

        http://lists.gnu.org/archive/html/automake/2002-11/msg00116.html

to my situation, but I'm getting stuck. I have:

<configure.ac>
 if test x$target_os == xmingw32; then
    WINSOCK=-lws2_32
 fi
 AC_SUBST(WINSOCK)
</configure.ac>

<Makefile.am>
 myprogram_LDADD := @LTLIBINTL@ @WINSOCK@
</Makefile.am>

My generated Makefile contains:

    WINSOCK = @WINSOCK@

When I build (for either target) I get this error:

    g++  -g -O2   -o myprogram  main.o  @WINSOCK@
    g++: @WINSOCK@: No such file or directory
    make[2]: *** [myprogram Error 1


Can someone explain what's going on and set me straight? Is there a
better standard approach to this?

On a related matter, do I need to do something else to assign a value to
target_os, of does the configure script take care of this?

By the way, this is all happening on Debian Sarge with:

m4 1.4.2-1
autoconf 2.59a-3
automake 1.9.5-1
mingw32 3.4.2.20040
mingw32-binutils 2.15.94-200
mingw32-runtime 3.7-1


Regards,

Mark




reply via email to

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