Skip to content

Commit

Permalink
fix: also readd src/doc
Browse files Browse the repository at this point in the history
  • Loading branch information
koen1711 committed Apr 26, 2024
1 parent 05ac506 commit 2da2e88
Show file tree
Hide file tree
Showing 8 changed files with 418 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/doc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
avrdude.t2d/
avrdude.t2p/
Makefile
Makefile.in
avrdude-html
avrdude.aux
avrdude.cp
avrdude.cps
avrdude.dvi
avrdude.fn
avrdude.info
avrdude.ky
avrdude.log
avrdude.pdf
avrdude.pg
avrdude.ps
avrdude.toc
avrdude.tp
avrdude.vr
mdate-sh
stamp-vti
texinfo.tex
version.texi
programmer_types.texi
parts.texi
programmers.texi
179 changes: 179 additions & 0 deletions src/doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
#
# CMakeLists.txt - CMake project for AVRDUDE documentation
# Copyright (C) 2022 Marius Greuel
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

set(AVRDUDE_CONF "${PROJECT_BINARY_DIR}/src/avrdude.conf")

set(TEXINFOS "${CMAKE_CURRENT_SOURCE_DIR}/avrdude.texi")
set(GENERATED_TEXINFOS
programmers.texi
programmer_types.texi
parts.texi
version.texi
)

string(TIMESTAMP TODAY "%d %B %Y")
set(DOCS_VERSION ${PROJECT_VERSION})
set(DOCS_UPDATED ${TODAY})

find_program(MAKEINFO_EXECUTABLE NAMES makeinfo)
find_program(TEXI2HTML_EXECUTABLE NAMES texi2html)

# =====================================
# Custom rules for auto-generated texi
# =====================================

add_custom_target(avrdude_binaries DEPENDS avrdude conf)

add_custom_command(
OUTPUT programmers.txt
DEPENDS avrdude_binaries
COMMAND $<TARGET_FILE:avrdude> -C ${AVRDUDE_CONF} -c ? 2>&1 | more > programmers.txt
VERBATIM
)

add_custom_command(
OUTPUT programmer_types.txt
DEPENDS avrdude_binaries
COMMAND $<TARGET_FILE:avrdude> -C ${AVRDUDE_CONF} -c ?type 2>&1 | more > programmer_types.txt
VERBATIM
)

add_custom_command(
OUTPUT parts.txt
DEPENDS avrdude_binaries
COMMAND $<TARGET_FILE:avrdude> -C ${AVRDUDE_CONF} -p ? 2>&1 | more > parts.txt
VERBATIM
)

add_custom_command(
OUTPUT programmers.texi
DEPENDS programmers.txt
COMMAND ${CMAKE_COMMAND}
-D TXT_FILE=programmers.txt
-D TEXI_FILE=programmers.texi
-P "${CMAKE_CURRENT_SOURCE_DIR}/programmers.cmake"
VERBATIM
)

add_custom_command(
OUTPUT programmer_types.texi
DEPENDS programmer_types.txt
COMMAND ${CMAKE_COMMAND}
-D TXT_FILE=programmer_types.txt
-D TEXI_FILE=programmer_types.texi
-P "${CMAKE_CURRENT_SOURCE_DIR}/programmer_types.cmake"
VERBATIM
)

add_custom_command(
OUTPUT parts.texi
DEPENDS parts.txt
COMMAND ${CMAKE_COMMAND}
-D TXT_FILE=parts.txt
-D TEXI_FILE=parts.texi
-D COMMENTS_FILE=${CMAKE_CURRENT_SOURCE_DIR}/parts_comments.txt
-P "${CMAKE_CURRENT_SOURCE_DIR}/parts.cmake"
VERBATIM
)

add_custom_command(
OUTPUT version.texi
COMMAND ${CMAKE_COMMAND} -E echo "@set EDITION ${DOCS_VERSION}" > version.texi
COMMAND ${CMAKE_COMMAND} -E echo "@set VERSION ${DOCS_VERSION}" >> version.texi
COMMAND ${CMAKE_COMMAND} -E echo "@set UPDATED ${DOCS_UPDATED}" >> version.texi
VERBATIM
)

# =====================================
# Custom rules for output files
# =====================================

add_custom_command(
OUTPUT avrdude.info
COMMAND ${MAKEINFO_EXECUTABLE} -o avrdude.info ${TEXINFOS}
DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS}
VERBATIM
)

