124 lines
3.4 KiB
Makefile
124 lines
3.4 KiB
Makefile
bin_PROGRAMS = ft_ping
|
|
noinst_LTLIBRARIES = libping_core.la
|
|
|
|
PING_VERSION = 0.0.1
|
|
VERSION_HEADER = $(top_srcdir)/includes/version_gen.h
|
|
|
|
# Version header: generated at build time (embeds git hash + date)
|
|
BUILT_SOURCES = $(VERSION_HEADER)
|
|
CLEANFILES = $(VERSION_HEADER)
|
|
|
|
$(VERSION_HEADER): FORCE
|
|
@NEW_HEADER=$$(mktemp); \
|
|
PING_BUILD_DATE=$$(git -C $(top_srcdir) log -1 --format=%cd \
|
|
--date=format:'%Y-%m-%d %H:%M:%S' 2>/dev/null \
|
|
|| date -u '+%Y-%m-%d %H:%M:%S'); \
|
|
PING_GIT_COMMIT=$$(git -C $(top_srcdir) rev-parse --short HEAD 2>/dev/null \
|
|
|| echo "nogit"); \
|
|
if test "$$PING_GIT_COMMIT" = "nogit"; then \
|
|
HAS_GIT=0; \
|
|
else \
|
|
HAS_GIT=1; \
|
|
fi; \
|
|
echo "/* Auto-generated - DO NOT EDIT */" > $$NEW_HEADER; \
|
|
echo "#ifndef PING_VERSION_GEN_H" >> $$NEW_HEADER; \
|
|
echo "#define PING_VERSION_GEN_H" >> $$NEW_HEADER; \
|
|
echo "#define PING_VERSION \"$(PING_VERSION)\"" >> $$NEW_HEADER; \
|
|
echo "#define PING_BUILD_DATE \"$$PING_BUILD_DATE\"" >> $$NEW_HEADER; \
|
|
echo "#define PING_GIT_COMMIT \"$$PING_GIT_COMMIT\"" >> $$NEW_HEADER; \
|
|
echo "#define PING_HAS_GIT_COMMIT $$HAS_GIT" >> $$NEW_HEADER; \
|
|
echo "" >> $$NEW_HEADER; \
|
|
echo "extern char* g_prog_name;" >> $$NEW_HEADER; \
|
|
echo "" >> $$NEW_HEADER; \
|
|
echo "#endif" >> $$NEW_HEADER; \
|
|
if test ! -f $(VERSION_HEADER) || ! cmp -s $$NEW_HEADER $(VERSION_HEADER); then \
|
|
mv $$NEW_HEADER $(VERSION_HEADER); \
|
|
echo "[OK] Version header generated"; \
|
|
else \
|
|
rm -f $$NEW_HEADER; \
|
|
fi
|
|
|
|
FORCE:
|
|
.PHONY: FORCE
|
|
|
|
libping_core_la_SOURCES = \
|
|
cli/parse.c \
|
|
cli/handlers/handle_count.c \
|
|
cli/handlers/handle_preload.c \
|
|
cli/handlers/handle_pattern.c \
|
|
cli/handlers/handle_dont_fragment.c \
|
|
cli/handlers/handle_linger.c \
|
|
cli/handlers/handle_flood.c \
|
|
cli/handlers/handle_help.c \
|
|
cli/handlers/handle_interval.c \
|
|
cli/handlers/handle_quiet.c \
|
|
cli/handlers/option_map.c \
|
|
cli/handlers/handle_size.c \
|
|
cli/handlers/handle_timeout.c \
|
|
cli/handlers/handle_tos.c \
|
|
cli/handlers/handle_ttl.c \
|
|
cli/handlers/handle_version.c \
|
|
cli/handlers/handle_verbose.c \
|
|
cli/parse_utils/parse_inet_addr.c \
|
|
cli/parse_utils/parse_destinations.c \
|
|
cli/config_free.c \
|
|
cli/messages/help.c \
|
|
cli/messages/version.c \
|
|
cli/messages/error.c \
|
|
core/ping.c \
|
|
core/loop.c \
|
|
core/send.c \
|
|
core/callback.c \
|
|
tracker/init.c \
|
|
tracker/record_send.c \
|
|
tracker/record_recv.c \
|
|
output/start.c \
|
|
output/packet.c \
|
|
output/error.c \
|
|
output/summary.c \
|
|
output/flood.c \
|
|
scheduler/scheduler_arm.c \
|
|
scheduler/scheduler_select_tv.c \
|
|
scheduler/scheduler_init.c \
|
|
stats/stats_get.c \
|
|
stats/stats_init.c \
|
|
stats/stats_update.c
|
|
|
|
BASE_CFLAGS = -std=c99 $(STRICT_CFLAGS)
|
|
|
|
if ENABLE_DEBUG
|
|
EXTRA_CFLAGS = -g -O0
|
|
else
|
|
EXTRA_CFLAGS =
|
|
endif
|
|
|
|
if ENABLE_SANITIZERS
|
|
SANITIZER_FLAGS = -fsanitize=address,undefined
|
|
else
|
|
SANITIZER_FLAGS =
|
|
endif
|
|
|
|
PING_CPPFLAGS = \
|
|
-I $(top_srcdir)/includes \
|
|
-I $(top_srcdir)/libicmp/includes \
|
|
-I $(top_srcdir)/libcli/include \
|
|
-D_GNU_SOURCE
|
|
|
|
PING_CFLAGS = $(BASE_CFLAGS) $(EXTRA_CFLAGS) $(SANITIZER_FLAGS)
|
|
|
|
libping_core_la_CPPFLAGS = $(PING_CPPFLAGS)
|
|
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_LDADD = \
|
|
libping_core.la \
|
|
$(top_srcdir)/libicmp/libicmp.a \
|
|
$(top_builddir)/libcli/src/libcli.la \
|
|
-lm
|
|
|
|
# Build libicmp (simple Makefile) before linking
|
|
$(top_srcdir)/libicmp/libicmp.a: FORCE
|
|
$(MAKE) -C $(top_srcdir)/libicmp BUILD_STATIC=yes BUILD_SHARED=no
|