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.
 
 

61 lines
1.7 KiB

# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: hroussea <hroussea@student.42lyon.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/08/14 14:44:12 by hroussea #+# #+# #
# Updated: 2021/09/16 22:15:38 by hroussea ### ########lyon.fr #
# #
# **************************************************************************** #
include sources.mk
SRCS_ = ${addprefix ${SRCDIR}/,${SRCS}}
OBJS_ = ${addprefix ${OBJDIR}/,${SRCS:.c=.o}}
DEPS_ = ${OBJS_:.o=.d}
INCS_ = ${addprefix -I,${INCLUDES}}
NAME = ${TARGET}
OBJDIRS_ = ${shell find ${SRCDIR} -type d | sed s/^${SRCDIR}/${OBJDIR}/g}
all: ${TARGET}
clean:
rm -rf ${OBJDIR}
fclean: clean
rm -rf ${TARGET}
re:
${MAKE} fclean
${MAKE} all
ifeq (${ARTIFACT_TYPE},"executable")
${TARGET}: ${OBJS_}
${CC} $^ -o $@
else
ifeq (${ARTIFACT_TYPE},"static_lib")
${TARGET}: ${OBJS_}
${AR} rcs $@ $^
else
${TARGET}:
$(error Please define the ARTIFACT_TYPE Makefile variable ("executable" or "static_lib") in sources.mk)
endif
endif
${OBJDIR}:
mkdir -p ${OBJDIRS_}
${OBJDIR}/%.o: ${SRCDIR}/%.c | ${OBJDIR}
${CC} ${INCS_} -MMD ${CFLAGS} ${OPTFLAGS} -c $< -o $@
norme:
norminette ${SRCDIR}
-include ${DEPS_}
.PHONY: all