libasm/Makefile
2026-06-22 14:30:12 +02:00

63 lines
1.2 KiB
Makefile

NASM=nasm
NASMFLAGS=-f elf64 -g -F dwarf -D PIC
AR=ar
ARFLAGS=rcs
CC=gcc
CFLAGS=-Wall -g
SRC_DIR=src
OBJ_DIR=obj
LIB_NAME=asm
STATIC_LIB=lib$(LIB_NAME).a
SHARED_LIB=lib$(LIB_NAME).so
SRCS=$(SRC_DIR)/ft_strlen.s \
$(SRC_DIR)/ft_strcpy.s \
$(SRC_DIR)/ft_strcmp.s \
$(SRC_DIR)/ft_write.s \
$(SRC_DIR)/ft_read.s \
$(SRC_DIR)/ft_strdup.s \
$(SRC_DIR)/ft_memcpy.s \
$(SRC_DIR)/ft_isspace.s \
$(SRC_DIR)/ft_bzero.s \
$(SRC_DIR)/ft_atoibase.s \
$(SRC_DIR)/ft_list_push_front.s \
$(SRC_DIR)/ft_list_size.s \
$(SRC_DIR)/ft_list_sort.s
OBJS=$(patsubst $(SRC_DIR)/%.s,$(OBJ_DIR)/%.o,$(SRCS))
DEPS=$(OBJS:.o=.d)
.PHONY: all clean fclean re dirs static shared
all: dirs $(STATIC_LIB) $(SHARED_LIB)
dirs:
@mkdir -p $(OBJ_DIR)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.s
$(NASM) $(NASMFLAGS) $< -o $@
$(STATIC_LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $^
$(SHARED_LIB): $(OBJS)
$(CC) -shared -o $@ $^
static: $(STATIC_LIB)
shared: $(SHARED_LIB)
test: test.c $(STATIC_LIB)
$(CC) $(CFLAGS) test.c -L. -l$(LIB_NAME) -o test -Wl,-rpath=.
clean:
$(RM) -rf $(OBJ_DIR)
fclean: clean
$(RM) $(STATIC_LIB) $(SHARED_LIB) test
re: fclean
$(MAKE) all
-include $(DEPS)