NULL =

SUBDIRS = . tests

COMMON = $(top_srcdir)/common

INCLUDES = \
	-I$(top_srcdir) \
	-I$(COMMON) \
	-DP11_KIT_FUTURE_UNSTABLE_API \
	$(NULL)

incdir = $(includedir)/p11-kit-1/p11-kit

inc_HEADERS = \
	p11-kit.h \
	pin.h \
	uri.h \
	$(NULL)

MODULE_SRCS = \
	util.c \
	conf.c conf.h \
	modules.c \
	pkcs11.h \
	pin.c \
	proxy.c \
	private.h \
	messages.c \
	uri.c \
	$(inc_HEADERS)

lib_LTLIBRARIES = \
	libp11-kit.la

libp11_kit_la_CFLAGS = \
	-DP11_SYSTEM_CONFIG_FILE=\""$(p11_system_config_file)"\" \
	-DP11_SYSTEM_CONFIG_MODULES=\""$(p11_system_config_modules)"\" \
	-DP11_PACKAGE_CONFIG_MODULES=\""$(p11_package_config_modules)"\" \
	-DP11_USER_CONFIG_FILE=\""$(p11_user_config_file)"\" \
	-DP11_USER_CONFIG_MODULES=\""$(p11_user_config_modules)"\" \
	-DP11_MODULE_PATH=\""$(p11_module_path)"\" \
	$(NULL)

libp11_kit_la_LDFLAGS = \
	-no-undefined \
	-version-info $(P11KIT_LT_RELEASE) \
	-export-symbols-regex '^C_GetFunctionList|^p11_kit_'

libp11_kit_la_SOURCES = $(MODULE_SRCS)

libp11_kit_la_LIBADD = \
	$(LTLIBINTL) \
	$(top_builddir)/common/libp11-compat.la \
	$(top_builddir)/common/libp11-library.la \
	$(NULL)

noinst_LTLIBRARIES = \
	libp11-kit-testable.la

libp11_kit_testable_la_LDFLAGS = -no-undefined
libp11_kit_testable_la_SOURCES = $(MODULE_SRCS)
libp11_kit_testable_la_LIBADD = $(libp11_kit_la_LIBADD)

if OS_WIN32

libp11_kit_testable_la_CFLAGS = \
	-DP11_SYSTEM_CONFIG_FILE=\""$(abs_top_srcdir)/p11-kit/tests/files/system-pkcs11.conf"\" \
	-DP11_SYSTEM_CONFIG_MODULES=\""$(abs_top_srcdir)/p11-kit/tests/files/system-modules/win32"\" \
	-DP11_PACKAGE_CONFIG_MODULES=\""$(abs_top_srcdir)/p11-kit/tests/files/package-modules/win32"\" \
	-DP11_USER_CONFIG_FILE=\""$(abs_top_srcdir)/p11-kit/tests/files/user-pkcs11.conf"\" \
	-DP11_USER_CONFIG_MODULES=\""$(abs_top_srcdir)/p11-kit/tests/files/user-modules/win32"\" \
	-DP11_MODULE_PATH=\""$(abs_top_builddir)/p11-kit/tests/.libs"\" \
	$(NULL)

else

libp11_kit_testable_la_CFLAGS = \
	-DP11_SYSTEM_CONFIG_FILE=\""$(abs_top_srcdir)/p11-kit/tests/files/system-pkcs11.conf"\" \
	-DP11_SYSTEM_CONFIG_MODULES=\""$(abs_top_srcdir)/p11-kit/tests/files/system-modules"\" \
	-DP11_PACKAGE_CONFIG_MODULES=\""$(abs_top_srcdir)/p11-kit/tests/files/package-modules"\" \
	-DP11_USER_CONFIG_FILE=\""$(abs_top_srcdir)/p11-kit/tests/files/user-pkcs11.conf"\" \
	-DP11_USER_CONFIG_MODULES=\""$(abs_top_srcdir)/p11-kit/tests/files/user-modules"\" \
	-DP11_MODULE_PATH=\""$(abs_top_builddir)/p11-kit/tests/.libs"\" \
	$(NULL)

endif

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = p11-kit-1.pc

exampledir = $(p11_system_config)
example_DATA = pkcs11.conf.example

EXTRA_DIST = \
	p11-kit-1.pc.in \
	pkcs11.conf.example.in

# Proxy module is actually same as library, so install a link
install-exec-hook:
	$(LN_S) -f `readlink $(DESTDIR)$(libdir)/libp11-kit.so` $(DESTDIR)$(libdir)/p11-kit-proxy.so
	$(MKDIR_P) $(p11_package_config_modules)