add_custom_command(
OUTPUT avrdude.dvi
COMMAND ${MAKEINFO_EXECUTABLE}
--dvi
--Xopt=--quiet
--Xopt=--build-dir=dvi
-o avrdude.dvi
${TEXINFOS}
DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS}
VERBATIM
)

add_custom_command(
OUTPUT avrdude.pdf
COMMAND ${MAKEINFO_EXECUTABLE}
--pdf
--Xopt=--quiet
--Xopt=--build-dir=pdf
-o avrdude.pdf
${TEXINFOS}
DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS}
VERBATIM
)

add_custom_command(
OUTPUT avrdude.ps
COMMAND ${MAKEINFO_EXECUTABLE}
--ps
--Xopt=--quiet
--Xopt=--build-dir=ps
-o avrdude.ps
${TEXINFOS}
DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS}
VERBATIM
)

add_custom_command(
OUTPUT avrdude-html/avrdude.html
COMMAND ${TEXI2HTML_EXECUTABLE}
--split=node
--css-include=avrdude.css
--output=avrdude-html
-I ${CMAKE_CURRENT_BINARY_DIR}
${TEXINFOS}
DEPENDS ${TEXINFOS} ${GENERATED_TEXINFOS} avrdude.css
VERBATIM
)

# =====================================
# Custom targets for output files
# =====================================

add_custom_target(info ALL DEPENDS avrdude.info)
add_custom_target(dvi ALL DEPENDS avrdude.dvi)
add_custom_target(pdf ALL DEPENDS avrdude.pdf)
add_custom_target(ps ALL DEPENDS avrdude.ps)
add_custom_target(html ALL DEPENDS avrdude-html/avrdude.html)

# =====================================
# Install
# =====================================

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.info" DESTINATION ${CMAKE_INSTALL_INFODIR})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.dvi" DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.pdf" DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.ps" DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/avrdude-html" DESTINATION ${CMAKE_INSTALL_DOCDIR})
95 changes: 95 additions & 0 deletions src/doc/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# avrdude - A Downloader/Uploader for AVR device programmers
# Copyright (C) 2003 Theodore A. Roth <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

#
# $Id$
#

GENERATED_TEXINFOS = \
$(builddir)/programmers.texi \
$(builddir)/parts.texi \
$(builddir)/programmer_types.texi \
$(builddir)/version.texi

CLEANFILES = \
$(GENERATED_TEXINFOS) \
$(builddir)/stamp-vti

info_TEXINFOS = avrdude.texi

EXTRA_DIST = \
parts_comments.txt

all-local: info html ps pdf

html: avrdude-html/avrdude.html

avrdude-html/avrdude.html: $(srcdir)/$(info_TEXINFOS) $(GENERATED_TEXINFOS)
texi2html --split=node --css-include=$(srcdir)/avrdude.css $(srcdir)/$(info_TEXINFOS)
if [ -e ./avrdude.html -o -e ./avrdude_1.html ]; then \
mkdir -p avrdude-html ; \
mv -f *.html avrdude-html ; \
else \
rm -rf avrdude-html; \
mv -f avrdude avrdude-html; \
fi;

$(builddir)/avrdude.info: $(GENERATED_TEXINFOS)
$(builddir)/avrdude.dvi: $(GENERATED_TEXINFOS)
$(builddir)/avrdude.pdf: $(GENERATED_TEXINFOS)

# if it does not exist make this first
../avrdude$(EXEEXT):
$(MAKE) -C .. avrdude$(EXEEXT)

$(builddir)/programmers.texi: ../avrdude$(EXEEXT) ../avrdude.conf Makefile
../avrdude$(EXEEXT) -C ../avrdude.conf -c \? 2>&1 \
| $(AWK) '$$2 ~ /^=$$/ {printf("@item @code{%s} @tab %s\n",$$1,gensub("[^=]+=[ \t]*","",1))}' \
| sed "s# *,\? *<\?\(http://[^ \t>]*\)>\?#,@*\n@url{\1}#g" \
>programmers.texi

$(builddir)/programmer_types.texi: ../avrdude$(EXEEXT) ../avrdude.conf Makefile
../avrdude$(EXEEXT) -C ../avrdude.conf -c \?type 2>&1 \
| $(AWK) '$$2 ~ /^=$$/ {printf("@item @code{%s} @tab %s\n",$$1,gensub("[^=]+=[ \t]*","",1))}' \
| sed "s#<\?\(http://[^ \t,>]*\)>\?#@url{\1}#g" \
>programmer_types.texi

