-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (61 loc) · 1.37 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
NAME =RTv1
CC =clang
CFLAGS =-Wall -Wextra -Werror
ifdef DEBUG
CFLAGS +=-g
endif
CFLAGS +=-Ofast
SRCDIR =./src/
OBJDIR =./obj/
INCLDIR =./include/
LIBFTDIR=./libft/
SDLDIR =./sdl2/
SRC =$(addprefix $(SRCDIR), \
main.c \
render.c \
render_utils.c \
vec3_basic.c \
vec3_utils.c \
parser.c \
controls.c \
misc.c \
lights.c \
plane.c \
sphere.c \
cylinder.c \
cone.c )
OBJ =$(SRC:$(SRCDIR)%.c=$(OBJDIR)%.o)
INCLUDE =-I$(INCLDIR) -I$(LIBFTDIR)
HEADERS =$(addprefix $(INCLDIR), rtv1.h)
LIBFT =$(addprefix $(LIBFTDIR), libft.a)
LFLAGS =-L$(LIBFTDIR) -lft -lm
OSNAME =$(shell uname -s)
ifeq ($(OSNAME), Darwin)
CG_LIBS =-framework OpenGL -framework AppKit -framework OpenCL \
-framework SDL2 -F$(SDLDIR) -rpath $(SDLDIR)
INCLUDE +=-F$(SDLDIR) \
-I$(SDLDIR)SDL2.framework/Headers/
else
CG_LIBS = `sdl2-config --libs`
endif
.PHONY: all clean fclean re
all: $(NAME)
$(NAME): $(OBJ) $(LIBFT)
$(info Linking objects)
@$(CC) $(OBJ) -o $(NAME) $(LFLAGS) $(CG_LIBS)
$(info Done.)
$(OBJDIR)%.o: $(SRCDIR)%.c $(HEADERS)
$(info Compiling $<)
@mkdir -p $(OBJDIR)
@$(CC) $(CFLAGS) -c $< -o $@ $(INCLUDE)
$(LIBFT):
@make -sC $(LIBFTDIR)
clean:
$(info Deleting objects)
@rm -rf $(OBJDIR)
@make -sC $(LIBFTDIR) clean
fclean: clean
$(info Deleting $(NAME))
@rm -rf $(NAME)
@make -sC $(LIBFTDIR) fclean
re: fclean all