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
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
|
if BUILD_BUNDLED_LIBCLI
|
||||||
SUBDIRS = libcli src
|
SUBDIRS = libcli src
|
||||||
|
else
|
||||||
if BUILD_TESTS
|
SUBDIRS = src
|
||||||
SUBDIRS += tests
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# libicmp uses a simple Makefile (not Autotools); invoke it as a hook.
|
# 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
|
# autogen.sh - Generate Autotools build files
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
mkdir -pv m4 build-aux
|
||||||
# Generate libcli configure first (it's an Autotools submodule)
|
autoreconf -f --install --verbose
|
||||||
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"
|
|
||||||
|
|
|
||||||
107
configure.ac
107
configure.ac
|
|
@ -2,7 +2,7 @@ AC_PREREQ([2.69])
|
||||||
AC_INIT([net-tools], [0.0.1], [])
|
AC_INIT([net-tools], [0.0.1], [])
|
||||||
AC_CONFIG_AUX_DIR([build-aux])
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AC_CONFIG_MACRO_DIRS([m4])
|
AC_CONFIG_MACRO_DIRS([m4])
|
||||||
AM_INIT_AUTOMAKE([foreign -Wall subdir-objects])
|
AM_INIT_AUTOMAKE([foreign -Wall -Werror subdir-objects])
|
||||||
|
|
||||||
# Compiler: prefer clang
|
# Compiler: prefer clang
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
|
@ -13,48 +13,69 @@ if test "x$GCC" = "xyes" && test "x$CC" = "xgcc"; then
|
||||||
AC_MSG_NOTICE([Using clang])
|
AC_MSG_NOTICE([Using clang])
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if test "x$ac_cv_env_CFLAGS_set" != "xset"; then
|
||||||
|
CFLAGS="-O2"
|
||||||
|
fi
|
||||||
|
|
||||||
AM_PROG_AR
|
AM_PROG_AR
|
||||||
LT_PREREQ([2.2])
|
LT_PREREQ([2.2])
|
||||||
LT_INIT
|
LT_INIT
|
||||||
|
|
||||||
# Strict flags — always enabled, not optional
|
PKG_PROG_PKG_CONFIG
|
||||||
STRICT_CFLAGS="-Wall -Wextra -Werror -Wpedantic -Wconversion -Wshadow"
|
|
||||||
AC_SUBST([STRICT_CFLAGS])
|
|
||||||
|
|
||||||
# libcli: Autotools submodule — configure automatically
|
|
||||||
AC_CONFIG_SUBDIRS([libcli])
|
|
||||||
|
|
||||||
# --enable-tests
|
|
||||||
AC_ARG_ENABLE([tests],
|
|
||||||
[AS_HELP_STRING([--enable-tests], [Build Criterion unit tests (default: no)])],
|
|
||||||
[enable_tests=$enableval],
|
|
||||||
[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_LIB([criterion], [main],
|
|
||||||
[CRITERION_LIBS="-lcriterion"],
|
|
||||||
[AC_MSG_ERROR([libcriterion not found])])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
|
|
||||||
# --enable-debug
|
# --enable-debug
|
||||||
AC_ARG_ENABLE([debug],
|
AC_ARG_ENABLE(
|
||||||
[AS_HELP_STRING([--enable-debug], [Enable debug build: -g -O0 (default: no)])],
|
[debug],
|
||||||
[enable_debug=$enableval],
|
[AS_HELP_STRING([--enable-debug], [Enable debug build: -g -O0 (default: no)])],
|
||||||
[enable_debug=no])
|
[enable_debug=$enableval],
|
||||||
|
[enable_debug=no]
|
||||||
|
)
|
||||||
AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = "xyes"])
|
AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = "xyes"])
|
||||||
|
|
||||||
# --enable-sanitizers
|
|
||||||
AC_ARG_ENABLE([sanitizers],
|
# --with-bundled-libcli
|
||||||
[AS_HELP_STRING([--enable-sanitizers],
|
AC_ARG_WITH(
|
||||||
[Enable AddressSanitizer and UndefinedBehaviorSanitizer (default: no)])],
|
[bundled-libcli],
|
||||||
[enable_sanitizers=$enableval],
|
AS_HELP_STRING([--with-bundled-libcli], [force using bundled ./libcli (ignore system)]),
|
||||||
[enable_sanitizers=no])
|
[with_bundled_libcli=yes],
|
||||||
AM_CONDITIONAL([ENABLE_SANITIZERS], [test "x$enable_sanitizers" = "xyes"])
|
[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])])
|
||||||
|
|
||||||
|
|
||||||
|
# --enable-tests
|
||||||
|
AC_ARG_ENABLE(
|
||||||
|
[tests],
|
||||||
|
[AS_HELP_STRING([--enable-tests], [Build Criterion unit tests (default: no)])],
|
||||||
|
[enable_tests=$enableval],
|
||||||
|
[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_LIB([criterion], [main],
|
||||||
|
[CRITERION_LIBS="-lcriterion"],
|
||||||
|
[AC_MSG_ERROR([libcriterion not found])])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
|
|
@ -62,15 +83,17 @@ AC_CONFIG_FILES([
|
||||||
src/ping/Makefile
|
src/ping/Makefile
|
||||||
tests/Makefile
|
tests/Makefile
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
AC_MSG_NOTICE([
|
AC_MSG_NOTICE([
|
||||||
|
|
||||||
net-tools $VERSION
|
net-tools $VERSION
|
||||||
------------------
|
------------------
|
||||||
CC : $CC
|
PREFIX : $prefix
|
||||||
CFLAGS : $STRICT_CFLAGS
|
CC : $CC
|
||||||
tests : $enable_tests
|
CFLAGS : $STRICT_CFLAGS
|
||||||
debug : $enable_debug
|
tests : $enable_tests
|
||||||
sanitizers : $enable_sanitizers
|
debug : $enable_debug
|
||||||
|
libcli : system=$have_system_libcli (forced bundled=$with_bundled_libcli)
|
||||||
])
|
])
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
bin_PROGRAMS = ft_ping
|
bin_PROGRAMS = ft_ping
|
||||||
noinst_LTLIBRARIES = libping_core.la
|
noinst_LTLIBRARIES = libping_core.la
|
||||||
|
|
||||||
PING_VERSION = 0.0.1
|
PING_VERSION = 0.0.1
|
||||||
VERSION_HEADER = $(top_srcdir)/includes/version_gen.h
|
VERSION_HEADER = $(top_srcdir)/includes/version_gen.h
|
||||||
|
|
||||||
# Version header: generated at build time (embeds git hash + date)
|
# Version header: generated at build time (embeds git hash + date)
|
||||||
BUILT_SOURCES = $(VERSION_HEADER)
|
BUILT_SOURCES = $(VERSION_HEADER)
|
||||||
CLEANFILES = $(VERSION_HEADER)
|
CLEANFILES = $(VERSION_HEADER)
|
||||||
|
|
||||||
$(VERSION_HEADER): FORCE
|
$(VERSION_HEADER): FORCE
|
||||||
@NEW_HEADER=$$(mktemp); \
|
@NEW_HEADER=$$(mktemp); \
|
||||||
|
|
@ -41,83 +41,78 @@ $(VERSION_HEADER): FORCE
|
||||||
FORCE:
|
FORCE:
|
||||||
.PHONY: FORCE
|
.PHONY: FORCE
|
||||||
|
|
||||||
libping_core_la_SOURCES = \
|
libping_core_la_SOURCES = \
|
||||||
cli/parse.c \
|
cli/parse.c \
|
||||||
cli/handlers/handle_count.c \
|
cli/handlers/handle_count.c \
|
||||||
cli/handlers/handle_preload.c \
|
cli/handlers/handle_preload.c \
|
||||||
cli/handlers/handle_pattern.c \
|
cli/handlers/handle_pattern.c \
|
||||||
cli/handlers/handle_dont_fragment.c \
|
cli/handlers/handle_dont_fragment.c \
|
||||||
cli/handlers/handle_linger.c \
|
cli/handlers/handle_linger.c \
|
||||||
cli/handlers/handle_flood.c \
|
cli/handlers/handle_flood.c \
|
||||||
cli/handlers/handle_help.c \
|
cli/handlers/handle_help.c \
|
||||||
cli/handlers/handle_interval.c \
|
cli/handlers/handle_interval.c \
|
||||||
cli/handlers/handle_quiet.c \
|
cli/handlers/handle_quiet.c \
|
||||||
cli/handlers/option_map.c \
|
cli/handlers/option_map.c \
|
||||||
cli/handlers/handle_size.c \
|
cli/handlers/handle_size.c \
|
||||||
cli/handlers/handle_timeout.c \
|
cli/handlers/handle_timeout.c \
|
||||||
cli/handlers/handle_tos.c \
|
cli/handlers/handle_tos.c \
|
||||||
cli/handlers/handle_ttl.c \
|
cli/handlers/handle_ttl.c \
|
||||||
cli/handlers/handle_version.c \
|
cli/handlers/handle_version.c \
|
||||||
cli/handlers/handle_verbose.c \
|
cli/handlers/handle_verbose.c \
|
||||||
cli/parse_utils/parse_inet_addr.c \
|
cli/parse_utils/parse_inet_addr.c \
|
||||||
cli/parse_utils/parse_destinations.c \
|
cli/parse_utils/parse_destinations.c \
|
||||||
cli/config_free.c \
|
cli/config_free.c \
|
||||||
cli/messages/help.c \
|
cli/messages/help.c \
|
||||||
cli/messages/version.c \
|
cli/messages/version.c \
|
||||||
cli/messages/error.c \
|
cli/messages/error.c \
|
||||||
core/ping.c \
|
core/ping.c \
|
||||||
core/loop.c \
|
core/loop.c \
|
||||||
core/send.c \
|
core/send.c \
|
||||||
core/callback.c \
|
core/callback.c \
|
||||||
tracker/init.c \
|
tracker/init.c \
|
||||||
tracker/record_send.c \
|
tracker/record_send.c \
|
||||||
tracker/record_recv.c \
|
tracker/record_recv.c \
|
||||||
output/start.c \
|
output/start.c \
|
||||||
output/packet.c \
|
output/packet.c \
|
||||||
output/error.c \
|
output/error.c \
|
||||||
output/summary.c \
|
output/summary.c \
|
||||||
output/flood.c \
|
output/flood.c \
|
||||||
scheduler/scheduler_arm.c \
|
scheduler/scheduler_arm.c \
|
||||||
scheduler/scheduler_select_tv.c \
|
scheduler/scheduler_select_tv.c \
|
||||||
scheduler/scheduler_init.c \
|
scheduler/scheduler_init.c \
|
||||||
stats/stats_get.c \
|
stats/stats_get.c \
|
||||||
stats/stats_init.c \
|
stats/stats_init.c \
|
||||||
stats/stats_update.c
|
stats/stats_update.c
|
||||||
|
|
||||||
BASE_CFLAGS = -std=c99 $(STRICT_CFLAGS)
|
BASE_CFLAGS = -std=c99 $(STRICT_CFLAGS)
|
||||||
|
|
||||||
if ENABLE_DEBUG
|
if ENABLE_DEBUG
|
||||||
EXTRA_CFLAGS = -g -O0
|
EXTRA_CFLAGS = -g -O0
|
||||||
else
|
else
|
||||||
EXTRA_CFLAGS =
|
EXTRA_CFLAGS =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ENABLE_SANITIZERS
|
|
||||||
SANITIZER_FLAGS = -fsanitize=address,undefined
|
|
||||||
else
|
|
||||||
SANITIZER_FLAGS =
|
|
||||||
endif
|
|
||||||
|
|
||||||
PING_CPPFLAGS = \
|
PING_CPPFLAGS = \
|
||||||
-I $(top_srcdir)/includes \
|
-I $(top_srcdir)/includes \
|
||||||
-I $(top_srcdir)/libicmp/includes \
|
-I $(top_srcdir)/libicmp/includes \
|
||||||
-I $(top_srcdir)/libcli/include \
|
-I $(top_srcdir)/libcli/include \
|
||||||
-D_GNU_SOURCE
|
-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_CPPFLAGS = $(PING_CPPFLAGS)
|
||||||
libping_core_la_CFLAGS = $(PING_CFLAGS)
|
libping_core_la_CFLAGS = $(PING_CFLAGS)
|
||||||
|
|
||||||
ft_ping_SOURCES = main.c
|
ft_ping_SOURCES = main.c
|
||||||
ft_ping_CPPFLAGS = $(PING_CPPFLAGS)
|
ft_ping_CPPFLAGS = $(PING_CPPFLAGS)
|
||||||
ft_ping_CFLAGS = $(PING_CFLAGS)
|
ft_ping_CFLAGS = $(PING_CFLAGS)
|
||||||
ft_ping_LDFLAGS = $(SANITIZER_FLAGS)
|
ft_ping_LDFLAGS =
|
||||||
ft_ping_LDADD = \
|
ft_ping_LDADD = \
|
||||||
libping_core.la \
|
libping_core.la \
|
||||||
$(top_srcdir)/libicmp/libicmp.a \
|
$(top_srcdir)/libicmp/libicmp.a \
|
||||||
$(top_builddir)/libcli/src/libcli.la \
|
$(top_builddir)/libcli/src/libcli.la \
|
||||||
-lm
|
-lm
|
||||||
|
|
||||||
# Build libicmp (simple Makefile) before linking
|
# Build libicmp (simple Makefile) before linking
|
||||||
$(top_srcdir)/libicmp/libicmp.a: FORCE
|
$(top_srcdir)/libicmp/libicmp.a: FORCE
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,53 @@
|
||||||
check_PROGRAMS = test_tracker test_stats test_send
|
check_PROGRAMS = test_tracker test_stats test_send
|
||||||
|
|
||||||
test_tracker_SOURCES = test_support.c ping/tracker/test_tracker.c
|
test_tracker_SOURCES = test_support.c ping/tracker/test_tracker.c
|
||||||
test_stats_SOURCES = test_support.c ping/stats/test_stats.c
|
test_stats_SOURCES = test_support.c ping/stats/test_stats.c
|
||||||
test_send_SOURCES = test_support.c send/test_do_send.c
|
test_send_SOURCES = test_support.c send/test_do_send.c
|
||||||
|
|
||||||
BASE_CFLAGS = -std=c99 $(STRICT_CFLAGS)
|
BASE_CFLAGS = -std=c99 $(STRICT_CFLAGS)
|
||||||
|
|
||||||
if ENABLE_DEBUG
|
if ENABLE_DEBUG
|
||||||
EXTRA_CFLAGS = -g -O0
|
EXTRA_CFLAGS = -g -O0
|
||||||
else
|
else
|
||||||
EXTRA_CFLAGS =
|
EXTRA_CFLAGS =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ENABLE_SANITIZERS
|
TEST_CPPFLAGS = \
|
||||||
SANITIZER_FLAGS = -fsanitize=address,undefined
|
-I $(top_srcdir)/includes \
|
||||||
else
|
-I $(top_srcdir)/libicmp/includes \
|
||||||
SANITIZER_FLAGS =
|
-I $(top_srcdir)/libcli/include \
|
||||||
endif
|
-I $(top_srcdir)/tests \
|
||||||
|
-D_GNU_SOURCE
|
||||||
|
|
||||||
TEST_CPPFLAGS = \
|
TEST_CFLAGS = $(BASE_CFLAGS) $(EXTRA_CFLAGS)
|
||||||
-I $(top_srcdir)/includes \
|
|
||||||
-I $(top_srcdir)/libicmp/includes \
|
|
||||||
-I $(top_srcdir)/libcli/include \
|
|
||||||
-I $(top_srcdir)/tests \
|
|
||||||
-D_GNU_SOURCE
|
|
||||||
|
|
||||||
TEST_CFLAGS = $(BASE_CFLAGS) $(EXTRA_CFLAGS) $(SANITIZER_FLAGS)
|
TEST_LDADD = \
|
||||||
|
$(top_builddir)/src/ping/libping_core.la \
|
||||||
|
$(top_srcdir)/libicmp/libicmp.a \
|
||||||
|
$(top_builddir)/libcli/src/libcli.la \
|
||||||
|
$(CRITERION_LIBS) \
|
||||||
|
-lm
|
||||||
|
|
||||||
TEST_LDADD = \
|
test_tracker_CPPFLAGS = $(TEST_CPPFLAGS)
|
||||||
$(top_builddir)/src/ping/libping_core.la \
|
test_tracker_CFLAGS = $(TEST_CFLAGS)
|
||||||
$(top_srcdir)/libicmp/libicmp.a \
|
test_tracker_LDFLAGS =
|
||||||
$(top_builddir)/libcli/src/libcli.la \
|
test_tracker_LDADD = $(TEST_LDADD)
|
||||||
$(CRITERION_LIBS) \
|
|
||||||
-lm
|
|
||||||
|
|
||||||
test_tracker_CPPFLAGS = $(TEST_CPPFLAGS)
|
test_stats_CPPFLAGS = $(TEST_CPPFLAGS)
|
||||||
test_tracker_CFLAGS = $(TEST_CFLAGS)
|
test_stats_CFLAGS = $(TEST_CFLAGS)
|
||||||
test_tracker_LDFLAGS = $(SANITIZER_FLAGS)
|
test_stats_LDFLAGS =
|
||||||
test_tracker_LDADD = $(TEST_LDADD)
|
test_stats_LDADD = $(TEST_LDADD)
|
||||||
|
|
||||||
test_stats_CPPFLAGS = $(TEST_CPPFLAGS)
|
test_send_CPPFLAGS = $(TEST_CPPFLAGS)
|
||||||
test_stats_CFLAGS = $(TEST_CFLAGS)
|
test_send_CFLAGS = $(TEST_CFLAGS)
|
||||||
test_stats_LDFLAGS = $(SANITIZER_FLAGS)
|
test_send_LDFLAGS = \
|
||||||
test_stats_LDADD = $(TEST_LDADD)
|
-Wl,--wrap=icmp_send_echo \
|
||||||
|
-Wl,--wrap=icmp_should_retry \
|
||||||
|
-Wl,--wrap=icmp_strerror \
|
||||||
|
-Wl,--wrap=ping_scheduler_arm
|
||||||
|
test_send_LDADD = $(TEST_LDADD)
|
||||||
|
|
||||||
test_send_CPPFLAGS = $(TEST_CPPFLAGS)
|
TESTS = test_tracker test_stats test_send
|
||||||
test_send_CFLAGS = $(TEST_CFLAGS)
|
|
||||||
test_send_LDFLAGS = $(SANITIZER_FLAGS) \
|
|
||||||
-Wl,--wrap=icmp_send_echo \
|
|
||||||
-Wl,--wrap=icmp_should_retry \
|
|
||||||
-Wl,--wrap=icmp_strerror \
|
|
||||||
-Wl,--wrap=ping_scheduler_arm
|
|
||||||
test_send_LDADD = $(TEST_LDADD)
|
|
||||||
|
|
||||||
TESTS = test_tracker test_stats test_send
|
|
||||||
|
|
||||||
# Version header needed by test_main.c
|
# Version header needed by test_main.c
|
||||||
BUILT_SOURCES = $(top_srcdir)/includes/version_gen.h
|
BUILT_SOURCES = $(top_srcdir)/includes/version_gen.h
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue