configure.ac 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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], [0])
  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],[libmodbus_version],
  23. [https://github.com/stephane/libmodbus/issues])
  24. AC_CONFIG_HEADERS([config.h tests/unit-test.h])
  25. AM_INIT_AUTOMAKE([foreign])
  26. # enable nice build output on automake1.11
  27. m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
  28. AC_CONFIG_MACRO_DIR([m4])
  29. LIBMODBUS_VERSION_MAJOR=libmodbus_version_major
  30. LIBMODBUS_VERSION_MINOR=libmodbus_version_minor
  31. LIBMODBUS_VERSION_MICRO=libmodbus_version_micro
  32. LIBMODBUS_VERSION=libmodbus_version
  33. AC_SUBST(LIBMODBUS_VERSION_MAJOR)
  34. AC_SUBST(LIBMODBUS_VERSION_MINOR)
  35. AC_SUBST(LIBMODBUS_VERSION_MICRO)
  36. AC_SUBST(LIBMODBUS_VERSION)
  37. # ABI version
  38. # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
  39. LIBMODBUS_LD_CURRENT=6
  40. LIBMODBUS_LD_REVISION=0
  41. LIBMODBUS_LD_AGE=1
  42. LIBMODBUS_LT_VERSION_INFO=$LIBMODBUS_LD_CURRENT:$LIBMODBUS_LD_REVISION:$LIBMODBUS_LD_AGE
  43. AC_SUBST(LIBMODBUS_LT_VERSION_INFO)
  44. AC_CANONICAL_HOST
  45. # OS check
  46. os_win32="false"
  47. os_qnx="false"
  48. case "${host_os}" in
  49. *mingw32*)
  50. os_win32="true"
  51. ;;
  52. *nto-qnx*)
  53. os_qnx="true"
  54. ;;
  55. esac
  56. AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "true")
  57. AM_CONDITIONAL(OS_QNX, test "$os_qnx" = "true")
  58. # Checks for programs.
  59. AC_PROG_CC
  60. AC_PROG_CXX
  61. AC_PROG_MAKE_SET
  62. LT_INIT([disable-static win32-dll])
  63. AC_CHECK_HEADERS([ \
  64. arpa/inet.h \
  65. errno.h \
  66. fcntl.h \
  67. limits.h \
  68. linux/serial.h \
  69. netdb.h \
  70. netinet/in.h \
  71. netinet/tcp.h \
  72. sys/ioctl.h \
  73. sys/socket.h \
  74. sys/time.h \
  75. sys/types.h \
  76. termios.h \
  77. time.h \
  78. unistd.h \
  79. ])
  80. # Check whether to build docs / install man pages
  81. AC_LIBMODBUS_CHECK_DOC_BUILD
  82. # Checks for header files.
  83. AC_HEADER_STDC
  84. # Checks for typedefs, structures, and compiler characteristics.
  85. AC_C_CONST
  86. AC_TYPE_SIZE_T
  87. AC_HEADER_TIME
  88. # AC_TYPE_UINT*_T: not supported by autoconf-2.59 of CentOS 5.3
  89. # AC_TYPE_UINT16_T
  90. # AC_TYPE_UINT32_T
  91. # AC_TYPE_UINT8_T
  92. # Cygwin defines IPTOS_LOWDELAY but can't handle that flag so it's necessary to
  93. # workaround that problem and Cygwin doesn't define MSG_DONTWAIT.
  94. AC_CHECK_DECLS([__CYGWIN__])
  95. # Checks for library functions.
  96. AC_FUNC_FORK
  97. AC_CHECK_FUNCS([accept4 getaddrinfo gettimeofday inet_ntoa memset select socket strerror strlcpy])
  98. # Add -Wall -Werror for GCC if not already there
  99. if test "x$GCC" = "xyes"; then
  100. case " $CFLAGS " in
  101. *[[\ \ ]]-Wall[[\ \ ]]*) ;;
  102. *) CFLAGS="$CFLAGS -Wall" ;;
  103. esac
  104. fi
  105. if test "x$GCC" = "xyes"; then
  106. case " $CFLAGS " in
  107. *[[\ \ ]]-Werror[[\ \ ]]*) ;;
  108. *) CFLAGS="$CFLAGS -Werror" ;;
  109. esac
  110. fi
  111. # Required for getaddrinfo (TCP PI - IPv6)
  112. AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes)
  113. if test "x$HAVE_WINSOCK2_H" = "xyes"; then
  114. LIBS="$LIBS -lws2_32"
  115. AC_SUBST(LIBS)
  116. fi
  117. # Check for RS485 support (Linux kernel version 2.6.28+)
  118. AC_CHECK_DECLS([TIOCSRS485], [], [], [[#include <sys/ioctl.h>]])
  119. # Check for RTS flags
  120. AC_CHECK_DECLS([TIOCM_RTS], [], [], [[#include <sys/ioctl.h>]])
  121. AC_CONFIG_FILES([
  122. Makefile
  123. src/Makefile
  124. src/modbus-version.h
  125. src/win32/modbus.dll.manifest
  126. doc/Makefile
  127. tests/Makefile
  128. libmodbus.pc
  129. libmodbus.spec
  130. ])
  131. AC_OUTPUT