Blame Makefile.inc

Packit Service 0af388
#
Packit Service 0af388
# Copyright (C) 2004 Christophe Varoqui, <christophe.varoqui@opensvc.com>
Packit Service 0af388
#
Packit Service 0af388
Packit Service 0af388
#
Packit Service 0af388
# Allow to force some libraries to be used statically. (Uncomment one of the
Packit Service 0af388
# following lines or define the values when calling make.)
Packit Service 0af388
#
Packit Service 0af388
# WITH_LOCAL_LIBDM	= 1
Packit Service 0af388
# WITH_LOCAL_LIBSYSFS	= 1
Packit Service 0af388
#
Packit Service 0af388
# Uncomment to disable libdmmp support
Packit Service 0af388
# ENABLE_LIBDMMP = 0
Packit Service 0af388
#
Packit Service 0af388
# Uncomment to disable dmevents polling support
Packit Service 0af388
# ENABLE_DMEVENTS_POLL = 0
Packit Service 0af388
Packit Service 0af388
ifeq ($(TOPDIR),)
Packit Service 0af388
	TOPDIR	= ..
Packit Service 0af388
endif
Packit Service 0af388
Packit Service 0af388
ifndef LIB
Packit Service 0af388
	ifeq ($(shell test -d /lib64 && echo 1),1)
Packit Service 0af388
		LIB=lib64
Packit Service 0af388
	else
Packit Service 0af388
		LIB=lib
Packit Service 0af388
	endif
Packit Service 0af388
endif
Packit Service 0af388
Packit Service 0af388
ifndef RUN
Packit Service 0af388
	ifeq ($(shell test -L /var/run -o ! -d /var/run && echo 1),1)
Packit Service 0af388
		RUN=run
Packit Service 0af388
	else
Packit Service 0af388
		RUN=var/run
Packit Service 0af388
	endif
Packit Service 0af388
endif
Packit Service 0af388
Packit Service 0af388
ifndef SYSTEMD
Packit Service 0af388
	ifeq ($(shell pkg-config --modversion libsystemd >/dev/null 2>&1 && echo 1), 1)
Packit Service 0af388
		SYSTEMD = $(shell pkg-config --modversion libsystemd)
Packit Service 0af388
	else
Packit Service 0af388
		ifeq ($(shell systemctl --version >/dev/null 2>&1 && echo 1), 1)
Packit Service 0af388
			SYSTEMD = $(shell systemctl --version 2> /dev/null | \
Packit Service 0af388
				sed -n 's/systemd \([0-9]*\).*/\1/p')
Packit Service 0af388
		endif
Packit Service 0af388
	endif
Packit Service 0af388
endif
Packit Service 0af388
Packit Service 0af388
ifndef SYSTEMDPATH
Packit Service 0af388
	SYSTEMDPATH=usr/lib
Packit Service 0af388
endif
Packit Service 0af388
Packit Service 0af388
prefix		=
Packit Service 0af388
exec_prefix	= $(prefix)
Packit Service 0af388
usr_prefix	= $(prefix)
Packit Service 11a9e6
bindir		= $(exec_prefix)/usr/sbin
Packit Service 0af388
libudevdir	= $(prefix)/$(SYSTEMDPATH)/udev
Packit Service 0af388
udevrulesdir	= $(libudevdir)/rules.d
Packit Service 0af388
multipathdir	= $(TOPDIR)/libmultipath
Packit Service 0af388
man8dir		= $(prefix)/usr/share/man/man8
Packit Service 0af388
man5dir		= $(prefix)/usr/share/man/man5
Packit Service 0af388
man3dir		= $(prefix)/usr/share/man/man3
Packit Service 0af388
syslibdir	= $(prefix)/$(LIB)
Packit Service 0af388
usrlibdir	= $(usr_prefix)/$(LIB)
Packit Service 0af388
libdir		= $(prefix)/$(LIB)/multipath
Packit Service 0af388
unitdir		= $(prefix)/$(SYSTEMDPATH)/systemd/system
Packit Service 0af388
mpathpersistdir	= $(TOPDIR)/libmpathpersist
Packit Service 0af388
mpathcmddir	= $(TOPDIR)/libmpathcmd
Packit Service 0af388
thirdpartydir	= $(TOPDIR)/third-party
Packit Service 0af388
libdmmpdir	= $(TOPDIR)/libdmmp
Packit Service 0af388
nvmedir		= $(TOPDIR)/libmultipath/nvme
Packit Service 0af388
includedir	= $(prefix)/usr/include
Packit Service 0af388
pkgconfdir	= $(usrlibdir)/pkgconfig
Packit Service 0af388
Packit Service 0af388
GZIP		= gzip -9 -c
Packit Service 0af388
RM		= rm -f
Packit Service 0af388
LN		= ln -sf
Packit Service 0af388
INSTALL_PROGRAM	= install
Packit Service 0af388
Packit Service 0af388
# $(call TEST_CC_OPTION,option,fallback)
Packit Service 0af388
# Test if the C compiler supports the option.
Packit Service 0af388
# Evaluates to "option" if yes, and "fallback" otherwise.
Packit Service 0af388
TEST_CC_OPTION = $(shell \
Packit Service 0af388
	if echo 'int main(void){return 0;}' | \
Packit Service 0af388
		$(CC) -o /dev/null -c -Werror "$(1)" -xc - >/dev/null 2>&1; \
Packit Service 0af388
	then \
Packit Service 0af388
		echo "$(1)"; \
Packit Service 0af388
	else \
Packit Service 0af388
		echo "$(2)"; \
Packit Service 0af388
	fi)
