Skip to content

Commit

Permalink
conditionally link with libssl
Browse files Browse the repository at this point in the history
rename generated CONFIG_SITE to TOOLCHAIN
  • Loading branch information
mdavidsaver committed Aug 8, 2023
1 parent de5896e commit dbd9dbc
Show file tree
Hide file tree
Showing 18 changed files with 156 additions and 70 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci-scripts-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,10 @@ jobs:
- name: "apt-get install"
run: |
sudo apt-get update
sudo apt-get -y install g++-mingw-w64-x86-64 cmake gdb qemu-system-x86
sudo apt-get -y install g++-mingw-w64-x86-64 cmake gdb qemu-system-x86 libssl-dev
if: runner.os == 'Linux'
- name: Host Info
run: openssl version -a
- name: Automatic core dumper analysis
uses: mdavidsaver/ci-core-dumper@master
- name: Prepare and compile dependencies
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ include $(TOP)/configure/CONFIG
# Directories to build, any order
DIRS += configure

DIRS += setup
setup_DEPEND_DIRS = configure

DIRS += src
src_DEPEND_DIRS = configure
src_DEPEND_DIRS = setup

DIRS += tools
tools_DEPEND_DIRS = src
Expand Down
2 changes: 2 additions & 0 deletions bundle/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
TOP=..

_PVXS_BOOTSTRAP = YES

include $(TOP)/configure/CONFIG

CMAKE ?= cmake
Expand Down
1 change: 1 addition & 0 deletions configure/CONFIG
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ include $(TOP)/configure/CONFIG_SITE
ifdef T_A
-include $(TOP)/configure/CONFIG_SITE.Common.$(T_A)
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
-include $(TOP)/configure/O.$(T_A)/TOOLCHAIN
endif

41 changes: 0 additions & 41 deletions configure/CONFIG_PVXS_MODULE

This file was deleted.

27 changes: 20 additions & 7 deletions configure/Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
TOP=..

# step 1. Use -I... to test event-config.h
# produce configure/O.$(T_A)/TOOLCHAIN
# step 2 in setup/Makefile
_PVXS_BOOTSTRAP = YES

include $(TOP)/configure/CONFIG

# 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))
LIBEVENT_$(T_A) ?= $(wildcard $(abspath $(TOP)/bundle/usr/$(T_A)))

INCLUDES += $(if $(LIBEVENT),-I$(LIBEVENT)/include)

TARGETS = $(CONFIG_TARGETS)
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))

CFG += CONFIG_PVXS_VERSION
CFG += CONFIG_PVXS_MODULE
CFG += RULES_PVXS_MODULE

include $(TOP)/configure/RULES

ifdef T_A
install: $(TOP)/configure/CONFIG_SITE.Common.$(T_A)

$(TOP)/configure/CONFIG_SITE.Common.$(T_A): toolchain.c
$(PREPROCESS.cpp)
install: TOOLCHAIN

CLEANS += ../CONFIG_SITE.Common.$(T_A)
TOOLCHAIN: toolchain.c
$(CPP) $(CPPFLAGS) $(INCLUDES) ../toolchain.c > $@.tmp
$(CPP) $(CPPFLAGS) $(INCLUDES) ../probe-openssl.c > probe-openssl.out && echo "EVENT2_HAS_OPENSSL = YES" >> $@.tmp || echo "No OpenSSL"
$(MV) $@.tmp $@

endif
17 changes: 17 additions & 0 deletions configure/probe-openssl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#include <openssl/opensslv.h>

#ifndef OPENSSL_VERSION_NUMBER
# error Some antique OpenSSL version?
#endif
#if OPENSSL_VERSION_NUMBER < 0x30000000
# error Minimum OpenSSL 3.0
#endif

#include <event2/event-config.h>

#ifndef EVENT__HAVE_OPENSSL
# error libevent not built with OpenSSL support
#endif

#include <event2/bufferevent_ssl.h>
3 changes: 3 additions & 0 deletions configure/toolchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* MSVC preprocessor emits C comments in output
*/
#endif
#ifndef __has_include
# define __has_include(X) (0)
#endif
#define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P))

CONFIG_LOADED=YES
Expand Down
5 changes: 2 additions & 3 deletions example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ TOP=..
include $(TOP)/configure/CONFIG
# cfg/ sometimes isn't correctly included due to a Base bug
# so we do here (maybe again) as workaround
include $(TOP)/configure/CONFIG_PVXS_MODULE
include $(TOP)/configure/CONFIG_PVXS_VERSION
-include $(wildcard $(TOP)/cfg/CONFIG*))
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
Expand Down Expand Up @@ -35,7 +34,7 @@ rpc_client_SRCS += rpc_client.cpp
#===========================

