include $(dir $(MAKEFILE_LIST))../common.mk

all:
	make -C subdir/A CXXFLAGS="$(CXXFLAGS)"
	$(CXX) $(CXXFLAGS) -c subdir/B/main.cpp -o subdir/B/main.o
	$(CXX) $(CXXFLAGS) subdir/B/main.o subdir/A/file1.o subdir/A/file2.o subdir/A/file3.o subdir/A/file4.o subdir/A/C/file5.o subdir/A/C/D/file6.o subdir/A/file7.o  -o subdir/B/testcase

run: txt lcov cobertura html sonarqube jacoco coveralls

coverage.json:
	./subdir/B/testcase
	$(GCOVR) --gcov-keep -r subdir --filter subdir/A --json-pretty --json $@

txt: coverage.json
	$(GCOVR) -r subdir -a $< -o coverage.txt

lcov: coverage.json
	$(GCOVR) -r subdir -a $< --lcov coverage.lcov

cobertura: coverage.json
	$(GCOVR) -r subdir -a $< --cobertura-pretty --cobertura cobertura.xml

html: coverage.json
	$(GCOVR) -r subdir -a $< --html-details --html-theme blue -o coverage.html

sonarqube: coverage.json
	$(GCOVR) -r subdir -a $< --sonarqube sonarqube.xml

jacoco: coverage.json
	$(GCOVR) -r subdir -a $< --jacoco jacoco.xml

coveralls:coverage.json
	$(GCOVR) -r subdir -a $< --coveralls-pretty --coveralls coveralls.json

clean:
	rm -f ./subdir/B/testcase subdir/lib.a
	rm -f *.gc* */*.gc* */*/*.gc* */*/*/*.gc* */*/*/*/*.gc*
	rm -f *.o */*.o */*/*.o */*/*/*.o */*/*/*/*.o
	rm -f coverage*.* cobertura*.* sonarqube*.* jacoco*.* coveralls.json
