-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
52 lines (33 loc) · 1.26 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
NAME = restofyourlife
CC = cc
CFLAGS = -Wextra -Wall -Werror
CFLAGS += -Iinclude -Isrc -O3 -Wunreachable-code -Ofast
# CFLAGS += -DDEBUG=1
LIBS = -ldl -lglfw -pthread -lm
OBJ_DIR = obj/
SRC_DIR = src/
INCLUDE += -I ./include
SRCS = $(addprefix $(SRC_DIR), main.c utils.c vec3.c color.c ray.c sphere.c hittable.c interval.c camera.c \
material.c texture.c rtw_stb_image.c quad.c disk.c box.c translated.c rotated.c onb.c pdf.c )
OBJS = $(patsubst $(SRC_DIR)%.c,$(OBJ_DIR)%.o,$(SRCS))
HDRS = $(addprefix include/, box.h utils.h vec3.h color.h sphere.h ray.h hittable.h hittable_list.h \
rtweekend.h interval.h camera.h material.h texture.h rtw_stb_image.h external/stb_image.h external/stb_image_write.h \
quad.h disk.h translated.h rotated.h onb.h pdf.h)
all: $(NAME)
# Static pattern rule for compilation - adding the .o files in the obj folder
# with includes for the libft that will allow the <libft.h> notation
$(OBJ_DIR)%.o: $(SRC_DIR)%.c
mkdir -p $(@D)
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
build:
@mkdir -p build
$(NAME): $(OBJS) $(HDRS)
$(CC) $(CFLAGS) $(OBJS) $(LIBS) $(INCLUDE) -o $(NAME)
clean:
rm -f $(OBJECTS) *~
@rm -rf $(OBJS)
fclean: clean
@rm -rf $(NAME)
rm -rf build
re: fclean all
.PHONY: all clean fclean re