include $(TOP)/configure/RULES
include $(TOP)/configure/RULES_PVXS_MODULE
-include $(wildcard $(TOP)/cfg/RULES*))
#----------------------------------------
# ADD RULES AFTER THIS LINE

5 changes: 2 additions & 3 deletions ioc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ TOP=..
include $(TOP)/configure/CONFIG
# cfg/ sometimes isn't correctly included due to an issue in epics-base
# so we do here (maybe again) as workaround
include $(TOP)/configure/CONFIG_PVXS_MODULE
include $(TOP)/configure/CONFIG_PVXS_VERSION
-include $(wildcard $(TOP)/cfg/CONFIG*))
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
Expand Down Expand Up @@ -80,7 +79,7 @@ LIB_LIBS += $(EPICS_BASE_IOC_LIBS)
#===========================

include $(TOP)/configure/RULES
include $(TOP)/configure/RULES_PVXS_MODULE
-include $(wildcard $(TOP)/cfg/RULES*))
#----------------------------------------
# ADD RULES AFTER THIS LINE

5 changes: 2 additions & 3 deletions qsrv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ TOP=..
include $(TOP)/configure/CONFIG
# cfg/ sometimes isn't correctly included due to a Base bug
# so we do here (maybe again) as workaround
include $(TOP)/configure/CONFIG_PVXS_MODULE
include $(TOP)/configure/CONFIG_PVXS_VERSION
-include $(wildcard $(TOP)/cfg/CONFIG*))
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
Expand All @@ -31,7 +30,7 @@ FINAL_LOCATION ?= $(shell $(PERL) $(TOOLS)/fullPathName.pl $(INSTALL_LOCATION))
#===========================

include $(TOP)/configure/RULES
include $(TOP)/configure/RULES_PVXS_MODULE
-include $(wildcard $(TOP)/cfg/RULES*))
#----------------------------------------
# ADD RULES AFTER THIS LINE

Expand Down
35 changes: 35 additions & 0 deletions setup/CONFIG_PVXS_MODULE
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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

ifneq (YES,$(_PVXS_BOOTSTRAP))
include $(_PVXS)/TOOLCHAIN_PVXS.$(T_A)
endif

# from generated cfg/TOOLCHAIN_PVXS.$(T_A)
LIBEVENT_PREFIX = $(LIBEVENT_PREFIX_$(T_A))
LIBEVENT_BUNDLE_LIBS = $(LIBEVENT_BUNDLE_LIBS_$(T_A))
LIBEVENT_SYS_LIBS = $(LIBEVENT_SYS_LIBS_$(T_A))

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

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

event_core_DIR = $(LIBEVENT_PREFIX)/lib
event_openssl_DIR = $(LIBEVENT_PREFIX)/lib
event_pthreads_DIR = $(LIBEVENT_PREFIX)/lib

endif # T_A

endif # _PVXS_CONF_INCLUDED

# logic continues in RULES_PVXS_MODULE
50 changes: 50 additions & 0 deletions setup/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
TOP=..

# step 1 in configure/Makefile
# step 2. generate cfg/TOOLCHAIN_PVXS.$(T_A)
# install cfg/*
# remaining TOP directories will include generated files
_PVXS_BOOTSTRAP = YES

include $(TOP)/configure/CONFIG

LIBEVENT ?= $(LIBEVENT_$(T_A))
LIBEVENT_$(T_A) ?= $(wildcard $(abspath $(TOP)/bundle/usr/$(T_A)))

_LIBEVENT_BUNDLE_LIBS_YES = event_openssl
_LIBEVENT_SYS_LIBS_YES += ssl crypto

_LIBEVENT_BUNDLE_LIBS += $(_LIBEVENT_BUNDLE_LIBS_$(EVENT2_HAS_OPENSSL))
_LIBEVENT_BUNDLE_LIBS += event_core

_LIBEVENT_SYS_LIBS += $(_LIBEVENT_SYS_LIBS_$(EVENT2_HAS_OPENSSL))

ifeq (WIN32,$(OS_CLASS))
_LIBEVENT_SYS_LIBS += bcrypt iphlpapi netapi32 ws2_32
else
_LIBEVENT_BUNDLE_LIBS += event_pthreads
endif

# at this point we have included the generated O.$(T_A)/TOOLCHAIN
# and use this to generated CONFIG_PVXS_MODULE

CFG += CONFIG_PVXS_MODULE
CFG += RULES_PVXS_MODULE

ifdef T_A
CFG += TOOLCHAIN_PVXS.$(T_A)
endif

include $(TOP)/configure/RULES

ifdef T_A

