#!/bin/sh
set -ex

# cp command
M2-Planet \
    -f /M2-Planet/test/common_x86/functions/file.c \
    -f /M2-Planet/test/common_x86/functions/exit.c \
    -f /M2-Planet/test/common_x86/functions/malloc.c \
    -f /M2-Planet/test/common_x86/functions/getcwd.c \
    -f /M2-Planet/test/common_x86/functions/chdir.c \
    -f functions/string.c \
    -f functions/file_print.c \
    -f functions/match.c \
    -f functions/require.c \
    -f /M2-Planet/functions/calloc.c \
    -f functions/in_set.c \
    -f functions/numerate_number.c \
    -f cp.c \
    --architecture x86 \
    --debug \
    -o cp.M1

blood-elf -f cp.M1 -o cp-footer.M1

M1 \
    -f /M2-Planet/test/common_x86/x86_defs.M1 \
    -f /M2-Planet/test/common_x86/libc-core.M1 \
    -f cp.M1 \
    -f cp-footer.M1 \
    --LittleEndian \
    --architecture x86 \
    -o hold

hex2 \
    -f /M2-Planet/test/common_x86/ELF-i386-debug.hex2 \
    -f hold \
    --LittleEndian \
    --architecture x86 \
    --BaseAddress 0x8048000 \
    -o /after/bin/cp \
    --exec_enable

# chmod command
M2-Planet \
    -f /M2-Planet/test/common_x86/functions/file.c \
    -f /M2-Planet/test/common_x86/functions/exit.c \
    -f /M2-Planet/test/common_x86/functions/malloc.c \
    -f /M2-Planet/test/common_x86/functions/getcwd.c \
    -f /M2-Planet/test/common_x86/functions/chdir.c \
    -f functions/string.c \
    -f functions/file_print.c \
    -f functions/match.c \
    -f functions/require.c \
    -f functions/in_set.c \
    -f functions/numerate_number.c \
    -f /M2-Planet/functions/calloc.c \
    -f /M2-Planet/test/common_x86/functions/stat.c \
    -f chmod.c \
    --architecture x86 \
    --debug \
    -o chmod.M1

blood-elf -f chmod.M1 -o chmod-footer.M1

M1 \
    -f /M2-Planet/test/common_x86/x86_defs.M1 \
    -f /M2-Planet/test/common_x86/libc-core.M1 \
    -f chmod.M1 \
    -f chmod-footer.M1 \
    --LittleEndian \
    --architecture x86 \
    -o hold

hex2 \
    -f /M2-Planet/test/common_x86/ELF-i386-debug.hex2 \
    -f hold \
    --LittleEndian \
    --architecture x86 \
    --BaseAddress 0x8048000 \
    -o /after/bin/chmod \
    --exec_enable
