Commit 03e9d630176e0d3b80b4582f51e4849883a80ce3
1 parent
c83fd179
Major update of build system
- depends of automake 1.11 - C99 - pic-only - more warning C flags - remove obscure checks - don't print directories - add libmodbus.pc to clean files - remove -Werror
Showing
5 changed files
with
74 additions
and
48 deletions
.gitignore
Makefile.am
| 1 | EXTRA_DIST = MIGRATION README.rst libmodbus.spec | 1 | EXTRA_DIST = MIGRATION README.rst libmodbus.spec |
| 2 | +CLEANFILES = | ||
| 2 | ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} | 3 | ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} |
| 3 | - | ||
| 4 | -SUBDIRS = src doc tests | 4 | +AM_MAKEFLAGS = --no-print-directory |
| 5 | 5 | ||
| 6 | pkgconfigdir = $(libdir)/pkgconfig | 6 | pkgconfigdir = $(libdir)/pkgconfig |
| 7 | pkgconfig_DATA = libmodbus.pc | 7 | pkgconfig_DATA = libmodbus.pc |
| 8 | +EXTRA_DIST += libmodbus.pc.in | ||
| 9 | +CLEANFILES += libmodbus.pc | ||
| 10 | + | ||
| 11 | +SUBDIRS = src doc tests |
configure.ac
| @@ -22,13 +22,19 @@ m4_define([libmodbus_version], | @@ -22,13 +22,19 @@ m4_define([libmodbus_version], | ||
| 22 | [libmodbus_version_major.libmodbus_version_minor.libmodbus_version_micro]) | 22 | [libmodbus_version_major.libmodbus_version_minor.libmodbus_version_micro]) |
| 23 | 23 | ||
| 24 | AC_PREREQ([2.63]) | 24 | AC_PREREQ([2.63]) |
| 25 | -AC_INIT([libmodbus],[libmodbus_version], | ||
| 26 | -[https://github.com/stephane/libmodbus/issues]) | ||
| 27 | -AC_CONFIG_HEADERS([config.h tests/unit-test.h]) | ||
| 28 | -AM_INIT_AUTOMAKE([foreign]) | ||
| 29 | -# enable nice build output on automake1.11 | ||
| 30 | -m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) | 25 | +AC_INIT([libmodbus], |
| 26 | + [libmodbus_version], | ||
| 27 | + [https://github.com/stephane/libmodbus/issues], | ||
| 28 | + [libmodbus], | ||
| 29 | + [http://libmodbus.org/]) | ||
| 30 | +AC_CONFIG_SRCDIR([src/modbus.c]) | ||
| 31 | +AC_CONFIG_AUX_DIR([build-aux]) | ||
| 32 | +AM_INIT_AUTOMAKE([check-news foreign 1.11 -Wall -Wno-portability silent-rules tar-pax no-dist-gzip dist-xz subdir-objects]) | ||
| 33 | +AC_PROG_CC_STDC | ||
| 34 | +AC_USE_SYSTEM_EXTENSIONS | ||
| 35 | +AC_SYS_LARGEFILE | ||
| 31 | AC_CONFIG_MACRO_DIR([m4]) | 36 | AC_CONFIG_MACRO_DIR([m4]) |
| 37 | +AM_SILENT_RULES([yes]) | ||
| 32 | 38 | ||
| 33 | LIBMODBUS_VERSION_MAJOR=libmodbus_version_major | 39 | LIBMODBUS_VERSION_MAJOR=libmodbus_version_major |
| 34 | LIBMODBUS_VERSION_MINOR=libmodbus_version_minor | 40 | LIBMODBUS_VERSION_MINOR=libmodbus_version_minor |
| @@ -54,20 +60,16 @@ os_win32="false" | @@ -54,20 +60,16 @@ os_win32="false" | ||
| 54 | os_qnx="false" | 60 | os_qnx="false" |
| 55 | case "${host_os}" in | 61 | case "${host_os}" in |
| 56 | *mingw32*) | 62 | *mingw32*) |
| 57 | - os_win32="true" | ||
| 58 | - ;; | 63 | + os_win32="true" |
| 64 | + ;; | ||
| 59 | *nto-qnx*) | 65 | *nto-qnx*) |
| 60 | - os_qnx="true" | ||
| 61 | - ;; | 66 | + os_qnx="true" |
| 67 | + ;; | ||
| 62 | esac | 68 | esac |
| 63 | AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "true") | 69 | AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "true") |
| 64 | AM_CONDITIONAL(OS_QNX, test "$os_qnx" = "true") | 70 | AM_CONDITIONAL(OS_QNX, test "$os_qnx" = "true") |
| 65 | 71 | ||
| 66 | -# Checks for programs. | ||
| 67 | -AC_PROG_CC | ||
| 68 | -AC_PROG_CXX | ||
| 69 | -AC_PROG_MAKE_SET | ||
| 70 | -LT_INIT([disable-static win32-dll]) | 72 | +LT_INIT([disable-static win32-dll pic-only]) |
| 71 | AC_CHECK_HEADERS([ \ | 73 | AC_CHECK_HEADERS([ \ |
| 72 | arpa/inet.h \ | 74 | arpa/inet.h \ |
| 73 | errno.h \ | 75 | errno.h \ |
| @@ -89,18 +91,6 @@ AC_CHECK_HEADERS([ \ | @@ -89,18 +91,6 @@ AC_CHECK_HEADERS([ \ | ||
| 89 | # Check whether to build docs / install man pages | 91 | # Check whether to build docs / install man pages |
| 90 | AC_LIBMODBUS_CHECK_DOC_BUILD | 92 | AC_LIBMODBUS_CHECK_DOC_BUILD |
| 91 | 93 | ||
| 92 | -# Checks for header files. | ||
| 93 | -AC_HEADER_STDC | ||
| 94 | - | ||
| 95 | -# Checks for typedefs, structures, and compiler characteristics. | ||
| 96 | -AC_C_CONST | ||
| 97 | -AC_TYPE_SIZE_T | ||
| 98 | -AC_HEADER_TIME | ||
| 99 | -# AC_TYPE_UINT*_T: not supported by autoconf-2.59 of CentOS 5.3 | ||
| 100 | -# AC_TYPE_UINT16_T | ||
| 101 | -# AC_TYPE_UINT32_T | ||
| 102 | -# AC_TYPE_UINT8_T | ||
| 103 | - | ||
| 104 | # Cygwin defines IPTOS_LOWDELAY but can't handle that flag so it's necessary to | 94 | # Cygwin defines IPTOS_LOWDELAY but can't handle that flag so it's necessary to |
| 105 | # workaround that problem and Cygwin doesn't define MSG_DONTWAIT. | 95 | # workaround that problem and Cygwin doesn't define MSG_DONTWAIT. |
| 106 | AC_CHECK_DECLS([__CYGWIN__]) | 96 | AC_CHECK_DECLS([__CYGWIN__]) |
| @@ -109,21 +99,6 @@ AC_CHECK_DECLS([__CYGWIN__]) | @@ -109,21 +99,6 @@ AC_CHECK_DECLS([__CYGWIN__]) | ||
| 109 | AC_FUNC_FORK | 99 | AC_FUNC_FORK |
| 110 | AC_CHECK_FUNCS([accept4 getaddrinfo gettimeofday inet_ntoa memset select socket strerror strlcpy]) | 100 | AC_CHECK_FUNCS([accept4 getaddrinfo gettimeofday inet_ntoa memset select socket strerror strlcpy]) |
| 111 | 101 | ||
| 112 | -# Add -Wall -Werror for GCC if not already there | ||
| 113 | -if test "x$GCC" = "xyes"; then | ||
| 114 | - case " $CFLAGS " in | ||
| 115 | - *[[\ \ ]]-Wall[[\ \ ]]*) ;; | ||
| 116 | - *) CFLAGS="$CFLAGS -Wall" ;; | ||
| 117 | - esac | ||
| 118 | -fi | ||
| 119 | - | ||
| 120 | -if test "x$GCC" = "xyes"; then | ||
| 121 | - case " $CFLAGS " in | ||
| 122 | - *[[\ \ ]]-Werror[[\ \ ]]*) ;; | ||
| 123 | - *) CFLAGS="$CFLAGS -Werror" ;; | ||
| 124 | - esac | ||
| 125 | -fi | ||
| 126 | - | ||
| 127 | # Required for getaddrinfo (TCP PI - IPv6) | 102 | # Required for getaddrinfo (TCP PI - IPv6) |
| 128 | AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes) | 103 | AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes) |
| 129 | if test "x$HAVE_WINSOCK2_H" = "xyes"; then | 104 | if test "x$HAVE_WINSOCK2_H" = "xyes"; then |
| @@ -136,6 +111,15 @@ AC_CHECK_DECLS([TIOCSRS485], [], [], [[#include <sys/ioctl.h>]]) | @@ -136,6 +111,15 @@ AC_CHECK_DECLS([TIOCSRS485], [], [], [[#include <sys/ioctl.h>]]) | ||
| 136 | # Check for RTS flags | 111 | # Check for RTS flags |
| 137 | AC_CHECK_DECLS([TIOCM_RTS], [], [], [[#include <sys/ioctl.h>]]) | 112 | AC_CHECK_DECLS([TIOCM_RTS], [], [], [[#include <sys/ioctl.h>]]) |
| 138 | 113 | ||
| 114 | +my_CFLAGS="-Wall \ | ||
| 115 | +-Wmissing-declarations -Wmissing-prototypes \ | ||
| 116 | +-Wnested-externs -Wpointer-arith \ | ||
| 117 | +-Wpointer-arith -Wsign-compare -Wchar-subscripts \ | ||
| 118 | +-Wstrict-prototypes -Wshadow \ | ||
| 119 | +-Wformat-security -Wtype-limits" | ||
| 120 | +AC_SUBST([my_CFLAGS]) | ||
| 121 | + | ||
| 122 | +AC_CONFIG_HEADERS([config.h tests/unit-test.h]) | ||
| 139 | AC_CONFIG_FILES([ | 123 | AC_CONFIG_FILES([ |
| 140 | Makefile | 124 | Makefile |
| 141 | src/Makefile | 125 | src/Makefile |
| @@ -146,4 +130,18 @@ AC_CONFIG_FILES([ | @@ -146,4 +130,18 @@ AC_CONFIG_FILES([ | ||
| 146 | libmodbus.pc | 130 | libmodbus.pc |
| 147 | libmodbus.spec | 131 | libmodbus.spec |
| 148 | ]) | 132 | ]) |
| 133 | + | ||
| 149 | AC_OUTPUT | 134 | AC_OUTPUT |
| 135 | +AC_MSG_RESULT([ | ||
| 136 | + $PACKAGE $VERSION | ||
| 137 | + =============== | ||
| 138 | + | ||
| 139 | + prefix: ${prefix} | ||
| 140 | + sysconfdir: ${sysconfdir} | ||
| 141 | + libdir: ${libdir} | ||
| 142 | + includedir: ${includedir} | ||
| 143 | + | ||
| 144 | + compiler: ${CC} | ||
| 145 | + cflags: ${CFLAGS} | ||
| 146 | + ldflags: ${LDFLAGS} | ||
| 147 | +]) |
src/Makefile.am
| 1 | +EXTRA_DIST = | ||
| 2 | +pkginclude_HEADERS = modbus.h | ||
| 1 | lib_LTLIBRARIES = libmodbus.la | 3 | lib_LTLIBRARIES = libmodbus.la |
| 4 | + | ||
| 5 | +AM_CPPFLAGS = \ | ||
| 6 | + -include $(top_builddir)/config.h \ | ||
| 7 | + -DSYSCONFDIR=\""$(sysconfdir)"\" \ | ||
| 8 | + -DLIBEXECDIR=\""$(libexecdir)"\" \ | ||
| 9 | + -I${top_srcdir}/src | ||
| 10 | + | ||
| 11 | +AM_CFLAGS = ${my_CFLAGS} | ||
| 12 | + | ||
| 13 | +AM_LDFLAGS = \ | ||
| 14 | + -Wl,--gc-sections \ | ||
| 15 | + -Wl,--as-needed | ||
| 16 | + | ||
| 2 | libmodbus_la_SOURCES = \ | 17 | libmodbus_la_SOURCES = \ |
| 3 | modbus.c \ | 18 | modbus.c \ |
| 4 | modbus.h \ | 19 | modbus.h \ |
| @@ -12,6 +27,9 @@ libmodbus_la_SOURCES = \ | @@ -12,6 +27,9 @@ libmodbus_la_SOURCES = \ | ||
| 12 | modbus-tcp-private.h \ | 27 | modbus-tcp-private.h \ |
| 13 | modbus-version.h | 28 | modbus-version.h |
| 14 | 29 | ||
| 30 | +libmodbus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined \ | ||
| 31 | + -version-info $(LIBMODBUS_LT_VERSION_INFO) | ||
| 32 | + | ||
| 15 | if OS_WIN32 | 33 | if OS_WIN32 |
| 16 | libmodbus_la_LIBADD = -lwsock32 | 34 | libmodbus_la_LIBADD = -lwsock32 |
| 17 | endif | 35 | endif |
| @@ -20,12 +38,10 @@ if OS_QNX | @@ -20,12 +38,10 @@ if OS_QNX | ||
| 20 | libmodbus_la_LIBADD = -lsocket | 38 | libmodbus_la_LIBADD = -lsocket |
| 21 | endif | 39 | endif |
| 22 | 40 | ||
| 23 | -libmodbus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info $(LIBMODBUS_LT_VERSION_INFO) | ||
| 24 | - | ||
| 25 | # Header files to install | 41 | # Header files to install |
| 26 | libmodbusincludedir = $(includedir)/modbus | 42 | libmodbusincludedir = $(includedir)/modbus |
| 27 | libmodbusinclude_HEADERS = modbus.h modbus-version.h modbus-rtu.h modbus-tcp.h | 43 | libmodbusinclude_HEADERS = modbus.h modbus-version.h modbus-rtu.h modbus-tcp.h |
| 28 | 44 | ||
| 29 | DISTCLEANFILES = modbus-version.h | 45 | DISTCLEANFILES = modbus-version.h |
| 30 | -EXTRA_DIST = modbus-version.h.in | 46 | +EXTRA_DIST += modbus-version.h.in |
| 31 | CLEANFILES = *~ | 47 | CLEANFILES = *~ |
tests/Makefile.am
| @@ -37,5 +37,12 @@ unit_test_client_LDADD = $(common_ldflags) | @@ -37,5 +37,12 @@ unit_test_client_LDADD = $(common_ldflags) | ||
| 37 | version_SOURCES = version.c | 37 | version_SOURCES = version.c |
| 38 | version_LDADD = $(common_ldflags) | 38 | version_LDADD = $(common_ldflags) |
| 39 | 39 | ||
| 40 | -INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src | 40 | +AM_CPPFLAGS = \ |
| 41 | + -include $(top_builddir)/config.h \ | ||
| 42 | + -DSYSCONFDIR=\""$(sysconfdir)"\" \ | ||
| 43 | + -DLIBEXECDIR=\""$(libexecdir)"\" \ | ||
| 44 | + -I${top_srcdir}/src | ||
| 45 | + | ||
| 46 | +AM_CFLAGS = ${my_CFLAGS} | ||
| 47 | + | ||
| 41 | CLEANFILES = *~ | 48 | CLEANFILES = *~ |