Эх сурвалжийг харах

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
Stéphane Raimbault 12 жил өмнө
parent
commit
03e9d63017
5 өөрчлөгдсөн 74 нэмэгдсэн , 48 устгасан
  1. 1 0
      .gitignore
  2. 6 2
      Makefile.am
  3. 40 42
      configure.ac
  4. 19 3
      src/Makefile.am
  5. 8 1
      tests/Makefile.am

+ 1 - 0
.gitignore

@@ -13,6 +13,7 @@ Makefile
 Makefile.in
 /aclocal.m4
 /autom4te.cache
+/build-aux
 /config.*
 /configure
 /depcomp

+ 6 - 2
Makefile.am

@@ -1,7 +1,11 @@
 EXTRA_DIST = MIGRATION README.rst libmodbus.spec
+CLEANFILES =
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-
-SUBDIRS = src doc tests
+AM_MAKEFLAGS = --no-print-directory
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libmodbus.pc
+EXTRA_DIST += libmodbus.pc.in
+CLEANFILES += libmodbus.pc
+
+SUBDIRS = src doc tests

+ 40 - 42
configure.ac

@@ -22,13 +22,19 @@ m4_define([libmodbus_version],
     [libmodbus_version_major.libmodbus_version_minor.libmodbus_version_micro])
 
 AC_PREREQ([2.63])
