# library
lib_LTLIBRARIES = src/libmega.la

# CXX flags
if WIN32
src_libmega_la_CXXFLAGS = -D_WIN32=1 -Iinclude/ -Iinclude/mega/win32 $(LIBS_EXTRA) $(ZLIB_CXXFLAGS) $(LIBUV_CXXFLAGS) $(LIBRAW_CXXFLAGS) $(LIBMEDIAINFO_CXXFLAGS) $(FFMPEG_CXXFLAGS) $(CRYPTO_CXXFLAGS) $(SODIUM_CXXFLAGS) $(DB_CXXFLAGS) $(CXXFLAGS) $(WINHTTP_CXXFLAGS) $(FI_CXXFLAGS) $(PDF_CXXFLAGS) $(ICU_CXXFLAGS) $(PCRE_CXXFLAGS)
else
src_libmega_la_CXXFLAGS = $(CARES_FLAGS) $(LIBCURL_FLAGS) $(ZLIB_CXXFLAGS) $(LIBUV_CXXFLAGS) $(LIBRAW_CXXFLAGS) $(LIBMEDIAINFO_CXXFLAGS) $(FFMPEG_CXXFLAGS) $(CRYPTO_CXXFLAGS) $(SODIUM_CXXFLAGS) $(DB_CXXFLAGS) $(FI_CXXFLAGS) $(PDF_CXXFLAGS) $(ICU_CXXFLAGS) $(LIBSSL_FLAGS) $(PCRE_CXXFLAGS)
endif

# Libs
if WIN32
src_libmega_la_LIBADD = $(LIBS_EXTRA)  $(FFMPEG_LDFLAGS) $(FFMPEG_LIBS) $(LIBUV_LDFLAGS) $(LIBUV_LIBS) $(LIBRAW_LDFLAGS) $(LIBRAW_LIBS) $(LIBMEDIAINFO_LDFLAGS) $(LIBMEDIAINFO_LIBS) $(ZLIB_LDFLAGS) $(ZLIB_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) $(SODIUM_LDFLAGS) $(SODIUM_LIBS) $(DB_LDFLAGS) $(DB_LIBS) $(WINHTTP_LDFLAGS) $(WINHTTP_LIBS) $(FI_LDFLAGS) $(FI_LIBS) $(PDF_LDFLAGS) $(PDF_LIBS) $(ICU_LDFLAGS) $(ICU_LIBS) $(PCRE_LDFLAGS) $(PCRE_LIBS)
else
src_libmega_la_LIBADD = $(CARES_LDFLAGS) $(CARES_LIBS) $(LIBCURL_LIBS) $(FFMPEG_LDFLAGS) $(FFMPEG_LIBS) $(LIBUV_LDFLAGS) $(LIBUV_LIBS) $(LIBRAW_LDFLAGS) $(LIBRAW_LIBS) $(LIBMEDIAINFO_LDFLAGS) $(LIBMEDIAINFO_LIBS) $(ZLIB_LDFLAGS) $(ZLIB_LIBS) $(CRYPTO_LDFLAGS) $(CRYPTO_LIBS) $(SODIUM_LDFLAGS) $(SODIUM_LIBS) $(DB_LDFLAGS) $(DB_LIBS) $(FI_LDFLAGS) $(FI_LIBS) $(PDF_LDFLAGS) $(PDF_LIBS) $(ICU_LDFLAGS) $(ICU_LIBS) $(LIBSSL_LDFLAGS) $(LIBSSL_LIBS) $(PCRE_LDFLAGS) $(PCRE_LIBS)
endif

# add library version
src_libmega_la_LDFLAGS = -version-info $(VERSION_INFO) $(LIBMEGA_EXTRALDFLAGS)

if ENABLE_STATIC
src_libmega_la_LDFLAGS += -Wl,-static -all-static
endif

