noinst_LIBRARIES = libbibledit.a

libbibledit_a_SOURCES = \
	library/bibledit.cpp \
	library/locks.c \
	webserver/webserver.cpp \
	webserver/http.cpp \
	webserver/request.cpp \
	bootstrap/bootstrap.cpp \
	filter/url.cpp \
	filter/string.cpp \
	filter/roles.cpp \
	filter/md5.cpp \
	filter/usfm.cpp \
	filter/archive.cpp \
	filter/text.cpp \
	filter/passage.cpp \
	filter/css.cpp \
	filter/git.cpp \
	filter/html.cpp \
	filter/diff.cpp \
	filter/shell.cpp \
	filter/merge.cpp \
	filter/date.cpp \
	filter/memory.cpp \
	filter/webview.cpp \
	filter/mail.cpp \
  filter/note.cpp \
	flate/flate.cpp \
	assets/view.cpp \
	assets/page.cpp \
	assets/header.cpp \
	assets/external.cpp \
	index/index.cpp \
	index/listing.cpp \
	config/globals.cpp \
	menu/logic.cpp \
	menu/index.cpp \
	locale/translate.cpp \
	locale/logic.cpp \
	database/config/general.cpp \
	database/config/bible.cpp \
	database/config/user.cpp \
	database/users.cpp \
	database/logs.cpp \
	database/sqlite.cpp \
	database/styles.cpp \
	database/bibles.cpp \
	database/books.cpp \
	database/bibleactions.cpp \
	database/check.cpp \
	database/localization.cpp \
	database/confirm.cpp \
	database/ipc.cpp \
	database/jobs.cpp \
	database/kjv.cpp \
	database/logic.cpp \
	database/oshb.cpp \
	database/sblgnt.cpp \
	database/sprint.cpp \
	database/mail.cpp \
	database/navigation.cpp \
	database/usfmresources.cpp \
	database/mappings.cpp \
	database/noteactions.cpp \
	database/versifications.cpp \
	database/modifications.cpp \
	database/notes.cpp \
	database/temporal.cpp \
	database/maintenance.cpp \
	database/imageresources.cpp \
	database/state.cpp \
	database/noteassignment.cpp \
	database/strong.cpp \
	database/morphgnt.cpp \
	database/etcbc4.cpp \
	database/hebrewlexicon.cpp \
	database/cache.cpp \
	database/login.cpp \
	database/privileges.cpp \
	database/git.cpp \
	database/userresources.cpp \
	database/statistics.cpp \
	database/sample.cpp \
	session/logic.cpp \
	session/login.cpp \
	session/logout.cpp \
	session/password.cpp \
	session/signup.cpp \
	session/switch.cpp \
	parsewebdata/ParseMultipartFormData.cpp \
	parsewebdata/ParseWebData.cpp \
	setup/index.cpp \
	setup/logic.cpp \
	journal/index.cpp \
	journal/logic.cpp \
	styles/logic.cpp \
	styles/indexm.cpp \
	styles/sheetm.cpp \
	styles/view.cpp \
	styles/css.cpp \
	styles/sheets.cpp \
	text/text.cpp \
	esword/text.cpp \
	olb/text.cpp \
	html/text.cpp \
	html/header.cpp \
	odf/text.cpp \
	timer/index.cpp \
	tasks/logic.cpp \
	tasks/run.cpp \
	config/logic.cpp \
	bb/logic.cpp \
	bb/manage.cpp \
	bb/settings.cpp \
	bb/book.cpp \
	bb/chapter.cpp \
	bb/import_run.cpp \
	bb/import.cpp \
	bb/order.cpp \
	bb/css.cpp \
	notes/logic.cpp \
	notes/actions.cpp \
	notes/note.cpp \
	notes/status-1.cpp \
	notes/assign-1.cpp \
	notes/notes.cpp \
	notes/status-n.cpp \
	notes/assign-n.cpp \
	notes/click.cpp \
	notes/poll.cpp \
	notes/summary.cpp \
	notes/bb-1.cpp \
	notes/comment.cpp \
	notes/select.cpp \
	notes/unassign-n.cpp \
	notes/bb-n.cpp \
	notes/create.cpp \
	notes/severity-1.cpp \
	notes/verses.cpp \
	notes/bulk.cpp \
	notes/edit.cpp \
	notes/index.cpp \
	notes/severity-n.cpp \
	trash/handler.cpp \
	help/index.cpp \
	confirm/worker.cpp \
	email/index.cpp \
	email/send.cpp \
	email/receive.cpp \
	user/notifications.cpp \
	user/account.cpp \
	user/logic.cpp \
	manage/index.cpp \
	manage/users.cpp \
  manage/accounts.cpp \
	manage/exports.cpp \
	manage/hyphenation.cpp \
	manage/hyphenate.cpp \
	manage/write.cpp \
	manage/privileges.cpp \
	system/index.cpp \
	system/logic.cpp \
	collaboration/index.cpp \
	collaboration/link.cpp \
	collaboration/settings.cpp \
	search/rebibles.cpp \
	search/renotes.cpp \
	access/user.cpp \
	access/bible.cpp \
	access/logic.cpp \
	dialog/entry.cpp \
	dialog/list.cpp \
	dialog/list2.cpp \
	dialog/yes.cpp \
	dialog/color.cpp \
	dialog/books.cpp \
	dialog/upload.cpp \
	fonts/logic.cpp \
	versification/index.cpp \
	versification/system.cpp \
	versification/logic.cpp \
	book/create.cpp \
	compare/index.cpp \
	compare/compare.cpp \
	jobs/index.cpp \
  editone/index.cpp \
  editone/load.cpp \
  editone/save.cpp \
  editone/verse.cpp \
  editone/logic.cpp \
  editone/update.cpp \
	navigation/passage.cpp \
	navigation/update.cpp \
	navigation/poll.cpp \
  navigation/paratext.cpp \
	ipc/focus.cpp \
	ipc/notes.cpp \
	checksum/logic.cpp \
	editusfm/focus.cpp \
	editusfm/index.cpp \
	editusfm/load.cpp \
	editusfm/offset.cpp \
	editusfm/save.cpp \
	editor/styles.cpp \
	editor/html2usfm.cpp \
	editor/usfm2html.cpp \
	editor/select.cpp \
  editor/html2format.cpp \
  editor/id.cpp \
  editor/style.cpp \
	edit/edit.cpp \
	edit/id.cpp \
	edit/index.cpp \
	edit/load.cpp \
	edit/save.cpp \
	edit/styles.cpp \
	edit/logic.cpp \
	edit/preview.cpp \
	edit/position.cpp \
	edit/navigate.cpp \
  edit/update.cpp \
	search/all.cpp \
	search/index.cpp \
	search/replace.cpp \
	search/getids.cpp \
	search/replacepre.cpp \
	search/replacego.cpp \
	search/search2.cpp \
	search/replace2.cpp \
	search/replacepre2.cpp \
	search/getids2.cpp \
	search/replacego2.cpp \
	search/similar.cpp \
	search/strongs.cpp \
	search/strong.cpp \
	search/originals.cpp \
	tmp/tmp.cpp \
	workspace/index.cpp \
	workspace/logic.cpp \
	workspace/settings.cpp \
	workspace/organize.cpp \
	sendreceive/logic.cpp \
	sendreceive/index.cpp \
	sendreceive/sendreceive.cpp \
	sendreceive/settings.cpp \
	sendreceive/bibles.cpp \
	sendreceive/notes.cpp \
	sendreceive/changes.cpp \
	sendreceive/files.cpp \
	sendreceive/resources.cpp \
	demo/logic.cpp \
	client/index.cpp \
	client/logic.cpp \
	sync/logic.cpp \
	sync/setup.cpp \
	sync/settings.cpp \
	sync/bibles.cpp \
	sync/usfmresources.cpp \
	sync/notes.cpp \
	sync/changes.cpp \
	sync/files.cpp \
	sync/resources.cpp \
	sync/mail.cpp \
	resource/index.cpp \
	resource/organize.cpp \
	resource/logic.cpp \
	resource/get.cpp \
	resource/external.cpp \
	resource/bb2resource.cpp \
	resource/convert2resource.cpp \
	resource/convert2bible.cpp \
	resource/manage.cpp \
	resource/print.cpp \
	resource/download.cpp \
	resource/images.cpp \
	resource/image.cpp \
	resource/img.cpp \
	resource/imagefetch.cpp \
	resource/sword.cpp \
	resource/select.cpp \
	resource/cache.cpp \
	resource/user9edit.cpp \
	resource/user1edit.cpp \
	resource/user9view.cpp \
	resource/user1view.cpp \
	resource/bbgateway.cpp \
	resource/studylight.cpp \
	resource/unload.cpp \
	jsonxx/jsonxx.cpp \
	mapping/index.cpp \
	mapping/map.cpp \
	statistics/statistics.cpp \
	changes/change.cpp \
	changes/changes.cpp \
	changes/logic.cpp \
	changes/manage.cpp \
	changes/modifications.cpp \
	changes/statistics.cpp \
	sprint/burndown.cpp \
	sprint/index.cpp \
	checks/run.cpp \
	checks/headers.cpp \
	checks/index.cpp \
	checks/logic.cpp \
	checks/sentences.cpp \
	checks/settings.cpp \
	checks/settingspatterns.cpp \
	checks/settingssentences.cpp \
	checks/space.cpp \
	checks/suppress.cpp \
	checks/usfm.cpp \
	checks/verses.cpp \
	checks/versification.cpp \
	checks/pairs.cpp \
	checks/settingspairs.cpp \
	checks/french.cpp \
	consistency/index.cpp \
	consistency/input.cpp \
	consistency/logic.cpp \
	consistency/poll.cpp \
	export/esword.cpp \
	export/html.cpp \
	export/index.cpp \
	export/info.cpp \
	export/logic.cpp \
	export/odt.cpp \
	export/onlinebible.cpp \
	export/textusfm.cpp \
	export/usfm.cpp \
	export/web.cpp \
	webbb/search.cpp \
	developer/index.cpp \
	developer/logic.cpp \
	paratext/logic.cpp \
	paratext/index.cpp \
	personalize/index.cpp \
	lexicon/logic.cpp \
	lexicon/definition.cpp \
	sources/etcbc4.cpp \
	sources/kjv.cpp \
	sources/morphhb.cpp \
	sources/morphgnt.cpp \
	sources/hebrewlexicon.cpp \
	sources/oshb.cpp \
	sword/logic.cpp \
	pugixml/pugixml.cpp \
	pugixml/utils.cpp \
	public/index.cpp \
	public/logic.cpp \
	public/login.cpp \
	public/chapter.cpp \
	public/notes.cpp \
	public/new.cpp \
	public/create.cpp \
	public/note.cpp \
	public/comment.cpp \
	search/logic.cpp \
	related/logic.cpp \
	sqlite/sqlite3.c \
	ldap/logic.cpp \
	quill/logic.cpp \
	rss/logic.cpp \
	rss/feed.cpp \
	microtar/microtar.c \
	miniz/miniz.c \
  read/index.cpp \
  read/load.cpp \
  read/verse.cpp \
  resource/divider.cpp \
  session/confirm.cpp \
  sources/abbott-smith.cpp \
  database/abbottsmith.cpp \
  resource/comparative9edit.cpp \
  resource/comparative1edit.cpp \
  resource/translated9edit.cpp \
  resource/translated1edit.cpp \
  developer/delay.cpp \
  images/index.cpp \
  images/view.cpp \
  images/fetch.cpp \
  images/logic.cpp \
  database/bibleimages.cpp \
  filter/image.cpp \
  mimetic098/header.cxx \
  mimetic098/contentid.cxx \
  mimetic098/contenttransferencoding.cxx \
  mimetic098/contentdisposition.cxx \
  mimetic098/contentdescription.cxx \
  mimetic098/mimeversion.cxx \
  mimetic098/contenttype.cxx \
  mimetic098/version.cxx \
  mimetic098/fieldparam.cxx \
  mimetic098/mimeentity.cxx \
  mimetic098/strutils.cxx \
  mimetic098/body.cxx \
  mimetic098/utils.cxx \
  mimetic098/rfc822/field.cxx \
  mimetic098/rfc822/header.cxx \
  mimetic098/rfc822/message.cxx \
  mimetic098/rfc822/addresslist.cxx \
  mimetic098/rfc822/fieldvalue.cxx \
  mimetic098/rfc822/mailbox.cxx \
  mimetic098/rfc822/messageid.cxx \
  mimetic098/rfc822/datetime.cxx \
  mimetic098/rfc822/group.cxx \
  mimetic098/rfc822/mailboxlist.cxx \
  mimetic098/rfc822/address.cxx \
  mimetic098/os/utils.cxx \
  mimetic098/os/file_iterator.cxx \
  mimetic098/os/mmfile.cxx \
  mimetic098/codec/base64.cxx \
  system/googletranslate.cpp \
  filter/google.cpp \
  tidy/access.c \
  tidy/alloc.c \
  tidy/attrdict.c \
  tidy/attrs.c \
  tidy/buffio.c \
  tidy/charsets.c \
  tidy/clean.c \
  tidy/config.c \
  tidy/entities.c \
  tidy/fileio.c \
  tidy/gdoc.c \
  tidy/istack.c \
  tidy/language.c \
  tidy/lexer.c \
  tidy/mappedio.c \
  tidy/message.c \
  tidy/messageobj.c \
  tidy/parser.c \
  tidy/pprint.c \
  tidy/sprtf.c \
  tidy/streamio.c \
  tidy/tagask.c \
  tidy/tags.c \
  tidy/tidylib.c \
  tidy/tmbstr.c \
  tidy/utf8.c \
  stylesv2/logic.cpp \
  gumbo/attribute.c \
  gumbo/char_ref.c \
  gumbo/error.c \
  gumbo/parser.c \
  gumbo/string_buffer.c \
  gumbo/string_piece.c \
  gumbo/tag.c \
  gumbo/tokenizer.c \
  gumbo/utf8.c \
  gumbo/util.c \
  gumbo/vector.c

