63 lines
1.2 KiB
Makefile
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.asm \
|
|
$(SRC_DIR)/ft_strcpy.asm \
|
|
$(SRC_DIR)/ft_strcmp.asm \
|
|
$(SRC_DIR)/ft_write.asm \
|
|
$(SRC_DIR)/ft_read.asm \
|
|
$(SRC_DIR)/ft_strdup.asm \
|
|
$(SRC_DIR)/ft_memcpy.asm \
|
|
$(SRC_DIR)/ft_isspace.asm \
|
|
$(SRC_DIR)/ft_bzero.asm \
|
|
$(SRC_DIR)/ft_atoibase.asm \
|
|
$(SRC_DIR)/ft_list_push_front.asm \
|
|
$(SRC_DIR)/ft_list_size.asm \
|
|
$(SRC_DIR)/ft_list_sort.asm
|
|
|
|
OBJS=$(patsubst $(SRC_DIR)/%.asm,$(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)/%.asm
|
|
$(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)
|