2023-05-14 16:05:37 +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
|
2023-05-14 17:16:12 +02:00
|
|
|
BIN_DIR := bin
|
2023-05-14 16:05:37 +02:00
|
|
|
|
|
|
|
# [--------------------COMPILE & RUN--------------------]
|
|
|
|
# CXX is the keyword to compile .c 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 := gcc
|
|
|
|
WFLAGS := -Wall
|
|
|
|
OFLAG := -o
|
2023-05-15 10:57:12 +02:00
|
|
|
TARGET1 := $(BIN_DIR)/F4Server
|
|
|
|
TARGET2 := $(BIN_DIR)/F4Client
|
2023-05-14 16:05:37 +02:00
|
|
|
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 "*.c")
|
|
|
|
FILES := $(notdir $(basename $(SRCS)))
|
|
|
|
OBJS := $(addprefix $(OBJ_DIR)/,$(addsuffix .o,$(FILES)))
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------
|
|
|
|
all: execute
|
|
|
|
#---------------------------------------------------
|
2023-05-15 10:57:12 +02:00
|
|
|
execute: linking_s linking_c
|
2023-05-14 16:05:37 +02:00
|
|
|
@ echo execute...
|
2023-05-15 10:57:12 +02:00
|
|
|
@ ./$(TARGET1)
|
2023-05-14 16:05:37 +02:00
|
|
|
@ echo ...terminate
|
|
|
|
#---------------------------------------------------
|
2023-05-15 10:57:12 +02:00
|
|
|
linking_s: $(OBJS) $(BIN_DIR)
|
2023-05-14 16:05:37 +02:00
|
|
|
@ echo linking
|
2023-05-15 10:57:12 +02:00
|
|
|
@ $(CXX) $(WFLAGS) $(OFLAG) $(TARGET1) $(OBJS)
|
|
|
|
#---------------------------------------------------
|
|
|
|
linking_c: $(OBJS) $(BIN_DIR)
|
|
|
|
@ echo linking
|
|
|
|
@ $(CXX) $(WFLAGS) $(OFLAG) $(TARGET2) $(OBJS)
|
2023-05-14 16:05:37 +02:00
|
|
|
#---------------------------------------------------
|
|
|
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(OBJ_DIR)
|
|
|
|
@ echo compile $<
|
|
|
|
@ $(CXX) $(WFLAGS) -c $< $(OFLAG) $@ $(INCLUDE)
|
|
|
|
#---------------------------------------------------
|
|
|
|
$(OBJ_DIR):
|
2023-05-14 17:16:12 +02:00
|
|
|
@ mkdir -p $(OBJ_DIR)
|
|
|
|
#---------------------------------------------------
|
|
|
|
$(BIN_DIR):
|
|
|
|
@ mkdir -p $(BIN_DIR)
|
2023-05-14 16:05:37 +02:00
|
|
|
#---------------------------------------------------
|
|
|
|
clean:
|
|
|
|
@ rm -rf $(OBJ)
|
|
|
|
#---------------------------------------------------
|