# Copyright (C) 2015 Colin Walters <walters@verbum.org>
# SPDX-License-Identifier: LGPL-2.0-or-later
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

EXTRA_DIST += \
	$(libglnx_srcpath)/README.md \
	$(libglnx_srcpath)/COPYING \
	$(libglnx_srcpath)/LICENSES/LGPL-2.0-or-later.txt \
	$(libglnx_srcpath)/LICENSES/LGPL-2.1-or-later.txt \
	$(libglnx_srcpath)/libglnx.m4 \
	$(NULL)

BUILT_SOURCES += $(top_builddir)/libglnx-config.h
CLEANFILES += $(top_builddir)/libglnx-config.h
$(top_builddir)/libglnx-config.h: Makefile.am
	echo '#include "config.h"' > $@

libglnx_la_SOURCES = \
	$(libglnx_srcpath)/glnx-macros.h \
	$(libglnx_srcpath)/glnx-backport-autocleanups.h \
	$(libglnx_srcpath)/glnx-backport-autoptr.h \
	$(libglnx_srcpath)/glnx-backport-testutils.h \
	$(libglnx_srcpath)/glnx-backport-testutils.c \
	$(libglnx_srcpath)/glnx-backports.h \
	$(libglnx_srcpath)/glnx-backports.c \
	$(libglnx_srcpath)/glnx-local-alloc.h \
	$(libglnx_srcpath)/glnx-local-alloc.c \
	$(libglnx_srcpath)/glnx-errors.h \
	$(libglnx_srcpath)/glnx-errors.c \
	$(libglnx_srcpath)/glnx-console.h \
	$(libglnx_srcpath)/glnx-console.c \
	$(libglnx_srcpath)/glnx-dirfd.h \
	$(libglnx_srcpath)/glnx-dirfd.c \
	$(libglnx_srcpath)/glnx-fdio.h \
	$(libglnx_srcpath)/glnx-fdio.c \
	$(libglnx_srcpath)/glnx-lockfile.h \
	$(libglnx_srcpath)/glnx-lockfile.c \
	$(libglnx_srcpath)/glnx-missing-syscall.h \
	$(libglnx_srcpath)/glnx-missing.h \
	$(libglnx_srcpath)/glnx-xattrs.h \
	$(libglnx_srcpath)/glnx-xattrs.c \
	$(libglnx_srcpath)/glnx-shutil.h \
	$(libglnx_srcpath)/glnx-shutil.c \
	$(libglnx_srcpath)/libglnx.h \
	$(libglnx_srcpath)/tests/libglnx-testlib.h \
	$(NULL)

libglnx_la_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags) -I$(builddir)
libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic 
libglnx_la_LIBADD = $(libglnx_libs)

libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors test-libglnx-macros test-libglnx-shutil
TESTS += $(libglnx_tests)

libglnx_testlib_sources = $(libglnx_srcpath)/tests/libglnx-testlib.c

check_PROGRAMS += $(libglnx_tests)
test_libglnx_xattrs_SOURCES = $(libglnx_testlib_sources) $(libglnx_srcpath)/tests/test-libglnx-xattrs.c
test_libglnx_xattrs_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_xattrs_LDADD = $(libglnx_libs) libglnx.la

test_libglnx_fdio_SOURCES = $(libglnx_testlib_sources) $(libglnx_srcpath)/tests/test-libglnx-fdio.c
test_libglnx_fdio_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_fdio_LDADD = $(libglnx_libs) libglnx.la

test_libglnx_errors_SOURCES = $(libglnx_testlib_sources) $(libglnx_srcpath)/tests/test-libglnx-errors.c
test_libglnx_errors_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_errors_LDADD = $(libglnx_libs) libglnx.la

test_libglnx_macros_SOURCES = $(libglnx_testlib_sources) $(libglnx_srcpath)/tests/test-libglnx-macros.c
test_libglnx_macros_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_macros_LDADD = $(libglnx_libs) libglnx.la

test_libglnx_shutil_SOURCES = $(libglnx_testlib_sources) $(libglnx_srcpath)/tests/test-libglnx-shutil.c
test_libglnx_shutil_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_shutil_LDADD = $(libglnx_libs) libglnx.la
