#
# Kangaroo Punch MultiPlayer Game Server Mark II
# Copyright (C) 2020-2021  Scott Duensing
#
# This program 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 3 of the License, or
# (at your option) any later version.
#
# This program 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 <https://www.gnu.org/licenses/>.
#

# NOTE:  You'll occasionally find a file with a capital "C" extension.
#        These are C files that we want ignored by the DOS compiler.

TEMPLATE = app
CONFIG -= qt
CONFIG += c99
CONFIG += ASAN

DESTDIR = $$OUT_PWD/bin
SHARED = $$PWD/../shared

QMAKE_CFLAGS += -O0

DEFINES *= CLIENT

DOS_HEADERS = \
	src/thirdparty/serial/serial.h \
	src/thirdparty/sqlite-3.4.2/build/sqlite.h

DOS_SOURCES = \
	src/thirdparty/serial/serial.c \
	src/dos/keyboard.c \
	src/dos/mouse.c \
	src/dos/vesa.c

LINUX_INCLUDES = \
	src/linux \
	src/thirdparty/sqlite-3.4.2/build-linux

LINUX_HEADERS = \
	$$SHARED/thirdparty/enet/include/enet.h \
	src/thirdparty/sqlite-3.4.2/build-linux/sqlite.h

LINUX_SOURCES = \
	src/linux/linux.c

INCLUDEPATH += \
	$$LINUX_INCLUDES \
	$$SHARED \
	src/system \
	src/gui \
	src

HEADERS = \
	$$LINUX_HEADERS \
	$$SHARED/stddclmr.h \
	$$SHARED/thirdparty/stb_ds.h \
	$$SHARED/thirdparty/stb_image.h \
	$$SHARED/thirdparty/memwatch/memwatch.h \
	$$SHARED/thirdparty/ini/src/ini.h \
	$$SHARED/thirdparty/tiny-AES-c/aes.h \
	$$SHARED/thirdparty/tiny-AES128-C/pkcs7_padding.h \
	$$SHARED/thirdparty/SHA256/sha256.h \
	$$SHARED/primes.h \
	$$SHARED/packet.h \
	$$SHARED/packets.h \
	../shared/game.h \
	../shared/macros.h \
	src/browser.h \
	src/config.h \
	$$SHARED/util.h \
	src/file.h \
	src/gui/msgbox.h \
	src/gui/timer.h \
	src/hangup.h \
	src/login.h \
	src/menu.h \
	src/runtime.h \
	src/signup.h \
	src/system/cache.h \
	src/system/db.h \
	src/thirdparty/minicoro/minicoro.h \
	src/system/comport.h \
	src/settings.h \
	src/system/color.h \
	$$SHARED/memory.h \
	src/system/surface.h \
	src/gui/taglist.h \
	src/system/keyboard.h \
	$$SHARED/array.h \
	$$SHARED/log.h \
	src/system/mouse.h \
	src/system/vesa.h \
	src/system/os.h \
	src/system/network.h \
	src/embedded/vga8x14.h \
	src/embedded/mouse.h \
	src/gui/listbox.h \
	src/gui/terminal.h \
	src/gui/updown.h \
	src/gui/button.h \
	src/gui/checkbox.h \
	src/gui/frame.h \
	src/gui/label.h \
	src/gui/picture.h \
	src/gui/radio.h \
	src/gui/rect.h \
	src/gui/textbox.h \
	src/gui/font.h \
	src/gui/desktop.h \
	src/gui/gui.h \
	src/gui/widget.h \
	src/gui/window.h \
	src/gui/image.h \
	src/welcome.h

SOURCES = \
	$$LINUX_SOURCES \
	$$SHARED/thirdparty/memwatch/memwatch.c \
	$$SHARED/thirdparty/ini/src/ini.c \
	$$SHARED/packet.c \
	$$SHARED/thirdparty/tiny-AES-c/aes.c \
	$$SHARED/thirdparty/tiny-AES128-C/pkcs7_padding.c \
	$$SHARED/thirdparty/SHA256/sha256.c \
	$$SHARED/memory.c \
	src/browser.c \
	src/file.c \
	src/gui/msgbox.c \
	src/gui/timer.c \
	src/hangup.c \
	src/runtime.c \
	src/system/cache.c \
	src/system/comport.c \
	src/system/db.c \
	src/system/os.c \
	src/system/surface.c \
	src/system/network.c \
	src/gui/taglist.c \
	$$SHARED/util.c \
	$$SHARED/array.c \
	$$SHARED/log.c \
	src/gui/listbox.c \
	src/gui/terminal.c \
	src/gui/updown.c \
	src/gui/font.c \
	src/gui/image.c \
	src/gui/gui.c \
	src/gui/desktop.c \
	src/gui/widget.c \
	src/gui/window.c \
	src/gui/picture.c \
	src/gui/radio.c \
	src/gui/textbox.c \
	src/gui/frame.c \
	src/gui/button.c \
	src/gui/checkbox.c \
	src/gui/label.c \
	src/config.c \
	src/main.c \
	src/welcome.c \
	src/login.c \
	src/menu.c \
	src/signup.c \
	src/settings.c

LIBS = \
	-L$$PWD/src/thirdparty/sqlite-3.4.2/build-linux/.libs \
	-lsqlite3 \
	-lSDL2 \
	-lSDL2_image

OTHER_FILES = \
	$$DOS_HEADERS \
	$$DOS_SOURCES \
	postBuild.sh

ASAN {
	QMAKE_CFLAGS += -fsanitize=address -g
	QMAKE_LFLAGS += -fsanitize=address -static-libasan
}

QMAKE_POST_LINK = $$PWD/postBuild.sh "$$PWD" "$$DESTDIR"

DISTFILES +=
