Skip to content

Commit bb31dcf

Browse files
authored
Merge pull request #1000 from appneta/revert-991-autoopt-asciidoctor
Revert "migrate autoopts -> getopt + asciidoctor"
2 parents a41644f + 768da2a commit bb31dcf

175 files changed

Lines changed: 26863 additions & 4979 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codeclimate.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ ratings:
66
paths:
77
- "**.c"
88
- "**.h"
9+
10+
exclude_paths:
11+
- libopts/

.github/workflows/c-linter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jobs:
99
- uses: actions/checkout@v3
1010
- run: |
1111
echo "Build Application"
12-
sudo apt-get -y install libpcap-dev
12+
sudo apt-get -y install libpcap-dev autogen
1313
./autogen.sh
14-
./configure
14+
./configure --disable-local-libopts
1515
- uses: cpp-linter/cpp-linter-action@v2
1616
id: linter
1717
env:

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ jobs:
5959

6060
- run: |
6161
echo "Build Application"
62-
sudo apt-get -y install libpcap-dev
62+
sudo apt-get -y install libpcap-dev autogen
6363
./autogen.sh
64-
./configure
64+
./configure --disable-local-libopts
6565
make
6666
6767
- name: Perform CodeQL Analysis

.github/workflows/github-actions-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ jobs:
1212
uses: actions/checkout@v3
1313
- run: echo "The ${{ github.repository }} repository has been cloned to the runner."
1414
- name: Install prereqs
15-
run: sudo apt -y install libpcap-dev automake autoconf libtool libxdp-dev asciidoctor
15+
run: sudo apt -y install autogen libpcap-dev automake autoconf libtool libxdp-dev
1616
- name: Create a build directory
1717
run: mkdir -p build
1818
- name: Create configure script
1919
run: pushd build; ../autogen.sh; popd
2020
- name: configure
21-
run: pushd build; ../configure --enable-debug --enable-test-hexdump; popd
21+
run: pushd build; ../configure --disable-local-libopts --enable-debug --enable-test-hexdump; popd
2222
- name: make
2323
run: pushd build; make; popd
2424
- name: make dist

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@ matrix:
1616
apt:
1717
packages:
1818
- libpcap-dev
19+
- autogen
1920
- os: linuxal
2021
env: CI_BUILD_PREFIX=scan-build-11
2122
addons:
2223
apt:
2324
packages:
2425
- libpcap-dev
26+
- autogen
2527
- clang-tools-11
2628

2729
before_script:
2830
- git pull --tags
2931

3032
script:
3133
- autoreconf -iv > build.log 2>&1 || (cat build.log && exit 1)
32-
- ${CI_BUILD_PREFIX} ./configure --enable-asan --with-testnic=$(ip l | grep ens | cut -d':' -f2 | xargs) > build.log 2>&1 || (cat build.log && exit 1)
34+
- ${CI_BUILD_PREFIX} ./configure --disable-local-libopts --enable-asan --with-testnic=$(ip l | grep ens | cut -d':' -f2 | xargs) > build.log 2>&1 || (cat build.log && exit 1)
3335
- ${CI_BUILD_PREFIX} make > build.log 2>&1 || (cat build.log && exit 1)
3436
- make dist > build.log 2>&1 || (cat build.log && exit 1)
3537
- sudo make test || (cat test/test.log && exit 1)

Makefile.am

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
# $Id$
2-
ACLOCAL_AMFLAGS = -I m4
2+
ACLOCAL_AMFLAGS = -I m4 -I libopts/m4
33

4+
if NEED_LIBOPTS
5+
SUBDIRS = scripts lib $(LIBOPTS_DIR) src
6+
else
47
SUBDIRS = scripts lib src
8+
endif
59

6-
DIST_SUBDIRS = scripts lib src docs test
10+
DIST_SUBDIRS = scripts lib libopts src docs test
711
.PHONY: manpages docs test man2html
812

913

