# $Id: Makefile.am 29720 2026-04-02 14:16:19Z yeti-dn $

# For each optional module foo there is variable foo_module that should be set
# to foo.la when the module is enabled.
#
# If a module is disabled, add its source files to disabled_sources.  This
# ensures they are still included in tarballs, preserves translations, etc.
disabled_sources =

if HAVE_JSON_GLIB
fusionscope_sources = fusionscope.c
veloxemd_sources = veloxemd.c
else
disabled_sources += fusionscope.c veloxemd.c
endif

hdf5_sources = \
	$(fusionscope_sources) \
	$(veloxemd_sources) \
	hdf5file.c \
	datxfile.c \
	epflfile.c \
	ergofile.c \
	gxsm4.c \
	nhffile.c \
	nsidfile.c \
	shilpsfile.c \
	gwyhdf5.c

# We never bundle since we only have one module here (we put all the hdf5
# functions to one plain module, not a bundle). It requires HDF5 to compile.
# When you add a new file type you must also add a prototype of its
# registration function to hdf5file.h as G_GNUC_INTERNAL and call it in
# hdf5file.c module_register().
#
# JSON-glib is required by fusionscope and veloxemd. We do not compile them at
# all in with JSON unavailble.
#
# JSON-glib is used in nhffile, optionally. The module builds with or without it
# so we just add the flags for the case they are set.
if HAVE_HDF5
file_modules        = hdf5file.la
hdf5file_la_SOURCES = $(hdf5_sources)
hdf5file_la_CFLAGS  = $(AM_CFLAGS) @HDF5_CPPFLAGS@ @HDF5_CFLAGS@ @JSON_GLIB_CFLAGS@
hdf5file_la_LIBADD  = @HDF5_LDFLAGS@ @HDF5_LIBS@ @JSON_GLIB_LIBS@
else
file_modules        =
disabled_sources   += $(hdf5_sources)
endif

filedir = $(libdir)/gwyddion3/modules/file

# Modules listed indirectly via a variable are built optionally.
file_LTLIBRARIES = $(file_modules)

noinst_HEADERS = \
	gwyhdf5.h \
	hdf5file.h

EXTRA_DIST = $(disabled_sources)

if OS_MSWIN
no_undefined = -no-undefined
endif

AM_CPPFLAGS = -I$(top_srcdir) -I$(srcdir)/.. -DG_LOG_DOMAIN=\"Gwy-Module\"
AM_CFLAGS = @GTK_CFLAGS@ @COMMON_CFLAGS@
AM_LDFLAGS = -avoid-version -module $(no_undefined) $(module_libadd)

if MODULE_DEPENDENCIES
module_libadd = \
	$(top_builddir)/libgwyapp/libgwyapp3.la \
	$(top_builddir)/libdraw/libgwydraw3.la \
	$(top_builddir)/libgwyddion/libgwyddion3.la \
	$(top_builddir)/libgwyui/libgwyui3.la \
	@GTK_LIBS@ @LIBM@
else
module_libadd = @LIBM@
endif

clean-local:
	rm -f core.* *~
