Files
CS-LABS/mine/lab_5/Makefile
2025-12-10 16:50:28 +07:00

61 lines
1.6 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
CC = gcc
CFLAGS = -Wall -Wextra -std=c99 -g
LDFLAGS_MQ = -lrt
# SERVER_ARGS: <total_honey> <portion> <period_ms> <starvation_ms>
# WORKER_ARGS: <honey_portion>
SERVER_ARGS = 1000 15 500 500
WORKER_ARGS = 7
all: msg
# ===== POSIX MQ targets =====
msg: msg_server msg_worker
msg_server: server.c common.h
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS_MQ)
msg_worker: worker.c common.h
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS_MQ)
# ===== Tests =====
test_msg_server: msg
@echo "=== Запуск сервера POSIX MQ ==="
@echo "В другом терминале выполните: make test_msg_workers"
./msg_server $(SERVER_ARGS)
test_msg_workers: msg
@echo "=== Запуск нескольких пчёл ==="
./msg_worker 7 & \
./msg_worker 9 & \
./msg_worker 5 & \
wait
# Автотест: сервер в фоне, несколько пчёл
test_all: msg
@echo "=== Автотест POSIX MQ ==="
./msg_server $(SERVER_ARGS) & \
SRV=$$!; \
sleep 2; \
./msg_worker $(WORKER_ARGS) & \
./msg_worker $(WORKER_ARGS) & \
./msg_worker $(WORKER_ARGS) & \
wait; \
wait $$SRV
# Очистка
clean:
@echo "Очистка..."
rm -f msg_server msg_worker
help:
@echo "Available targets:"
@echo " msg - Build POSIX message queue programs"
@echo " test_msg_server - Run MQ server (use workers in another terminal)"
@echo " test_msg_workers - Run several worker processes"
@echo " test_all - Automatic end-to-end test"
@echo " clean - Remove built files"
@echo " help - Show this help"
.PHONY: all msg test_msg_server test_msg_workers test_all clean help