10-
# Only (re)generate the man pages during `make dist` when asciidoctor is
11-
# available. Without it there is no rule to build them, and any pre-built
12-
# *.1 pages (e.g. from a release tarball) are already distributed via the
13-
# BUILD_MANPAGES blocks in src/Makefile.am, so invoking the manpages target
14-
# here would only emit a spurious "asciidoctor required" warning.
15-
if HAVE_ASCIIDOCTOR
1614
dist-hook: version manpages
1715
rm $(distdir)/src/defines.h
18-
else
19-
dist-hook: version
20-
rm $(distdir)/src/defines.h
21-
endif
2216

2317
DOCS_DIR = $(top_builddir)/docs
2418

@@ -37,6 +31,9 @@ postweb: docs doxygen
3731

3832
TEST_DIR = $(top_builddir)/test
3933

34+
autoopts:
35+
cd src && make autoopts
36+
4037
test:
4138
echo Making test in $(TEST_DIR)
4239
cd $(TEST_DIR) && make test

autogen.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cd $(dirname $0)
66

77
rm -f config/config.guess config/config.sub config/ltmain.sh 2>/dev/null
88
rm -f aclocal.m4 2>/dev/null
9-
aclocal
9+
aclocal -I libopts/m4/
1010
if test -x "$(which glibtoolize)" ; then
1111
# Necessary under OS X
1212
glibtoolize --copy --automake --force

configure.ac

Lines changed: 70 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ AC_CONFIG_AUX_DIR(config)
1111
AM_MAINTAINER_MODE([enable])
1212
AM_WITH_DMALLOC
1313

14+
dnl People building from GitHub need the same version of Autogen as I'm using
15+
dnl or specify --disable-local-libopts to force using the locally-installed
16+
dnl copy of libopts rather than the source in the `./libopts/` directory.
17+
MAINTAINER_AUTOGEN_VERSION=5.18.16
18+
1419
AC_CONFIG_MACRO_DIR([m4])
1520

1621
TCPREPLAY_VERSION=$PACKAGE_VERSION
@@ -176,20 +181,70 @@ AC_EXEEXT
176181
AC_PATH_PROG(PRINTF, printf)
177182
AC_PATH_PROG(ECHO, echo)
178183
AC_PATH_PROG(CUT, cut)
179-
AC_PATH_PROG(ASCIIDOCTOR, asciidoctor)
180-
181-
dnl asciidoctor is used to render hand-written man pages (replacing AutoGen
182-
dnl for tools that have been migrated away from AutoOpts). The generated man
183-
dnl page is shipped in release tarballs, so asciidoctor is only required when
184-
dnl (re)building the man page from its .adoc source.
185-
AM_CONDITIONAL([HAVE_ASCIIDOCTOR], [test -n "$ASCIIDOCTOR"])
186-
187-
AM_CONDITIONAL([BUILD_MANPAGES],
188-
[test -n "$ASCIIDOCTOR" || test -f "$srcdir/src/tcpreplay.1"])
184+
AC_PATH_PROG(AUTOGEN, autogen)
185+
AC_PATH_PROG(GROFF, groff)
189186
AC_PATH_PROG(depmod, depmod, /sbin/depmod, $PATH:/sbin)
190187
AC_PATH_PROG(insmod, insmod, /sbin/insmod, $PATH:/sbin)
191188
AC_PATH_PROG(rmmod, rmmod, /sbin/rmmod, $PATH:/sbin)
192189

