1#
2#  Copyright 2021 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 = \
31	libntech \
32	libcfnet \
33	libenv \
34	cf-check \
35	libpromises \
36	cf-agent \
37	cf-execd \
38	cf-key \
39	cf-monitord \
40	cf-promises \
41	cf-runagent \
42	cf-serverd \
43	cf-testd \
44	cf-upgrade \
45	cf-net \
46	cf-secret \
47	misc \
48	ext \
49	examples \
50	tests \
51	contrib/vagrant-ci/centos-7-x64
52
53
54# Hide the buildsystem's username, at least with GNU tar.
55TAR_OPTIONS = --owner=0 --group=0
56export TAR_OPTIONS
57
58
59EXTRA_DIST = ChangeLog INSTALL README.md LICENSE CFVERSION
60
61doc_DATA = README.md ChangeLog
62
63#
64# Some basic clean ups
65#
66MOSTLYCLEANFILES = *~
67
68#
69# Get everything removed down to where rebuilding requires:
70# "configure; make; make install"
71#
72DISTCLEANFILES =
73
74#
75# Get everything removed down to where rebuilding requires:
76# "aclocal; autoconf; autoheader; automake --add-missing"
77# "configure; make; make install"
78#
79MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.sub \
80	configure install-sh missing mkinstalldirs depcomp ylwrap \
81	ltmain.sh mdate-sh
82
83#
84# Pass proper flags to aclocal to pick up Libtool macros
85#
86ACLOCAL_AMFLAGS = -I m4
87
88list:
89	@$(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 '^$@$$'
90
91install-data-local:
92	$(MKDIR_P) -m 700 $(DESTDIR)$(workdir)/inputs
93	$(MKDIR_P) -m 755 $(DESTDIR)$(workdir)/modules
94	$(MKDIR_P) -m 700 $(DESTDIR)$(workdir)/outputs
95	$(MKDIR_P) -m 700 $(DESTDIR)$(workdir)/ppkeys
96	$(MKDIR_P) -m 700 $(DESTDIR)$(workdir)/plugins
97	$(MKDIR_P) -m 750 $(DESTDIR)$(workdir)/state
98
99
100tar-package:
101	pkgdir=`mktemp -d`  &&  export pkgdir  &&  \
102	origdir=`pwd`       &&  export origdir &&  \
103	$(MAKE) DESTDIR=$$pkgdir install  &&  \
104	(   cd $$pkgdir  &&  \
105	    find . -name '*.cf*' | xargs -n1 chmod go-w  &&  \
106	    tardir=.  &&  \
107	    $(am__tar) | GZIP=$(GZIP_ENV) gzip -c  \
108	        > "$$origdir"/$(PACKAGE)-$(VERSION).pkg.tar.gz  \
109	)  ;  \
110	[ x$$pkgdir != x ]  &&  rm -rf $$pkgdir
111
112#
113# Code coverage
114#
115
116clean-coverage:
117	find -L $(srcdir) -name '*.gcda' -delete
118
119run-coverage:
120	-$(MAKE) check -k
121
122
123collect-coverage:
124	mkdir -p coverage
125	$(LCOV) $(LCOV_FLAGS) --capture --initial --directory . --output-file coverage/cfengine-lcov-base.info
126	$(LCOV) $(LCOV_FLAGS) --capture --directory . --output-file coverage/lcov.info --test-name CFENGINE --no-checksum --compat-libtool
127	$(LCOV) $(LCOV_FLAGS) -a coverage/cfengine-lcov-base.info -a coverage/lcov.info --output-file coverage/cfengine-lcov.info
128	$(LCOV) $(LCOV_FLAGS) --remove coverage/lcov.info '/usr/include/*' --output-file coverage/lcov.info
129	LANG=C $(LCOV_GENHTML) $(LCOV_FLAGS) --prefix . --output-directory coverage-html --title "CFEngine Code Coverage" --legend --show-details coverage/lcov.info
130	@echo
131	@echo " Code coverage information: file://"`pwd`"/coverage-html/index.html"
132	@echo " Code coverage summary for IDEs: file://"`pwd`"/coverage/lcov.info"
133	@echo
134
135coverage: clean-coverage run-coverage collect-coverage
136
137################################################################################
138# Identical to what is in libpromises/Makefile.am.
139# This is because there is a circular dependency libcfnet <-> libpromises
140# so we need to generate it before everything else.
141################################################################################
142BUILT_SOURCES = \
143	$(srcdir)/libpromises/enterprise_extension.c \
144	$(srcdir)/libpromises/enterprise_extension.h
145$(srcdir)/libpromises/enterprise_extension.c: libpromises/extensions_template.c.pre libpromises/enterprise_extension.sed
146	$(V_SED) $(SED) -f $(srcdir)/libpromises/enterprise_extension.sed $< > $@
147$(srcdir)/libpromises/enterprise_extension.h: libpromises/extensions_template.h.pre libpromises/enterprise_extension.sed
148	$(V_SED) $(SED) -f $(srcdir)/libpromises/enterprise_extension.sed $< > $@
149V_PERL = $(cf__v_PERL_$(V))
150cf__v_PERL_ = $(cf__v_PERL_$(AM_DEFAULT_VERBOSITY))
151cf__v_PERL_0 = @echo "  PERL    " "$@";
152cf__v_PERL_1 =
153V_SED = $(cf__v_SED_$(V))
154cf__v_SED_ = $(cf__v_SED_$(AM_DEFAULT_VERBOSITY))
155cf__v_SED_0 = @echo "  SED     " "$@";
156cf__v_SED_1 =
157
158vm-check:
159	$(MAKE) -C contrib/vagrant-ci/centos-7-x64/ vm-check
160
161vm-check-full:
162	$(MAKE) -C contrib/vagrant-ci/centos-7-x64/ vm-check-full
163
164destroy-vms:
165	$(MAKE) -C contrib/vagrant-ci/centos-7-x64/ destroy-vms
166
167static-check:
168	tests/static-check/run.sh
169
170static-check-f%:
171	STATIC_CHECKS_FEDORA_VERSION=$* tests/static-check/run.sh
172
173#
174# Get everything removed down to where rebuilding requires:
175# "make; make install"
176#
177CLEANFILES = cfengine-lcov-base.info cfengine-lcov.info \
178	$(BUILT_SOURCES)
179