Graphs/Makefile

83 lines
1.6 KiB
Makefile

# [--------------------DIRECTORIES--------------------]
# SRC_DIR is the source directory
# OBJ_DIR is the object directory
# INC_DIR is the header directory
SRC_DIR := src
OBJ_DIR := obj
INC_DIR := inc
# [--------------------COMPILE & RUN--------------------]
# 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--------------------]
# SRCS extract all file in src/
# FILES extract the name of the file
# OBJS concat obj/ + FILES + .o
SRCS := $(shell find $(SRC_DIR) -name "*.cpp")
FILES := $(notdir $(basename $(SRCS)))
OBJS := $(addprefix $(OBJ_DIR)/,$(addsuffix .o,$(FILES)))
all:
all:
execute: linking
@ echo execute...
@ ./$(TARGET)
@ echo ...terminate
linking: $(OBJS)
@ echo linking
@ $(CXX) $(WFLAGS) $(OFLAG) $(TARGET) $(OBJS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(OBJ_DIR)
@ echo compile $<
@ $(CXX) $(WFLAGS) -c $< $(OFLAG) $@ $(INCLUDE)
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
clean:
@ rm -rf $(OBJ)
# random git command
# lista file
git_list:
git ls-tree -r master --name-only
# push
git_push:
git push
# commint add message
_commit: git_commit git_push
git_commit:
@ read -p "Enter git message: " msg; \
git commit -am "$$msg"
# remove a file only on git, not local
_remove: git_rm git_push
git_rm:
git rm --cached $(FILE)
# difference between local and git
git_diff:
git diff