3 ## This file is part of AutoGen.
5 ## AutoGen Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
7 ## AutoGen is free software: you can redistribute it and/or modify it
8 ## under the terms of the GNU General Public License as published by the
9 ## Free Software Foundation, either version 3 of the License, or
10 ## (at your option) any later version.
12 ## AutoGen is distributed in the hope that it will be useful, but
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 ## See the GNU General Public License for more details.
17 ## You should have received a copy of the GNU General Public License along
18 ## with this program. If not, see <http://www.gnu.org/licenses/>.
20 PS4='+mtx=${FUNCNAME:-=}-$LINENO> '
25 typeset -r prog=$(basename "$0" .sh)
26 typeset -r progdir=$(\cd $(dirname "$0") && pwd -P)
27 typeset -r program=${progdir}/$(basename "$0")
31 . ${top_builddir:-..}/config/shdefs
35 exec 1> ${TMPDIR}/err-report.txt 2>&1
36 echo "mk-agen-texi FAILED: $*"
40 cat ${TMPDIR}/err-report.txt
42 echo leaving ${TMPDIR} in place
49 TMPDIR=`pwd`/ag-texi-$$.d
51 mkdir ${TMPDIR} || die "cannot make ${TMPDIR} directory"
55 *x* ) trap "echo 'saved tmp dir: ${TMPDIR}';chmod 777 ${TMPDIR}" EXIT
57 * ) trap "rm -rf ${TMPDIR}" EXIT
61 LOG_FILE=${TMPDIR}/texi.log
63 exec 8>&2 2> ${LOG_FILE}
67 . ${top_builddir}/config/shdefs
68 : ${MAKE=`which make`}
70 srcdir=`cd ${srcdir} >/dev/null ; pwd`
73 for d in ${top_srcdir} ${top_builddir} \
74 ${top_builddir}/autoopts ${top_srcdir}/autoopts
76 (\cd ${d} && pwd) 2>/dev/null
81 CFLAGS="${INCLUDES} "`echo ${CFLAGS} | \
82 ${SED:-sed} -e "s/-Werror[^ ${ht}]*//g;s/-Wextra//g"`
85 test -d ${top_builddir}/autoopts/.libs \
86 && echo ${top_builddir}/autoopts/.libs \
87 || echo ${top_builddir}/autoopts
90 export CC CFLAGS LIBS MAKE LOG_FILE TMPDIR
95 # Now auto-export variables:
99 PATH=${top_builddir}/columns:${PATH}
100 timer=`expr ${AG_TIMEOUT} '*' 5`
101 d=`find ${top_builddir}/autoopts -type f -name libopts.a -print`
102 test -f "$d" || die "Cannot locate libopts.a"
105 eval `${EGREP} '^AG_[A-Z_]*' ${top_srcdir}/VERSION`
107 AGsrc=${top_srcdir}/agen5
108 OPTIONS_DEF=${AGsrc}/opts.def
109 GETDEF_SRC=`${FGREP} -l '/*=' ${AGsrc}/*.[ch] ${AGsrc}/*.scm`
111 for d in "${top_builddir}" "${top_srcdir}"
112 do test -f "$d/agen5/invoke-autogen.texi" || continue
113 AGEN_TEXI=${d}/agen5/invoke-autogen.texi
116 DOC_TEXT=${top_srcdir}/doc/autogen-texi.txt
119 ${top_srcdir}/doc/bitmaps.texi
120 ${top_builddir}/columns/invoke-columns.texi
121 ${top_builddir}/getdefs/invoke-getdefs.texi
122 ${top_builddir}/xml2ag/invoke-xml2ag.texi
123 ${top_srcdir}/doc/snprintfv.texi"
126 ${AGsrc}/defParse-fsm.c
128 ${top_builddir}/autoopts/libopts.texi
129 ${top_srcdir}/doc/autogen-intro.texi
132 DOC_TEMPLATE=${top_builddir}/doc/auto_gen.tpl
135 echo ${DOC_TEMPLATE} ${OPTIONS_DEF} ${ADDON_MENU} ${ADDON_TEXI} \
136 ${DOC_INCLUDES} ${GETDEF_SRC} ${DOC_TEXT}`
141 # We have our executables and texi's. Collect the definitions:
145 gd_cfg=${TMPDIR}/getdefs.cfg
148 output ${TMPDIR}/${GEN_BASE}.def
152 template auto_gen.tpl
153 assign ag-texi = invoke-autogen.texi
154 subblock exparg = arg_name,arg_desc,arg_optional,arg_list
157 tf=invoke-autogen.texi
158 test -f ${tf} || ln -s ${AGEN_TEXI} ${tf}
160 for f in ${ADDON_TEXI}
167 test -f ${tf} || ln -s ${f} ${tf}
168 echo "assign addon-texi = ${tf}"
171 for f in ${GETDEF_SRC}
176 echo + ${GDexe} load-opt=${gd_cfg} >&8
177 ${GDexe} load-opt=${gd_cfg} || die cannot run ${GDexe}
182 # Make sure the executables are there
184 test -x ${AGexe} || (cd `dirname ${AGexe}` ; ${MAKE}) || exit 0
185 test -x ${GDexe} || (cd `dirname ${GDexe}` ; ${MAKE}) || exit 0
186 test -x ${CLexe} || (cd `dirname ${CLexe}` ; ${MAKE}) || exit 0
187 PATH="`dirname ${AGexe}`:`dirname ${CLexe}`:$PATH"
189 # See to it that the .texi files have been generated, too.
191 for f in ${ADDON_TEXI} ${AGEN_TEXI} \
192 ${top_builddir}/autoopts/libopts.texi
196 ${MAKE} `basename "${f}"` >&2
197 test $? -ne 0 && die MAKE of ${f} failed.
201 # Make sure we have all our sources and generate the doc
203 for f in ${DOC_DEPENDS}
204 do test -f "${f}" || die cannot find doc file: ${f}
205 test -f `basename $f` || ln -s "${f}" .
210 # Validate everything:
218 sh -c set | sed '/^BASH/d'
224 templ-dirs ${top_srcdir}/autoopts/tpl
225 base-name ${GEN_BASE}
226 make-dep F ${GEN_BASE}.dep
231 echo "trace-out >>${TMPDIR}/ag.log"
236 opts="--load-opts=${TMPDIR}/ag.ini"
237 cmd=`echo ${AGexe} ${opts} ${TMPDIR}/${GEN_BASE}.def`
238 echo "${PS4:-+} " ${cmd} >&8
240 timeout ${timer}s ${cmd} || {
241 head -n999999 ${TMPDIR}/ag.ini ${TMPDIR}/*.log
242 die could not regenerate doc
245 test -f ${GEN_BASE}.texi || die "MISSING: ${GEN_BASE}.texi"
252 local sedcmd='/^@author @email/ {
261 *x* ) local dashx=-x ;;
265 title=`sed -n 's/^@title *//p' agdoc.texi`
266 email=--email' '`sed -n "$sedcmd" agdoc.texi`
267 opts="--texi2html ${email}"
268 PS4='+gd=${FUNCNAME:-=}-$LINENO> ' ${SHELL} ${dashx} \
269 ${top_srcdir}/config/gendocs.sh $opts autogen "$title"
275 '\internalpagesizes{46\baselineskip}{6in}{-.25in}{-.25in}{\bindingoffset}{36pt}%'
277 cat > ${tfile}$$ <<- _EOF_
282 @c %**start of header
283 @setfilename ${tfile%.texi}.info
284 @include ${GEN_BASE}.texi
287 if test -f ${tfile} && cmp -s ${tfile} ${tfile}$$
288 then rm -f ${tfile}$$
289 else mv -f ${tfile}$$ ${tfile}
293 PS4='+agt=${FUNCNAME:-=}-$LINENO> '
296 test "X$1" = X--force && {
300 test -f agdoc.texi || build_agdoc
304 gnudocs | gnudoc ) build_gnudocs ;;
311 ## mode: shell-script
312 ## indent-tabs-mode: nil
314 ## sh-basic-offset: 2