LIBSQFS_HEARDS = include/sqfs/meta_writer.h \
		include/sqfs/meta_reader.h include/sqfs/id_table.h \
		include/sqfs/compressor.h include/sqfs/block_processor.h \
		include/sqfs/super.h include/sqfs/inode.h \
		include/sqfs/dir.h include/sqfs/xattr.h \
		include/sqfs/table.h include/sqfs/predef.h \
		include/sqfs/error.h include/sqfs/dir_reader.h \
		include/sqfs/dir_writer.h include/sqfs/io.h \
		include/sqfs/data_reader.h include/sqfs/block.h \
		include/sqfs/xattr_reader.h include/sqfs/xattr_writer.h \
		include/sqfs/frag_table.h include/sqfs/block_writer.h

libsquashfs_la_SOURCES = $(LIBSQFS_HEARDS) lib/sqfs/id_table.c lib/sqfs/super.c
libsquashfs_la_SOURCES += lib/sqfs/readdir.c lib/sqfs/xattr/xattr.c
libsquashfs_la_SOURCES += lib/sqfs/write_table.c lib/sqfs/meta_writer.c
libsquashfs_la_SOURCES += lib/sqfs/read_super.c lib/sqfs/meta_reader.c
libsquashfs_la_SOURCES += lib/sqfs/read_inode.c lib/sqfs/write_inode.c
libsquashfs_la_SOURCES += lib/sqfs/dir_writer.c lib/sqfs/xattr/xattr_reader.c
libsquashfs_la_SOURCES += lib/sqfs/read_table.c lib/sqfs/comp/compressor.c
libsquashfs_la_SOURCES += lib/sqfs/comp/internal.h
libsquashfs_la_SOURCES += lib/sqfs/dir_reader.c lib/sqfs/read_tree.c
libsquashfs_la_SOURCES += lib/sqfs/inode.c lib/sqfs/xattr/xattr_writer.c
libsquashfs_la_SOURCES += lib/sqfs/xattr/xattr_writer_flush.c
libsquashfs_la_SOURCES += lib/sqfs/xattr/xattr_writer_record.c
libsquashfs_la_SOURCES += lib/sqfs/xattr/xattr_writer.h
libsquashfs_la_SOURCES += lib/sqfs/write_super.c lib/sqfs/data_reader.c
libsquashfs_la_SOURCES += lib/sqfs/block_processor/internal.h
libsquashfs_la_SOURCES += lib/sqfs/block_processor/common.c
libsquashfs_la_SOURCES += lib/sqfs/block_processor/frontend.c
libsquashfs_la_SOURCES += lib/sqfs/frag_table.c include/sqfs/frag_table.h
libsquashfs_la_SOURCES += lib/sqfs/block_writer.c include/sqfs/block_writer.h
libsquashfs_la_CPPFLAGS = $(AM_CPPFLAGS)
libsquashfs_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBSQUASHFS_SO_VERSION)
libsquashfs_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS)
libsquashfs_la_CFLAGS += $(XZ_CFLAGS) $(LZ4_CFLAGS)
libsquashfs_la_CFLAGS += $(ZSTD_CFLAGS) $(PTHREAD_CFLAGS)
libsquashfs_la_LIBADD = $(XZ_LIBS) $(ZLIB_LIBS) $(LZ4_LIBS)
libsquashfs_la_LIBADD += $(ZSTD_LIBS) $(PTHREAD_LIBS)

# directly "import" stuff from libutil
libsquashfs_la_SOURCES += lib/util/str_table.c lib/util/alloc.c
libsquashfs_la_SOURCES += lib/util/xxhash.c
libsquashfs_la_SOURCES += lib/util/hash_table.c include/hash_table.h

if WINDOWS
libsquashfs_la_SOURCES += lib/sqfs/win32/io_file.c
libsquashfs_la_CFLAGS += -DWINVER=0x0600 -D_WIN32_WINNT=0x0600
libsquashfs_la_CFLAGS += -Wc,-static-libgcc
libsquashfs_la_LDFLAGS += -no-undefined -avoid-version
else
libsquashfs_la_SOURCES += lib/sqfs/unix/io_file.c
endif

if HAVE_PTHREAD
libsquashfs_la_SOURCES += lib/sqfs/block_processor/winpthread.c
libsquashfs_la_CPPFLAGS += -DWITH_PTHREAD
else
if WINDOWS
libsquashfs_la_SOURCES += lib/sqfs/block_processor/winpthread.c
else
libsquashfs_la_SOURCES += lib/sqfs/block_processor/serial.c
endif
endif

if WITH_GZIP
libsquashfs_la_SOURCES += lib/sqfs/comp/gzip.c
libsquashfs_la_CPPFLAGS += -DWITH_GZIP

if WITH_OWN_ZLIB
libsquashfs_la_CPPFLAGS += -I$(top_srcdir)/lib/zlib
libsquashfs_la_LIBADD += libz.la
endif
endif

if WITH_XZ
libsquashfs_la_SOURCES += lib/sqfs/comp/xz.c
libsquashfs_la_SOURCES += lib/sqfs/comp/lzma.c
libsquashfs_la_CPPFLAGS += -DWITH_XZ
endif

if WITH_LZ4
libsquashfs_la_SOURCES += lib/sqfs/comp/lz4.c
libsquashfs_la_CPPFLAGS += -DWITH_LZ4

if WITH_OWN_LZ4
libsquashfs_la_CPPFLAGS += -I$(top_srcdir)/lib/lz4
libsquashfs_la_LIBADD += liblz4.la
endif
endif

if WITH_ZSTD
libsquashfs_la_SOURCES += lib/sqfs/comp/zstd.c
libsquashfs_la_CPPFLAGS += -DWITH_ZSTD
endif

sqfsincludedir = $(includedir)/sqfs
sqfsinclude_HEADERS = $(LIBSQFS_HEARDS)

lib_LTLIBRARIES += libsquashfs.la

pkgconfig_DATA += lib/sqfs/libsquashfs1.pc
