basic makefile libft main
This commit is contained in:
107
Makefile
Normal file
107
Makefile
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
# - - - - - - #
|
||||||
|
# #
|
||||||
|
# COLORS #
|
||||||
|
# #
|
||||||
|
# - - - - - - #
|
||||||
|
|
||||||
|
GRAY = "\e[0;30m"
|
||||||
|
RED = "\e[0;31m"
|
||||||
|
GREEN = "\e[0;32m"
|
||||||
|
YELLOW = "\e[0;33m"
|
||||||
|
BLUE = "\e[0;34m"
|
||||||
|
PURPLE = "\e[0;35m"
|
||||||
|
CYAN = "\e[0;36m"
|
||||||
|
WHITE = "\e[0;37m"
|
||||||
|
|
||||||
|
B_GRAY = "\e[1;30m"
|
||||||
|
B_RED = "\e[1;31m"
|
||||||
|
B_GREEN = "\e[1;32m"
|
||||||
|
B_YELLOW = "\e[1;33m"
|
||||||
|
B_BLUE = "\e[1;34m"
|
||||||
|
B_PURPLE = "\e[1;35m"
|
||||||
|
B_CYAN = "\e[1;36m"
|
||||||
|
B_WHITE = "\e[1;37m"
|
||||||
|
|
||||||
|
RESET = "\e[0m"
|
||||||
|
|
||||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||||
|
# . name = value \ . += append to a variable #
|
||||||
|
# VARIABLES . value . != set result of command #
|
||||||
|
# . name is case sensitive . ?= set if not already set #
|
||||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||||
|
|
||||||
|
# FILES :
|
||||||
|
NAME = computorv1
|
||||||
|
D_LIB = ./libft
|
||||||
|
D_SRCS = ./src
|
||||||
|
D_HEADERS = ./headers
|
||||||
|
SRCS = computorv1.c
|
||||||
|
HEADERS = computorv1.h
|
||||||
|
|
||||||
|
# COMPILATION CONFIG :
|
||||||
|
CC = gcc
|
||||||
|
EXT = c
|
||||||
|
CFLAGS = -Wall -Wextra -Werror $(INCLUDES) -g3
|
||||||
|
LFLAGS = -L$(D_LIB) -lft
|
||||||
|
|
||||||
|
# AUTOMATICALLY CREATED :
|
||||||
|
D_OBJS = builds
|
||||||
|
OBJS = $(SRCS:%.$(EXT)=$(D_OBJS)/%.o)
|
||||||
|
VPATH = $(D_SRCS)
|
||||||
|
F_INCLUDES = $(HEADERS:%=$(D_HEADERS)/%)
|
||||||
|
INCLUDES = -I$(D_HEADERS)
|
||||||
|
ifeq "$(D_OBJS)" "."
|
||||||
|
RM_OBJS = rm -f $(OBJS)
|
||||||
|
else
|
||||||
|
RM_OBJS = rm -rf $(D_OBJS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||||
|
# . target: prerequisites . $@ : target #
|
||||||
|
# RULES . recipe . $< : 1st prerequisite #
|
||||||
|
# . recipe . $^ : all prerequisites #
|
||||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
|
||||||
|
|
||||||
|
all: $(NAME)
|
||||||
|
|
||||||
|
# %.$(EXT) | $(D_OBJS) -> pipe is for order-only prerequisites :
|
||||||
|
# - for each file "%.$(EXT)" :
|
||||||
|
# - if it has been modified since last time
|
||||||
|
# - execute rules on corresponding target file "$(D_OBJS)/%.o"
|
||||||
|
# - and directory "$(D_OBJS)" is order-only prerequisite :
|
||||||
|
# - it must exist before executing rule
|
||||||
|
# - but last time modification is not checked
|
||||||
|
# - it avoids recompiling each time because the build folder was
|
||||||
|
# modified by creation of other objects files
|
||||||
|
$(D_OBJS)/%.o: %.$(EXT) | $(D_OBJS)
|
||||||
|
@echo $(YELLOW)"compilation (objects.o)"$(RESET)
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(D_OBJS):
|
||||||
|
mkdir $@
|
||||||
|
|
||||||
|
$(OBJS): $(F_INCLUDES)
|
||||||
|
|
||||||
|
$(NAME): $(OBJS)
|
||||||
|
@echo $(YELLOW)"build libft"$(RESET)
|
||||||
|
make -C $(D_LIB)
|
||||||
|
@echo $(YELLOW)"linkage (link objects.o)"$(RESET)
|
||||||
|
$(CC) $(OBJS) -o $@ $(LFLAGS)
|
||||||
|
|
||||||
|
run: $(NAME)
|
||||||
|
@echo $(YELLOW)"run"$(RESET)
|
||||||
|
@./$(NAME)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM_OBJS)
|
||||||
|
|
||||||
|
fclean: clean
|
||||||
|
rm -f $(NAME)
|
||||||
|
|
||||||
|
re: fclean all
|
||||||
|
|
||||||
|
leaks: $(NAME)
|
||||||
|
valgrind --leak-check=full --show-leak-kinds=all $(NAME)
|
||||||
|
|
||||||
|
.PHONY : all run clean fclean re leaks
|
||||||
6
headers/computorv1.h
Normal file
6
headers/computorv1.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef COMPUTORV1_H
|
||||||
|
# define COMPUTORV1_H
|
||||||
|
|
||||||
|
# include "../libft/includes/libft.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
15
src/computorv1.c
Normal file
15
src/computorv1.c
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
#include "computorv1.h"
|
||||||
|
|
||||||
|
int main(int ac, char **av)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while(i < ac) {
|
||||||
|
ft_putstr_fd(av[i], 1);
|
||||||
|
ft_putchar_fd('\n', 1);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user