Commit 03e9d630176e0d3b80b4582f51e4849883a80ce3

Authored by Stéphane Raimbault
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
.gitignore
... ... @@ -13,6 +13,7 @@ Makefile
13 13 Makefile.in
14 14 /aclocal.m4
15 15 /autom4te.cache
  16 +/build-aux
16 17 /config.*
17 18 /configure
18 19 /depcomp
... ...
Makefile.am
1 1 EXTRA_DIST = MIGRATION README.rst libmodbus.spec
  2 +CLEANFILES =
2 3 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
3   -
4   -SUBDIRS = src doc tests
  4 +AM_MAKEFLAGS = --no-print-directory
5 5  
6 6 pkgconfigdir = $(libdir)/pkgconfig
7 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 22 [libmodbus_version_major.libmodbus_version_minor.libmodbus_version_micro])
23 23  
24 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 36 AC_CONFIG_MACRO_DIR([m4])
  37 +AM_SILENT_RULES([yes])
32 38  
33 39 LIBMODBUS_VERSION_MAJOR=libmodbus_version_major
34 40 LIBMODBUS_VERSION_MINOR=libmodbus_version_minor
... ... @@ -54,20 +60,16 @@ os_win32="false"
54 60 os_qnx="false"
55 61 case "${host_os}" in
56 62 *mingw32*)
57   - os_win32="true"
58   - ;;
  63 + os_win32="true"
  64 + ;;
59 65 *nto-qnx*)
60   - os_qnx="true"
61   - ;;
  66 + os_qnx="true"
  67 + ;;
62 68 esac
63 69 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "true")
64 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 73 AC_CHECK_HEADERS([ \
72 74 arpa/inet.h \
73 75 errno.h \
... ... @@ -89,18 +91,6 @@ AC_CHECK_HEADERS([ \
89 91 # Check whether to build docs / install man pages
90 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 94 # Cygwin defines IPTOS_LOWDELAY but can't handle that flag so it's necessary to
105 95 # workaround that problem and Cygwin doesn't define MSG_DONTWAIT.
106 96 AC_CHECK_DECLS([__CYGWIN__])
... ... @@ -109,21 +99,6 @@ AC_CHECK_DECLS([__CYGWIN__])
109 99 AC_FUNC_FORK
110 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 102 # Required for getaddrinfo (TCP PI - IPv6)
128 103 AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes)
129 104 if test "x$HAVE_WINSOCK2_H" = "xyes"; then
... ... @@ -136,6 +111,15 @@ AC_CHECK_DECLS([TIOCSRS485], [], [], [[#include <sys/ioctl.h>]])
136 111 # Check for RTS flags
137 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 123 AC_CONFIG_FILES([
140 124 Makefile
141 125 src/Makefile
... ... @@ -146,4 +130,18 @@ AC_CONFIG_FILES([
146 130 libmodbus.pc
147 131 libmodbus.spec
148 132 ])
  133 +
149 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 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 17 libmodbus_la_SOURCES = \
3 18 modbus.c \
4 19 modbus.h \
... ... @@ -12,6 +27,9 @@ libmodbus_la_SOURCES = \
12 27 modbus-tcp-private.h \
13 28 modbus-version.h
14 29  
  30 +libmodbus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined \
  31 + -version-info $(LIBMODBUS_LT_VERSION_INFO)
  32 +
15 33 if OS_WIN32
16 34 libmodbus_la_LIBADD = -lwsock32
17 35 endif
... ... @@ -20,12 +38,10 @@ if OS_QNX
20 38 libmodbus_la_LIBADD = -lsocket
21 39 endif
22 40  
23   -libmodbus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info $(LIBMODBUS_LT_VERSION_INFO)
24   -
25 41 # Header files to install
26 42 libmodbusincludedir = $(includedir)/modbus
27 43 libmodbusinclude_HEADERS = modbus.h modbus-version.h modbus-rtu.h modbus-tcp.h
28 44  
29 45 DISTCLEANFILES = modbus-version.h
30   -EXTRA_DIST = modbus-version.h.in
  46 +EXTRA_DIST += modbus-version.h.in
31 47 CLEANFILES = *~
... ...
tests/Makefile.am
... ... @@ -37,5 +37,12 @@ unit_test_client_LDADD = $(common_ldflags)
37 37 version_SOURCES = version.c
38 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 48 CLEANFILES = *~
... ...