#!/bin/bash

export CFLAGS=-O3
export JDIR=jpeg-6b
export CC=mb-gcc
export MBDIR=../microblaze_0

make -C $JDIR clean || exit 1
make -C $JDIR libjpeg.a || exit 1

for i in "" "2"
do
    $CC -o djpeg${i}.elf main.c embedded_data.c hwdriver.c spad.c \
        -I$JDIR -L$JDIR -ljpeg  $CFLAGS \
        -mno-xl-soft-mul -mxl-barrel-shift \
        -mno-xl-soft-div -mcpu=v7.10.d  -Wl,-T -Wl,main${i}.ld  -g  \
        -I$MBDIR/include/ -I. -L$MBDIR/lib/ -Wall || exit 1
done
mb-objcopy -O binary  --remove-section=.spad  djpeg.elf djpeg.bin || exit 1
python ../boot/prepare.py djpeg.bin || exit 1


exit 0

