# -*- Mode: makefile; indent-tabs-mode: t -*-
#
# This file is part of systemd.
#
# Copyright 2010-2012 Lennart Poettering
# Copyright 2010-2012 Kay Sievers
# Copyright 2013 Zbigniew Jędrzejewski-Szmek
# Copyright 2013 David Strauss
# Copyright 2016 Luke Shumaker
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# systemd is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see .
mod.sd.description = (systemd) shared build rules
mod.sd.depends += am
define mod.sd.doc
# User variables:
# (flags)
# - `CFLAGS`
# - `CPPFLAGS`
# - `LDFLAGS`
# - `LIBTOOLFLAGS`
# (programs)
# - `CC`
# - `CCLD`
# - `LIBTOOL`
# - `MKDIR_P`
# - `SED`
# (verbosity)
# - `V`
# - `AM_V_*`
# - `INTLTOOL_V_MERGE*`
# (substitutions)$(foreach v,$(sort $(sd.substitution_keys)),$(at.nl)# - $v)
# Inputs:
# - Global variable : `DEPDIR`
# - Global variable : `ENABLE_TESTS`
# - Global variable : `ENABLE_UNSAFE_TESTS`
# - Global variable : `OUR_CFLAGS`
# - Global variable : `OUR_CPPFLAGS`
# - Global variable : `OUR_LDFLAGS`
# - Global variable : `OUR_LIBTOOLFLAGS`
# (Makefiles)
# - Directory variable : `sd.CFLAGS`
# - Directory variable : `sd.CPPFLAGS`
# - Directory variable : `sd.LDFLAGS`
# - Directory variable : `sd.LIBTOOLFLAGS`
# - Directory variable : `sd.sed_files` (default based on `EXTRA_DIST`)
# (am)
# - Directory variable : `EXTRA_DIST`
# - Directory variable : `am.out_PROGRAMS`
# - Directory variable : `am.CFLAGS`
# - Directory variable : `am.CPPFLAGS`
# - Target variable : `am.LDFLAGS`
# Outputs:
# - Global variable : `SHELL`
# - Make setting : `.DELETE_ON_ERROR`
# - Make setting : `.SECONDARY`
# - Global variable : `sd.substitutions`
# - Global variable : `sd.substitution_keys`
# - Global variable : `sd.sed_process`
# - Directory variable : `files.out.int`
# - Target variable : `sd.ALL_CFLAGS`
# - Target variable : `sd.ALL_CPPFLAGS`
# - Target variable : `sd.ALL_LDFLAGS`
# - Target variable : `sd.ALL_LIBTOLFLAGS`
# - Target variable : `sd.COMPILE`
# - Target variable : `sd.LTCOMPILE`
# - Target variable : `sd.LINK`
# - Target : `$$(outdir)/%.o`
# - Target : `$$(outdir)/%.lo`
# - Target : `$$(outdir)/$$(DEPDIR)`
# - Target : `$$(outdir)/%.la`
# - Target : `$$(addprefix $$(outdir)/,$$(am.out_PROGRAMS))`
# - Target : `$$(outdir)/test-lib%-sym.c`
# - Target : `$$(outdir)/%-from-name.gperf`
# - Target : `$$(outdir)/%-from-name.h`
# - Target : `$$(addprefix $$(outdir)/,$$(sd.sed_files))`
# - Target : `$$(outdir)/%.c: $$(srcdir)/%.gperf`
# - Target : `$$(outdir)/%: $$(srcdir)/%.m4`
# ???:
# - tests
# - unsafe_tests
# - TESTS
endef
tests ?=
unsafe_tests ?=
TESTS = $(if $(ENABLE_TESTS),$(tests) \
$(if $(ENABLE_UNSAFE_TESTS),$(unsafe_tests)))
# Make behavior
SHELL = bash -o pipefail
.DELETE_ON_ERROR:
.SECONDARY:
# Autoconf
OUR_CPPFLAGS += -MT $@ -MD -MP -MF $(@D)/$(DEPDIR)/$(basename $(@F)).P$(patsubst .%,%,$(suffix $(@F)))
OUR_CPPFLAGS += -include $(topoutdir)/config.h
OUR_CPPFLAGS += $(sort -I$(@D) $(if $( $@