You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
1.9 KiB

NAME = cub3d
2 years ago
LIBFT = lib/libft.a
MLX = lib/libmlx.a
2 years ago
2 years ago
SRCS = src/main.c src/vectors.c
SRCS += src/mlx/mlx_1.c src/mlx/mlx_2.c
2 years ago
SRCS += src/parsing/parsing.c src/parsing/getline.c src/parsing/map.c src/parsing/utils.c
SRCS += src/render/render.c src/render/minimap.c src/render/utils.c src/render/raycast.c
OBJS = ${SRCS:.c=.o}
CC = gcc
RM = rm -rf
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
2 years ago
LFLAGS = -lXext -lX11 -lm -lz -Llib -lft -lmlx
endif
ifeq ($(UNAME_S), Darwin)
2 years ago
LFLAGS = -framework OpenGL -framework AppKit -Llib -lft -lmlx
endif
2 years ago
CFLAGS = -Werror -Wall -Wextra -O3 -ffast-math -funsafe-math-optimizations
%.o:%.c
${CC} ${CFLAGS} -c $< -o ${<:.c=.o}
all: $(NAME)
$(VERBOSE).SILENT:
$(LIBFT):
mkdir -p lib
echo "Downloading narnaud/libft and making library"
2 years ago
bash -c "if [[ ! -d "libft" ]]; then git clone \
https://git.narnaud.net/nicolas-arnaud/Libft.git libft; fi"
${MAKE} -C libft/
2 years ago
cp libft/libft.a lib/
cp libft/libft.h includes/
echo
$(MLX):
echo "Downloading 42Paris/minilibx and making library"
2 years ago
ifeq ($(UNAME_S), Linux)
2 years ago
bash -c "if [[ ! -d "mlx" ]]; then git clone \
https://github.com/42Paris/minilibx-linux.git mlx; fi"
${MAKE} -C mlx/
cp mlx/libmlx_Linux.a lib/libmlx.a
2 years ago
cp mlx/mlx.h includes/
2 years ago
endif
ifeq ($(UNAME_S), Darwin)
2 years ago
${MAKE} -C mlx_mac/
cp mlx_mac/libmlx.a lib/
cp mlx_mac/mlx.h includes/
2 years ago
endif
echo
$(NAME): $(LIBFT) $(MLX) $(OBJS)
echo Making Cub3D...
2 years ago
${CC} ${OBJS} ${LFLAGS} -o ${NAME}
echo
3 years ago
debug: $(LIBFT)
echo Making Cub3D with debug on...
2 years ago
${CC} ${SRCS} -g -fsanitize=address -D DEBUG=1 ${CFLAGS} ${LFLAGS} -o ${NAME}
echo
clean:
echo Cleaning objects...
${RM} ${OBJS}
echo
fclean: clean
${MAKE} -C libft fclean
2 years ago
${RM} lib/libft.a
${RM} includes/libft.h
2 years ago
${RM} lib/libmlx.a
${RM} includes/mlx.h
echo Cleaning binary...
${RM} ${NAME}
echo
re: fclean all
3 years ago
.PHONY: all clean fclean re debug