42_libasm/Makefile

41 lines
615 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
$(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