include (SafeCheckSymbolExists)
include (LibAddMacros)

set (plugin path)

if (DEPENDENCY_PHASE)
	add_definitions (-D_GNU_SOURCE)
	safe_check_symbol_exists (euidaccess "unistd.h" TEST_EUIDACCESS)
	safe_check_symbol_exists (access "unistd.h" TEST_ACCESS)
	safe_check_symbol_exists (geteuid "unistd.h" TEST_GETEUID)
	safe_check_symbol_exists (getegid "unistd.h" TEST_GETEGID)
	safe_check_symbol_exists (seteuid "unistd.h" TEST_SETEUID)
	safe_check_symbol_exists (setegid "unistd.h" TEST_SETEGID)
	safe_check_symbol_exists (getpwnam "pwd.h" TEST_GETPWNAM)
	safe_check_symbol_exists (getpwuid "pwd.h" TEST_GETPWUID)
	safe_check_symbol_exists (getgrouplist "grp.h" TEST_GETGROUPLIST)
	safe_check_symbol_exists (getgrgid "grp.h" TEST_GETGRGID)

	if (NOT TEST_EUIDACCESS)
		remove_plugin (${plugin} "could not find euidaccess.")
	elseif (NOT TEST_ACCESS)
		remove_plugin (${plugin} "could not find access.")
	elseif (NOT TEST_GETEUID)
		remove_plugin (${plugin} "could not find geteuid.")
	elseif (NOT TEST_GETEGID)
		remove_plugin (${plugin} "could not find getegid.")
	elseif (NOT TEST_SETEUID)
		remove_plugin (${plugin} "could not find seteuid.")
	elseif (NOT TEST_SETEGID)
		remove_plugin (${plugin} "could not find setegid.")
	elseif (NOT TEST_GETPWNAM)
		remove_plugin (${plugin} "could not find getpwnam.")
	elseif (NOT TEST_GETPWUID)
		remove_plugin (${plugin} "could not find getpwuid.")
	elseif (NOT TEST_GETGROUPLIST)
		remove_plugin (${plugin} "could not find getgrouplist.")
	elseif (NOT TEST_GETGRGID)
		remove_plugin (${plugin} "could not find getgrgid.")
	endif ()
endif ()

add_plugin (
	path
	SOURCES path.h path.c
	TEST_README COMPONENT libelektra${SO_VERSION}-extra)