bin_PROGRAMS = bibledit-cloud

bibledit_cloud_SOURCES = executable/bibledit.cpp

bibledit_cloud_LDADD = libbibledit.a

	unittests/unittest.cpp \
	unittests/utilities.cpp \
	unittests/sqlite.cpp \
	unittests/session.cpp \
	unittests/folders.cpp \
	unittests/flate.cpp \
	unittests/checksum.cpp \
	unittests/bibles.cpp \
	unittests/usfm-html.cpp \
	unittests/workspaces.cpp \
	unittests/client.cpp \
	unittests/sentences.cpp \
	unittests/versification.cpp \
	unittests/usfm.cpp \
	unittests/verses.cpp \
	unittests/pairs.cpp \
	unittests/paratext.cpp \
	unittests/hyphenate.cpp \
	unittests/search.cpp \
	unittests/json.cpp \
	unittests/related.cpp \
	unittests/editone.cpp \
	unittests/http.cpp \
	unittests/memory.cpp \
	unittests/tasks.cpp \
	unittests/rss.cpp \
	unittests/space.cpp \
	unittests/roles.cpp \
	unittests/md5.cpp \
	unittests/string.cpp \
	unittests/users.cpp \
	unittests/date.cpp \
	unittests/export.cpp \
	unittests/html.cpp \
	unittests/archive.cpp \
	unittests/odf.cpp \
	unittests/text.cpp \
	unittests/url.cpp \
	unittests/passage.cpp \
	unittests/styles.cpp \
	unittests/diff.cpp \
	unittests/git.cpp \
	unittests/ipc.cpp \
	unittests/shell.cpp \
	unittests/ldap.cpp \
	unittests/dev.cpp \
	unittests/sample.cpp \
	unittests/config.cpp \
	unittests/log.cpp \
	unittests/books.cpp \
	unittests/check.cpp \
	unittests/localization.cpp \
	unittests/confirm.cpp \
	unittests/jobs.cpp \
	unittests/kjv.cpp \
	unittests/oshb.cpp \
	unittests/sblgnt.cpp \
	unittests/sprint.cpp \
	unittests/mail.cpp \
	unittests/navigation.cpp \
	unittests/resources.cpp \
	unittests/notes.cpp \
	unittests/modifications.cpp \
	unittests/volatile.cpp \
	unittests/state.cpp \
	unittests/strong.cpp \
	unittests/morphgnt.cpp \
	unittests/etcbc4.cpp \
	unittests/lexicon.cpp \
	unittests/cache.cpp \
	unittests/login.cpp \
	unittests/privileges.cpp \
	unittests/statistics.cpp \
	unittests/webview.cpp \
	unittests/javascript.cpp \
	unittests/french.cpp \
  unittests/merge.cpp \
  unittests/html2format.cpp \
  unittests/bibleimages.cpp \
  unittests/image.cpp \
  unittests/scraper.cpp


	executable/generate.cpp \
	sources/styles.cpp


