# Copyright 2016 CERN and GSI
#
# 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 <http://www.gnu.org/licenses/>.

PROJECT = silecs
PRODUCT = diagnostic
VERSION = 0.0.0

SKIP_MANIFEST = TRUE
#local
#COMMON_MAKE_PATH ?= /common/home/bel/schwinn/lnx/workspace-silecs-neon/generic-makefiles
#global
COMMON_MAKE_PATH ?= /opt/cern/buildsystem/generic/2.13.2

# product configuration
BIN_NAME = $(PROJECT)-$(PRODUCT)
DBG = false

#DEFINES = -DWITH_RBAC -D_REENTRANT -DQT_NO_DEBUG_OUTPUT -DQT_NO_WARNING_OUTPUT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
DEFINES = -D_REENTRANT -DQT_NO_DEBUG_OUTPUT -DQT_NO_WARNING_OUTPUT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -DQT_WIDGETS_LIB
COMPILER_FLAGS = -O2 -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -mtune=generic $(DEFINES)

#Enable C++11 Support
COMPILER_FLAGS += -std=c++11

LINKER_FLAGS = -Wl,-O1

# list Qt generated files
EXTRA_HEADERS = generated/ui_diagnostictoolmainview.h\
 generated/ui_displayarraydialog.h\
 generated/ui_logindialog.h

EXTRA_SRCS = generated/qrc_images.cpp\
 generated/moc_diagnostictoolmainview.cpp\
 generated/moc_displayarraydialog.cpp\
 generated/moc_logindialog.cpp\
 generated/moc_stderrredirect.cpp

# Include the generic make file
include $(COMMON_MAKE_PATH)/Make.generic

QT_RCC = /usr/bin/rcc-qt5
QT_UIC = /usr/bin/uic-qt5
QT_MOC = /usr/bin/moc-qt5

# rules to generate Qt files
before_compile::
	$(QT_RCC) -name images src/silecs-diagnostic/resources/images.qrc -o src/silecs-diagnostic/generated/qrc_images.cpp
	
	$(QT_UIC) src/silecs-diagnostic/resources/gui/diagnostictoolmainview.ui -o src/silecs-diagnostic/generated/ui_diagnostictoolmainview.h
	$(QT_UIC) src/silecs-diagnostic/resources/gui/displayarraydialog.ui -o src/silecs-diagnostic/generated/ui_displayarraydialog.h
	$(QT_UIC) src/silecs-diagnostic/resources/gui/logindialog.ui -o src/silecs-diagnostic/generated/ui_logindialog.h
	
	$(QT_MOC) $(DEFINES) src/silecs-diagnostic/diagnostictoolmainview.h -o src/silecs-diagnostic/generated/moc_diagnostictoolmainview.cpp
	$(QT_MOC) $(DEFINES) src/silecs-diagnostic/displayarraydialog.h -o src/silecs-diagnostic/generated/moc_displayarraydialog.cpp
	$(QT_MOC) $(DEFINES) src/silecs-diagnostic/logindialog.h -o src/silecs-diagnostic/generated/moc_logindialog.cpp
	$(QT_MOC) $(DEFINES) src/silecs-diagnostic/stderrredirect.h -o src/silecs-diagnostic/generated/moc_stderrredirect.cpp

after_clean::
	rm -f src/silecs-diagnostic/generated/*