-AC_INIT([libmodbus],[libmodbus_version],
-[https://github.com/stephane/libmodbus/issues])
-AC_CONFIG_HEADERS([config.h tests/unit-test.h])
-AM_INIT_AUTOMAKE([foreign])
-# enable nice build output on automake1.11
-m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
+AC_INIT([libmodbus],
+        [libmodbus_version],
+        [https://github.com/stephane/libmodbus/issues],
+        [libmodbus],
+        [http://libmodbus.org/])
+AC_CONFIG_SRCDIR([src/modbus.c])
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE([check-news foreign 1.11 -Wall -Wno-portability silent-rules tar-pax no-dist-gzip dist-xz subdir-objects])
+AC_PROG_CC_STDC
+AC_USE_SYSTEM_EXTENSIONS
+AC_SYS_LARGEFILE
 AC_CONFIG_MACRO_DIR([m4])
+AM_SILENT_RULES([yes])
 
 LIBMODBUS_VERSION_MAJOR=libmodbus_version_major
 LIBMODBUS_VERSION_MINOR=libmodbus_version_minor
@@ -54,20 +60,16 @@ os_win32="false"
 os_qnx="false"
 case "${host_os}" in
       *mingw32*)
-		os_win32="true"
-	;;
+    os_win32="true"
+  ;;
       *nto-qnx*)
-		os_qnx="true"
-	;;
+    os_qnx="true"
+  ;;
 esac
 AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "true")
 AM_CONDITIONAL(OS_QNX, test "$os_qnx" = "true")
 
-# Checks for programs.
-AC_PROG_CC
-AC_PROG_CXX
-AC_PROG_MAKE_SET
-LT_INIT([disable-static win32-dll])
+LT_INIT([disable-static win32-dll pic-only])
 AC_CHECK_HEADERS([ \
     arpa/inet.h \
     errno.h \
@@ -89,18 +91,6 @@ AC_CHECK_HEADERS([ \
 # Check whether to build docs / install man pages
 AC_LIBMODBUS_CHECK_DOC_BUILD
 
-# Checks for header files.
-AC_HEADER_STDC
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_TYPE_SIZE_T
-AC_HEADER_TIME
-# AC_TYPE_UINT*_T: not supported by autoconf-2.59 of CentOS 5.3
-# AC_TYPE_UINT16_T
-# AC_TYPE_UINT32_T
-# AC_TYPE_UINT8_T
-
 # Cygwin defines IPTOS_LOWDELAY but can't handle that flag so it's necessary to
 # workaround that problem and Cygwin doesn't define MSG_DONTWAIT.
 AC_CHECK_DECLS([__CYGWIN__])
@@ -109,21 +99,6 @@ AC_CHECK_DECLS([__CYGWIN__])
 AC_FUNC_FORK
 AC_CHECK_FUNCS([accept4 getaddrinfo gettimeofday inet_ntoa memset select socket strerror strlcpy])
 
-# Add -Wall -Werror for GCC if not already there
-if test "x$GCC" = "xyes"; then
-  case " $CFLAGS " in
-  *[[\ \	]]-Wall[[\ \	]]*) ;;
-  *) CFLAGS="$CFLAGS -Wall" ;;
-  esac
-fi
-
-if test "x$GCC" = "xyes"; then
-  case " $CFLAGS " in
-  *[[\ \	]]-Werror[[\ \	]]*) ;;
-  *) CFLAGS="$CFLAGS -Werror" ;;
-  esac
-fi
-
 # Required for getaddrinfo (TCP PI - IPv6)
 AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes)
 if test "x$HAVE_WINSOCK2_H" = "xyes"; then
@@ -136,6 +111,15 @@ AC_CHECK_DECLS([TIOCSRS485], [], [], [[#include <sys/ioctl.h>]])
 # Check for RTS flags
 AC_CHECK_DECLS([TIOCM_RTS], [], [], [[#include <sys/ioctl.h>]])
 
+my_CFLAGS="-Wall \
+-Wmissing-declarations -Wmissing-prototypes \
+-Wnested-externs -Wpointer-arith \
+-Wpointer-arith -Wsign-compare -Wchar-subscripts \
+-Wstrict-prototypes -Wshadow \
+-Wformat-security -Wtype-limits"
+AC_SUBST([my_CFLAGS])
+
+AC_CONFIG_HEADERS([config.h tests/unit-test.h])
 AC_CONFIG_FILES([
         Makefile
         src/Makefile
@@ -146,4 +130,18 @@ AC_CONFIG_FILES([
         libmodbus.pc
         libmodbus.spec
 ])
+
 AC_OUTPUT
+AC_MSG_RESULT([
+        $PACKAGE $VERSION
+        ===============
+
+        prefix:                 ${prefix}
+        sysconfdir:             ${sysconfdir}
+        libdir:                 ${libdir}
+        includedir:             ${includedir}
+
+        compiler:               ${CC}
+        cflags:                 ${CFLAGS}
+        ldflags:                ${LDFLAGS}
+])

+ 19 - 3
src/Makefile.am

@@ -1,4 +1,19 @@
+EXTRA_DIST =
+pkginclude_HEADERS = modbus.h
 lib_LTLIBRARIES = libmodbus.la
+
+AM_CPPFLAGS = \
+    -include $(top_builddir)/config.h \
+    -DSYSCONFDIR=\""$(sysconfdir)"\" \
+    -DLIBEXECDIR=\""$(libexecdir)"\" \
+    -I${top_srcdir}/src
+
+AM_CFLAGS = ${my_CFLAGS}
+
+AM_LDFLAGS = \
+    -Wl,--gc-sections \
+    -Wl,--as-needed
+
 libmodbus_la_SOURCES = \
         modbus.c \
         modbus.h \
@@ -12,6 +27,9 @@ libmodbus_la_SOURCES = \
         modbus-tcp-private.h \
         modbus-version.h
 
+libmodbus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined \
+        -version-info $(LIBMODBUS_LT_VERSION_INFO)
+
 if OS_WIN32
 libmodbus_la_LIBADD = -lwsock32
 endif
@@ -20,12 +38,10 @@ if OS_QNX
 libmodbus_la_LIBADD = -lsocket
 endif
 
-libmodbus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined -version-info $(LIBMODBUS_LT_VERSION_INFO)
-
 # Header files to install
 libmodbusincludedir = $(includedir)/modbus
 libmodbusinclude_HEADERS = modbus.h modbus-version.h modbus-rtu.h modbus-tcp.h
 
 DISTCLEANFILES = modbus-version.h
-EXTRA_DIST = modbus-version.h.in
+EXTRA_DIST += modbus-version.h.in
 CLEANFILES = *~

+ 8 - 1
tests/Makefile.am

@@ -37,5 +37,12 @@ unit_test_client_LDADD = $(common_ldflags)
 version_SOURCES = version.c
 version_LDADD = $(common_ldflags)
 
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src
+AM_CPPFLAGS = \
+    -include $(top_builddir)/config.h \
+    -DSYSCONFDIR=\""$(sysconfdir)"\" \
+    -DLIBEXECDIR=\""$(libexecdir)"\" \
+    -I${top_srcdir}/src
+
+AM_CFLAGS = ${my_CFLAGS}
+
 CLEANFILES = *~