configure.ac 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # libmodbus package version number, (as distinct from shared library version)
  2. # An odd micro number indicates in-progress development from Git
  3. # An even micro number indicates a released version
  4. #
  5. # Making a point release:
  6. # - increase libmodbus_version_micro to the next even number
  7. #
  8. # After the release:
  9. # - increase libmodbus_version_minor to the next odd number
  10. #
  11. # Take care to update the libtool versioning when required (LIBMODBUS_LD_*).
  12. # http://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
  13. #
  14. m4_define([libmodbus_version_major], [3])
  15. m4_define([libmodbus_version_minor], [1])
  16. m4_define([libmodbus_version_micro], [1])
  17. m4_define([libmodbus_release_status],
  18. [m4_if(m4_eval(libmodbus_version_minor % 2), [1], [snapshot], [release])])
  19. m4_define([libmodbus_version],
  20. [libmodbus_version_major.libmodbus_version_minor.libmodbus_version_micro])
  21. AC_PREREQ([2.63])
  22. AC_INIT([libmodbus],
  23. [libmodbus_version],
  24. [https://github.com/stephane/libmodbus/issues],
  25. [libmodbus],
  26. [http://libmodbus.org/])
  27. AC_CONFIG_SRCDIR([src/modbus.c])
  28. AC_CONFIG_AUX_DIR([build-aux])
  29. AM_INIT_AUTOMAKE([check-news foreign 1.11 -Wall -Wno-portability silent-rules tar-pax subdir-objects])
  30. AC_PROG_CC_STDC
  31. AC_USE_SYSTEM_EXTENSIONS
  32. AC_SYS_LARGEFILE
  33. AC_CONFIG_MACRO_DIR([m4])
  34. AM_SILENT_RULES([yes])
  35. LIBMODBUS_VERSION_MAJOR=libmodbus_version_major
  36. LIBMODBUS_VERSION_MINOR=libmodbus_version_minor
  37. LIBMODBUS_VERSION_MICRO=libmodbus_version_micro
  38. LIBMODBUS_VERSION=libmodbus_version
  39. AC_SUBST(LIBMODBUS_VERSION_MAJOR)
  40. AC_SUBST(LIBMODBUS_VERSION_MINOR)
  41. AC_SUBST(LIBMODBUS_VERSION_MICRO)
  42. AC_SUBST(LIBMODBUS_VERSION)
  43. # ABI version
  44. # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
  45. LIBMODBUS_LD_CURRENT=6
  46. LIBMODBUS_LD_REVISION=0
  47. LIBMODBUS_LD_AGE=1
  48. LIBMODBUS_LT_VERSION_INFO=$LIBMODBUS_LD_CURRENT:$LIBMODBUS_LD_REVISION:$LIBMODBUS_LD_AGE
  49. AC_SUBST(LIBMODBUS_LT_VERSION_INFO)
  50. AC_CANONICAL_HOST
  51. # OS check
  52. os_win32="false"
  53. os_qnx="false"
  54. case "${host_os}" in
  55. *mingw32*)
  56. os_win32="true"
  57. ;;
  58. *nto-qnx*)
  59. os_qnx="true"
  60. ;;
  61. esac
  62. AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "true")
  63. AM_CONDITIONAL(OS_QNX, test "$os_qnx" = "true")
  64. LT_INIT([disable-static win32-dll pic-only])
  65. AC_CHECK_HEADERS([ \
  66. arpa/inet.h \
  67. byteswap.h \
  68. errno.h \
  69. fcntl.h \
  70. limits.h \
  71. linux/serial.h \
  72. netdb.h \
  73. netinet/in.h \
  74. netinet/tcp.h \
  75. sys/ioctl.h \
  76. sys/socket.h \
  77. sys/time.h \
  78. sys/types.h \
  79. termios.h \
  80. time.h \
  81. unistd.h \
  82. ])
  83. # Check whether to build docs / install man pages
  84. AC_LIBMODBUS_CHECK_BUILD_DOC
  85. # Cygwin defines IPTOS_LOWDELAY but can't handle that flag so it's necessary to
  86. # workaround that problem and Cygwin doesn't define MSG_DONTWAIT.
  87. AC_CHECK_DECLS([__CYGWIN__])
  88. # Checks for library functions.
  89. AC_FUNC_FORK
  90. AC_CHECK_FUNCS([accept4 getaddrinfo gettimeofday inet_ntoa memset select socket strerror strlcpy])
  91. # Required for MinGW with GCC v4.8.1 on Win7
  92. AC_DEFINE(WINVER, 0x0501, _)
  93. # Required for getaddrinfo (TCP PI - IPv6)
  94. AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes)
  95. if test "x$HAVE_WINSOCK2_H" = "xyes"; then
  96. LIBS="$LIBS -lws2_32"
  97. AC_SUBST(LIBS)
  98. fi
  99. # Check for RS485 support (Linux kernel version 2.6.28+)
  100. AC_CHECK_DECLS([TIOCSRS485], [], [], [[#include <sys/ioctl.h>]])
  101. # Check for RTS flags
  102. AC_CHECK_DECLS([TIOCM_RTS], [], [], [[#include <sys/ioctl.h>]])
  103. # Wtype-limits is not supported by gcc 4.2 (default on recent Mac OS X)
  104. my_CFLAGS="-Wall \
  105. -Wmissing-declarations -Wmissing-prototypes \
  106. -Wnested-externs -Wpointer-arith \
  107. -Wpointer-arith -Wsign-compare -Wchar-subscripts \
  108. -Wstrict-prototypes -Wshadow \
  109. -Wformat-security"
  110. AC_SUBST([my_CFLAGS])
  111. AC_CONFIG_HEADERS([config.h tests/unit-test.h])
  112. AC_CONFIG_FILES([
  113. Makefile
  114. src/Makefile
  115. src/modbus-version.h
  116. src/win32/modbus.dll.manifest
  117. tests/Makefile
  118. doc/Makefile
  119. libmodbus.pc
  120. libmodbus.spec
  121. ])
  122. AC_OUTPUT
  123. AC_MSG_RESULT([
  124. $PACKAGE $VERSION
  125. ===============
  126. prefix: ${prefix}
  127. sysconfdir: ${sysconfdir}
  128. libdir: ${libdir}
  129. includedir: ${includedir}
  130. compiler: ${CC}
  131. cflags: ${CFLAGS}
  132. ldflags: ${LDFLAGS}
  133. documentation: ${ac_libmodbus_build_doc}
  134. ])