add Makefile's comment
This commit is contained in:
parent
83caba483f
commit
e9c28e42e4
50
Makefile
50
Makefile
|
@ -1,34 +1,50 @@
|
||||||
# VARIABLES
|
# [--------------------DIRECTORIES--------------------]
|
||||||
CXX = g++
|
# SRC_DIR is the source directory
|
||||||
SRC_DIR = src
|
# OBJ_DIR is the object directory
|
||||||
OBJ_DIR = .obj
|
# INC_DIR is the header directory
|
||||||
INC_DIR = inc
|
SRC_DIR := src
|
||||||
WFLAGS = -Wall
|
OBJ_DIR := obj
|
||||||
OFLAG = -o
|
INC_DIR := inc
|
||||||
TARGET = main
|
|
||||||
EXEC = ./$(TARGET)
|
# [--------------------COMPILE & RUN--------------------]
|
||||||
INCLUDE = -I $(INC_DIR)
|
# CXX is the keyword to compile .cpp src files
|
||||||
|
# WFLAG is a flag to detect all the warnings
|
||||||
|
# OFLAG is the flag to rename the output of the compiler
|
||||||
|
# TARGET is the name of the output
|
||||||
|
# INCLUDE add to g++ path the custom include path
|
||||||
|
CXX := g++
|
||||||
|
WFLAGS := -Wall
|
||||||
|
OFLAG := -o
|
||||||
|
TARGET := main
|
||||||
|
INCLUDE := -I $(INC_DIR)
|
||||||
|
|
||||||
|
|
||||||
# FUNCTION:
|
# [--------------------FUNCTION--------------------]
|
||||||
SRCS := $(shell find $(SRC_DIR) -name "*.cpp") # extract all file in src/
|
# SRCS extract all file in src/
|
||||||
FILES := $(notdir $(basename $(SRCS))) # extract the name of the file
|
# FILES extract the name of the file
|
||||||
OBJS := $(addprefix $(OBJ_DIR)/,$(addsuffix .o,$(FILES))) # concat obj/ + FILES + .o
|
# OBJS concat obj/ + FILES + .o
|
||||||
|
SRCS := $(shell find $(SRC_DIR) -name "*.cpp")
|
||||||
|
FILES := $(notdir $(basename $(SRCS)))
|
||||||
|
OBJS := $(addprefix $(OBJ_DIR)/,$(addsuffix .o,$(FILES)))
|
||||||
|
|
||||||
|
|
||||||
all: execute
|
all: execute
|
||||||
|
|
||||||
execute: linking
|
execute: linking
|
||||||
@ echo execute...
|
@ echo execute...
|
||||||
@ $(EXEC)
|
@ ./$(TARGET)
|
||||||
@ echo ...terminate
|
@ echo ...terminate
|
||||||
|
|
||||||
linking: $(OBJS)
|
linking: $(OBJS)
|
||||||
@ echo linking
|
@ echo linking
|
||||||
@ $(CXX) $(WFLAGS) $(OFLAG) $(TARGET) $(OBJS)
|
@ $(CXX) $(WFLAGS) $(OFLAG) $(TARGET) $(OBJS)
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(OBJ_DIR)
|
||||||
@ echo compile $<
|
@ echo compile $<
|
||||||
@ $(CXX) $(WFLAGS) -c $< $(OFLAG) $@ $(INCLUDE)
|
@ $(CXX) $(WFLAGS) -c $< $(OFLAG) $@ $(INCLUDE)
|
||||||
|
|
||||||
|
$(OBJ_DIR):
|
||||||
|
mkdir -p $(OBJ_DIR)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@ -rm -f $(OBJS)
|
@ rm -rf $(OBJ)
|
Loading…
Reference in New Issue