#
# This file is licensed under the MIT No Attribution license.
#

FROM alpine

RUN apk --no-cache add \
  bash \
  build-base \
  m4 \
  perl \
;

COPY texinfo.tmp.tar.gz /
WORKDIR /
RUN mkdir texinfo.tmp
WORKDIR texinfo.tmp
RUN tar xzf ../texinfo.tmp.tar.gz
RUN mv * texinfo
WORKDIR texinfo
RUN ./configure
RUN make
RUN make install

COPY groff-*.tar.gz /
WORKDIR /
RUN mkdir groff
WORKDIR groff
RUN tar xzf ../groff-*.tar.gz
RUN mv * groff
WORKDIR groff
RUN sed -i.old \
  -e 's/{ "\\\\-", "2212" }/{ "\\\\-", "002D" }/' \
  src/libs/libgroff/glyphuni.cpp \
;
RUN sed -i.old \
  -e 's/{ "002C", "," },/& { "002D", "\\\\-" },/' \
  src/libs/libgroff/uniglyph.cpp \
;
RUN ./configure
RUN make
RUN make install

COPY dist.tmp /texinfo/texinfo/
WORKDIR /texinfo/texinfo

COPY *.bash.tmp /
ARG v
RUN bash /patch.bash.tmp ${v?}
RUN bash /render.bash.tmp ${v?}
