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], [6])
  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_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. LT_INIT([disable-static win32-dll pic-only])
  69. AC_CHECK_HEADERS([ \
  70. arpa/inet.h \
  71. byteswap.h \
  72. errno.h \
  73. fcntl.h \
  74. limits.h \
  75. linux/serial.h \
  76. netdb.h \
  77. netinet/in.h \
  78. netinet/tcp.h \
  79. sys/ioctl.h \
  80. sys/params.h \
  81. sys/socket.h \
  82. sys/time.h \
  83. sys/types.h \
  84. termios.h \
  85. time.h \
  86. unistd.h \
  87. ])
  88. # Check whether to build docs / install man pages
  89. AC_LIBMODBUS_CHECK_BUILD_DOC
  90. # Cygwin defines IPTOS_LOWDELAY but can't handle that flag so it's necessary to
  91. # workaround that problem and Cygwin doesn't define MSG_DONTWAIT.
  92. AC_CHECK_DECLS([__CYGWIN__])
  93. # Checks for library functions.
  94. AC_CHECK_FUNCS([accept4 getaddrinfo gettimeofday inet_ntoa select socket strerror strlcpy])
  95. # Required for MinGW with GCC v4.8.1 on Win7
  96. AC_DEFINE(WINVER, 0x0501, _)
  97. # Required for bswap
  98. AC_C_INLINE
  99. # libtool
  100. AC_PROG_CXX
  101. # Various types
  102. AC_TYPE_INT64_T
  103. AC_TYPE_SIZE_T
  104. AC_TYPE_SSIZE_T
  105. AC_TYPE_UINT16_T
  106. AC_TYPE_UINT32_T
  107. AC_TYPE_UINT8_T
  108. if test "$os_cygwin" = "false"; then
  109. # Required for getaddrinfo (TCP IP - IPv6)
  110. AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes)
  111. if test "x$HAVE_WINSOCK2_H" = "xyes"; then
  112. LIBS="$LIBS -lws2_32"
  113. AC_SUBST(LIBS)
  114. fi
  115. fi
  116. # Check for RS485 support (Linux kernel version 2.6.28+)
  117. AC_CHECK_DECLS([TIOCSRS485], [], [], [[#include <sys/ioctl.h>]])
  118. # Check for RTS flags
  119. AC_CHECK_DECLS([TIOCM_RTS], [], [], [[#include <sys/ioctl.h>]])
  120. # Wtype-limits is not supported by gcc 4.2 (default on recent Mac OS X)
  121. my_CFLAGS="-Wall \
  122. -Wmissing-declarations -Wmissing-prototypes \
  123. -Wnested-externs -Wpointer-arith \
  124. -Wpointer-arith -Wsign-compare -Wchar-subscripts \
  125. -Wstrict-prototypes -Wshadow \
  126. -Wformat-security"
  127. AC_SUBST([my_CFLAGS])
  128. # Build options
  129. AC_ARG_ENABLE(tests,
  130. AS_HELP_STRING([--disable-tests],
  131. [Build tests (default: yes)]),,
  132. [enable_tests=yes])
  133. AM_CONDITIONAL(BUILD_TESTS, [test $enable_tests != no])
  134. AC_CONFIG_HEADERS([config.h tests/unit-test.h])
  135. AC_CONFIG_FILES([
  136. Makefile
  137. src/Makefile
  138. src/modbus-version.h
  139. src/win32/modbus.dll.manifest
  140. tests/Makefile
  141. doc/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. documentation: ${ac_libmodbus_build_doc}
  156. tests: ${enable_tests}
  157. ])