WIP
This commit is contained in:
parent
459b5ac959
commit
9999b9595d
5 changed files with 176 additions and 173 deletions
|
|
@ -1,9 +1,9 @@
|
|||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
if BUILD_BUNDLED_LIBCLI
|
||||
SUBDIRS = libcli src
|
||||
|
||||
if BUILD_TESTS
|
||||
SUBDIRS += tests
|
||||
else
|
||||
SUBDIRS = src
|
||||
endif
|
||||
|
||||
# libicmp uses a simple Makefile (not Autotools); invoke it as a hook.
|
||||
|
|
|
|||
13
autogen.sh
13
autogen.sh
|
|
@ -2,14 +2,5 @@
|
|||
# autogen.sh - Generate Autotools build files
|
||||
|
||||
set -e
|
||||
|
||||
# Generate libcli configure first (it's an Autotools submodule)
|
||||
if [ -f libcli/autogen.sh ]; then
|
||||
echo "[autogen] Configuring libcli submodule..."
|
||||
(cd libcli && ./autogen.sh)
|
||||
fi
|
||||
|
||||
echo "[autogen] Running autoreconf..."
|
||||
autoreconf -fiv
|
||||
|
||||
echo "[autogen] Done. Now run: ./configure && make"
|
||||
mkdir -pv m4 build-aux
|
||||
autoreconf -f --install --verbose
|
||||
|
|
|
|||
77
configure.ac
77
configure.ac
|
|
@ -2,7 +2,7 @@ AC_PREREQ([2.69])
|
|||
AC_INIT([net-tools], [0.0.1], [])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_MACRO_DIRS([m4])
|
||||
AM_INIT_AUTOMAKE([foreign -Wall subdir-objects])
|
||||
AM_INIT_AUTOMAKE([foreign -Wall -Werror subdir-objects])
|
||||
|
||||
# Compiler: prefer clang
|
||||
AC_PROG_CC
|
||||
|
|
@ -13,48 +13,69 @@ if test "x$GCC" = "xyes" && test "x$CC" = "xgcc"; then
|
|||
AC_MSG_NOTICE([Using clang])
|
||||
fi
|
||||
fi
|
||||
if test "x$ac_cv_env_CFLAGS_set" != "xset"; then
|
||||
CFLAGS="-O2"
|
||||
fi
|
||||
|
||||
AM_PROG_AR
|
||||
LT_PREREQ([2.2])
|
||||
LT_INIT
|
||||
|
||||
# Strict flags — always enabled, not optional
|
||||
STRICT_CFLAGS="-Wall -Wextra -Werror -Wpedantic -Wconversion -Wshadow"
|
||||
AC_SUBST([STRICT_CFLAGS])
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
# --enable-debug
|
||||
AC_ARG_ENABLE(
|
||||
[debug],
|
||||
[AS_HELP_STRING([--enable-debug], [Enable debug build: -g -O0 (default: no)])],
|
||||
[enable_debug=$enableval],
|
||||
[enable_debug=no]
|
||||
)
|
||||
AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = "xyes"])
|
||||
|
||||
|
||||
# --with-bundled-libcli
|
||||
AC_ARG_WITH(
|
||||
[bundled-libcli],
|
||||
AS_HELP_STRING([--with-bundled-libcli], [force using bundled ./libcli (ignore system)]),
|
||||
[with_bundled_libcli=yes],
|
||||
[with_bundled_libcli=no]
|
||||
)
|
||||
have_system_libcli=no
|
||||
|
||||
AS_IF([test "x$with_bundled_libcli" != "xyes"], [
|
||||
PKG_CHECK_MODULES(
|
||||
[LIBCLI], [libcli >= 0.1.0],
|
||||
[have_system_libcli=yes],
|
||||
[have_system_libcli=no]
|
||||
)
|
||||
])
|
||||
|
||||
AM_CONDITIONAL([USE_SYSTEM_LIBCLI], [test "x$have_system_libcli" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_BUNDLED_LIBCLI], [test "x$have_system_libcli" != "xyes"])
|
||||
|
||||
AC_SUBST([LIBCLI_CFLAGS])
|
||||
AC_SUBST([LIBCLI_LIBS])
|
||||
|
||||
AS_IF([test "x$have_system_libcli" != "xyes"], [AC_CONFIG_SUBDIRS([libcli])])
|
||||
|
||||
# libcli: Autotools submodule — configure automatically
|
||||
AC_CONFIG_SUBDIRS([libcli])
|
||||
|
||||
# --enable-tests
|
||||
AC_ARG_ENABLE([tests],
|
||||
AC_ARG_ENABLE(
|
||||
[tests],
|
||||
[AS_HELP_STRING([--enable-tests], [Build Criterion unit tests (default: no)])],
|
||||
[enable_tests=$enableval],
|
||||
[enable_tests=no])
|
||||
[enable_tests=no]
|
||||
)
|
||||
AM_CONDITIONAL([BUILD_TESTS], [test "x$enable_tests" = "xyes"])
|
||||
AS_IF([test "x$enable_tests" = "xyes"], [
|
||||
PKG_CHECK_MODULES([CRITERION], [criterion], [], [
|
||||
AC_MSG_NOTICE([pkg-config could not find criterion -- trying manual detection])
|
||||
AC_CHECK_HEADER([criterion/criterion.h], [], [
|
||||
AC_MSG_ERROR([criterion/criterion.h not found])])
|
||||
AC_CHECK_HEADER([criterion/criterion.h], [], [AC_MSG_ERROR([criterion/criterion.h not found])])
|
||||
AC_CHECK_LIB([criterion], [main],
|
||||
[CRITERION_LIBS="-lcriterion"],
|
||||
[AC_MSG_ERROR([libcriterion not found])])
|
||||
])
|
||||
])
|
||||
|
||||
# --enable-debug
|
||||
AC_ARG_ENABLE([debug],
|
||||
[AS_HELP_STRING([--enable-debug], [Enable debug build: -g -O0 (default: no)])],
|
||||
[enable_debug=$enableval],
|
||||
[enable_debug=no])
|
||||
AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = "xyes"])
|
||||
|
||||
# --enable-sanitizers
|
||||
AC_ARG_ENABLE([sanitizers],
|
||||
[AS_HELP_STRING([--enable-sanitizers],
|
||||
[Enable AddressSanitizer and UndefinedBehaviorSanitizer (default: no)])],
|
||||
[enable_sanitizers=$enableval],
|
||||
[enable_sanitizers=no])
|
||||
AM_CONDITIONAL([ENABLE_SANITIZERS], [test "x$enable_sanitizers" = "xyes"])
|
||||
])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
|
|
@ -62,15 +83,17 @@ AC_CONFIG_FILES([
|
|||
src/ping/Makefile
|
||||
tests/Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
AC_MSG_NOTICE([
|
||||
|
||||
net-tools $VERSION
|
||||
------------------
|
||||
PREFIX : $prefix
|
||||
CC : $CC
|
||||
CFLAGS : $STRICT_CFLAGS
|
||||
tests : $enable_tests
|
||||
debug : $enable_debug
|
||||
sanitizers : $enable_sanitizers
|
||||
libcli : system=$have_system_libcli (forced bundled=$with_bundled_libcli)
|
||||
])
|
||||
|
|
|
|||
|
|
@ -92,11 +92,6 @@ else
|
|||
EXTRA_CFLAGS =
|
||||
endif
|
||||
|
||||
if ENABLE_SANITIZERS
|
||||
SANITIZER_FLAGS = -fsanitize=address,undefined
|
||||
else
|
||||
SANITIZER_FLAGS =
|
||||
endif
|
||||
|
||||
PING_CPPFLAGS = \
|
||||
-I $(top_srcdir)/includes \
|
||||
|
|
@ -104,7 +99,7 @@ PING_CPPFLAGS = \
|
|||
-I $(top_srcdir)/libcli/include \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
PING_CFLAGS = $(BASE_CFLAGS) $(EXTRA_CFLAGS) $(SANITIZER_FLAGS)
|
||||
PING_CFLAGS = $(BASE_CFLAGS) $(EXTRA_CFLAGS)
|
||||
|
||||
libping_core_la_CPPFLAGS = $(PING_CPPFLAGS)
|
||||
libping_core_la_CFLAGS = $(PING_CFLAGS)
|
||||
|
|
@ -112,7 +107,7 @@ libping_core_la_CFLAGS = $(PING_CFLAGS)
|
|||
ft_ping_SOURCES = main.c
|
||||
ft_ping_CPPFLAGS = $(PING_CPPFLAGS)
|
||||
ft_ping_CFLAGS = $(PING_CFLAGS)
|
||||
ft_ping_LDFLAGS = $(SANITIZER_FLAGS)
|
||||
ft_ping_LDFLAGS =
|
||||
ft_ping_LDADD = \
|
||||
libping_core.la \
|
||||
$(top_srcdir)/libicmp/libicmp.a \
|
||||
|
|
|
|||
|
|
@ -12,12 +12,6 @@ else
|
|||
EXTRA_CFLAGS =
|
||||
endif
|
||||
|
||||
if ENABLE_SANITIZERS
|
||||
SANITIZER_FLAGS = -fsanitize=address,undefined
|
||||
else
|
||||
SANITIZER_FLAGS =
|
||||
endif
|
||||
|
||||
TEST_CPPFLAGS = \
|
||||
-I $(top_srcdir)/includes \
|
||||
-I $(top_srcdir)/libicmp/includes \
|
||||
|
|
@ -25,7 +19,7 @@ TEST_CPPFLAGS = \
|
|||
-I $(top_srcdir)/tests \
|
||||
-D_GNU_SOURCE
|
||||
|
||||
TEST_CFLAGS = $(BASE_CFLAGS) $(EXTRA_CFLAGS) $(SANITIZER_FLAGS)
|
||||
TEST_CFLAGS = $(BASE_CFLAGS) $(EXTRA_CFLAGS)
|
||||
|
||||
TEST_LDADD = \
|
||||
$(top_builddir)/src/ping/libping_core.la \
|
||||
|
|
@ -36,17 +30,17 @@ TEST_LDADD = \
|
|||
|
||||
test_tracker_CPPFLAGS = $(TEST_CPPFLAGS)
|
||||
test_tracker_CFLAGS = $(TEST_CFLAGS)
|
||||
test_tracker_LDFLAGS = $(SANITIZER_FLAGS)
|
||||
test_tracker_LDFLAGS =
|
||||
test_tracker_LDADD = $(TEST_LDADD)
|
||||
|
||||
test_stats_CPPFLAGS = $(TEST_CPPFLAGS)
|
||||
test_stats_CFLAGS = $(TEST_CFLAGS)
|
||||
test_stats_LDFLAGS = $(SANITIZER_FLAGS)
|
||||
test_stats_LDFLAGS =
|
||||
test_stats_LDADD = $(TEST_LDADD)
|
||||
|
||||
test_send_CPPFLAGS = $(TEST_CPPFLAGS)
|
||||
test_send_CFLAGS = $(TEST_CFLAGS)
|
||||
test_send_LDFLAGS = $(SANITIZER_FLAGS) \
|
||||
test_send_LDFLAGS = \
|
||||
-Wl,--wrap=icmp_send_echo \
|
||||
-Wl,--wrap=icmp_should_retry \
|
||||
-Wl,--wrap=icmp_strerror \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue