42_libasm/Makefile
2024-09-11 20:20:49 +02:00

41 lines
642 B
Makefile

SRCDIR = src
OBJDIR = obj
BUILDDIR = build
SRC := $(wildcard $(SRCDIR)/*.asm)
OBJ := $(patsubst $(SRCDIR)/%.asm,$(OBJDIR)/%.o,$(SRC))
CC = gcc
CFLAGS = -g
AS = nasm
ASFLAGS = -f elf64 -g
AR = ar
ARFLAGS =
NAME = libasm.a
$(OBJDIR)/%.o: $(SRCDIR)/%.asm
mkdir -p $(OBJDIR)
$(AS) $(ASFLAGS) $< -o $@
all : $(NAME)
test : $(NAME)
$(CC) $(CFLAGS) test/test.c $(BUILDDIR)/$(NAME) -o $(BUILDDIR)/test
valgrind --leak-check=full $(BUILDDIR)/test
clean :
rm -rf $(OBJDIR)
fclean : clean
rm -rf $(BUILDDIR)
$(NAME) : $(OBJ)
mkdir -p $(BUILDDIR)
$(AR) -rc $(BUILDDIR)/$(NAME) $(OBJ)
re: fclean all
.PHONY: clean fclean test all re