bles
This commit is contained in:
parent
95d7ef4212
commit
b79c9584d5
14
Makefile
14
Makefile
@ -1,5 +1,4 @@
|
||||
# Basic configuration
|
||||
TARGET := langc
|
||||
AFLAGS = -felf64 -F dwarf -g
|
||||
|
||||
ifdef DEBUG
|
||||
@ -10,7 +9,9 @@ endif
|
||||
SRCDIR := src
|
||||
OBJDIR := obj
|
||||
LIBDIR := lib
|
||||
BINDIR := bin
|
||||
|
||||
TARGET := $(BINDIR)/langc
|
||||
# Core directories
|
||||
COREDIR := $(SRCDIR)/core
|
||||
MATHDIR := $(COREDIR)/math
|
||||
@ -132,6 +133,7 @@ ALL_OBJ := $(patsubst $(SRCDIR)/%.s,$(OBJDIR)/%.o,$(ALL_SRC))
|
||||
|
||||
# Library settings
|
||||
LIBNAME := $(LIBDIR)/core/core.a
|
||||
LIBCORE_DIR := $(LIBDIR)/core
|
||||
LIBFTDIR := $(LIBDIR)/libft
|
||||
LIBFT := $(LIBFTDIR)/lib/libft.a
|
||||
LIB_OBJ := $(filter-out $(OBJDIR)/start.o, $(ALL_OBJ))
|
||||
@ -158,14 +160,20 @@ all: prepare-build build-core build-parser build-lexer build-global build-main l
|
||||
# Stage 1: Prepare build environment
|
||||
prepare-build: create-directories
|
||||
|
||||
create-directories: | $(OBJDIRS) $(LIBDIR)
|
||||
create-directories: | $(OBJDIRS) $(LIBDIR) $(LIBCORE_DIR) $(BINDIR)
|
||||
|
||||
$(OBJDIRS):
|
||||
mkdir -p $@
|
||||
|
||||
$(BINDIR):
|
||||
mkdir -p $@
|
||||
|
||||
$(LIBDIR):
|
||||
mkdir -p $@
|
||||
|
||||
$(LIBCORE_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
# Stage 2: Build core modules
|
||||
build-core: build-math build-string build-memory build-vector build-print build-file build-syscall build-string-builder
|
||||
|
||||
@ -214,7 +222,7 @@ $(TARGET): $(ALL_OBJ) $(LIBFT) $(LIBNAME)
|
||||
# Stage 8: Create library
|
||||
create-library: $(LIBNAME)
|
||||
|
||||
$(LIBNAME): $(LIB_OBJ) | $(LIBDIR)
|
||||
$(LIBNAME): $(LIB_OBJ) $(LIBDIR)
|
||||
ar rcs $@ $(LIB_OBJ)
|
||||
|
||||
$(LIBFT):
|
||||
|
||||
9
compile
9
compile
@ -1,17 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
LD_ARGS="-nostdlib -static"
|
||||
NASM_FLAG="-felf64 -g"
|
||||
LIBS="./lib/core/core.a ./lib/libft/lib/libft.a"
|
||||
PROGNAME="langproc"
|
||||
|
||||
COMPILER_PATH=./bin/langc
|
||||
|
||||
filename=$1
|
||||
comp_out=${filename%.lang}.s
|
||||
nasm_out=${comp_output%.s}.o
|
||||
nasm_out=${comp_out%.s}.o
|
||||
PROGNAME=${filename%.lang}
|
||||
|
||||
./langc ${filename}
|
||||
${COMPILER_PATH} ${filename}
|
||||
|
||||
nasm ${NASM_FLAG} ${comp_out} -o ${nasm_out}
|
||||
ld ${nasm_out} ${LD_ARGS} ${LIBS} -o ${PROGNAME}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
# By: vvobis <marvin@42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/09/17 14:23:19 by vvobis #+# #+# #
|
||||
# Updated: 2025/05/14 15:16:25 by vvobis ### ########.fr #
|
||||
# Updated: 2025/05/29 15:50:55 by victor ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -14,7 +14,7 @@ NAME := libft.a
|
||||
|
||||
CC := cc
|
||||
|
||||
CFLAGS := -Wall -Wextra -Werror -mabi=sysv
|
||||
CFLAGS := -Wall -Wextra -Werror -fstack-protector
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -g3
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
%include "./src/core/string_builder/sb.s"
|
||||
%include "./src/inc/c_alignment.s"
|
||||
|
||||
section .data
|
||||
usage: db "Usage: ./debug <file>.lang", 0xa, 0
|
||||
@ -67,10 +68,13 @@ _start:
|
||||
mov rdi, rax
|
||||
mov rdi, [rdi]
|
||||
mov rsi, dot_s
|
||||
call ft_strjoin
|
||||
c_call ft_strjoin
|
||||
mov rdi, rax
|
||||
mov rsi, 0x241
|
||||
mov rdx, 0o644
|
||||
push rdi
|
||||
call putstr
|
||||
pop rdi
|
||||
call open
|
||||
mov [fd_out], rax
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user