EXPAND_ARGS = -a $(T_A) -t "$(INSTALL_LOCATION)"
EXPAND_ARGS += "-DLIBEVENT=$(LIBEVENT)"
EXPAND_ARGS += "-DLIBEVENT_BUNDLE_LIBS=$(_LIBEVENT_BUNDLE_LIBS)"
EXPAND_ARGS += "-DLIBEVENT_SYS_LIBS=$(_LIBEVENT_SYS_LIBS)"

TOOLCHAIN_PVXS.$(T_A): ../TOOLCHAIN_PVXS.target@
$(EXPAND_TOOL) $(EXPAND_ARGS) $< $@

endif
2 changes: 1 addition & 1 deletion configure/RULES_PVXS_MODULE → setup/RULES_PVXS_MODULE
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif

_PVXS_CHECK_VARS := PROD TESTPROD LIB $(PROD) $(TESTPROD) $(LIBRARY)

ifeq (,$(LIBEVENT))
ifeq (,$(LIBEVENT_PREFIX))
# libevent in default search path

# $(1) is PROD or LIBRARY name
Expand Down
3 changes: 3 additions & 0 deletions setup/TOOLCHAIN_PVXS.target@
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LIBEVENT_PREFIX_@ARCH@ = @LIBEVENT@
LIBEVENT_BUNDLE_LIBS_@ARCH@ = @LIBEVENT_BUNDLE_LIBS@
LIBEVENT_SYS_LIBS_@ARCH@ = @LIBEVENT_SYS_LIBS@
11 changes: 7 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ TOP=..
include $(TOP)/configure/CONFIG
# cfg/ sometimes isn't correctly included due to a Base bug
# so we do here (maybe again) as workaround
include $(TOP)/configure/CONFIG_PVXS_MODULE
include $(TOP)/configure/CONFIG_PVXS_VERSION
-include $(wildcard $(TOP)/cfg/CONFIG*))
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================

USR_CPPFLAGS += -DPVXS_API_BUILDING
USR_CPPFLAGS += -DPVXS_ENABLE_EXPERT_API

ifeq (YES,$(EVENT2_HAS_OPENSSL))
USR_CPPFLAGS += -DPVXS_ENABLE_OPENSSL
endif

ifdef T_A
ifneq ($(CONFIG_LOADED),YES)
$(error Toolchain inspection failed $(MAKEFILE_LIST))
Expand Down Expand Up @@ -111,7 +114,7 @@ LIB_SRCS += clientdiscover.cpp
LIB_LIBS += Com

# special case matching configure/RULES_PVXS_MODULE
ifeq (,$(LIBEVENT))
ifeq (,$(LIBEVENT_PREFIX))
LIB_SYS_LIBS += $(LIBEVENT_BUNDLE_LIBS)
else
LIB_LIBS += $(LIBEVENT_BUNDLE_LIBS)
Expand All @@ -122,7 +125,7 @@ LIB_SYS_LIBS += $(LIBEVENT_SYS_LIBS)
#===========================

include $(TOP)/configure/RULES
include $(TOP)/configure/RULES_PVXS_MODULE
-include $(wildcard $(TOP)/cfg/RULES*))
#----------------------------------------
# ADD RULES AFTER THIS LINE

Expand Down
5 changes: 2 additions & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ TOP=..
include $(TOP)/configure/CONFIG
# cfg/ sometimes isn't correctly included due to a Base bug
# so we do here (maybe again) as workaround
include $(TOP)/configure/CONFIG_PVXS_MODULE
include $(TOP)/configure/CONFIG_PVXS_VERSION
-include $(wildcard $(TOP)/cfg/CONFIG*))
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
Expand Down Expand Up @@ -181,7 +180,7 @@ endif
#===========================

include $(TOP)/configure/RULES
include $(TOP)/configure/RULES_PVXS_MODULE
-include $(wildcard $(TOP)/cfg/RULES*))
#----------------------------------------
# ADD RULES AFTER THIS LINE

Expand Down
5 changes: 2 additions & 3 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ TOP=..
include $(TOP)/configure/CONFIG
# cfg/ sometimes isn't correctly included due to a Base bug
# so we do here (maybe again) as workaround
include $(TOP)/configure/CONFIG_PVXS_MODULE
include $(TOP)/configure/CONFIG_PVXS_VERSION
-include $(wildcard $(TOP)/cfg/CONFIG*))
#----------------------------------------
# ADD MACRO DEFINITIONS AFTER THIS LINE
#=============================
Expand Down Expand Up @@ -41,7 +40,7 @@ pvxmshim_SRCS += mshim.cpp
#===========================

include $(TOP)/configure/RULES
include $(TOP)/configure/RULES_PVXS_MODULE
-include $(wildcard $(TOP)/cfg/RULES*))
#----------------------------------------
# ADD RULES AFTER THIS LINE

0 comments on commit dbd9dbc

Please sign in to comment.