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