AM_CFLAGS = -g
AM_CFLAGS += $(OPENSSL_CFLAGS)

AM_CXXFLAGS = -fno-var-tracking -g
if COMPILERWARNINGS
AM_CFLAGS += -Wall -Wno-unknown-pragmas -Wextra -pedantic -Wno-pragmas
AM_CXXFLAGS += -Wall -Wno-unknown-pragmas -Wextra -pedantic -Wshadow -Warray-bounds -Wcast-align -Wcast-qual -Wconversion -Wctor-dtor-privacy -Wdelete-non-virtual-dtor -Weffc++ -Wextra-semi -Wfloat-equal -Wformat=2 -Wmissing-include-dirs -Wmissing-noreturn -Wnull-dereference -Wold-style-cast -Woverloaded-virtual  -Wredundant-decls -Wsign-promo -Wsuggest-override -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wunused-but-set-parameter -Wunused-macros -Wunused-parameter -Wvla -Wzero-as-null-pointer-constant -Wmismatched-tags
if COMPILERGCC
AM_CXXFLAGS += -Wcatch-value=2 -Wconditionally-supported -Wduplicated-branches -Wduplicated-cond -Wformat-overflow=2 -Wlogical-op -Wnoexcept -Wno-non-template-friend -Wrestrict -Wstrict-null-sentinel -Wuseless-cast -Wcomma-subscript -Wredundant-tags -Wvolatile
endif
endif
if COMPILERCLANG
endif
AM_CXXFLAGS += $(CURL_CFLAGS)
AM_CXXFLAGS += $(OPENSSL_CFLAGS)
AM_CXXFLAGS += $(GTK_CFLAGS)
AM_CXXFLAGS += $(WEBKIT2GTK_CFLAGS)
AM_CXXFLAGS += $(ICU_CFLAGS)
AM_CXXFLAGS += $(XML2_CFLAGS)
AM_CXXFLAGS += $(UTF8PROC_CFLAGS)
# AM_CXXFLAGS += $(TIDY_CFLAGS) -I/usr/include/tidy
AM_CXXFLAGS += $(PUGIXML_CFLAGS)
AM_CXXFLAGS += $(GTEST_CFLAGS)

