libexec_PROGRAMS += cockpit-tls cockpit-wsinstance-factory
noinst_PROGRAMS += wsinstance-start

wsinstance_start_SOURCES = \
	src/tls/utils.h \
	src/tls/socket-io.h \
	src/tls/socket-io.c \
	src/tls/wsinstance-start.c \
	$(NULL)

cockpit_wsinstance_factory_LDADD = -lsystemd
cockpit_wsinstance_factory_SOURCES = \
	src/tls/utils.h \
	src/tls/socket-io.h \
	src/tls/socket-io.c \
	src/tls/wsinstance-factory.c \
	$(NULL)

cockpit_tls_SOURCES =					\
	src/tls/utils.h					\
	src/tls/socket-io.h				\
	src/tls/socket-io.c				\
	src/tls/certfile.h				\
	src/tls/certfile.c				\
	src/tls/connection.h				\
	src/tls/connection.c				\
	src/tls/server.h				\
	src/tls/server.c				\
	src/tls/main.c					\
	$(NULL)

cockpit_tls_CFLAGS = 					\
	-I$(top_srcdir)/src/tls				\
	$(COCKPIT_TLS_CFLAGS)				\
	$(NULL)

cockpit_tls_LDFLAGS = -pthread
cockpit_tls_LDADD = 					\
	libcockpit-common-nodeps.a			\
	$(COCKPIT_TLS_LIBS)				\
	$(NULL)

# TESTS

TEST_CFLAGS = $(COCKPIT_TLS_CFLAGS) $(COCKPIT_CFLAGS)
TEST_LDADD = \
	libcockpit-common.a				\
	libcockpit-common-nodeps.a			\
	$(COCKPIT_TLS_LIBS)				\
	$(COCKPIT_LIBS)					\
	$(JSON_GLIB_LIBS)				\
	$(NULL)

TLS_TESTS = \
	test-tls-connection \
	test-tls-server \
	test-tls-certfile \
	$(NULL)

TLS_SCRIPT_TESTS = \
	src/tls/test-socket-activation-helper.sh	\
	$(NULL)

test_tls_certfile_SOURCES = \
	src/tls/certfile.h \
	src/tls/certfile.c \
	src/tls/test-certfile.c \
	$(NULL)

test_tls_certfile_CFLAGS = $(TEST_CFLAGS)
test_tls_certfile_LDADD = $(TEST_LDADD)


test_tls_connection_SOURCES = \
	src/tls/testing.h				\
	src/tls/socket-io.h				\
	src/tls/socket-io.c				\
	src/tls/certfile.h				\
	src/tls/certfile.c				\
	src/tls/connection.c				\
	src/tls/test-connection.c			\
	$(NULL)

test_tls_connection_CFLAGS = $(TEST_CFLAGS)
test_tls_connection_LDADD = $(TEST_LDADD)

test_tls_server_SOURCES = \
	src/tls/socket-io.h				\
	src/tls/socket-io.c				\
	src/tls/certfile.h				\
	src/tls/certfile.c				\
	src/tls/connection.c				\
	src/tls/server.c				\
	src/tls/test-server.c				\
	$(NULL)

test_tls_server_CFLAGS = $(TEST_CFLAGS)
test_tls_server_LDADD = $(TEST_LDADD)

socket_activation_helper_CFLAGS = $(TEST_CFLAGS)
socket_activation_helper_SOURCES = \
	src/tls/testing.h \
	src/tls/socket-io.h \
	src/tls/socket-io.c \
	src/tls/socket-activation-helper.c \
	$(NULL)

noinst_PROGRAMS += $(TLS_TESTS) socket-activation-helper
EXTRA_DIST += \
	src/tls/alternate.crt \
	src/tls/alternate.key \
	$(TLS_SCRIPT_TESTS) \
	$(NULL)
TESTS += $(TLS_TESTS) $(TLS_SCRIPT_TESTS)
