2019-06-25 23:37:13 +02:00
|
|
|
#
|
|
|
|
# Copyright (c) 2019 Stefan Strobel <stefan.strobel@shimatta.net>
|
|
|
|
#
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
#
|
|
|
|
|
|
|
|
OBJ_DIR := output/
|
|
|
|
|
|
|
|
CC := gcc
|
|
|
|
CPP := g++
|
|
|
|
LN := ln
|
|
|
|
|
|
|
|
SOURCES := src/shellmatta.c \
|
|
|
|
src/shellmatta_autocomplete.c \
|
|
|
|
src/shellmatta_history.c \
|
|
|
|
src/shellmatta_utils.c \
|
2020-03-08 22:02:51 +01:00
|
|
|
src/shellmatta_escape.c \
|
|
|
|
src/shellmatta_opt.c
|
2019-12-05 22:55:28 +01:00
|
|
|
|
2019-06-25 23:37:13 +02:00
|
|
|
INCLUDES := api .
|
|
|
|
|
2019-12-05 17:55:03 +01:00
|
|
|
UNITTEST_SOURCES := test/unittest/test_main.cpp \
|
2020-03-16 22:08:06 +01:00
|
|
|
test/unittest/shellmatta_opt/test_opt_findNextHunk.cpp \
|
2020-10-31 15:16:16 +01:00
|
|
|
test/unittest/shellmatta_opt/test_opt_peekNextHunk.cpp \
|
2019-12-05 17:55:03 +01:00
|
|
|
test/unittest/shellmatta_utils/test_utils_writeEcho.cpp \
|
|
|
|
test/unittest/shellmatta_utils/test_utils_shellItoa.cpp \
|
|
|
|
test/unittest/shellmatta_utils/test_utils_saveCursorPos.cpp \
|
|
|
|
test/unittest/shellmatta_utils/test_utils_restoreCursorPos.cpp \
|
|
|
|
test/unittest/shellmatta_utils/test_utils_eraseLine.cpp \
|
|
|
|
test/unittest/shellmatta_utils/test_utils_rewindCursor.cpp \
|
|
|
|
test/unittest/shellmatta_utils/test_utils_forwardCursor.cpp \
|
|
|
|
test/unittest/shellmatta_utils/test_utils_clearInput.cpp \
|
|
|
|
test/unittest/shellmatta_utils/test_utils_insertChars.cpp \
|
2020-05-18 21:14:47 +02:00
|
|
|
test/unittest/shellmatta_utils/test_utils_terminateInput.cpp \
|
|
|
|
test/unittest/shellmatta_utils/test_utils_removeChars.cpp \
|
2019-12-05 22:55:28 +01:00
|
|
|
test/unittest/shellmatta_autocomplete/test_autocomplete_run.cpp \
|
2019-12-05 17:55:03 +01:00
|
|
|
test/unittest/shellmatta_escape/test_escape_processArrowKeys.cpp \
|
|
|
|
test/unittest/shellmatta_history/test_appendHistoryByte.cpp \
|
|
|
|
test/unittest/shellmatta/test_shellmatta_doInit.cpp
|
2019-07-28 22:28:54 +02:00
|
|
|
|
2020-03-22 18:56:17 +01:00
|
|
|
INTEGRATIONTEST_SOURCES := test/integrationtest/test_main.cpp \
|
|
|
|
test/integrationtest/test_integration.cpp \
|
|
|
|
test/integrationtest/test_integration_opt.cpp \
|
2020-03-28 11:26:50 +01:00
|
|
|
test/integrationtest/test_integration_optLong.cpp \
|
2020-05-01 13:43:58 +02:00
|
|
|
test/integrationtest/test_integration_continue.cpp \
|
2020-03-28 11:26:50 +01:00
|
|
|
test/integrationtest/test_integration_busy.cpp
|
2019-07-28 22:28:54 +02:00
|
|
|
|
|
|
|
UNITTEST_CPPOBJ := $(patsubst %.cpp,$(OBJ_DIR)%.o,$(UNITTEST_SOURCES))
|
|
|
|
|
|
|
|
INTEGRATIONTEST_CPPOBJ := $(patsubst %.cpp,$(OBJ_DIR)%.o,$(INTEGRATIONTEST_SOURCES))
|
2019-06-25 23:37:13 +02:00
|
|
|
|
2020-03-01 17:53:27 +01:00
|
|
|
CFLAGS := $(INCLUDES:%=-I%) -g -Wall -Werror -Wextra -pedantic -DSHELLMATTA_HELP_ALIAS=\"?\"
|
|
|
|
TESTFLAGS := $(INCLUDES:%=-I%) -g -Wall -Werror -Wextra -fprofile-arcs -ftest-coverage -pedantic
|
2019-06-25 23:37:13 +02:00
|
|
|
TESTLFLAGS := -fprofile-arcs -Wl,--allow-multiple-definition
|
|
|
|
|
|
|
|
DEPEND = -MT $@ -MF "$(@:%.o=%.d)" -MG -MM
|
2020-04-19 14:45:42 +02:00
|
|
|
|
2019-06-25 23:37:13 +02:00
|
|
|
COBJ := $(patsubst %.c,$(OBJ_DIR)%.o,$(SOURCES))
|
|
|
|
|
|
|
|
EXAMPLE_SOURCES := example/main.c
|
|
|
|
EXAMPLE_COBJ := $(patsubst %.c,$(OBJ_DIR)%.o,$(EXAMPLE_SOURCES))
|
|
|
|
|
|
|
|
EXAMPLE_TARGET := $(OBJ_DIR)example/example
|
|
|
|
|
2019-07-28 22:28:54 +02:00
|
|
|
UNITTEST_TARGET := $(OBJ_DIR)test/unittest/unittest
|
|
|
|
|
|
|
|
INTEGRATIONTEST_TARGET := $(OBJ_DIR)test/integrationtest/integrationtest
|
2019-06-25 23:37:13 +02:00
|
|
|
|
2019-07-28 22:28:54 +02:00
|
|
|
OBJ := $(COBJ) $(EXAMPLE_COBJ) $(UNITTEST_CPPOBJ) $(INTEGRATIONTEST_CPPOBJ)
|
2019-06-25 23:37:13 +02:00
|
|
|
DEPS := $(OBJ:%.o=%.d)
|
|
|
|
|
|
|
|
export
|
|
|
|
|
|
|
|
help:
|
2020-05-18 21:10:26 +02:00
|
|
|
@echo Shellmatta help
|
|
|
|
@echo -----------------------------------------------
|
|
|
|
@echo test - run all tests
|
|
|
|
@echo cppcheck - run static code analysis (cppcheck)
|
|
|
|
@echo example - build example
|
|
|
|
@echo -----------------------------------------------
|
2019-06-25 23:37:13 +02:00
|
|
|
|
2019-07-28 22:28:54 +02:00
|
|
|
test: unittest integrationtest
|
|
|
|
|
2019-08-04 23:17:15 +02:00
|
|
|
cppcheck:
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p output/cppcheck/html
|
|
|
|
cppcheck --enable=all --template=gcc --cppcheck-build-dir=output/cppcheck $(SOURCES)
|
|
|
|
cppcheck --enable=all --template=gcc --cppcheck-build-dir=output/cppcheck $(SOURCES) --xml 2>output/cppcheck/cppcheck.xml
|
|
|
|
cppcheck-htmlreport --file=output/cppcheck/cppcheck.xml --title="Shellmatta" --report-dir=output/cppcheck/html
|
2019-08-04 23:17:15 +02:00
|
|
|
|
2019-07-28 22:28:54 +02:00
|
|
|
unittest: $(UNITTEST_TARGET)
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p output/test/unittest/report
|
|
|
|
@echo running test:
|
|
|
|
@# remove coverage from former run
|
|
|
|
@-find . -name "*.gcda" -type f -delete
|
|
|
|
-$(UNITTEST_TARGET)
|
|
|
|
@#gcov -o output/test/unittest $(UNITTEST_CPPOBJ) -r src
|
|
|
|
|
|
|
|
@# remove report from former run
|
|
|
|
-rm -rf $(OBJ_DIR)test/unittest/report/*
|
|
|
|
gcovr --html-details --output $(OBJ_DIR)test/unittest/report/report.html output/test/unittest -f src -f api
|
|
|
|
@#-rm *.gcov
|
|
|
|
|
2019-07-28 22:28:54 +02:00
|
|
|
integrationtest: $(INTEGRATIONTEST_TARGET)
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p output/test/integrationtest/report
|
|
|
|
@echo running test:
|
|
|
|
-$(INTEGRATIONTEST_TARGET)
|
|
|
|
#gcov -o output/test $(TEST_CPPOBJ) -r
|
|
|
|
gcovr --html-details --output $(OBJ_DIR)test/integrationtest/report/report.html output/src -f src -f api
|
|
|
|
#-rm *.gcov
|
|
|
|
|
2019-06-25 23:37:13 +02:00
|
|
|
example: $(EXAMPLE_TARGET)
|
2020-05-18 21:10:26 +02:00
|
|
|
@echo building example
|
2019-06-25 23:37:13 +02:00
|
|
|
|
|
|
|
doc:
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p output/doc/html
|
|
|
|
- @mkdir -p output/doc/latex
|
|
|
|
doxygen cfg/doxygen/doxyfile
|
|
|
|
|
2019-06-25 23:37:13 +02:00
|
|
|
clean:
|
2020-05-18 21:10:26 +02:00
|
|
|
- rm -rf $(OBJ_DIR)
|
2019-06-25 23:37:13 +02:00
|
|
|
|
|
|
|
$(EXAMPLE_TARGET): $(COBJ) $(EXAMPLE_COBJ)
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p $(@D)
|
|
|
|
$(CC) $(LFLAGS) $(LIB_PATH) -o $@ $^ $(LIBS)
|
2019-06-25 23:37:13 +02:00
|
|
|
|
2019-07-28 22:28:54 +02:00
|
|
|
$(UNITTEST_TARGET): $(UNITTEST_CPPOBJ)
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p $(@D)
|
|
|
|
$(CPP) $(TESTLFLAGS) $(LIB_PATH) -o $@ $^ $(LIBS)
|
|
|
|
|
2019-07-28 22:28:54 +02:00
|
|
|
$(INTEGRATIONTEST_TARGET): $(INTEGRATIONTEST_CPPOBJ) $(COBJ)
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p $(@D)
|
|
|
|
$(CPP) $(TESTLFLAGS) $(LIB_PATH) -o $@ $^ $(LIBS)
|
2019-06-25 23:37:13 +02:00
|
|
|
|
|
|
|
$(TARGET): $(OBJ)
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p $(@D)
|
|
|
|
$(CC) $(LFLAGS) $(LIB_PATH) -o $@ $^ $(LIBS)
|
|
|
|
|
2019-06-25 23:37:13 +02:00
|
|
|
$(COBJ):
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p $(@D)
|
|
|
|
@$(CC) -c $(CFLAGS) $(DEPEND) -o $@ $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
|
|
|
|
$(CC) -c $(CFLAGS) -o $@ $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
|
2019-06-25 23:37:13 +02:00
|
|
|
|
|
|
|
$(EXAMPLE_COBJ):
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p $(@D)
|
|
|
|
@$(CC) -c $(CFLAGS) $(DEPEND) -o $@ $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
|
|
|
|
$(CC) -c $(CFLAGS) -o $@ $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
|
2019-06-25 23:37:13 +02:00
|
|
|
|
2019-07-28 22:28:54 +02:00
|
|
|
$(UNITTEST_CPPOBJ) $(INTEGRATIONTEST_CPPOBJ):
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p $(@D)
|
|
|
|
@$(CPP) -c $(TESTFLAGS) $(DEPEND) -o $@ $(subst $(OBJ_DIR), ,$(@:%.o=%.cpp))
|
|
|
|
$(CPP) -c $(TESTFLAGS) -o $@ $(subst $(OBJ_DIR), ,$(@:%.o=%.cpp))
|
2019-06-25 23:37:13 +02:00
|
|
|
|
|
|
|
%.o: %.cpp
|
2020-05-18 21:10:26 +02:00
|
|
|
- @mkdir -p $(@D)
|
|
|
|
@$(CPP) -c $(CFLAGS) $(DEPEND) -o $@ $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
|
|
|
|
$(CPP) -c $(CFLAGS) -o $@ $<
|
2019-06-25 23:37:13 +02:00
|
|
|
|
|
|
|
-include $(DEPS)
|