Packit Service 0af388
Packit Service 0af388
ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,)
Packit Service d8504d
WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered -Wno-error=clobbered,)
Packit Service dab482
ifndef RPM_OPT_FLAGS
Packit Service dab482
	STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
Packit Service dab482
	OPTFLAGS	= -O2 -g -pipe -Wall -Werror=format-security \
Packit Service dab482
			  -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \
Packit Service dab482
			  $(STACKPROT) -grecord-gcc-switches \
Packit Service dab482
			  -fasynchronous-unwind-tables
Packit Service dab482
	ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-hardened-cc1 && echo 1),1)
Packit Service dab482
		OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
Packit Service dab482
	endif
Packit Service dab482
	ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-annobin-cc1 && echo 1),1)
Packit Service dab482
		OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
Packit Service dab482
	endif
Packit Service dab482
else
Packit Service dab482
	OPTFLAGS = $(RPM_OPT_FLAGS)
Packit Service dab482
endif
Packit Service dab482
OPTFLAGS	+= -Werror -Wextra -Wstrict-prototypes -Wformat=2 \
Packit Service dab482
		   -Werror=implicit-int -Werror=implicit-function-declaration \
Packit Service dab482
		   $(WNOCLOBBERED) \
Packit Service dab482
		   -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \
Packit Service dab482
		   --param=ssp-buffer-size=4
Packit Service 0af388
Packit Service 0af388
CFLAGS		:= $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \
Packit Service 0af388
		   -MMD -MP $(CFLAGS)
Packit Service 0af388
BIN_CFLAGS	= -fPIE -DPIE
Packit Service 0af388
LIB_CFLAGS	= -fPIC
Packit Service 0af388
SHARED_FLAGS	= -shared
Packit Service 0af388
LDFLAGS		= -Wl,-z,relro -Wl,-z,now
Packit Service 0af388
BIN_LDFLAGS	= -pie
Packit Service 0af388
Packit Service 0af388
# Check whether a function with name $1 has been declared in header file $2.
Packit Service 0af388
check_func = $(shell \
Packit Service 0af388
	if grep -Eq "^[^[:blank:]]+[[:blank:]]+$1[[:blank:]]*(.*)*" "$2"; then \
Packit Service 0af388
		found=1; \
Packit Service 0af388
		status="yes"; \
Packit Service 0af388
	else \
Packit Service 0af388
		found=0; \
Packit Service 0af388
		status="no"; \
Packit Service 0af388
	fi; \
Packit Service 0af388
	echo 1>&2 "Checking for $1 in $2 ... $$status"; \
Packit Service 0af388
	echo "$$found" \
Packit Service 0af388
	)
Packit Service 0af388
Packit Service 0af388
# Checker whether a file with name $1 exists
Packit Service 0af388
check_file = $(shell \
Packit Service 0af388
	if [ -f "$1" ]; then \
Packit Service 0af388
		found=1; \
Packit Service 0af388
		status="yes"; \
Packit Service 0af388
	else \
Packit Service 0af388
		found=0; \
Packit Service 0af388
		status="no"; \
Packit Service 0af388
	fi; \
Packit Service 0af388
	echo 1>&2 "Checking if $1 exists ... $$status"; \
Packit Service 0af388
	echo "$$found" \
Packit Service 0af388
	)
Packit Service 0af388
Packit Service 0af388
%.o:	%.c
Packit Service 0af388
	@echo building $@ because of $?
Packit Service dab482
	$(CC) $(CFLAGS) -c -o $@ $<