190+
191+
dnl tcpreplay has (so far) been relying on leading-edge autogen.
192+
dnl Therefore, by default:
193+
dnl - use the version we ship with
194+
dnl - do not install it
195+
dnl - build a static copy (AC_DISABLE_SHARED - implicitly done earlier)
196+
case "${enable_local_libopts+set}" in
197+
set) ;;
198+
*) enable_local_libopts=yes ;;
199+
esac
200+
201+
case "${enable_libopts_install+set}" in
202+
set) ;;
203+
*) enable_libopts_install=no ;;
204+
esac
205+
206+
dnl check autogen version
207+
AUTOGEN_VERSION="unknown - man pages will not be built"
208+
if test -n "${AUTOGEN}" ; then
209+
AC_MSG_CHECKING(for autogen version >= ${MAINTAINER_AUTOGEN_VERSION})
210+
AUTOGEN_VERSION=$(${AUTOGEN} -v | ${CUT} -d' ' -f 4)
211+
AUTOGEN_MAJOR=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 1)
212+
AUTOGEN_MINOR=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 2)
213+
AUTOGEN_BUILD=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 3)
214+
if test -z "$AUTOGEN_BUILD"; then
215+
AUTOGEN_BUILD=0
216+
fi
217+
if (test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -eq 18 && test ${AUTOGEN_BUILD} -lt 4) ||
218+
(test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -lt 18) ||
219+
test ${AUTOGEN_MAJOR} -lt 5 ; then
220+
AC_MSG_RESULT(no)
221+
if test ! "x$enable_local_libopts" = "xyes"; then
222+
AC_MSG_ERROR([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from source code. Upgrade to 5.18.4 or higher])
223+
fi
224+
AUTOGEN_VERSION="${AUTOGEN_VERSION} - downlevel"
225+
else
226+
AC_MSG_RESULT(yes)
227+
fi
228+
229+
dnl Compare the installed version with the maintainer version if building from GitHub and not using system libopts
230+
if test ! -f src/tcpreplay_opts.c && test "x$enable_local_libopts" = "xyes" ; then
231+
if test $MAINTAINER_AUTOGEN_VERSION != $AUTOGEN_VERSION ; then
232+
AC_MSG_ERROR([Your version of autogen ($AUTOGEN_VERSION) != libopts tear off ($MAINTAINER_AUTOGEN_VERSION) Either install the correct version or specify --disable-local-libopts])
233+
fi
234+
fi
235+
else
236+
if test ! -f src/tcpreplay_opts.c ; then
237+
AC_MSG_ERROR([Please install GNU autogen $MAINTAINER_AUTOGEN_VERSION or higher if you are building from GitHub. To avoid this message download source from https://github.com/appneta/tcpreplay/releases/latest])
238+
fi
239+
fi
240+
AC_DEFINE([AUTOGEN_VERSION], [${AUTOGEN_VERSION}], [What version of autogen is installed on this system])
241+
242+
if test "x$enable_local_libopts" = "xyes" ; then
243+
AC_MSG_NOTICE([Using included libopts tearoff])
244+
else
245+
AC_MSG_NOTICE([Using system libopts])
246+
fi
247+
193248
AC_PROG_EGREP
194249
AC_HEADER_MAJOR
195250

@@ -224,7 +279,6 @@ AC_CHECK_TYPE(u_short, uint16_t)
224279
AC_CHECK_TYPE(u_int, uint32_t)
225280
AC_CHECK_TYPE(u_int32_t, uint32_t)
226281
AC_CHECK_TYPE(u_int64_t, uint64_t)
227-
AC_CHECK_SIZEOF([long])
228282

229283
# required by C23 standard
230284
CFLAGS="-D_DEFAULT_SOURCE $CFLAGS"
@@ -1961,6 +2015,9 @@ else
19612015
AC_MSG_RESULT(no)
19622016
fi
19632017

2018+
LIBOPTS_CHECK(libopts)
2019+
2020+
19642021
AC_CONFIG_FILES([Makefile
19652022
doxygen.cfg
19662023
lib/Makefile
@@ -1984,6 +2041,8 @@ AC_MSG_RESULT([
19842041
libpcap: ${foundpcap} (${libpcap_version})
19852042
PF_RING libpcap ${pf_ring_found} ${pf_ring_lib}
19862043
libdnet: ${founddnet} ${libdnet_version}
2044+
autogen: ${AUTOGEN} (${AUTOGEN_VERSION})
2045+
Use libopts tearoff: ${enable_local_libopts}
19872046
64bit counter support: ${use64bit_counters}
19882047
tcpdump binary path: ${tcpdump_path}
19892048
fragroute support: ${enable_fragroute}

docs/HACKING

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The file layout is pretty simple:
2929

3030
/ - Base directory
3131
/lib - 3rd party libraries stolen verbatim
32+
/libopts - GNU AutoOpts tearoff
3233
/src - Main code routines
3334
/src/common - Common routines for all binaries
3435
/src/tcpedit - libtcpedit

docs/Makefile.am

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ MAKEFLAGS=-s
44

55
docs: clean-docs manpages
66

7-
web/tcpreplay.html: $(srcdir)/tcpreplay.1.adoc
8-
mkdir -p web; @ASCIIDOCTOR@ --backend html5 --out-file web/tcpreplay.html $(srcdir)/tcpreplay.1.adoc
7+
web/tcpreplay.html:
8+
mkdir -p web; @GROFF@ -Thtml -mman ../src/tcpreplay.1 > web/tcpreplay.html
99

10-
web/tcpprep.html: $(srcdir)/tcpprep.1.adoc
11-
mkdir -p web; @ASCIIDOCTOR@ --backend html5 --out-file web/tcpprep.html $(srcdir)/tcpprep.1.adoc
10+
web/tcpprep.html:
11+
@GROFF@ -Thtml -mman ../src/tcpprep.1 > web/tcpprep.html
1212

13-
web/tcprewrite.html: $(srcdir)/tcprewrite.1.adoc $(srcdir)/tcpedit_options.adoc
14-
mkdir -p web; @ASCIIDOCTOR@ --backend html5 --out-file web/tcprewrite.html $(srcdir)/tcprewrite.1.adoc
13+
web/tcprewrite.html:
14+
@GROFF@ -Thtml -mman ../src/tcprewrite.1 > web/tcprewrite.html
1515

16-
web/tcpbridge.html: $(srcdir)/tcpbridge.1.adoc $(srcdir)/tcpedit_options.adoc
17-
mkdir -p web; @ASCIIDOCTOR@ --backend html5 --out-file web/tcpbridge.html $(srcdir)/tcpbridge.1.adoc
16+
web/tcpbridge.html:
17+
@GROFF@ -Thtml -mman ../src/tcpbridge.1 > web/tcpbridge.html
1818

19-
web/tcpreplay-edit.html: $(srcdir)/tcpreplay-edit.1.adoc $(srcdir)/tcpedit_options.adoc
20-
mkdir -p web; @ASCIIDOCTOR@ --backend html5 --out-file web/tcpreplay-edit.html $(srcdir)/tcpreplay-edit.1.adoc
19+
web/tcpreplay-edit.html:
20+
@GROFF@ -Thtml -mman ../src/tcpreplay-edit.1 > web/tcpreplay-edit.html
2121

22-
web/tcpliveplay.html: $(srcdir)/tcpliveplay.1.adoc
23-
mkdir -p web; @ASCIIDOCTOR@ --backend html5 --out-file web/tcpliveplay.html $(srcdir)/tcpliveplay.1.adoc
22+
web/tcpliveplay.html:
23+
@GROFF@ -Thtml -mman ../src/tcpliveplay.1 > web/tcpliveplay.html
2424

25-
web/tcpcapinfo.html: $(srcdir)/tcpcapinfo.1.adoc
26-
mkdir -p web; @ASCIIDOCTOR@ --backend html5 --out-file web/tcpcapinfo.html $(srcdir)/tcpcapinfo.1.adoc
25+
web/tcpcapinfo.html:
26+
@GROFF@ -Thtml -mman ../src/tcpcapinfo.1 > web/tcpcapinfo.html
2727

2828
manpages: web/tcpreplay.html web/tcpprep.html web/tcprewrite.html \
2929
web/tcpbridge.html web/tcpreplay-edit.html web/tcpliveplay.html \
@@ -36,10 +36,7 @@ postweb: manpages
3636
scp CHANGELOG TODO aturner@malbec.synfin.net:/var/vhosts/tcpreplay/
3737

3838

39-
EXTRA_DIST = CHANGELOG CREDIT HACKING INSTALL LICENSE Win32Readme.txt \
40-
tcpcapinfo.1.adoc tcpliveplay.1.adoc tcpprep.1.adoc \
41-
tcprewrite.1.adoc tcpbridge.1.adoc tcpedit_options.adoc \
42-
tcpreplay.1.adoc tcpreplay-edit.1.adoc tcpreplay_options.adoc
39+
EXTRA_DIST = CHANGELOG CREDIT HACKING INSTALL LICENSE Win32Readme.txt
4340

4441
clean-docs: clean
4542
-rm -f web/*.html

0 commit comments

Comments
 (0)