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)
|
|
|
|
|
2023-05-16 18:43:56 +02:00
|
|
|
|
2023-05-14 16:05:37 +02:00
|
|
|
|
|
|
|
# [--------------------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)))
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------
|
2023-05-16 18:46:41 +02:00
|
|
|
all: test
|
2023-05-14 16:05:37 +02:00
|
|
|
#---------------------------------------------------
|
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-16 18:43:56 +02:00
|
|
|
@ ./$(TARGET1) $(ARGS)
|
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)
|
2023-05-16 18:46:41 +02:00
|
|
|
#---------------------------------------------------
|
|
|
|
|
2023-05-17 14:38:44 +02:00
|
|
|
|
|
|
|
|
2023-05-17 14:45:05 +02:00
|
|
|
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
|
|
MKFILE_DIR := $(dir $(mkfile_path))
|
2023-05-17 14:38:44 +02:00
|
|
|
|
2023-05-16 18:46:41 +02:00
|
|
|
ARGSSERVER := 6 7 O X
|
2023-05-17 15:57:10 +02:00
|
|
|
ARGSCLIENT1 := Cacca
|
|
|
|
ARGSCLIENT2 := Molla
|
2023-05-16 18:46:41 +02:00
|
|
|
|
2023-05-17 14:46:16 +02:00
|
|
|
test: comp
|
2023-05-17 14:45:05 +02:00
|
|
|
x-terminal-emulator -e $(MKFILE_DIR)$(TARGET2) $(ARGSCLIENT1)
|
|
|
|
x-terminal-emulator -e $(MKFILE_DIR)$(TARGET2) $(ARGSCLIENT2)
|
2023-05-17 14:38:44 +02:00
|
|
|
./$(TARGET1) $(ARGSSERVER)
|
2023-05-17 14:46:16 +02:00
|
|
|
|
|
|
|
comp: server_c client_c
|
2023-05-17 14:38:44 +02:00
|
|
|
|
|
|
|
server_c:
|
2023-05-19 15:21:15 +02:00
|
|
|
gcc src/F4Server.c src/custom_sem.c src/custom_shm.c src/custom_signal.c src/custom_msgq.c src/errExit.c src/forza4.c src/server.c src/nonsodovemetterle.c -o bin/F4Server -I inc/
|
2023-05-17 14:38:44 +02:00
|
|
|
client_c:
|
2023-05-19 15:21:15 +02:00
|
|
|
gcc src/F4Client.c src/custom_sem.c src/custom_shm.c src/custom_signal.c src/custom_msgq.c src/errExit.c src/forza4.c src/nonsodovemetterle.c -o bin/F4Client -I inc/
|