default: all #==================================================================================================# #-------------------------------------------- Shell -----------------------------------------------# #==================================================================================================# SHELL := /bin/sh #==================================================================================================# #-------------------------------------------- Directories -----------------------------------------# #==================================================================================================# INCS_DIR = inc/ SRCS_DIR = src/ OBJS_DIR = obj/ LFT_DIR = libft/ MLX_DIR = minilibx/ MLX_GNU_DIR = minilibx-linux/ MLX_BSD_DIR = minilibx-bsd/ #==================================================================================================# #---------------------------------------------- Files ---------------------------------------------# #==================================================================================================# INCS = cub3d.h INCS += cub3d_defines.h INCS += cub3d_structs.h #--------------------------------------------------------------------------------------------------# SRCS_NAME = main.c SRCS_NAME += ft_init_lists.c SRCS_NAME += ft_hooks_and_loops.c SRCS_NAME += ft_key_events.c SRCS_NAME += ft_click_close.c SRCS_NAME += ft_exit.c SRCS_NAME += ft_parse_map.c SRCS_NAME += ft_select_get.c SRCS_NAME += ft_get_screen_size.c SRCS_NAME += ft_get_res.c SRCS_NAME += ft_get_tex.c SRCS_NAME += ft_get_sprite.c SRCS_NAME += ft_get_colors.c SRCS_NAME += ft_get_map.c SRCS_NAME += ft_get_map_dims.c SRCS_NAME += ft_get_tex_nl.c SRCS_NAME += ft_get_tex_extra.c SRCS_NAME += ft_get_path_nl.c SRCS_NAME += ft_get_nlvl_pos.c SRCS_NAME += ft_get_player_spawn.c SRCS_NAME += ft_get_music.c SRCS_NAME += ft_get_darkness.c SRCS_NAME += ft_get_traps.c SRCS_NAME += ft_get_sprite_spawns.c SRCS_NAME += ft_set_minimap_scale.c SRCS_NAME += ft_check_missing.c SRCS_NAME += ft_check_not_found.c SRCS_NAME += ft_check_map_line.c SRCS_NAME += ft_check_map_surrounds.c SRCS_NAME += ft_free_words.c SRCS_NAME += ft_error.c SRCS_NAME += ft_init_winlx.c SRCS_NAME += ft_draw_square.c SRCS_NAME += ft_draw_circle.c SRCS_NAME += ft_draw_map.c SRCS_NAME += ft_draw_scene.c SRCS_NAME += ft_basic_keys.c SRCS_NAME += ft_extra_keys.c SRCS_NAME += ft_wall_cast.c SRCS_NAME += ft_rgb_to_hex.c SRCS_NAME += ft_hex_to_rgb.c SRCS_NAME += ft_raycasting.c SRCS_NAME += ft_init_s_ray.c SRCS_NAME += ft_init_map.c SRCS_NAME += ft_tex_init.c SRCS_NAME += ft_detect.c SRCS_NAME += ft_check_ext.c SRCS_NAME += ft_draw_textures.c SRCS_NAME += ft_key_release.c SRCS_NAME += ft_convert_keycode.c SRCS_NAME += ft_key_loop.c SRCS_NAME += ft_draw_hud.c SRCS_NAME += ft_music.c SRCS_NAME += ft_draw_sprite.c SRCS_NAME += ft_draw_sprite_extra.c SRCS_NAME += ft_warp_level.c SRCS_NAME += ft_save_to_bmp.c SRCS_NAME += ft_treat_args.c SRCS_NAME += ft_init_funptr.c SRCS_NAME += ft_init_bmp.c SRCS_NAME += ft_floor_cast.c SRCS_NAME += ft_floor_cast_inits.c SRCS_NAME += ft_suffer_animation.c SRCS_NAME += ft_draw_life_bar.c SRCS_NAME += ft_init_sfx.c SRCS_NAME += ft_sfx_death.c SRCS_NAME += ft_sfx_footstep.c SRCS_NAME += ft_sfx_new_level.c SRCS_NAME += ft_sfx_pain.c SRCS_NAME += ft_sfx_trap.c SRCS_NAME += ft_sfx_heal.c SRCS_NAME += ft_sfx_weapon_one.c SRCS_NAME += ft_sfx_weapon_two.c SRCS_NAME += ft_sfx_weapon_two_alt.c SRCS_NAME += ft_sfx_weapon_three.c SRCS_NAME += ft_sfx_ooa.c SRCS_NAME += ft_death_screen.c SRCS_NAME += ft_death_hooks.c SRCS_NAME += ft_init_sprites.c SRCS_NAME += ft_get_fps_count.c SRCS_NAME += ft_find_item.c SRCS_NAME += ft_tex_weap_init.c SRCS_NAME += ft_draw_handweap.c SRCS_NAME += ft_switch_weapons.c SRCS_NAME += ft_check_missing_defines.c SRCS_NAME += ft_check_missing_sfx.c SRCS_NAME += ft_del_tex.c SRCS_NAME += ft_del_map.c SRCS_NAME += ft_del_sprites_lists.c SRCS_NAME += ft_del_sfx_cmd.c SRCS_NAME += ft_get_spawns.c SRCS_NAME += ft_tex_num_init.c SRCS_NAME += ft_tex_sprites_extra_init.c SRCS_NAME += ft_draw_health_caption.c SRCS_NAME += ft_draw_ammo_caption.c SRCS_NAME += ft_draw_map_back.c SRCS_NAME += ft_draw_ammo_back.c SRCS_NAME += ft_draw_ammo_bar.c SRCS_NAME += ft_shoot.c SRCS_NAME += ft_hud_threads.c SRCS_NAME += ft_hud_threads_next.c SRCS_NAME += ft_wall_threads.c SRCS_NAME += ft_floor_threads.c SRCS_NAME += ft_castray_loop.c SRCS_NAME += ft_sort_s_t.c SRCS_NAME += ft_big_t.c SRCS_NAME += ft_time.c SRCS_NAME += ft_init_bad_boys.c SRCS_NAME += ft_bad_boy_actions.c SRCS_NAME += ft_select_bad_boy_action.c SRCS_NAME += ft_collision.c SRCS_NAME += ft_damage_bad_boy.c SRCS_NAME += ft_sfx_bb_death.c SRCS_NAME += ft_sfx_bb_scream.c SRCS_NAME += ft_sfx_bb_fire.c SRCS_NAME += ft_can_it_shoot.c SRCS_NAME += ft_tex_bad_boy_init.c #--------------------------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME}) #--------------------------------------------------------------------------------------------------# OBJS = $(patsubst ${SRCS_DIR}%.c,${OBJS_DIR}%.o,${SRCS}) #--------------------------------------------------------------------------------------------------# LFT_SRCS = $(shell find libft/src -name "*.c") #==================================================================================================# #--------------------------------------------- UNIX -----------------------------------------------# #==================================================================================================# MKDIR = mkdir -p RM = rm -rf MV = mv OS = $(shell uname) ifeq (${OS}, Darwin) # SCR_SZE = $(shell osascript -e 'tell application "Finder" to get bounds of window of desktop' \ | tr ',' 'x' | tr -d '\n' | tr -d ' ' | cut -c 5-) SCR_SZE = 1920x1080 else SCR_SZE = $(shell xdpyinfo | grep dimensions | awk '{print $$2}') endif #==================================================================================================# #------------------------------------------ Compiler ----------------------------------------------# #==================================================================================================# ifeq (${OS}, Linux) DBG = -ggdb else DBG = -glldb endif FSANITIZE = -fsanitize=address #--------------------------------------------------------------------------------------------------# ifeq (${OS}, Linux) CC = gcc else CC = clang endif #--------------------------------------------------------------------------------------------------# CFLAGS = -std=c89 CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Werror CFLAGS += -pedantic CFLAGS += -pthread #--------------------------------------------------------------------------------------------------# ifdef DEBUG CFLAGS += ${DBG} endif #--------------------------------------------------------------------------------------------------# ifdef ASAN CFLAGS += ${DBG} CFLAGS += ${FSANITIZE} endif #--------------------------------------------------------------------------------------------------# CDEFS = -D_DEFAULT_SOURCE CDEFS += -DFT_SCR_SIZE=\"${SCR_SZE}\" ifeq (${OS}, Darwin) CDEFS += -DFT_OS=1 else ifeq (${OS}, Linux) CDEFS += -DFT_OS=2 else CDEFS += -DFT_OS=3 endif #--------------------------------------------------------------------------------------------------# NAME = Cub3D #==================================================================================================# #------------------------------------------ Rules -------------------------------------------------# #==================================================================================================# ${OBJS_DIR}%.o: ${SRCS_DIR}%.c ${INCS_DIR} @${MKDIR} ${OBJS_DIR} ifeq (${OS}, Darwin) ${CC} -c ${CFLAGS} ${CDEFS} -I${LFT_DIR}${INCS_DIR} -I${MLX_DIR} -I${INCS_DIR} -o $@ $< else ifeq (${OS}, Linux) ${CC} -c ${CFLAGS} ${CDEFS} -I${LFT_DIR}${INCS_DIR} -I${MLX_GNU_DIR} -I${INCS_DIR} -o $@ $< else ${CC} -c ${CFLAGS} ${CDEFS} -I${LFT_DIR}${INCS_DIR} -I${MLX_BSD_DIR} -I${INCS_DIR} -o $@ $< endif #--------------------------------------------------------------------------------------------------# ${NAME}: ${OBJS} ${LFT_SRCS} ${LFT_DIR}${INCS_DIR}libft.h ifeq (${OS}, Darwin) @$(MAKE) --no-print-directory -C ${MLX_DIR} all else ifeq (${OS}, Linux) @${MAKE} --no-print-directory -C ${MLX_GNU_DIR} all else @${MAKE} --no-print-directory -C ${MLX_BSD_DIR} all endif ifdef ASAN @$(MAKE) --no-print-directory -C ${LFT_DIR} all ASAN=1 else @$(MAKE) --no-print-directory -C ${LFT_DIR} all endif ifeq (${OS}, Darwin) ${CC} ${CFLAGS} -o $@ ${OBJS} -L${LFT_DIR} -L${MLX_DIR} -lft -lmlx -lm -lpthread \ -framework OpenGL -framework AppKit else ifeq (${OS}, Linux) ${CC} ${CFLAGS} -o $@ ${OBJS} -L${LFT_DIR} -L${MLX_GNU_DIR} \ -lft -lX11 -lXext -lmlx -lm -lbsd -lpthread else ${CC} ${CFLAGS} -o $@ ${OBJS} -L${LFT_DIR} -L${MLX_BSD_DIR} -L/usr/local/lib \ -lft -lX11 -lXext -lmlx -lm -lpthread endif #--------------------------------------------------------------------------------------------------# all: ${NAME} #--------------------------------------------------------------------------------------------------# clean: ifeq (${OS}, Darwin) @$(MAKE) --no-print-directory -C ${MLX_DIR} clean else ifeq (${OS}, Linux) @${MAKE} --no-print-directory -C ${MLX_GNU_DIR} clean else @${MAKE} --no-print-directory -C ${MLX_BSD_DIR} clean endif @$(MAKE) --no-print-directory -C ${LFT_DIR} clean ${RM} ${OBJS_DIR} #--------------------------------------------------------------------------------------------------# fclean: clean @$(MAKE) --no-print-directory -C ${LFT_DIR} fclean ifeq (${OS}, Linux) ${RM} ${MLX_GNU_DIR}libmlx_x86_64.a endif ifeq (${OS}, FreeBSD) ${RM} ${MLX_BSD_DIR}libmlx_FreeBSD.a endif ${RM} ${NAME} ${RM} ${NAME}.dSYM ${RM} ${NAME}.core #--------------------------------------------------------------------------------------------------# re: fclean all #--------------------------------------------------------------------------------------------------# bonus: all #--------------------------------------------------------------------------------------------------# run: all @./${NAME} "map/quest_start.cub" #--------------------------------------------------------------------------------------------------# .PHONY: all clean clean fclean re bonus run default #============================================== EOF ===============================================#