| 1 |
# |
| 2 |
# boxes - Command line filter to draw/remove ASCII boxes around text |
| 3 |
# Copyright (c) 1999-2024 Thomas Jensen and the boxes contributors |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public |
| 6 |
# License, version 3, as published by the Free Software Foundation. |
| 7 |
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 8 |
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 9 |
# details. |
| 10 |
# You should have received a copy of the GNU General Public License along with this program. |
| 11 |
# If not, see <https://www.gnu.org/licenses/>. |
| 12 |
#____________________________________________________________________________________________________________________ |
| 13 |
#==================================================================================================================== |
| 14 |
|
| 15 |
CC = gcc |
| 16 |
|
| 17 |
OUT_DIR = ../out |
| 18 |
SRC_DIR = ../src |
| 19 |
UTEST_DIR = ../utest |
| 20 |
VPATH = $(SRC_DIR):$(SRC_DIR)/misc:$(UTEST_DIR) |
| 21 |
|
| 22 |
UTEST_NORM = global_mock.c bxstring_test.o cmdline_test.c logging_test.c tools_test.c regulex_test.o remove_test.o \ |
| 23 |
main.o unicode_test.o utest_tools.o |
| 24 |
|
| 25 |
.PHONY: check_dir flags_unix flags_win32 flags_ utest |
| 26 |
|
| 27 |
.NOTPARALLEL: |
| 28 |
|
| 29 |
check_dir: |
| 30 |
@if [ "$(shell pwd | sed -e 's/^.*\///')" != "out" ] ; then \ |
| 31 |
echo ERROR: Please call make from the top level directory. ; \ |
| 32 |
exit 1 ; \ |
| 33 |
fi |
| 34 |
|
| 35 |
$(OUT_DIR): |
| 36 |
mkdir $(OUT_DIR) |
| 37 |
|
| 38 |
flags_unix: |
| 39 |
$(eval CFLAGS := -I. -I$(SRC_DIR) -O -Wall -W -Wno-stringop-overflow $(CFLAGS_ADDTL)) |
| 40 |
$(eval LDFLAGS := $(LDFLAGS) --coverage $(LDFLAGS_ADDTL)) |
| 41 |
$(eval UTEST_EXECUTABLE_NAME := unittest) |
| 42 |
$(eval UTEST_OBJ := $(UTEST_NORM:.c=.o)) |
| 43 |
|
| 44 |
flags_win32: |
| 45 |
$(eval CFLAGS := -Os -s -std=c99 -m32 -I. -I$(SRC_DIR) -Wall -W $(CFLAGS_ADDTL)) |
| 46 |
$(eval LDFLAGS := $(LDFLAGS) -s -std=c99 -m32 $(LDFLAGS_ADDTL)) |
| 47 |
$(eval UTEST_EXECUTABLE_NAME := unittest.exe) |
| 48 |
$(eval UTEST_OBJ := $(UTEST_NORM:.c=.o)) |
| 49 |
|
| 50 |
flags_: |
| 51 |
@echo Please call make from the top level directory. |
| 52 |
exit 1 |
| 53 |
|
| 54 |
utest: flags_$(BOXES_PLATFORM) | $(OUT_DIR) |
| 55 |
$(MAKE) -C $(OUT_DIR) -f $(UTEST_DIR)/Makefile BOXES_PLATFORM=$(BOXES_PLATFORM) UTEST_OBJ="$(UTEST_OBJ)" \ |
| 56 |
CFLAGS_ADDTL="$(CFLAGS_ADDTL)" flags_$(BOXES_PLATFORM) $(UTEST_EXECUTABLE_NAME) |
| 57 |
rm -f $(OUT_DIR)/*.gcda |
| 58 |
cd $(OUT_DIR) ; ./$(UTEST_EXECUTABLE_NAME) |
| 59 |
@OUT_DIR=$(OUT_DIR) SRC_DIR=$(SRC_DIR) ./report.sh |
| 60 |
|
| 61 |
unittest: $(UTEST_OBJ) | check_dir |
| 62 |
$(CC) $(LDFLAGS) $^ $(shell cat modules.txt) -o $@ -lunistring -lpcre2-32 -lcmocka |
| 63 |
|
| 64 |
unittest.exe: $(UTEST_OBJ) | check_dir |
| 65 |
$(CC) $(LDFLAGS) $^ $(shell cat modules.txt) -o $@ \ |
| 66 |
-lkernel32 -l:libunistring.a -l:libpcre2-32.a -l:libiconv.a -l:libcmocka.dll.a |
| 67 |
|
| 68 |
|
| 69 |
global_mock.o: global_mock.c global_mock.h boxes.h unicode.h tools.h config.h | check_dir |
| 70 |
bxstring_test.o: bxstring_test.c bxstring_test.h boxes.h bxstring.h global_mock.h tools.h unicode.h utest_tools.h config.h | check_dir |
| 71 |
cmdline_test.o: cmdline_test.c cmdline_test.h boxes.h cmdline.h global_mock.h tools.h config.h | check_dir |
| 72 |
logging_test.o: logging_test.c logging_test.h boxes.h global_mock.h logging.h tools.h config.h | check_dir |
| 73 |
tools_test.o: tools_test.c tools_test.h tools.h unicode.h config.h | check_dir |
| 74 |
regulex_test.o: regulex_test.c regulex_test.h boxes.h global_mock.h regulex.h config.h | check_dir |
| 75 |
remove_test.o: remove_test.c remove_test.h boxes.h remove.h shape.h tools.h unicode.h global_mock.h utest_tools.h config.h | check_dir |
| 76 |
main.o: main.c bxstring_test.h cmdline_test.h global_mock.h tools_test.h regulex_test.h unicode_test.h config.h | check_dir |
| 77 |
unicode_test.o: unicode_test.c unicode_test.h boxes.h tools.h unicode.h config.h | check_dir |
| 78 |
utest_tools.o: utest_tools.c utest_tools.h config.h | check_dir |