Commit 01127e3c4d0ca5d6fce579ba51ab2a24a6596018
Committed by
Stéphane Raimbault
1 parent
04cde66b
Allow building Win32 using autotools infrastructure
Some small modifications were neccessary to make libmodbus build using a MinGW (cross-)compiler. Libtool is now configured to build DLL files on Win32. The wsock32 library has been added to the list of libraries to link against. Signed-off-by: Stéphane Raimbault <stephane.raimbault@gmail.com>
Showing
2 changed files
with
18 additions
and
1 deletions
configure.ac
| @@ -46,9 +46,22 @@ LIBMODBUS_LD_AGE=0 | @@ -46,9 +46,22 @@ LIBMODBUS_LD_AGE=0 | ||
| 46 | LIBMODBUS_LT_VERSION_INFO=$LIBMODBUS_LD_CURRENT:$LIBMODBUS_LD_REVISION:$LIBMODBUS_LD_AGE | 46 | LIBMODBUS_LT_VERSION_INFO=$LIBMODBUS_LD_CURRENT:$LIBMODBUS_LD_REVISION:$LIBMODBUS_LD_AGE |
| 47 | AC_SUBST(LIBMODBUS_LT_VERSION_INFO) | 47 | AC_SUBST(LIBMODBUS_LT_VERSION_INFO) |
| 48 | 48 | ||
| 49 | +# Check whether we are building for Win32 | ||
| 50 | +build_win32="false" | ||
| 51 | +case "${host}" in | ||
| 52 | + *mingw32) | ||
| 53 | + AC_DEFINE([BUILD_WIN32], [], [Build libmodbus for Win32]) | ||
| 54 | + build_win32="true" | ||
| 55 | + ;; | ||
| 56 | +esac | ||
| 57 | + | ||
| 58 | +AM_CONDITIONAL(BUILD_WIN32, test "$build_win32" = "true") | ||
| 59 | + | ||
| 49 | # Checks for programs. | 60 | # Checks for programs. |
| 50 | AC_PROG_CC | 61 | AC_PROG_CC |
| 51 | AC_PROG_CXX | 62 | AC_PROG_CXX |
| 63 | +AC_LIBTOOL_WIN32_DLL | ||
| 64 | +AC_PROG_LIBTOOL | ||
| 52 | AC_PROG_MAKE_SET | 65 | AC_PROG_MAKE_SET |
| 53 | LT_INIT([disable-static]) | 66 | LT_INIT([disable-static]) |
| 54 | 67 |
src/Makefile.am
| @@ -11,7 +11,11 @@ libmodbus_la_SOURCES = \ | @@ -11,7 +11,11 @@ libmodbus_la_SOURCES = \ | ||
| 11 | modbus-tcp.h \ | 11 | modbus-tcp.h \ |
| 12 | modbus-tcp-private.h \ | 12 | modbus-tcp-private.h \ |
| 13 | modbus-version.h | 13 | modbus-version.h |
| 14 | -libmodbus_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBMODBUS_LT_VERSION_INFO) | 14 | +if BUILD_WIN32 |
| 15 | +libmodbus_la_LIBADD = -lwsock32 | ||
| 16 | +endif | ||
| 17 | + | ||
| 18 | +libmodbus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info $(LIBMODBUS_LT_VERSION_INFO) | ||
| 15 | 19 | ||
| 16 | # Header files to install | 20 | # Header files to install |
| 17 | libmodbusincludedir = $(includedir)/modbus | 21 | libmodbusincludedir = $(includedir)/modbus |