# common sources
src_libmega_la_SOURCES = src/megaclient.cpp
src_libmega_la_SOURCES += src/attrmap.cpp
src_libmega_la_SOURCES += src/autocomplete.cpp
src_libmega_la_SOURCES += src/backofftimer.cpp
src_libmega_la_SOURCES += src/base64.cpp
src_libmega_la_SOURCES += src/command.cpp
src_libmega_la_SOURCES += src/commands.cpp
src_libmega_la_SOURCES += src/db.cpp
src_libmega_la_SOURCES += src/fileattributefetch.cpp
src_libmega_la_SOURCES += src/file.cpp
src_libmega_la_SOURCES += src/filefingerprint.cpp
src_libmega_la_SOURCES += src/filesystem.cpp
src_libmega_la_SOURCES += src/gfx.cpp
src_libmega_la_SOURCES += src/http.cpp
src_libmega_la_SOURCES += src/json.cpp
src_libmega_la_SOURCES += src/mediafileattribute.cpp
src_libmega_la_SOURCES += src/node.cpp
src_libmega_la_SOURCES += src/pubkeyaction.cpp
src_libmega_la_SOURCES += src/raid.cpp
src_libmega_la_SOURCES += src/testhooks.cpp
src_libmega_la_SOURCES += src/request.cpp
src_libmega_la_SOURCES += src/serialize64.cpp
src_libmega_la_SOURCES += src/nodemanager.cpp
src_libmega_la_SOURCES += src/setandelement.cpp
src_libmega_la_SOURCES += src/share.cpp
src_libmega_la_SOURCES += src/sharenodekeys.cpp
src_libmega_la_SOURCES += src/sync.cpp
src_libmega_la_SOURCES += src/transfer.cpp
src_libmega_la_SOURCES += src/transferslot.cpp
src_libmega_la_SOURCES += src/treeproc.cpp
src_libmega_la_SOURCES += src/user.cpp
src_libmega_la_SOURCES += src/useralerts.cpp
src_libmega_la_SOURCES += src/utils.cpp
src_libmega_la_SOURCES += src/logging.cpp
src_libmega_la_SOURCES += src/waiterbase.cpp
src_libmega_la_SOURCES += src/proxy.cpp
src_libmega_la_SOURCES += src/crypto/cryptopp.cpp
src_libmega_la_SOURCES += src/db/sqlite.cpp
src_libmega_la_SOURCES += src/mega_utf8proc.cpp
src_libmega_la_SOURCES += src/mega_ccronexpr.cpp
src_libmega_la_SOURCES += src/mega_evt_tls.cpp
src_libmega_la_SOURCES += src/gfx/external.cpp
src_libmega_la_SOURCES += src/pendingcontactrequest.cpp
src_libmega_la_SOURCES += src/textchat.cpp
src_libmega_la_SOURCES += src/mega_zxcvbn.cpp

EXTRA_DIST = src/mega_utf8proc_data.c

if BUILD_MEGAAPI
src_libmega_la_SOURCES += src/megaapi_impl.cpp
src_libmega_la_SOURCES += src/megaapi.cpp
src_libmega_la_SOURCES += src/heartbeats.cpp
endif

if USE_PDFIUM
src_libmega_la_SOURCES += src/gfx/gfx_pdfium.cpp
endif

if USE_FREEIMAGE
src_libmega_la_SOURCES += src/gfx/freeimage.cpp
endif

if USE_SODIUM
src_libmega_la_SOURCES += src/crypto/sodium.cpp
endif

if USE_LIBUV
src_libmega_la_SOURCES += src/mega_http_parser.cpp
endif

if USE_DRIVE_NOTIFICATIONS
src_libmega_la_SOURCES += src/drivenotify.cpp
if WIN32
src_libmega_la_SOURCES += src/win32/drivenotifywin.cpp
src_libmega_la_LDFLAGS += -lwbemuuid
else
if DARWIN
src_libmega_la_SOURCES += src/osx/drivenotifyosx.cpp
src_libmega_la_LDFLAGS += -framework CoreFoundation -framework DiskArbitration
else
src_libmega_la_SOURCES += src/posix/drivenotifyposix.cpp
src_libmega_la_LDFLAGS += -ludev
endif
endif
endif

# IOS specific
if USE_IOS
src_libmega_la_SOURCES += src/gfx/GfxProcCG.mm
else
if DARWIN
# MacOS specific
src_libmega_la_OBJCXXFLAGS = $(src_libmega_la_CXXFLAGS)
src_libmega_la_SOURCES += src/osx/osxutils.mm
src_libmega_la_LDFLAGS += -framework SystemConfiguration -framework Foundation
endif
endif



# win32 sources
if WIN32
src_libmega_la_SOURCES+= src/win32/fs.cpp
src_libmega_la_SOURCES+= src/win32/console.cpp
src_libmega_la_SOURCES+= src/win32/net.cpp
src_libmega_la_SOURCES+= src/win32/waiter.cpp
src_libmega_la_SOURCES+= src/win32/consolewaiter.cpp

if HAVE_PTHREAD
src_libmega_la_SOURCES += src/thread/posixthread.cpp
else
src_libmega_la_SOURCES+= src/thread/win32thread.cpp
endif


# posix sources
else
src_libmega_la_SOURCES += src/posix/fs.cpp
src_libmega_la_SOURCES += src/posix/console.cpp
src_libmega_la_SOURCES += src/posix/net.cpp
src_libmega_la_SOURCES += src/posix/waiter.cpp
src_libmega_la_SOURCES += src/posix/consolewaiter.cpp

src_libmega_la_SOURCES += src/thread/posixthread.cpp

endif

if ANDROID
src_libmega_la_SOURCES += src/mega_glob.c
endif

if DARWIN
src_libmega_la_SOURCES += src/osx/fs.cpp
endif

