/
solidbase
/
C3_s21_stringplus
Обзор
Документация
Войти
/
solidbase
/
C3_s21_stringplus
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
src/Makefile
105 строк
4 KB
maxiewal
fix cppcheck mistakes
05 фев 2026, 17:19
05 фев 2026, 17:19
e416499
Код
Авторство
О чём код?
# • Provide a Makefile for building the library and tests # (with the targets all, clean, test, s21_string.a, gcov_report). all: gcov_report s21_string.a test # targets: .PHONY: all clean test s21_string.a gcov_report s21_sscanf format # !!! Workaround for the bug in GCC 13.2.0 and the latest macOS: keep `-std=c11` only for the Linux version; # the code will still comply with the standard on Mac as long as it's compiled on Linux... CC=gcc CFLAGS= -Werror -Wall -Wextra -D_POSIX_C_SOURCE=200809L TEST_CFLAGS= -Werror -Wall -Wextra -D_POSIX_C_SOURCE=200809L -Wno-gnu-zero-variadic-macro-arguments # Detect OS for correct libraries UNAME_S := $(shell uname -s) IS_UBUNTU = $(shell grep -i 'ubuntu' /etc/os-release 2>/dev/null) # Library settings based on OS ifeq ($(UNAME_S), Linux) ifneq ($(IS_UBUNTU),) CHECK_LIBS = -lcheck -lm -lpthread -lsubunit else CHECK_LIBS = -lcheck -lm -lpthread endif CFLAGS += -std=c11 TEST_CFLAGS += -std=c11 endif ifeq ($(UNAME_S), Darwin) CHECK_INCLUDE = -I/opt/homebrew/opt/check/include CHECK_LDFLAGS = -L/opt/homebrew/opt/check/lib CHECK_LIBS = -lcheck -lm endif # make DEBUG=1 - debug build for gcc -g DEBUG ?= 1 ifeq ($(DEBUG), 1) CFLAGS += -g TEST_CFLAGS += -g endif s21_string.a: @$(CC) $(CFLAGS) -c -fPIC s21_string.c s21_mem.c s21_sprintf.c s21_sscanf.c @ar rc s21_string.a s21_string.o s21_mem.o s21_sprintf.o s21_sscanf.o test_str: @$(CC) $(TEST_CFLAGS) $(CHECK_INCLUDE) $(CHECK_LDFLAGS) tests/test_str.c s21_string.a \ $(CHECK_LIBS) -o tests/test_str test_strproc: @$(CC) $(TEST_CFLAGS) $(CHECK_INCLUDE) $(CHECK_LDFLAGS) tests/test_strproc.c s21_string.a\ $(CHECK_LIBS) -o tests/test_strproc test_mem: @$(CC) $(TEST_CFLAGS) $(CHECK_INCLUDE) $(CHECK_LDFLAGS) tests/test_mem.c s21_mem.o \ $(CHECK_LIBS) -o tests/test_mem test_sprintf: @$(CC) $(TEST_CFLAGS) $(CHECK_INCLUDE) $(CHECK_LDFLAGS) tests/tests_sprintf.c s21_string.a\ $(CHECK_LIBS) -o tests/test_sprintf test_sscanf: @$(CC) $(TEST_CFLAGS) $(CHECK_INCLUDE) $(CHECK_LDFLAGS) tests/test_sscanf.c s21_string.a\ $(CHECK_LIBS) -o tests/test_sscanf test: s21_string.a test_str test_strproc test_mem test_sprintf test_sscanf @./tests/test_mem @./tests/test_str @./tests/test_strproc @./tests/test_sprintf @./tests/test_sscanf s21_sscanf: clean s21_string.a test_sscanf @./tests/test_sscanf format: @cp ../materials/linters/.clang-format . @clang-format -n *.c *.h */*.c */*.h @clang-format -i *.c *.h */*.c */*.h valgrind: test @valgrind --track-origins=yes --leak-check=full ./tests/test_mem @valgrind --track-origins=yes --leak-check=full ./tests/test_str @valgrind --track-origins=yes --leak-check=full ./tests/test_strproc @valgrind --track-origins=yes --leak-check=full ./tests/test_sprintf @valgrind --track-origins=yes --leak-check=full ./tests/test_sscanf cppcheck:all cppcheck --std=c11 . # • The gcov_report target should generate a gcov report in the form # of an html page. Unit tests must be run with gcov flags to do this. GCOV_FLAGS = --coverage -lgcov gcov_report: CFLAGS += $(GCOV_FLAGS) gcov_report: TEST_CFLAGS += $(GCOV_FLAGS) gcov_report: clean test @lcov -c -d . -o tests/coverage.info @genhtml tests/coverage.info -o tests/coverage_report @rm -rf *.{gcov,gcda,gcno} tests/*.{gcov,gcda,gcno} @echo "Open tests/coverage_report/index.html in browser" clean: @rm -rf s21_string.a s21_string.o s21_mem.o s21_sscanf.o s21_sprintf.o ./tests/test_str ./tests/test_mem \ ./tests/test_strproc ./tests/test_sprintf ./tests/test_sscanf @rm -rf *.gcov *.gcda *.gcno tests/*.info tests/coverage_report tests/*.gcov tests/*.gcda tests/*.gcno