if MACFLAGS
# Building Bibledit for macOS for two architectures
# due to the switch from macOS from the x86_64 to the arm64 architecture.
# Additionally it uses the includes and libraries from the macOS SDK.
# Generate the macOS SDK path: $ xcrun --show-sdk-path
AM_CXXFLAGS += -mmacosx-version-min=10.10 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -arch x86_64 -arch arm64
AM_CFLAGS += -mmacosx-version-min=10.10 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -arch x86_64 -arch arm64
endif

LIBS = -Wall -lpthread -L. -g -rdynamic -ldl
LIBS += $(CURL_LIBS)
LIBS += $(OPENSSL_LIBS)
LIBS += $(GTK_LIBS)
LIBS += $(WEBKIT2GTK_LIBS)
LIBS += $(ICU_LIBS)
LIBS += $(XML2_LIBS)
LIBS += $(UTF8PROC_LIBS)
# LIBS += $(TIDY_LIBS)
LIBS += $(PUGIXML_LIBS)
LIBS += $(GTEST_LIBS)

# The core library compiles and embeds the mbedtls library.
# On Debian this gives a lintian error:
# E: bibledit: embedded-library usr/bin/bibledit: mbedtls
# Solve this on Debian by omitting that library from the core,
# and by linking to the mbed TLS library provided by the system.
# For other platforms, the library remains in the core.
 LIBS += -lmbedtls -lmbedcrypto -lmbedx509

EXTRA_DIST = a* bb bibledit bibles book bootstrap c* d* D* e* f* g* h* i* j* l* m* n* o* p* q* r* s* t* u* v* w*

dist-hook:
	rm -rf `find $(distdir) -name *.o`
	rm -rf `find $(distdir) -name *.a`
	rm -rf `find $(distdir) -name autom4te.cache`
	rm -f $(distdir)/server
	rm -f $(distdir)/unittest
	rm -rf `find $(distdir) -name .dirstamp`
	rm -rf `find $(distdir) -name .deps`
	rm -rf `find $(distdir) -name *~`
	rm -f $(distdir)/config.h
	rm -f $(distdir)/config.log
	rm -f $(distdir)/config.status

CLEANFILES = bibledit*.gz *~

all-local:
	pkgdata/create.sh

install-data-hook:
	$(srcdir)/pkgdata/install.sh $(srcdir) $(DESTDIR) $(pkgdatadir)

uninstall-local:
	rm -rf $(DESTDIR)$(pkgdatadir)/*

man_MANS = man/bibledit-cloud.1
