Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
noinst_LIBRARIES = libtio.a libprot.a libdict.a libexpr.a

AM_CPPFLAGS=-I$(top_srcdir)
AM_CFLAGS = $(PIC_CFLAGS)
AM_CFLAGS = $(PIC_CFLAGS) $(DEBUG_CFLAGS) $(EXTRA_CFLAGS)

libtio_a_SOURCES = tio.c tio.h

Expand Down
2 changes: 1 addition & 1 deletion compat/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
noinst_LIBRARIES = libcompat.a

AM_CPPFLAGS=-I$(top_srcdir)
AM_CFLAGS = $(PIC_CFLAGS)
AM_CFLAGS = $(PIC_CFLAGS) $(DEBUG_CFLAGS) $(EXTRA_CFLAGS)

EXTRA_DIST = getopt_long.c getopt_long.h \
ether.c ether.h \
Expand Down
36 changes: 11 additions & 25 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -101,39 +101,25 @@ then
fi

# check for debugging options
DEBUG_CFLAGS=""
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
[enable extensive debugging and logging]),
[if test "x$enableval" != "xno" ; then CFLAGS="-g -DDEBUG $CFLAGS" ; fi])
[AS_IF([test "x$enableval" != "xno"],
[AX_APPEND_COMPILE_FLAGS([-g -DDEBUG],[DEBUG_CFLAGS])]
)])
AC_SUBST([DEBUG_CFLAGS])

# check for extra compiler warnings
DESIRED_CFLAGS=""
EXTRA_CFLAGS=""
AC_ARG_ENABLE(warnings,
AS_HELP_STRING([--enable-warnings],
[enable extra compiler warnings (gcc)]),
[if test "x$enableval" != "no"
then
CFLAGS="$CFLAGS -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Waggregate-return -Wmissing-declarations -Wunused -Wformat=2 -Wswitch-default -Wswitch-enum -Wfloat-equal -Wbad-function-cast -Wredundant-decls"
DESIRED_CFLAGS="$DESIRED_CFLAGS -Wextra -Wdeclaration-after-statement -Werror-implicit-function-declaration -Werror=implicit"
fi])
test_gcc_flag() {
AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
$CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
ret=$?
rm -f conftest.o
return $ret
}
for flag in $DESIRED_CFLAGS
do
AC_MSG_CHECKING([whether $CC accepts $flag])
if test_gcc_flag $flag
then
CFLAGS="$CFLAGS $flag"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
done
[AS_IF([test "x$enableval" != "xno"],[
AX_APPEND_COMPILE_FLAGS([-pedantic -Wall -Wshadow -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Waggregate-return -Wmissing-declarations -Wunused -Wformat=2 -Wswitch-default -Wswitch-enum -Wfloat-equal -Wbad-function-cast -Wredundant-decls],[EXTRA_CFLAGS],[-Werror])
AX_APPEND_COMPILE_FLAGS([-Wextra -Wdeclaration-after-statement -Werror-implicit-function-declaration -Werror=implicit],[EXTRA_CFLAGS],[-Werror])
])])
AC_SUBST([EXTRA_CFLAGS])

# check for Position Independent Code compiler option
PIC_CFLAGS=""
Expand Down
46 changes: 46 additions & 0 deletions m4/ax_append_compile_flags.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# ============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
# ============================================================================
#
# SYNOPSIS
#
# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# For every FLAG1, FLAG2 it is checked whether the compiler works with the
# flag. If it does, the flag is added FLAGS-VARIABLE
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. During the check the flag is always added to the
# current language's flags.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: This macro depends on the AX_APPEND_FLAG and
# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
# AX_APPEND_LINK_FLAGS.
#
# LICENSE
#
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 7

AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
for flag in $1; do
AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
done
])dnl AX_APPEND_COMPILE_FLAGS
50 changes: 50 additions & 0 deletions m4/ax_append_flag.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
#
# DESCRIPTION
#
# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
# added in between.
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
# FLAG.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 8

AC_DEFUN([AX_APPEND_FLAG],
[dnl
AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
AS_VAR_SET_IF(FLAGS,[
AS_CASE([" AS_VAR_GET(FLAGS) "],
[*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
[
AS_VAR_APPEND(FLAGS,[" $1"])
AC_RUN_LOG([: FLAGS="$FLAGS"])
])
],
[
AS_VAR_SET(FLAGS,[$1])
AC_RUN_LOG([: FLAGS="$FLAGS"])
])
AS_VAR_POPDEF([FLAGS])dnl
])dnl AX_APPEND_FLAG
53 changes: 53 additions & 0 deletions m4/ax_check_compile_flag.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 6

AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS
37 changes: 37 additions & 0 deletions m4/ax_require_defined.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_REQUIRE_DEFINED(MACRO)
#
# DESCRIPTION
#
# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
# been defined and thus are available for use. This avoids random issues
# where a macro isn't expanded. Instead the configure script emits a
# non-fatal:
#
# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
#
# It's like AC_REQUIRE except it doesn't expand the required macro.
#
# Here's an example:
#
# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
#
# LICENSE
#
# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 2

AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
])dnl AX_REQUIRE_DEFINED
2 changes: 1 addition & 1 deletion nslcd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
sbin_PROGRAMS = nslcd

AM_CPPFLAGS=-I$(top_srcdir)
AM_CFLAGS = $(PTHREAD_CFLAGS)
AM_CFLAGS = $(PTHREAD_CFLAGS) $(DEBUG_CFLAGS) $(EXTRA_CFLAGS)

nslcd_SOURCES = nslcd.c ../nslcd.h ../common/nslcd-prot.h \
../compat/attrs.h \
Expand Down
2 changes: 1 addition & 1 deletion nss/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
noinst_PROGRAMS = nss_ldap.so

AM_CPPFLAGS=-I$(top_srcdir)
AM_CFLAGS = $(PIC_CFLAGS)
AM_CFLAGS = $(PIC_CFLAGS) $(DEBUG_CFLAGS) $(EXTRA_CFLAGS)

nss_ldap_so_SOURCES = common.c common.h prototypes.h solnss.h \
../nslcd.h ../common/nslcd-prot.h \
Expand Down
2 changes: 1 addition & 1 deletion pam/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
noinst_PROGRAMS = pam_ldap.so

AM_CPPFLAGS=-I$(top_srcdir)
AM_CFLAGS = $(PIC_CFLAGS)
AM_CFLAGS = $(PIC_CFLAGS) $(DEBUG_CFLAGS) $(EXTRA_CFLAGS)

pam_ldap_so_SOURCES = ../nslcd.h ../common/nslcd-prot.h \
../compat/attrs.h pam.c common.h
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ clean-local:
-rm -rf *.pyc *.pyo __pycache__ flake8-venv

AM_CPPFLAGS = -I$(top_srcdir)
AM_CFLAGS = $(PTHREAD_CFLAGS) -g
AM_CFLAGS = $(PTHREAD_CFLAGS) -g $(DEBUG_CFLAGS) $(EXTRA_CFLAGS)

test_dict_SOURCES = test_dict.c ../common/dict.h
test_dict_LDADD = ../common/libdict.a
Expand Down