FROM alpine as base
ARG PREFIX=/usr/local
ARG DESTDIR=/opt/spm/libjpeg-10
RUN apk update && apk add \
	make \
	gcc \
	pkgconf \
	musl-dev \
	wget
RUN wget https://www.ijg.org/files/jpegsrc.v10.tar.gz
RUN tar -xf jpegsrc.v10.tar.gz
WORKDIR /build-libjpeg
RUN CFLAGS='-ffunction-sections -fdata-sections -Os' \
    ../jpeg-10/configure \
    --enable-shared=no
RUN make -j$(nproc)
RUN make install DESTDIR=$DESTDIR
FROM scratch
COPY --from=base /opt/spm/libjpeg-10/usr/local/ /opt/spm/libjpeg-10/
