Skip to content

Commit 5aaaf76

Browse files
committed
Add basic elf2tag(1) manpage
Add basic elf2tag(1) manpage using asciidoc/asciidoctor. To update the elf2tag.1 file from elf2tag.1.adoc, run the update-elf2tag-manpage script. No CI or buildsystem or git precommit hook integration yet.
1 parent 2f6bd67 commit 5aaaf76

File tree

3 files changed

+191
-0
lines changed

3 files changed

+191
-0
lines changed

src/elf2tag.1

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
'\" t
2+
.\" Title: elf2tag
3+
.\" Author: [see the "AUTHOR(S)" section]
4+
.\" Generator: Asciidoctor 2.0.20
5+
.\" Date: 2024-11-20
6+
.\" Manual: avrdude Manual
7+
.\" Source: avrdude
8+
.\" Language: English
9+
.\"
10+
.TH "ELF2TAG" "1" "2024-11-20" "avrdude" "avrdude Manual"
11+
.ie \n(.g .ds Aq \(aq
12+
.el .ds Aq '
13+
.ss \n[.ss] 0
14+
.nh
15+
.ad l
16+
.de URL
17+
\fI\\$2\fP <\\$1>\\$3
18+
..
19+
.als MTO URL
20+
.if \n[.g] \{\
21+
. mso www.tmac
22+
. am URL
23+
. ad l
24+
. .
25+
. am MTO
26+
. ad l
27+
. .
28+
. LINKSTYLE blue R < >
29+
.\}
30+
.SH "NAME"
31+
elf2tag \- output a tagfile for the avrdude disasm command
32+
.SH "SYNOPSIS"
33+
.sp
34+
\fBelf2tag\fP <file.elf>
35+
.sp
36+
\fBelf2tag\fP [\fB\-h\fP | \fB\-\-help\fP]
37+
.SH "DESCRIPTION"
38+
.sp
39+
\fIelf2tag\fP generates a tagfile for use with the \fIavrdude disasm\fP command.
40+
.SH "OPTIONS"
41+
.sp
42+
\fB\-h\fP \fB\-\-help\fP
43+
.RS 4
44+
Prints the help message and exits.
45+
.RE
46+
.SH "EXAMPLES"
47+
.sp
48+
.if n .RS 4
49+
.nf
50+
.fam C
51+
$ elf2tag blink.elf > blink.tag
52+
$ avrdude \-qq \-c dryrun \-p m328p \-U blink.elf \-t
53+
avrdude> disasm \-t=file.tag flash 0 512
54+
.fam
55+
.fi
56+
.if n .RE
57+
.SH "AUTHORS"
58+
.sp
59+
\fIelf2tag\fP was written by Johannes Bauer with small modifications by Stefan Rueger.
60+
.SH "SEE ALSO"
61+
.sp
62+
\fBavrdude(1)\fP, \fBavr\-nm(1)\fP, \fBavr\-objdump(1)\fP

src/elf2tag.1.adoc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
ELF2TAG(1)
2+
==========
3+
:doctype: manpage
4+
:man source: avrdude
5+
:man manual: avrdude Manual
6+
7+
NAME
8+
----
9+
10+
elf2tag - output a tagfile for the avrdude disasm command
11+
12+
SYNOPSIS
13+
--------
14+
15+
*elf2tag* <file.elf>
16+
17+
*elf2tag* [*-h* | *--help*]
18+
19+
DESCRIPTION
20+
-----------
21+
22+
_elf2tag_ generates a tagfile for use with the _avrdude disasm_ command.
23+
24+
OPTIONS
25+
-------
26+
27+
*-h* *--help*::
28+
Prints the help message and exits.
29+
30+
EXAMPLES
31+
--------
32+
33+
....
34+
$ elf2tag blink.elf > blink.tag
35+
$ avrdude -qq -c dryrun -p m328p -U blink.elf -t
36+
avrdude> disasm -t=blink.tag flash 0 512
37+
....
38+
39+
AUTHORS
40+
-------
41+
42+
_elf2tag_ was written by Johannes Bauer with small modifications by Stefan Rueger.
43+
44+
SEE ALSO
45+
--------
46+
47+
*avrdude(1)*, *avr-nm(1)*, *avr-objdump(1)*

src/update-elf2tag-manpage

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
3+
# update-elf2tag-manpage - update the elf2tag.1 manpage from adoc source
4+
#
5+
# Usage: ./path/to/update-elf2tag-manpage
6+
#
7+
# Changes to the directory where update-elf2tag-manpage and elf2tag.1.adoc
8+
# are, runs elf2tag.1.adoc through asciidoctor to produce a man page, but
9+
# only updates the elf2tag.1 file in the case of actual changes.
10+
#
11+
# Just the asciidoctor version or the current date being different from
12+
# the last asciidoctor run is not an actual change.
13+
#
14+
# Requires asciidoctor to be installed.
15+
#
16+
# Environment variables used (if unset, uses the command from PATH):
17+
# ASCIIDOCTOR the asciidoctor command to run
18+
# CMP the cmp command to run (e.g. "busybox cmp")
19+
# SED the sed command to run (e.g. "busybox sed")
20+
21+
# This script uses the shell feature called "process substitution" which
22+
# is implemented by bash and busybox sh, but not by e.g. dash and can
23+
# therefore not be a /bin/sh script.
24+
25+
set -e
26+
27+
case "$1" in
28+
-h | --help )
29+
${SED-sed} -n '/^#\( .*\)$/,$p' "$0" \
30+
| ${SED-sed} '/^#\( .*\)\?$/!q' \
31+
| ${SED-sed} '/^$/d' \
32+
| ${SED-sed} 's|^#$||; s|^# ||'
33+
exit 0
34+
;;
35+
esac
36+
37+
cd "$(dirname "$0")"
38+
39+
test -s elf2tag.1.adoc
40+
test -s elf2tag
41+
42+
normalize_manpage() {
43+
${SED-sed} -f <(cat<<EOF
44+
s|^\.\\" Generator: Asciidoctor .*|.\\" Generator: GENERATOR|
45+
s|^\.\\" Date: 20[0-9][0-9]-[0-1][0-9]-[0-3][0-9]|.\\" Date: DATE|
46+
s|^.TH "ELF2TAG" "1" "20[0-9][0-9]-[0-1][0-9]-[0-3][0-9]" "avrdude" "avrdude Manual"|\.\\" TH HEADER|
47+
EOF
48+
) < "$1" > "$2"
49+
}
50+
51+
tmpdir="tmp$$"
52+
53+
if ! ${ASCIIDOCTOR-asciidoctor} -b manpage -D "$tmpdir" elf2tag.1.adoc; then
54+
echo "Error updating elf2tag.1"
55+
exit 2
56+
fi
57+
58+
if ! test -e elf2tag.1; then
59+
echo "Generate elf2tag.1"
60+
mv -f "$tmpdir/elf2tag.1" elf2tag.1
61+
rmdir "$tmpdir"
62+
exit 0
63+
fi
64+
65+
normalize_manpage elf2tag.1 "$tmpdir/elf2tag.1.old"
66+
normalize_manpage "$tmpdir/elf2tag.1" "$tmpdir/elf2tag.1.new"
67+
68+
if ${CMP-cmp} "$tmpdir/elf2tag.1.old" "$tmpdir/elf2tag.1.new" > /dev/null; then
69+
echo "elf2tag.1 is up to date"
70+
rm -f "$tmpdir/elf2tag.1"
71+
rm -f "$tmpdir/elf2tag.1.old"
72+
rm -f "$tmpdir/elf2tag.1.new"
73+
rmdir "$tmpdir"
74+
exit 0
75+
fi
76+
77+
echo "Updating elf2tag.1"
78+
mv -f "$tmpdir/elf2tag.1" elf2tag.1
79+
rm -f "$tmpdir/elf2tag.1.old"
80+
rm -f "$tmpdir/elf2tag.1.new"
81+
rmdir "$tmpdir"
82+
exit 0

0 commit comments

Comments
 (0)