From b503900b1456e8bd4b60d1deb0ef7cc3665676f1 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Sun, 4 Apr 2021 21:59:14 +0200 Subject: First step of cleaning up the Makefile.in hell. The goal is to get rid of the Makefile.in's (replace it with Automake Makefile.am's) as they duplicate lot's of text. That decreases readability and is in general a bad design pattern. It seems appropriate to use Automake for an Autoconf based project. Currently achieved: * using libtool to build the core library (+libtool's semantic versioning) * out-of-source builds should work right now * introducing Automake based Makefile in src/ * removed some (maybe) unused GIT ignored files * provide some small python fixes Signed-off-by: Toni Uhlig --- utils/generate_automake_am.sh | 164 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100755 utils/generate_automake_am.sh (limited to 'utils/generate_automake_am.sh') diff --git a/utils/generate_automake_am.sh b/utils/generate_automake_am.sh new file mode 100755 index 000000000..5219a6445 --- /dev/null +++ b/utils/generate_automake_am.sh @@ -0,0 +1,164 @@ +#!/usr/bin/env sh +# +# This script is used for automatic generation of src/Makefile.am and fuzz/Makefile.am +# That way it is not necessary anymore to use wildcard *.c includes. +# Automake does not support it: https://www.gnu.org/software/automake/manual/html_node/Wildcards.html +# +# This script should run everytime a new *.c file should be part of the library. +# + +set -e + +MYDIR="$(realpath "$(dirname "${0}")")" + +generate_src_am() +{ + # enumerate all *.c sources below src/ with a max. depth of three + cd "${MYDIR}/../src" + C_INCLUDES_GEN=$(find include -iname "*.h.in" | sort) + C_INCLUDES_PRV=$(find lib lib/protocols lib/third_party/include -maxdepth 1 -iname "*.h" -o -iname "*.c.inc" | sort) + C_INCLUDES=$(find include -iname "*.h" | sort) + C_SOURCES=$(find lib -maxdepth 3 -iname "*.c" | sort) + C_THIRD_PARTY_HLL_SOURCES=$(find lib/third_party/src/hll -iname "*.c" | sort) + + # extra dist source files (required by nDPI through #include) + printf '%s' 'EXTRA_DIST =' >Makefile.am + + # HLL sources + for src in ${C_THIRD_PARTY_HLL_SOURCES}; do + printf ' \\\n\t%s' "${src}" >>Makefile.am + done + + # private headers + for inc in ${C_INCLUDES_PRV}; do + printf ' \\\n\t%s' "${inc}" >>Makefile.am + done + printf '\n\n' >>Makefile.am + + printf '%s\n\n' 'includendpidir = $(includedir)/ndpi' >>Makefile.am + + printf '%s' 'includendpi_HEADERS =' >>Makefile.am + + # generated headers + for inc in ${C_INCLUDES_GEN}; do + printf ' \\\n\t%s' "${inc%.in}" >>Makefile.am + done + + # headers + for inc in ${C_INCLUDES}; do + SKIP_INC=0 + for check_inc in ${C_INCLUDES_GEN}; do + test "x${inc}.in" != "x${check_inc}" || SKIP_INC=1 + done + test ${SKIP_INC} -eq 0 || continue + printf ' \\\n\t%s' "${inc}" >>Makefile.am + done + printf '\n\n' >>Makefile.am + + # libtool init + printf '%s\n\n' 'lib_LTLIBRARIES = libndpi.la' >>Makefile.am + printf '%s' 'libndpi_la_SOURCES =' >>Makefile.am + + # add all *.c files found to SOURCES + for src in ${C_SOURCES}; do + printf ' \\\n\t%s' "${src}" >>Makefile.am + done + printf '\n\n' >>Makefile.am + + # libtool CFLAGS / LDFLAGS +cat >>Makefile.am <Makefile.am <>Makefile.am + done + printf '\n\n' >>Makefile.am + + printf '%s\n%s\n' \ + 'fuzz_ndpi_reader_seed_corpus.zip: $(TESTPCAPS)' \ + ' zip -r fuzz_ndpi_reader_seed_corpus.zip $(TESTPCAPS)' >>Makefile.am + + cd "${MYDIR}" +} + +generate_src_am +generate_fuzz_am -- cgit v1.2.3