Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stephane committed Nov 12, 2012
1 parent c83fd17 commit 03e9d63
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,6 +13,7 @@ Makefile
Makefile.in
/aclocal.m4
/autom4te.cache
/build-aux
/config.*
/configure
/depcomp
Expand Down
8 changes: 6 additions & 2 deletions 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
82 changes: 40 additions & 42 deletions configure.ac
Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -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__])
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}
])
22 changes: 19 additions & 3 deletions src/Makefile.am
@@ -1,4 +1,19 @@
EXTRA_DIST =
pkginclude_HEADERS = modbus.h

This comment has been minimized.

Copy link
@dansut

dansut Oct 15, 2015

Is there a specific reason for this pkginclude_HEADERS?
It seems to be causing a duplicate install of ${includedir}/libmodbus/modbus.h , also in ${includedir}/modbus/modbus.h from libmodbusinclude_HEADERS
I am not saying it is wrong, just looking to understand why pkg-config might need this, or why useful to have this header repeated in a different directory.

This comment has been minimized.

Copy link
@stephane

stephane Oct 15, 2015

Author Owner

Very good catch!

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 \
Expand All @@ -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
Expand All @@ -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 = *~
9 changes: 8 additions & 1 deletion tests/Makefile.am
Expand Up @@ -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 = *~

0 comments on commit 03e9d63

Please sign in to comment.