I'm having trouble building a makefile for a library in nasm, since it requires that you run nasm with one input file at a time. I have tried with the %.o : %.s thing but I'm probably doing it incorrectly since it's not working. Here is what I have:
NAME = libfts.a
SRC_ASM = file1.s \
file2.s \
file3.s \
OBJ_ASM = $(SRC_ASM:.s=.o)
FLAGS = -Wall -Werror -Wextra
CC_ASM = nasm
ASM_FLAGS = -f macho64
all : $(NAME)
$(NAME) : $(OBJ_ASM)
@ar rc $(NAME) $(OBJ_ASM)
@ranlib $(NAME)
#$(OBJ_ASM) : $(SRC_ASM)
# nasm -f macho64 -o $(OBJ_ASM) $(SRC_ASM)
%.o : %.s
nasm $(ASM_FLAGS) -o $@ $<
clean:
rm -f *.o main.o
fclean : clean
rm -f libfts.a
re : fclean all
.PHONY: clean fclean re
I tried commenting and uncommenting the commented part, moving things around, but nothing seems to work for me :(
Right now I'm getting ar: no archive members specified
Other errors I had included as
running instead of nasm
and for just the 1st file in SRC_ASM
thanks :)
The following appears to work fine for me:
The terminal output I get is: