1#
2#  Copyright 2020 Northern.tech AS
3#
4#  This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
5#
6#  This program is free software; you can redistribute it and/or modify it
7#  under the terms of the GNU General Public License as published by the
8#  Free Software Foundation; version 3.
9#
10#  This program is distributed in the hope that it will be useful,
11#  but WITHOUT ANY WARRANTY; without even the implied warranty of
12#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13#  GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
18#
19# To the extent this program is licensed as part of the Enterprise
20# versions of CFEngine, the applicable Commercial Open Source License
21# (COSL) may apply to this file if you as a licensee so wish it. See
22# included file COSL.txt.
23#
24AUTOMAKE_OPTIONS = foreign
25
26MAKEFLAGS = $(if $(filter-out 0,$(V)),,--no-print-directory --quiet)
27
28LCOV_FLAGS = $(if $(filter-out 0,$(V)),,-q)
29
30SUBDIRS = libcompat \
31	libutils \
32	tests
33
34
35# Hide the buildsystem's username, at least with GNU tar.
36TAR_OPTIONS = --owner=0 --group=0
37export TAR_OPTIONS
38
39
40EXTRA_DIST = README.md LICENSE
41
42doc_DATA = README.md
43
44#
45# Some basic clean ups
46#
47MOSTLYCLEANFILES = *~
48
49#
50# Get everything removed down to where rebuilding requires:
51# "configure; make; make install"
52#
53DISTCLEANFILES =
54
55#
56# Get everything removed down to where rebuilding requires:
57# "aclocal; autoconf; autoheader; automake --add-missing"
58# "configure; make; make install"
59#
60MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.sub \
61	configure install-sh missing mkinstalldirs depcomp ylwrap \
62	ltmain.sh mdate-sh
63
64#
65# Pass proper flags to aclocal to pick up Libtool macros
66#
67ACLOCAL_AMFLAGS = -I m4
68
69list:
70	@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
71
72install-data-local:
73	$(MKDIR_P) -m 700 $(DESTDIR)$(workdir)/inputs
74	$(MKDIR_P) -m 755 $(DESTDIR)$(workdir)/modules
75	$(MKDIR_P) -m 700 $(DESTDIR)$(workdir)/outputs
76	$(MKDIR_P) -m 700 $(DESTDIR)$(workdir)/ppkeys
77	$(MKDIR_P) -m 700 $(DESTDIR)$(workdir)/plugins
78	$(MKDIR_P) -m 750 $(DESTDIR)$(workdir)/state
79
80
81tar-package:
82	pkgdir=`mktemp -d`  &&  export pkgdir  &&  \
83	origdir=`pwd`       &&  export origdir &&  \
84	$(MAKE) DESTDIR=$$pkgdir install  &&  \
85	( \
86		cd $$pkgdir  &&  \
87		find . -name '*.cf*' | xargs -n1 chmod go-w  &&  \
88		tardir=.  && \
89		$(am__tar) | GZIP=$(GZIP_ENV) gzip -c  \
90			> "$$origdir"/$(PACKAGE)-$(VERSION).pkg.tar.gz  \
91	)  ;  \
92	[ x$$pkgdir != x ]  &&  rm -rf $$pkgdir
93
94#
95# Code coverage
96#
97
98clean-coverage:
99	find -L $(srcdir) -name '*.gcda' -delete
100
101run-coverage:
102	-$(MAKE) check -k
103
104
105collect-coverage:
106	mkdir -p coverage
107	$(LCOV) $(LCOV_FLAGS) --capture --initial --directory . --output-file coverage/cfengine-lcov-base.info
108	$(LCOV) $(LCOV_FLAGS) --capture --directory . --output-file coverage/lcov.info --test-name CFENGINE --no-checksum --compat-libtool
109	$(LCOV) $(LCOV_FLAGS) -a coverage/cfengine-lcov-base.info -a coverage/lcov.info --output-file coverage/cfengine-lcov.info
110	$(LCOV) $(LCOV_FLAGS) --remove coverage/lcov.info '/usr/include/*' --output-file coverage/lcov.info
111	LANG=C $(LCOV_GENHTML) $(LCOV_FLAGS) --prefix . --output-directory coverage-html --title "CFEngine Code Coverage" --legend --show-details coverage/lcov.info
112	@echo
113	@echo " Code coverage information: file://"`pwd`"/coverage-html/index.html"
114	@echo " Code coverage summary for IDEs: file://"`pwd`"/coverage/lcov.info"
115	@echo
116
117coverage: clean-coverage run-coverage collect-coverage
118
119V_PERL = $(cf__v_PERL_$(V))
120cf__v_PERL_ = $(cf__v_PERL_$(AM_DEFAULT_VERBOSITY))
121cf__v_PERL_0 = @echo "  PERL    " "$@";
122cf__v_PERL_1 =
123V_SED = $(cf__v_SED_$(V))
124cf__v_SED_ = $(cf__v_SED_$(AM_DEFAULT_VERBOSITY))
125cf__v_SED_0 = @echo "  SED     " "$@";
126cf__v_SED_1 =
127
128
129#
130# Get everything removed down to where rebuilding requires:
131# "make; make install"
132#
133CLEANFILES = cfengine-lcov-base.info cfengine-lcov.info \
134	$(BUILT_SOURCES)
135