CC = gcc

NAME = libmemmove.so
SRCS = apex_memmove.c apex_memmove_real.c apex_memmove_wrap.c
TEST_SRCS = main.c

OBJS = $(SRCS:.c=.o)
TEST_OBJS = $(TEST_SRCS:.c=.o)

CFLAGS  = -W -Wall -Wextra
CFLAGS += -fPIC
CFLAGS += -O3 -march=native

LDFLAGS = -fPIC -shared -O3

$(NAME): $(OBJS)
	$(CC) $(LDFLAGS) $(OBJS) -o $@

$(TEST_OBJS) $(OBJS): Makefile

all: $(NAME) test
test: $(NAME) $(TEST_OBJS)
	$(CC) -o $@ $(TEST_OBJS)

clean:
	rm -f $(OBJS) $(TEST_OBJS)

fclean: clean
	rm -f $(NAME) test

re: fclean all

.PHONY: all clean fclean re
.DEFAULT_GOAL = all