$(builddir)/parts.texi: ../avrdude$(EXEEXT) ../avrdude.conf parts_comments.txt Makefile
../avrdude$(EXEEXT) -C ../avrdude.conf -p \? 2>&1 \
| $(AWK) '$$2 ~ /^=$$/ {printf("@item @code{%s} @tab %s\n",$$1,$$3)}' \
| sed -e "`sed 's:\([^ \t]*\)[ \t]*\(.*\):s/\1$$/\1 \2/g:g' <parts_comments.txt`" \
>parts.texi

clean-local:
rm -rf avrdude-html *.info

install-data-local: install-docs

install-docs: html ps pdf
$(mkinstalldirs) $(DOC_INST_DIR)
$(INSTALL_DATA) avrdude.ps $(DOC_INST_DIR)/avrdude.ps
$(INSTALL_DATA) avrdude.pdf $(DOC_INST_DIR)/avrdude.pdf
$(mkinstalldirs) $(DOC_INST_DIR)/avrdude-html
@list=`echo avrdude-html/*.html`; \
for file in $$list; \
do \
$(INSTALL_DATA) $$file $(DOC_INST_DIR)/$$file; \
done

uninstall-local:
rm -rf $(DOC_INST_DIR)
20 changes: 20 additions & 0 deletions src/doc/avrdude.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
body { background-color: #ffd; }
h1 { text-shadow: .05em .05em #ccc; }
table {
border: 3px solid #ccf;
background-color: white;
}
div.smallexample {
background-color: #dfd;
border: 3px solid #cfc;
}
div.example {
background-color: #dfd;
border: 3px solid #cfc;
}
samp {
color: blue;
}
code {
color: green;
}
37 changes: 37 additions & 0 deletions src/doc/parts.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# programmers.cmake - create parts.texi from parts.txt
# Copyright (C) 2022 Marius Greuel
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

file(STRINGS ${COMMENTS_FILE} COMMENTS_CONTENTS)

file(STRINGS ${TXT_FILE} TXT_CONTENTS REGEX "=")

set(TEXI_CONTENTS "")
foreach(TXT_LINE IN LISTS TXT_CONTENTS)
string(REGEX REPLACE "^[ \t]*([^ \t]+)[ \t]*=[ \t]*(.*)$" "@item @code{\\1} @tab \\2" TEXI_LINE "${TXT_LINE}")

foreach(COMMENTS_LINE IN LISTS COMMENTS_CONTENTS)
string(REGEX MATCH "^([^ \t]*)(.*)$" DUMMY "${COMMENTS_LINE}")
set(PART_REGEX "${CMAKE_MATCH_1}")
set(COMMENT "${CMAKE_MATCH_2}")
string(REGEX REPLACE "(${PART_REGEX})" "\\1${COMMENT}" TEXI_LINE "${TEXI_LINE}")
endforeach()

set(TEXI_CONTENTS "${TEXI_CONTENTS}${TEXI_LINE}\n")
endforeach()

file(WRITE ${TEXI_FILE} "${TEXI_CONTENTS}")
5 changes: 5 additions & 0 deletions src/doc/parts_comments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
AT90S1200 (****)
AT90S2343 (*)
ATmega2560 (**)
ATmega2561 (**)
ATtiny11 (***)
28 changes: 28 additions & 0 deletions src/doc/programmer_types.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# programmer_types.cmake - create programmer_types.texi from programmer_types.txt
# Copyright (C) 2022 Marius Greuel
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

file(STRINGS ${TXT_FILE} TXT_CONTENTS REGEX "=")

SET(TEXI_CONTENTS "")
foreach(TXT_LINE IN LISTS TXT_CONTENTS)
string(REGEX REPLACE "^[ \t]*([^ \t]+)[ \t]*=[ \t]*(.*)$" "@item @code{\\1} @tab \\2" TEXI_LINE "${TXT_LINE}")
string(REGEX REPLACE "<?(http[s]?://[^ \t,>]+)>?" "@url{\\1}" TEXI_LINE "${TEXI_LINE}")
set(TEXI_CONTENTS "${TEXI_CONTENTS}${TEXI_LINE}\n")
endforeach()

file(WRITE ${TEXI_FILE} "${TEXI_CONTENTS}")
Loading

0 comments on commit 2da2e88

Please sign in to comment.