# auto-compute location of this file.
# avoid need to standardize configure/RELEASE name
_PVXS := $(dir $(lastword $(MAKEFILE_LIST)))

# we're appending so must be idempotent
ifeq (,$(_PVXS_CONF_INCLUDED))
_PVXS_CONF_INCLUDED := YES

ifdef T_A

# use custom libevent2 install prefix by:
#   setting LIBEVENT only for single arch build
#   setting LIBEVENT_$(T_A) for each arch
#   leave unset to use implicit system search path
# NOTE: only needed if not present in default search paths
LIBEVENT ?= $(LIBEVENT_$(T_A))

# default to bundled location if it exists
LIBEVENT_$(T_A) ?= $(wildcard $(abspath $(_PVXS)/../bundle/usr/$(T_A)))

# apply to include search paths
INCLUDES += $(if $(LIBEVENT),-I$(LIBEVENT)/include)

LIBEVENT_BUNDLE_LIBS += event_core
LIBEVENT_BUNDLE_LIBS_POSIX_YES = event_pthreads
LIBEVENT_BUNDLE_LIBS += $(LIBEVENT_BUNDLE_LIBS_POSIX_$(POSIX))

LIBEVENT_SYS_LIBS_WIN32 = bcrypt iphlpapi netapi32 ws2_32
LIBEVENT_SYS_LIBS += $(LIBEVENT_SYS_LIBS_$(OS_CLASS))

LIBEVENT_BUNDLE_LDFLAGS_Darwin_NO = -Wl,-rpath,$(LIBEVENT)/lib
LIBEVENT_BUNDLE_LDFLAGS += $(LIBEVENT_BUNDLE_LDFLAGS_$(OS_CLASS)_$(STATIC_BUILD))

event_core_DIR = $(LIBEVENT)/lib
event_pthreads_DIR = $(LIBEVENT)/lib

endif # T_A

endif # _PVXS_CONF_INCLUDED

# logic continues in RULES_PVXS_MODULE
