configure.ac 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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], [3])
  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_FUNC_FORK
  95. AC_FUNC_MALLOC
  96. AC_CHECK_FUNCS([accept4 getaddrinfo gettimeofday inet_ntoa memset select socket strerror strlcpy])
  97. # Required for MinGW with GCC v4.8.1 on Win7
  98. AC_DEFINE(WINVER, 0x0501, _)
  99. # Required for bswap
  100. AC_C_INLINE
  101. # libtool
  102. AC_PROG_CXX
  103. # Various types
  104. AC_TYPE_INT64_T
  105. AC_TYPE_SIZE_T
  106. AC_TYPE_SSIZE_T
  107. AC_TYPE_UINT16_T
  108. AC_TYPE_UINT32_T
  109. AC_TYPE_UINT8_T
  110. if test "$os_cygwin" = "false"; then
  111. # Required for getaddrinfo (TCP IP - 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. fi
  118. # Check for RS485 support (Linux kernel version 2.6.28+)
  119. AC_CHECK_DECLS([TIOCSRS485], [], [], [[#include <sys/ioctl.h>]])
  120. # Check for RTS flags
  121. AC_CHECK_DECLS([TIOCM_RTS], [], [], [[#include <sys/ioctl.h>]])
  122. # Wtype-limits is not supported by gcc 4.2 (default on recent Mac OS X)
  123. my_CFLAGS="-Wall \
  124. -Wmissing-declarations -Wmissing-prototypes \
  125. -Wnested-externs -Wpointer-arith \
  126. -Wpointer-arith -Wsign-compare -Wchar-subscripts \
  127. -Wstrict-prototypes -Wshadow \
  128. -Wformat-security"
  129. AC_SUBST([my_CFLAGS])
  130. # Build options
  131. AC_ARG_ENABLE(tests,
  132. AS_HELP_STRING([--disable-tests],
  133. [Build tests (default: yes)]),,
  134. [enable_tests=yes])
  135. AM_CONDITIONAL(BUILD_TESTS, [test $enable_tests != no])
  136. AC_CONFIG_HEADERS([config.h tests/unit-test.h])
  137. AC_CONFIG_FILES([
  138. Makefile
  139. src/Makefile
  140. src/modbus-version.h
  141. src/win32/modbus.dll.manifest
  142. tests/Makefile
  143. doc/Makefile
  144. libmodbus.pc
  145. ])
  146. AC_OUTPUT
  147. AC_MSG_RESULT([
  148. $PACKAGE $VERSION
  149. ===============
  150. prefix: ${prefix}
  151. sysconfdir: ${sysconfdir}
  152. libdir: ${libdir}
  153. includedir: ${includedir}
  154. compiler: ${CC}
  155. cflags: ${CFLAGS}
  156. ldflags: ${LDFLAGS}
  157. documentation: ${ac_libmodbus_build_doc}
  158. tests: ${enable_tests}
  159. ])