configure.ac 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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], [10])
  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
  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_cygwin="false"
  54. os_qnx="false"
  55. case "${host_os}" in
  56. *mingw32*)
  57. os_win32="true"
  58. ;;
  59. *nto-qnx*)
  60. os_qnx="true"
  61. ;;
  62. *cygwin*)
  63. os_cygwin="true"
  64. ;;
  65. esac
  66. AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "true")
  67. AM_CONDITIONAL(OS_QNX, test "$os_qnx" = "true")
  68. m4_pattern_forbid([^LT_INIT])dnl
  69. LT_INIT([disable-static win32-dll pic-only])
  70. AC_CHECK_HEADERS([ \
  71. arpa/inet.h \
  72. byteswap.h \
  73. errno.h \
  74. fcntl.h \
  75. limits.h \
  76. linux/serial.h \
  77. netdb.h \
  78. netinet/in.h \
  79. netinet/tcp.h \
  80. sys/ioctl.h \
  81. sys/params.h \
  82. sys/socket.h \
  83. sys/time.h \
  84. sys/types.h \
  85. termios.h \
  86. time.h \
  87. unistd.h \
  88. ])
  89. # Cygwin defines IPTOS_LOWDELAY but can't handle that flag so it's necessary to
  90. # workaround that problem and Cygwin doesn't define MSG_DONTWAIT.
  91. AC_CHECK_DECLS([__CYGWIN__])
  92. # Check for network function in libnetwork for Haiku
  93. AC_SEARCH_LIBS(accept, network socket)
  94. # Checks for library functions.
  95. AC_CHECK_FUNCS([accept4 getaddrinfo gettimeofday inet_pton inet_ntop select socket strerror strlcpy])
  96. # Required for MinGW with GCC v4.8.1 on Win7
  97. AC_DEFINE(WINVER, 0x0501, _)
  98. # Required for bswap
  99. AC_C_INLINE
  100. # libtool
  101. AC_PROG_CXX
  102. # Various types
  103. AC_TYPE_INT64_T
  104. AC_TYPE_SIZE_T
  105. AC_TYPE_SSIZE_T
  106. AC_TYPE_UINT16_T
  107. AC_TYPE_UINT32_T
  108. AC_TYPE_UINT8_T
  109. if test "$os_cygwin" = "false"; then
  110. # Required for getaddrinfo (TCP IP - IPv6)
  111. AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes)
  112. if test "x$HAVE_WINSOCK2_H" = "xyes"; then
  113. LIBS="$LIBS -lws2_32"
  114. AC_SUBST(LIBS)
  115. fi
  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. # Wtype-limits is not supported by gcc 4.2 (default on recent Mac OS X)
  122. my_CFLAGS="-Wall \
  123. -Wmissing-declarations -Wmissing-prototypes \
  124. -Wnested-externs -Wpointer-arith \
  125. -Wpointer-arith -Wsign-compare -Wchar-subscripts \
  126. -Wstrict-prototypes -Wshadow \
  127. -Wformat-security"
  128. AC_SUBST([my_CFLAGS])
  129. # Build options
  130. AC_ARG_ENABLE(tests,
  131. AS_HELP_STRING([--disable-tests],
  132. [Build tests (default: yes)]),,
  133. [enable_tests=yes])
  134. AM_CONDITIONAL(BUILD_TESTS, [test $enable_tests != no])
  135. AC_CONFIG_HEADERS([config.h tests/unit-test.h])
  136. AC_CONFIG_FILES([
  137. Makefile
  138. src/Makefile
  139. src/modbus-version.h
  140. src/win32/modbus.dll.manifest
  141. tests/Makefile
  142. libmodbus.pc
  143. ])
  144. AC_OUTPUT
  145. AC_MSG_RESULT([
  146. $PACKAGE $VERSION
  147. ===============
  148. prefix: ${prefix}
  149. sysconfdir: ${sysconfdir}
  150. libdir: ${libdir}
  151. includedir: ${includedir}
  152. compiler: ${CC}
  153. cflags: ${CFLAGS}
  154. ldflags: ${LDFLAGS}
  155. tests: ${enable_tests}
  156. ])