lang/compile
2025-10-15 23:18:21 +02:00

22 lines
404 B
Bash
Executable File

#!/bin/sh
set -e
set -x
LD_ARGS="-nostdlib -static"
NASM_FLAG="-felf64 -g"
LIBS="./lib/core/core.a ./lib/libft/lib/libft.a"
COMPILER_PATH=./bin/langc
filename=$1
comp_out=${filename%.lang}.s
nasm_out=${comp_out%.s}.o
PROGNAME=${filename%.lang}
${COMPILER_PATH} ${filename}
nasm ${NASM_FLAG} ${comp_out} -o ${nasm_out}
ld ${nasm_out} ${LD_ARGS} ${LIBS} -o ${PROGNAME}
rm -rf ${comp_out} ${nasm_out}