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

52 lines
1.5 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_IPC = -lrt -pthread
SHM_NAME ?= /myshm
SEM_CLIENT_NAME ?= /sem_client
SEM_SERVER_NAME ?= /sem_server
SERVER_ITERS ?= 1000
all: shm
shm: server client
server: server.c
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS_IPC)
client: client.c
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS_IPC)
test_server: shm
@echo "=== Запуск сервера POSIX SHM+SEM ==="
@echo "В другом терминале выполните: make test_client"
./server $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME) $(SERVER_ITERS)
test_client: shm
@echo "=== Запуск клиента, чтение input.txt, вывод на stdout ==="
./client $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME)
test_all: shm
@echo "=== Автотест POSIX SHM+SEM с файлами input.txt/output.txt ==="
./server $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME) $(SERVER_ITERS) & \
SRV=$$!; \
sleep 1; \
./client $(SHM_NAME) $(SEM_CLIENT_NAME) $(SEM_SERVER_NAME); \
wait $$SRV
clean:
@echo "Очистка..."
rm -f server client
rm -f output.txt
help:
@echo "Available targets:"
@echo " shm - Build POSIX SHM+SEM programs"
@echo " test_server - Run SHM+SEM server (client in another terminal)"
@echo " test_client - Run client reading input.txt"
@echo " test_all - Automatic end-to-end test with input.txt/output.txt"
@echo " clean - Remove built files"
@echo " help - Show this help"
.PHONY: all shm test_server test_client test_all clean help