From 0f4f3c3261c1936a8826dbb2aeba10f2f0bf320b Mon Sep 17 00:00:00 2001 From: Freak 4L Date: Fri, 27 Sep 2024 23:59:05 +0330 Subject: [PATCH] Update Makefile --- Makefile | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index e7a8605..d937f2b 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,30 @@ -CC=gcc -CFLAGS=-Wall -Wextra -O2 -SRC_DIR=src +# Compiler settings +CC := gcc +CFLAGS := -Wall -Wextra -O2 -all: $(SRC_DIR)/tcp_connect_time $(SRC_DIR)/optimize_tcp_params +# Directories +SRC_DIR := src +BIN_DIR := $(SRC_DIR) -$(SRC_DIR)/tcp_connect_time: $(SRC_DIR)/tcp_connect_time.c - $(CC) $(CFLAGS) -o $@ $< +# Source files and targets +SOURCES := $(wildcard $(SRC_DIR)/*.c) +TARGETS := $(patsubst $(SRC_DIR)/%.c,$(BIN_DIR)/%,$(SOURCES)) -$(SRC_DIR)/optimize_tcp_params: $(SRC_DIR)/optimize_tcp_params.c - $(CC) $(CFLAGS) -o $@ $< +# Phony targets +.PHONY: all clean + +# Default target +all: $(TARGETS) +# Compile rule +$(BIN_DIR)/%: $(SRC_DIR)/%.c + @mkdir -p $(BIN_DIR) + $(CC) $(CFLAGS) $< -o $@ + +# Clean rule clean: - rm -f $(SRC_DIR)/tcp_connect_time $(SRC_DIR)/optimize_tcp_params + rm -f $(TARGETS) -.PHONY: all clean +# Print variables for debugging +print-%: + @echo '$*=$($*)'