2023-04-17 19:05:52 +02:00
|
|
|
# [--------------------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)))
|
|
|
|
|
2023-04-17 16:45:43 +02:00
|
|
|
|
2023-04-18 00:22:23 +02:00
|
|
|
#---------------------------------------------------
|
2023-04-17 22:49:14 +02:00
|
|
|
all:
|
2023-04-18 00:22:23 +02:00
|
|
|
<<<<<<< HEAD
|
2023-04-17 22:49:14 +02:00
|
|
|
|
2023-04-17 19:54:18 +02:00
|
|
|
all:
|
|
|
|
|
2023-04-17 16:45:43 +02:00
|
|
|
|
2023-04-18 00:22:23 +02:00
|
|
|
=======
|
|
|
|
#---------------------------------------------------
|
|
|
|
>>>>>>> b5b04b6 (implement my first regexp)
|
2023-04-17 16:45:43 +02:00
|
|
|
execute: linking
|
|
|
|
@ echo execute...
|
2023-04-17 19:05:52 +02:00
|
|
|
@ ./$(TARGET)
|
2023-04-17 16:45:43 +02:00
|
|
|
@ echo ...terminate
|
2023-04-18 00:22:23 +02:00
|
|
|
#---------------------------------------------------
|
2023-04-17 16:45:43 +02:00
|
|
|
linking: $(OBJS)
|
|
|
|
@ echo linking
|
|
|
|
@ $(CXX) $(WFLAGS) $(OFLAG) $(TARGET) $(OBJS)
|
2023-04-18 00:22:23 +02:00
|
|
|
#---------------------------------------------------
|
2023-04-17 19:05:52 +02:00
|
|
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(OBJ_DIR)
|
2023-04-17 16:45:43 +02:00
|
|
|
@ echo compile $<
|
|
|
|
@ $(CXX) $(WFLAGS) -c $< $(OFLAG) $@ $(INCLUDE)
|
2023-04-18 00:22:23 +02:00
|
|
|
#---------------------------------------------------
|
2023-04-17 19:05:52 +02:00
|
|
|
$(OBJ_DIR):
|
|
|
|
mkdir -p $(OBJ_DIR)
|
2023-04-18 00:22:23 +02:00
|
|
|
#---------------------------------------------------
|
2023-04-17 16:45:43 +02:00
|
|
|
clean:
|
2023-04-17 19:54:18 +02:00
|
|
|
@ rm -rf $(OBJ)
|
2023-04-18 00:22:23 +02:00
|
|
|
#---------------------------------------------------
|
2023-04-17 19:54:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
# 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:
|
2023-04-17 22:49:14 +02:00
|
|
|
@ read -p "Enter git message: " msg; \
|
2023-04-17 19:54:18 +02:00
|
|
|
git commit -am "$$msg"
|
|
|
|
|
|
|
|
# remove a file only on git, not local
|
|
|
|
_remove: git_rm git_push
|
|
|
|
|
|
|
|
git_rm:
|
|
|
|
git rm --cached $(FILE)
|
2023-04-18 00:22:23 +02:00
|
|
|
|
|
|
|
git_reset: _dump _reset
|
|
|
|
|
|
|
|
_reset:
|
|
|
|
git reset --hard HEAD^
|
|
|
|
|
|
|
|
# awk work with regexp
|
|
|
|
# the expression is $1 ~ /commit/ { print $2 }:
|
|
|
|
# $N -> nth word
|
|
|
|
# ~ -> when the operand coincide is true
|
|
|
|
# /word/: -> the word appears
|
|
|
|
# translate: write only the second word
|
|
|
|
# where appears "commit" in first field
|
|
|
|
|
|
|
|
_dump:
|
|
|
|
@ git log | awk '$$1 ~ /commit/ { print $$2 }' > dump_git_tree.txt
|
|
|
|
|
2023-04-17 19:54:18 +02:00
|
|
|
|
|
|
|
# difference between local and git
|
|
|
|
git_diff:
|
|
|
|
git diff
|