Skip to content

Commit

Permalink
Update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
FReak4L authored Sep 27, 2024
1 parent 2315e2f commit 0f4f3c3
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 '$*=$($*)'

0 comments on commit 0f4f3c3

Please sign in to comment.