## Copyright (c) 2009-2010  Openismus GmbH  <http://www.openismus.com/>
##
## This file is part of Glom.
##
## Glom is free software: you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published
## by the Free Software Foundation, either version 2 of the License,
## or (at your option) any later version.
##
## Glom 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 General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.


libglom_defines =

lib_LTLIBRARIES = glom/libglom/libglom-@GLOM_ABI_VERSION@.la

include $(top_srcdir)/glom/libglom/filelist.am

# Gather together the various variables for Boost::Python.
#
# Note that AX_BOOST_PYTHON just gives us the name of the library (BOOST_PYTHON_LIB),
# not giving us the actual linker flag, so we must add the -l prefix manually,
# and it does not give us the location of the library, so we have no -L linker option,
# so we must just hope that it is somewhere common.
# 
# Note also that AX_BOOST_PYTHON does not provide any CPPFLAGS,
# so we must assume that they are at the top of /usr/include,
# or at least next to the python headers.
boost_python_cflags = $(PYTHON_CPPFLAGS)
boost_python_libs = $(PYTHON_LIBS) $(PYTHON_EXTRA_LDFLAGS) -l$(BOOST_PYTHON_LIB)

libglom_includedir = $(includedir)/glom-$(GLOM_ABI_VERSION)/libglom
libglom_include_HEADERS = $(libglom_toplevel_headers)

libglom_data_structure_includedir = $(libglom_includedir)/data_structure
libglom_data_structure_include_HEADERS = $(libglom_data_structure_headers)

libglom_ds_layout_includedir = $(libglom_data_structure_includedir)/layout
libglom_ds_layout_include_HEADERS = $(libglom_ds_layout_headers)

libglom_ds_l_report_parts_includedir = $(libglom_ds_layout_includedir)/report_parts
libglom_ds_l_report_parts_include_HEADERS = $(libglom_ds_l_report_parts_headers)

libglom_document_includedir = $(libglom_includedir)/document
libglom_document_include_HEADERS = $(libglom_document_headers)

libglom_d_bakery_includedir = $(libglom_document_includedir)/bakery
libglom_d_bakery_include_HEADERS = $(libglom_d_bakery_headers)

libglom_d_b_view_includedir = $(libglom_d_bakery_includedir)/view
libglom_d_b_view_include_HEADERS = $(libglom_d_b_view_headers)

glom_libglom_libglom_@GLOM_ABI_VERSION@_la_SOURCES = \
	$(libglom_sources) \
	glom/libglom/data/libglom-resources.c

libglom_all_libs = $(LIBGLOM_LIBS) $(boost_python_libs) -lgettextpo $(GCOV_CFLAGS)
glom_libglom_libglom_@GLOM_ABI_VERSION@_la_LIBADD = $(libglom_all_libs)


# Generate the GResource source file for the xslt files:
libglom_resource_file = $(srcdir)/glom/libglom/data/libglom.gresource.xml
BUILT_SOURCES = glom/libglom/data/libglom-resources.c
glom/libglom/data/libglom-resources.c: $(libglom_resource_file) $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(libglom_resource_file))
	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --internal --target=$@ --sourcedir=$(srcdir) --generate-source $(libglom_resource_file)

EXTRA_DIST = \
 	$(libglom_resource_file) \
	glom/libglom/data/xslt/print_report_to_html.xsl


if HOST_WIN32
glom_libglom_libglom_@GLOM_ABI_VERSION@_la_LIBADD += -lws2_32
endif
glom_libglom_libglom_@GLOM_ABI_VERSION@_la_LDFLAGS = -no-undefined

glom_libglom_libglom_@GLOM_ABI_VERSION@_la_CPPFLAGS = $(glom_includes) $(LIBGLOM_CFLAGS) $(boost_python_cflags) $(GCOV_CFLAGS) $(libglom_defines)

pyexec_LTLIBRARIES = glom/python_embed/python_module/glom_@GLOM_ABI_VERSION_UNDERLINED@.la

glom_python_embed_python_module_glom_@GLOM_ABI_VERSION_UNDERLINED@_la_SOURCES = \
	glom/python_embed/python_module/py_glom_module.cc	\
	glom/python_embed/python_module/py_glom_module.h

glom_python_embed_python_module_glom_@GLOM_ABI_VERSION_UNDERLINED@_la_LIBADD = \
	glom/libglom/libglom-$(GLOM_ABI_VERSION).la \
	$(boost_python_libs)

if HOST_WIN32
pymod_ldflags = -module -avoid-version -no-undefined -shrext .pyd
else
pymod_ldflags = -module -avoid-version -no-undefined
endif
glom_pyexport = -export-symbols-regex '^_*initglom'
glom_python_embed_python_module_glom_@GLOM_ABI_VERSION_UNDERLINED@_la_LDFLAGS = $(pymod_ldflags) $(glom_pyexport)
glom_python_embed_python_module_glom_@GLOM_ABI_VERSION_UNDERLINED@_la_CPPFLAGS = $(glom_includes) $(LIBGLOM_CFLAGS) $(boost_python_cflags)

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = glom/libglom/glom-@GLOM_ABI_VERSION@.pc


# Command-line tools:

glom_commandline_ldadd = glom/libglom/libglom-$(GLOM_ABI_VERSION).la $(libglom_all_libs)
glom_commandline_cppflags = $(glom_includes) $(LIBGLOM_CFLAGS) $(boost_python_cflags) $(glom_defines)

bin_PROGRAMS = glom/glom_create_from_example \
  glom/glom_test_connection \
  glom/glom_export_po \
  glom/glom_export_po_all \
  glom/glom_import_po_all

glom_glom_create_from_example_SOURCES = glom/glom_create_from_example.cc
glom_glom_create_from_example_LDADD = $(glom_commandline_ldadd)
glom_glom_create_from_example_CPPFLAGS = $(glom_commandline_cppflags)

glom_glom_test_connection_SOURCES = glom/glom_test_connection.cc
glom_glom_test_connection_LDADD = $(glom_commandline_ldadd)
glom_glom_test_connection_CPPFLAGS = $(glom_commandline_cppflags)

glom_glom_export_po_SOURCES = glom/glom_export_po.cc
glom_glom_export_po_LDADD = $(glom_commandline_ldadd)
glom_glom_export_po_CPPFLAGS = $(glom_commandline_cppflags)

glom_glom_export_po_all_SOURCES = glom/glom_export_po_all.cc
glom_glom_export_po_all_LDADD = $(glom_commandline_ldadd)
glom_glom_export_po_all_CPPFLAGS = $(glom_commandline_cppflags)

glom_glom_import_po_all_SOURCES = glom/glom_import_po_all.cc
glom_glom_import_po_all_LDADD = $(glom_commandline_ldadd)
glom_glom_import_po_all_CPPFLAGS = $(glom_commandline_cppflags)
