Elaborato_SO/Makefile

82 lines
2.6 KiB
Makefile
Raw Normal View History

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
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
#---------------------------------------------------
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
#---------------------------------------------------
linking_s: $(OBJS) $(BIN_DIR)
2023-05-14 16:05:37 +02:00
@ echo linking
@ $(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
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path))
2023-05-16 18:46:41 +02:00
ARGSSERVER := 6 7 O X
2023-05-17 14:38:44 +02:00
ARGSCLIENT1 := cacca
ARGSCLIENT2 := molla
2023-05-16 18:46:41 +02:00
2023-05-17 14:38:44 +02:00
test: server_c client_c
x-terminal-emulator -e $(mkfile_dir)$(TARGET2) $(ARGSCLIENT1)
x-terminal-emulator -e $(mkfile_dir)$(TARGET2) $(ARGSCLIENT2)
./$(TARGET1) $(ARGSSERVER)
2023-05-16 18:46:41 +02:00
2023-05-17 14:38:44 +02:00
server_c:
2023-05-16 23:27:27 +02:00
gcc src/F4Server.c src/custom_sem.c src/custom_shm.c src/custom_signal.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-16 23:27:27 +02:00
gcc src/F4Client.c src/custom_sem.c src/custom_shm.c src/custom_signal.c src/errExit.c src/forza4.c src/nonsodovemetterle.c -o bin/F4Client -I inc/