Add CNTK comment in mne-cpp.pri

Add CNTK comment in mne-cpp.pri

############################################## GLOBAL FUNCTIONS ###############################################
#Define minQtVersion Test
defineTest(minQtVersion) {
    maj = $$1
    min = $$2
    patch = $$3
    isEqual(QT_MAJOR_VERSION, $$maj) {
        isEqual(QT_MINOR_VERSION, $$min) {
            isEqual(QT_PATCH_VERSION, $$patch) {
                return(true)
            }
            greaterThan(QT_PATCH_VERSION, $$patch) {
                return(true)
            }
        }
        greaterThan(QT_MINOR_VERSION, $$min) {
            return(true)
        }
    }
    greaterThan(QT_MAJOR_VERSION, $$maj) {
        return(true)
    }
    return(false)
}

############################################### GLOBAL DEFINES ################################################

MNE_CPP_VERSION = 1.0.0
MNE_LIB_VERSION = 1

QMAKE_TARGET_PRODUCT = mne-cpp
QMAKE_TARGET_DESCRIPTION = MNE Qt 5 based C++ library.
QMAKE_TARGET_COPYRIGHT = Copyright (C) 2018 Authors of mne-cpp. All rights reserved.

########################################### PROJECT CONFIGURATION #############################################

## To build only the minimal version, i.e, for mne_rt_server run: qmake MNECPP_CONFIG+=minimalVersion
## To set CodeCov coverage compiler flag run: qmake MNECPP_CONFIG+=withCodeCov
## To disable tests run: qmake MNECPP_CONFIG+=noTests
## To disable examples run: qmake MNECPP_CONFIG+=noExamples
## To build basic MNE Scan version run: qmake MNECPP_CONFIG+=buildBasicMneScanVersion
## To build MNE-CPP libraries as static libs: qmake MNECPP_CONFIG+=static
## To build MNE-CPP Deep library based CNTK: qmake MNECPP_CONFIG+=buildDeep

#Build minimalVersion for qt versions < 5.10.0
!minQtVersion(5, 10, 0) {
    message("Building minimal version due to Qt version $${QT_VERSION}.")
    MNECPP_CONFIG += minimalVersion
}

########################################### DIRECTORY DEFINITIONS #############################################

# Eigen
EIGEN_INCLUDE_DIR = $$EIGEN_INCLUDE_DIR
isEmpty(EIGEN_INCLUDE_DIR) {
    EIGEN_INCLUDE_DIR = $${PWD}/include/3rdParty/eigen3
}

#CNTK
CNTK_INCLUDE_DIR = $$CNTK_INCLUDE_DIR
isEmpty( CNTK_INCLUDE_DIR ) {
    # Check CNTK Path options
    exists($$(CNTKPATH)/cntk/Include/Eval.h) {
        CNTK_TEST_DIR = $$(CNTKPATH)/cntk
    }
    exists($$(CNTKPATH)/Include/Eval.h) {
        CNTK_TEST_DIR = $$(CNTKPATH)
    }
    exists($$(MYCNTKPATH)/cntk/Include/Eval.h) {
        CNTK_TEST_DIR = $$(MYCNTKPATH)/cntk
    }
    exists($$(MYCNTKPATH)/Include/Eval.h) {
        CNTK_TEST_DIR = $$(MYCNTKPATH)
    }
    # Set CNTK path variables
    !isEmpty( CNTK_TEST_DIR ) {
        CNTK_INCLUDE_DIR = $${CNTK_TEST_DIR}/Include
        CNTK_LIBRARY_DIR = $${CNTK_TEST_DIR}/cntk
    }
}

# include
MNE_INCLUDE_DIR = $$MNE_INCLUDE_DIR
isEmpty( MNE_INCLUDE_DIR ) {
    MNE_INCLUDE_DIR = $${PWD}/libraries
}
MNE_SCAN_INCLUDE_DIR = $$MNE_SCAN_INCLUDE_DIR
isEmpty( MNE_SCAN_INCLUDE_DIR ) {
    MNE_SCAN_INCLUDE_DIR = $${PWD}/applications/mne_scan/libs
}
MNE_ANALYZE_INCLUDE_DIR = $$MNE_ANALYZE_INCLUDE_DIR
isEmpty( MNE_ANALYZE_INCLUDE_DIR ) {
    MNE_ANALYZE_INCLUDE_DIR = $${PWD}/applications/mne_analyze/libs
}
MNE_ANALYZE_EXTENSIONS_DIR = $$MNE_ANALYZE_EXTENSIONS_DIR
isEmpty( MNE_ANALYZE_EXTENSIONS_DIR ) {
    MNE_ANALYZE_EXTENSIONS_DIR = $${PWD}/applications/mne_analyze/extensions
}

# lib
MNE_LIBRARY_DIR = $$MNE_LIBRARY_DIR
isEmpty( MNE_LIBRARY_DIR ) {
    MNE_LIBRARY_DIR = $${PWD}/lib
}
contains(MNECPP_CONFIG, buildDeep) {
    CNTK_LIBRARY_DIR = $$CNTK_LIBRARY_DIR
    isEmpty( CNTK_LIBRARY_DIR ) {
        CNTK_LIBRARY_DIR = C:/local/cntk/cntk
    }
}

# bin
MNE_BINARY_DIR = $$MNE_BINARY_DIR
isEmpty( MNE_BINARY_DIR ) {
    MNE_BINARY_DIR = $${PWD}/bin
}

# repository dir
ROOT_DIR = $${PWD}

############################################## GLOBAL FUNCTIONS ###############################################
#Define minQtVersion Test
defineTest(minQtVersion) {
    maj = $$1
    min = $$2
    patch = $$3
    isEqual(QT_MAJOR_VERSION, $$maj) {
        isEqual(QT_MINOR_VERSION, $$min) {
            isEqual(QT_PATCH_VERSION, $$patch) {
                return(true)
            }
            greaterThan(QT_PATCH_VERSION, $$patch) {
                return(true)
            }
        }
        greaterThan(QT_MINOR_VERSION, $$min) {
            return(true)
        }
    }
    greaterThan(QT_MAJOR_VERSION, $$maj) {
        return(true)
    }
    return(false)
}

############################################### GLOBAL DEFINES ################################################

MNE_CPP_VERSION = 1.0.0
MNE_LIB_VERSION = 1

QMAKE_TARGET_PRODUCT = mne-cpp
QMAKE_TARGET_DESCRIPTION = MNE Qt 5 based C++ library.
QMAKE_TARGET_COPYRIGHT = Copyright (C) 2018 Authors of mne-cpp. All rights reserved.

########################################### PROJECT CONFIGURATION #############################################

## To build only the minimal version, i.e, for mne_rt_server run: qmake MNECPP_CONFIG+=minimalVersion
## To set CodeCov coverage compiler flag run: qmake MNECPP_CONFIG+=withCodeCov
## To disable tests run: qmake MNECPP_CONFIG+=noTests
## To disable examples run: qmake MNECPP_CONFIG+=noExamples
## To build basic MNE Scan version run: qmake MNECPP_CONFIG+=buildBasicMneScanVersion
## To build MNE-CPP libraries as static libs: qmake MNECPP_CONFIG+=static
## To build MNE-CPP Deep library: qmake MNECPP_CONFIG+=buildDeep

#Build minimalVersion for qt versions < 5.10.0
!minQtVersion(5, 10, 0) {
    message("Building minimal version due to Qt version $${QT_VERSION}.")
    MNECPP_CONFIG += minimalVersion
}

########################################### DIRECTORY DEFINITIONS #############################################

# Eigen
EIGEN_INCLUDE_DIR = $$EIGEN_INCLUDE_DIR
isEmpty(EIGEN_INCLUDE_DIR) {
    EIGEN_INCLUDE_DIR = $${PWD}/include/3rdParty/eigen3
}

#CNTK
CNTK_INCLUDE_DIR = $$CNTK_INCLUDE_DIR
isEmpty( CNTK_INCLUDE_DIR ) {
    # Check CNTK Path options
    exists($$(CNTKPATH)/cntk/Include/Eval.h) {
        CNTK_TEST_DIR = $$(CNTKPATH)/cntk
    }
    exists($$(CNTKPATH)/Include/Eval.h) {
        CNTK_TEST_DIR = $$(CNTKPATH)
    }
    exists($$(MYCNTKPATH)/cntk/Include/Eval.h) {
        CNTK_TEST_DIR = $$(MYCNTKPATH)/cntk
    }
    exists($$(MYCNTKPATH)/Include/Eval.h) {
        CNTK_TEST_DIR = $$(MYCNTKPATH)
    }
    # Set CNTK path variables
    !isEmpty( CNTK_TEST_DIR ) {
        CNTK_INCLUDE_DIR = $${CNTK_TEST_DIR}/Include
        CNTK_LIBRARY_DIR = $${CNTK_TEST_DIR}/cntk
    }
}

# include
MNE_INCLUDE_DIR = $$MNE_INCLUDE_DIR
isEmpty( MNE_INCLUDE_DIR ) {
    MNE_INCLUDE_DIR = $${PWD}/libraries
}
MNE_SCAN_INCLUDE_DIR = $$MNE_SCAN_INCLUDE_DIR
isEmpty( MNE_SCAN_INCLUDE_DIR ) {
    MNE_SCAN_INCLUDE_DIR = $${PWD}/applications/mne_scan/libs
}
MNE_ANALYZE_INCLUDE_DIR = $$MNE_ANALYZE_INCLUDE_DIR
isEmpty( MNE_ANALYZE_INCLUDE_DIR ) {
    MNE_ANALYZE_INCLUDE_DIR = $${PWD}/applications/mne_analyze/libs
}
MNE_ANALYZE_EXTENSIONS_DIR = $$MNE_ANALYZE_EXTENSIONS_DIR
isEmpty( MNE_ANALYZE_EXTENSIONS_DIR ) {
    MNE_ANALYZE_EXTENSIONS_DIR = $${PWD}/applications/mne_analyze/extensions
}

# lib
MNE_LIBRARY_DIR = $$MNE_LIBRARY_DIR
isEmpty( MNE_LIBRARY_DIR ) {
    MNE_LIBRARY_DIR = $${PWD}/lib
}
contains(MNECPP_CONFIG, buildDeep) {
    CNTK_LIBRARY_DIR = $$CNTK_LIBRARY_DIR
    isEmpty( CNTK_LIBRARY_DIR ) {
        CNTK_LIBRARY_DIR = C:/local/cntk/cntk
    }
}

# bin
MNE_BINARY_DIR = $$MNE_BINARY_DIR
isEmpty( MNE_BINARY_DIR ) {
    MNE_BINARY_DIR = $${PWD}/bin
}

# repository dir
ROOT_DIR = $${PWD}


added warning surpressor

added warning surpressor

QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -Wno-unused-parameter
QMAKE_CXXFLAGS += -Wno-sign-compare
QMAKE_CXXFLAGS += -Wno-unused-local-typedefs

CONFIG(debug, debug|release) {
CONF=debug
}

CONFIG(release, debug|release) {
CONF=release
}

PLATFORM = generic
win32{
    PLATFORM = win32
}
BOOST=../external

QT += sql

plugin{
DESTDIR = $$PWD/../libraries/$$PLATFORM$$CONF/$$TARGET
DLLDESTDIR = $$PWD/../output/$$PLATFORM$$CONF/bin/extensions/$$TARGET
}dll{
DESTDIR = $$PWD/../libraries/$$PLATFORM$$CONF/$$TARGET
DLLDESTDIR = $$PWD/../output/$$PLATFORM$$CONF/bin
}else {
DESTDIR = $$PWD/../libraries/$$PLATFORM$$CONF/$$TARGET
DLLDESTDIR = $$PWD/../output/$$PLATFORM$$CONF/bin
}

INCLUDEPATH += core \
                core/ilwisobjects \
                core/ilwisobjects/geometry \
                core/util \
                core/ilwisobjects/geometry/geodeticdatum \
                core/ilwisobjects/geometry/projection \
                core/ilwisobjects/geometry/coordinatesystem \
                core/ilwisobjects/geometry/georeference \
                core/ilwisobjects/coverage \
                core/ilwisobjects/table \
                core/ilwisobjects/operation \
                core/catalog \
                core/ilwisobjects/domain \
                $$BOOST

QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -Wno-unused-parameter
QMAKE_CXXFLAGS += -Wno-sign-compare

CONFIG(debug, debug|release) {
CONF=debug
}

CONFIG(release, debug|release) {
CONF=release
}

PLATFORM = generic
win32{
    PLATFORM = win32
}
BOOST=../external

QT += sql

plugin{
DESTDIR = $$PWD/../libraries/$$PLATFORM$$CONF/$$TARGET
DLLDESTDIR = $$PWD/../output/$$PLATFORM$$CONF/bin/extensions/$$TARGET
}dll{
DESTDIR = $$PWD/../libraries/$$PLATFORM$$CONF/$$TARGET
DLLDESTDIR = $$PWD/../output/$$PLATFORM$$CONF/bin
}else {
DESTDIR = $$PWD/../libraries/$$PLATFORM$$CONF/$$TARGET
DLLDESTDIR = $$PWD/../output/$$PLATFORM$$CONF/bin
}

INCLUDEPATH += core \
                core/ilwisobjects \
                core/ilwisobjects/geometry \
                core/util \
                core/ilwisobjects/geometry/geodeticdatum \
                core/ilwisobjects/geometry/projection \
                core/ilwisobjects/geometry/coordinatesystem \
                core/ilwisobjects/geometry/georeference \
                core/ilwisobjects/coverage \
                core/ilwisobjects/table \
                core/ilwisobjects/operation \
                core/catalog \
                core/ilwisobjects/domain \
                $$BOOST


Fixed compiler version detection for GCC

# Copyright 2016 Iakov Kirilenko, 2007-2017 QReal Research Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#	  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

win32 {
	PLATFORM = windows
}

unix:!macx {
	PLATFORM = linux
}

macx {
	PLATFORM = mac
}

CONFIG(debug, debug | release) {
	CONFIGURATION = debug
	CONFIGURATION_SUFFIX = -d
	unix {
		QMAKE_CXXFLAGS += -coverage
		QMAKE_LFLAGS += -coverage
	}
} else {
	CONFIGURATION = release
	CONFIGURATION_SUFFIX =
}

DESTDIR = $$PWD/bin/$$CONFIGURATION

PROJECT_BASENAME = $$basename(_PRO_FILE_)
PROJECT_NAME = $$section(PROJECT_BASENAME, ".", 0, 0)

isEmpty(TARGET) {
	TARGET = $$PROJECT_NAME$$CONFIGURATION_SUFFIX
} else {
	TARGET = $$TARGET$$CONFIGURATION_SUFFIX
}

equals(TEMPLATE, app) {
	unix:!macx {
		QMAKE_LFLAGS += -Wl,-rpath-link,$$DESTDIR
		!CONFIG(no_rpath) QMAKE_LFLAGS += -Wl,-O1,-rpath,.
	}
	macx:!CONFIG(no_rpath) {
		QMAKE_LFLAGS += -rpath . -rpath @executable_path/../Lib -rpath @executable_path/../Frameworks -rpath @executable_path/../../../
	}
}

macx-clang {
	QMAKE_MACOSX_DEPLOYMENT_TARGET=10.9
	QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
}

!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -qEe '"\<5\.[0-9]+\."' ){ CONFIG += gcc5 }
!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -qEe '"\<4\.[0-9]+\."' ){ CONFIG += gcc4 }

CONFIG(no-sanitizers): CONFIG += nosanitizers

!CONFIG(nosanitizers):!clang:gcc:*-g++*:gcc4{
	warning("Disabled sanitizers, failed to detect compiler version or too old compiler: $$QMAKE_CXX")
	CONFIG += nosanitizers
}

unix:!CONFIG(nosanitizers) {

	# seems like we want USan always, but are afraid of ....
	!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!CONFIG(sanitize_memory):!CONFIG(sanitize_kernel_address) {
		# Ubsan is turned on by default
		CONFIG += sanitizer sanitize_undefined
	}

	CONFIG(debug, debug | release):!CONFIG(sanitize_address):!macx-clang { CONFIG += sanitize_leak }

	CONFIG(sanitize_leak) {
		#LSan can be used without performance degrade even in release build
		QMAKE_CFLAGS += -fsanitize=leak
		QMAKE_CXXFLAGS += -fsanitize=leak
		QMAKE_LFLAGS += -fsanitize=leak
	}

	CONFIG(sanitize_undefined):macx-clang {
		# sometimes runtime is missing in clang. this hack allows to avoid runtime dependency.
		QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fsanitize-trap=undefined
		QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined
		QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fsanitize-trap=undefined
	}

	CONFIG(gcc5){
		CONFIG(sanitize_undefined){
		# Ubsan has (had at least) known issues with false errors about calls of methods of the base class.
		# That must be disabled. Variables for confguring ubsan are taken from here:
		# https://codereview.qt-project.org/#/c/43420/17/mkspecs/common/sanitize.conf
		# They can change in some version of Qt, keep track of it.
		# By the way, simply setting QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS instead of those used below
		# will not work due to arguments order ("-fsanitize=undefined" must be declared before "-fno-sanitize=vptr").
			QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fno-sanitize=vptr
			QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fno-sanitize=vptr
			QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fno-sanitize=vptr
		}
	}

	CONFIG(release, debug | release){
		CONFIG(gcc4) {
			message("Too old compiler: $$QMAKE_CXX")
		} else {
			QMAKE_CFLAGS += -fsanitize-recover=all
			QMAKE_CXXFLAGS += -fsanitize-recover=all
		}
	}

}

OBJECTS_DIR = .build/$$CONFIGURATION/obj
MOC_DIR = .build/$$CONFIGURATION/moc
RCC_DIR = .build/$$CONFIGURATION/rcc
UI_DIR = .build/$$CONFIGURATION/ui

INCLUDEPATH += $$_PRO_FILE_PWD_ \
	$$_PRO_FILE_PWD_/include \
	$$PWD \

LIBS += -L$$DESTDIR

QMAKE_CXXFLAGS += -pedantic-errors -ansi -std=c++11 -Wextra

CONFIG(gcc5)|clang{
	QMAKE_CXXFLAGS +=-Werror=pedantic -Werror=delete-incomplete
}

QMAKE_CXXFLAGS += -Werror=cast-qual -Werror=write-strings -Werror=redundant-decls -Werror=unreachable-code \
			-Werror=non-virtual-dtor -Wno-error=overloaded-virtual \
			-Werror=uninitialized -Werror=init-self

# I want -Werror to be turned on, but Qt has problems
#QMAKE_CXXFLAGS += -Werror -Wno-error=inconsistent-missing-override -Wno-error=deprecated-declarations -Wno-error=unused-parameter

GLOBAL_PWD = $$PWD

# Simple function that checks if given argument is a file or directory.
# Returns false if argument 1 is a file or does not exist.
defineTest(isDir) {
	exists($$1/*):return(true)
	return(false)
}

# Useful function to copy additional files to destination,
# from http://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output
defineTest(copyToDestdir) {
	FILES = $$1
	NOW = $$2

	for(FILE, FILES) {
		DESTDIR_SUFFIX =
		AFTER_SLASH = $$section(FILE, "/", -1, -1)
		# This ugly code is needed because xcopy requires to add source directory name to target directory name when copying directories
		win32 {
			FILE = $$system_path($$FILE)
			isDir($$FILE) {
				ABSOLUTE_PATH = $$absolute_path($$FILE, $$GLOBAL_PWD)
				BASE_NAME = $$section(ABSOLUTE_PATH, "/", -1, -1)
				DESTDIR_SUFFIX = /$$BASE_NAME
			}
		}

		DDIR = $$DESTDIR/$$3$$DESTDIR_SUFFIX
		#win32:DDIR ~= s,/,\\,g ??? why not system_path?
		DDIR = $$system_path($$DDIR)
		mkpath($$DDIR)

		isEmpty(NOW) {
			# In case this is directory add "*" to copy contents of a directory instead of directory itself under linux.
			!win32:equals(AFTER_SLASH, ""):FILE = $$FILE* #looks like inconsistent behaviour
			win32:equals(AFTER_SLASH, "*"):FILE = $$section(FILE, "*", 0, -2)\\\*
			win32:QMAKE_POST_LINK += $$quote("xcopy /s /e /q /y /i") $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
			!win32:QMAKE_POST_LINK += $(COPY_DIR) $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
		} else {
			win32 {
				# Message here is very useful in diagnostics.
				message("Executing cmd /C \\\"xcopy $$quote($$FILE) $$quote($$DDIR) /s /e /q /y /i\\\"")
				system("cmd /C \\\"xcopy $$quote($$FILE) $$quote($$DDIR) /s /e /q /y /i\\\"")
			}

			unix:!macx {
				system("cp -r -f $$FILE $$DDIR/")
			}

			macx {
				system("rsync -avz $$FILE $$DDIR/")
			}
		}
	}

	export(QMAKE_POST_LINK)
}

defineTest(includes) {
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		INCLUDEPATH += $$GLOBAL_PWD/$$PROJECT $$GLOBAL_PWD/$$PROJECT/include
	}

	export(INCLUDEPATH)
}

defineTest(links) {
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		LIBS += -l$$PROJECT$$CONFIGURATION_SUFFIX
	}

	export(LIBS)
}

# Copyright 2016 Iakov Kirilenko, 2007-2017 QReal Research Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#	  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

win32 {
	PLATFORM = windows
}

unix:!macx {
	PLATFORM = linux
}

macx {
	PLATFORM = mac
}

CONFIG(debug, debug | release) {
	CONFIGURATION = debug
	CONFIGURATION_SUFFIX = -d
	unix {
		QMAKE_CXXFLAGS += -coverage
		QMAKE_LFLAGS += -coverage
	}
} else {
	CONFIGURATION = release
	CONFIGURATION_SUFFIX =
}

DESTDIR = $$PWD/bin/$$CONFIGURATION

PROJECT_BASENAME = $$basename(_PRO_FILE_)
PROJECT_NAME = $$section(PROJECT_BASENAME, ".", 0, 0)

isEmpty(TARGET) {
	TARGET = $$PROJECT_NAME$$CONFIGURATION_SUFFIX
} else {
	TARGET = $$TARGET$$CONFIGURATION_SUFFIX
}

equals(TEMPLATE, app) {
	unix:!macx {
		QMAKE_LFLAGS += -Wl,-rpath-link,$$DESTDIR
		!CONFIG(no_rpath) QMAKE_LFLAGS += -Wl,-O1,-rpath,.
	}
	macx:!CONFIG(no_rpath) {
		QMAKE_LFLAGS += -rpath . -rpath @executable_path/../Lib -rpath @executable_path/../Frameworks -rpath @executable_path/../../../
	}
}

macx-clang {
	QMAKE_MACOSX_DEPLOYMENT_TARGET=10.9
	QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
}

!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -oe \'\\<[5-6]\\.[0-9]\\+\\.\' ){ CONFIG += gcc5 }
!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -oe \'\\<4\\.[0-9]\\+\\.\' ){ CONFIG += gcc4 }

unix:!CONFIG(nosanitizers) {

	# seems like we want USan always, but are afraid of ....
	!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!CONFIG(sanitize_memory):!CONFIG(sanitize_kernel_address) {
		# Ubsan is turned on by default
		CONFIG += sanitizer sanitize_undefined
	}

	CONFIG(debug, debug | release):!CONFIG(sanitize_address):!macx-clang { CONFIG += sanitize_leak }

	CONFIG(sanitize_leak) {
		#LSan can be used without performance degrade even in release build
		QMAKE_CFLAGS += -fsanitize=leak
		QMAKE_CXXFLAGS += -fsanitize=leak
		QMAKE_LFLAGS += -fsanitize=leak
	}

	CONFIG(sanitize_undefined):macx-clang {
		# sometimes runtime is missing in clang. this hack allows to avoid runtime dependency.
		QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fsanitize-trap=undefined
		QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined
		QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fsanitize-trap=undefined
	}

	CONFIG(gcc5){
		CONFIG(sanitize_undefined){
		# Ubsan has (had at least) known issues with false errors about calls of methods of the base class.
		# That must be disabled. Variables for confguring ubsan are taken from here:
		# https://codereview.qt-project.org/#/c/43420/17/mkspecs/common/sanitize.conf
		# They can change in some version of Qt, keep track of it.
		# By the way, simply setting QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS instead of those used below
		# will not work due to arguments order ("-fsanitize=undefined" must be declared before "-fno-sanitize=vptr").
			QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fno-sanitize=vptr
			QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fno-sanitize=vptr
			QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fno-sanitize=vptr
		}
	}

	CONFIG(release, debug | release){
		CONFIG(gcc4) {
			message("Too old compiler: $$QMAKE_CXX")
		} else {
			QMAKE_CFLAGS += -fsanitize-recover=all
			QMAKE_CXXFLAGS += -fsanitize-recover=all
		}
	}

}

OBJECTS_DIR = .build/$$CONFIGURATION/obj
MOC_DIR = .build/$$CONFIGURATION/moc
RCC_DIR = .build/$$CONFIGURATION/rcc
UI_DIR = .build/$$CONFIGURATION/ui

INCLUDEPATH += $$_PRO_FILE_PWD_ \
	$$_PRO_FILE_PWD_/include \
	$$PWD \

LIBS += -L$$DESTDIR

QMAKE_CXXFLAGS += -pedantic-errors -ansi -std=c++11 -Wextra

CONFIG(gcc5)|clang{
	QMAKE_CXXFLAGS +=-Werror=pedantic -Werror=delete-incomplete
}

QMAKE_CXXFLAGS += -Werror=cast-qual -Werror=write-strings -Werror=redundant-decls -Werror=unreachable-code \
			-Werror=non-virtual-dtor -Wno-error=overloaded-virtual \
			-Werror=uninitialized -Werror=init-self

# I want -Werror to be turned on, but Qt has problems
#QMAKE_CXXFLAGS += -Werror -Wno-error=inconsistent-missing-override -Wno-error=deprecated-declarations -Wno-error=unused-parameter

GLOBAL_PWD = $$PWD

# Simple function that checks if given argument is a file or directory.
# Returns false if argument 1 is a file or does not exist.
defineTest(isDir) {
	exists($$1/*):return(true)
	return(false)
}

# Useful function to copy additional files to destination,
# from http://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output
defineTest(copyToDestdir) {
	FILES = $$1
	NOW = $$2

	for(FILE, FILES) {
		DESTDIR_SUFFIX =
		AFTER_SLASH = $$section(FILE, "/", -1, -1)
		# This ugly code is needed because xcopy requires to add source directory name to target directory name when copying directories
		win32 {
			FILE = $$system_path($$FILE)
			isDir($$FILE) {
				ABSOLUTE_PATH = $$absolute_path($$FILE, $$GLOBAL_PWD)
				BASE_NAME = $$section(ABSOLUTE_PATH, "/", -1, -1)
				DESTDIR_SUFFIX = /$$BASE_NAME
			}
		}

		DDIR = $$DESTDIR/$$3$$DESTDIR_SUFFIX
		#win32:DDIR ~= s,/,\\,g ??? why not system_path?
		DDIR = $$system_path($$DDIR)
		mkpath($$DDIR)

		isEmpty(NOW) {
			# In case this is directory add "*" to copy contents of a directory instead of directory itself under linux.
			!win32:equals(AFTER_SLASH, ""):FILE = $$FILE* #looks like inconsistent behaviour
			win32:equals(AFTER_SLASH, "*"):FILE = $$section(FILE, "*", 0, -2)\\\*
			win32:QMAKE_POST_LINK += $$quote("xcopy /s /e /q /y /i") $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
			!win32:QMAKE_POST_LINK += $(COPY_DIR) $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
		} else {
			win32 {
				# Message here is very useful in diagnostics.
				message("Executing cmd /C \\\"xcopy $$quote($$FILE) $$quote($$DDIR) /s /e /q /y /i\\\"")
				system("cmd /C \\\"xcopy $$quote($$FILE) $$quote($$DDIR) /s /e /q /y /i\\\"")
			}

			unix:!macx {
				system("cp -r -f $$FILE $$DDIR/")
			}

			macx {
				system("rsync -avz $$FILE $$DDIR/")
			}
		}
	}

	export(QMAKE_POST_LINK)
}

defineTest(includes) {
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		INCLUDEPATH += $$GLOBAL_PWD/$$PROJECT $$GLOBAL_PWD/$$PROJECT/include
	}

	export(INCLUDEPATH)
}

defineTest(links) {
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		LIBS += -l$$PROJECT$$CONFIGURATION_SUFFIX
	}

	export(LIBS)
}


Fix a merge error.

Fix a merge error.

include(../symbian_defines.pri)

# Symbian plugin header and source files
SYMBIAN_PATHS += \
        ../../inc \
        ../../rss \
        ../../../../../src/global \
        ../../../../../src/contacts \
        ../../../../../src/contacts/details \
        ../../../../../src/contacts/filters \
        ../../../../../src/contacts/requests

SYMBIAN_HEADERS += \
        ../../inc/cntsymbianengine.h \
        ../../inc/transform/cnttransformcontact.h \
        ../../inc/transform/cnttransformcontactdata.h \
        ../../inc/transform/cnttransformname.h \
        ../../inc/transform/cnttransformnickname.h \
        ../../inc/transform/cnttransformphonenumber.h \
        ../../inc/transform/cnttransformemail.h \
        ../../inc/transform/cnttransformaddress.h \
        ../../inc/transform/cnttransformurl.h \
        ../../inc/transform/cnttransformbirthday.h \
        ../../inc/transform/cnttransformonlineaccount.h \
        ../../inc/transform/cnttransformonlineaccountsimple.h \
        ../../inc/transform/cnttransformorganisation.h \
        ../../inc/transform/cnttransformpresence.h \
        ../../inc/transform/cnttransformringtone.h \
        ../../inc/transform/cnttransformthumbnail.h \
        ../../inc/transform/cnttransformavatar.h \
        ../../inc/transform/cntthumbnailcreator.h \
        ../../inc/transform/cnttransformsynctarget.h \
        ../../inc/transform/cnttransformgender.h \
        ../../inc/transform/cnttransformanniversary.h \
        ../../inc/transform/cnttransformanniversarysimple.h \
        ../../inc/transform/cnttransformgeolocation.h \
        ../../inc/transform/cnttransformnote.h \
        ../../inc/transform/cnttransformfamily.h \
        ../../inc/transform/cnttransformempty.h \
        ../../inc/filtering/cntabstractcontactfilter.h \
        ../../inc/filtering/cntsymbianfilterdbms.h \
        ../../inc/filtering/cntsymbianfiltersql.h \
        ../../inc/filtering/cntsymbiansorterdbms.h \
        ../../inc/filtering/cntabstractcontactsorter.h \
        ../../inc/cntrelationship.h \
        ../../inc/cntabstractrelationship.h \
        ../../inc/cntrelationshipgroup.h \
        ../../inc/filtering/cntsymbiansrvconnection.h \
        ../../inc/cntsymbiantransformerror.h \
        ../../inc/cntsymbiandatabase.h \
        ../../inc/cntdisplaylabel.h \
        ../../inc/filtering/cntdisplaylabelsqlfilter.h \
        ../../inc/filtering/cntsqlsearch.h \
        ../../inc/filtering/cntdbinfo.h \
        ../../inc/filtering/cntfilterdetail.h \
        ../../inc/filtering/cntfilterdefault.h \
        ../../inc/filtering/cntfilterintersection.h \
        ../../inc/filtering/cntfilterunion.h \
        ../../inc/filtering/cntfilterrelationship.h \
        ../../inc/filtering/cntfilterdetaildisplaylabel.h \

SYMBIAN_SOURCES += \
        ../../src/cntsymbianengine.cpp \
        ../../src/transform/cnttransformcontact.cpp \
        ../../src/transform/cnttransformcontactdata.cpp \
        ../../src/transform/cnttransformname.cpp \
        ../../src/transform/cnttransformnickname.cpp \
        ../../src/transform/cnttransformphonenumber.cpp \
        ../../src/transform/cnttransformemail.cpp \
        ../../src/transform/cnttransformaddress.cpp \
        ../../src/transform/cnttransformurl.cpp \
        ../../src/transform/cnttransformbirthday.cpp \
        ../../src/transform/cnttransformonlineaccount.cpp \
        ../../src/transform/cnttransformonlineaccountsimple.cpp \
        ../../src/transform/cnttransformorganisation.cpp \
        ../../src/transform/cnttransformpresence.cpp \
        ../../src/transform/cnttransformringtone.cpp \
        ../../src/transform/cnttransformthumbnail.cpp \
        ../../src/transform/cnttransformavatar.cpp \
        ../../src/transform/cntthumbnailcreator.cpp \
        ../../src/transform/cnttransformsynctarget.cpp \
        ../../src/transform/cnttransformgender.cpp \
        ../../src/transform/cnttransformanniversarysimple.cpp \
        ../../src/transform/cnttransformanniversary.cpp \
        ../../src/transform/cnttransformgeolocation.cpp \
        ../../src/transform/cnttransformnote.cpp \
        ../../src/transform/cnttransformfamily.cpp \
        ../../src/transform/cnttransformempty.cpp \
        ../../src/filtering/cntsymbianfilterdbms.cpp \
        ../../src/filtering/cntsymbiansorterdbms.cpp \
        ../../src/filtering/cntsymbianfiltersql.cpp \
        ../../src/cntrelationship.cpp \
        ../../src/cntabstractrelationship.cpp \
        ../../src/cntrelationshipgroup.cpp \
        ../../src/filtering/cntsymbiansrvconnection.cpp \
        ../../src/cntsymbiantransformerror.cpp \
        ../../src/cntsymbiandatabase.cpp \
        ../../src/cntdisplaylabel.cpp \
        ../../src/filtering/cntdisplaylabelsqlfilter.cpp \
        ../../src/filtering/cntsqlsearch.cpp \
        ../../src/filtering/cntdbinfo.cpp \
        ../../src/filtering/cntfilterdetail.cpp \
        ../../src/filtering/cntfilterdefault.cpp \
        ../../src/filtering/cntfilterintersection.cpp \
        ../../src/filtering/cntfilterunion.cpp \
        ../../src/filtering/cntfilterrelationship.cpp \
        ../../src/filtering/cntfilterdetaildisplaylabel.cpp \

SYMBIAN_LIBS += \
        -lcntmodel \
        -lQtContacts \
        -lcentralrepository \
        -lestor \
        -lefsrv \
        -lfbscli \
        -limageconversion \
        -lbitmaptransforms \
        -lbafl \
        -lplatformenv \
        -ltzclient

include(../symbian_defines.pri)

# Symbian plugin header and source files
SYMBIAN_PATHS += \
        ../../inc \
        ../../rss \
        ../../../../../src/global \
        ../../../../../src/contacts \
        ../../../../../src/contacts/details \
        ../../../../../src/contacts/filters \
        ../../../../../src/contacts/requests

SYMBIAN_HEADERS += \
        ../../inc/cntsymbianengine.h \
        ../../inc/transform/cnttransformcontact.h \
        ../../inc/transform/cnttransformcontactdata.h \
        ../../inc/transform/cnttransformname.h \
        ../../inc/transform/cnttransformnickname.h \
        ../../inc/transform/cnttransformphonenumber.h \
        ../../inc/transform/cnttransformemail.h \
        ../../inc/transform/cnttransformaddress.h \
        ../../inc/transform/cnttransformurl.h \
        ../../inc/transform/cnttransformbirthday.h \
        ../../inc/transform/cnttransformonlineaccount.h \
        ../../inc/transform/cnttransformonlineaccountsimple.h \
        ../../inc/transform/cnttransformorganisation.h \
        ../../inc/transform/cnttransformpresence.h \
        ../../inc/transform/cnttransformringtone.h \
        ../../inc/transform/cnttransformthumbnail.h \
        ../../inc/transform/cnttransformavatar.h \
        ../../inc/transform/cntthumbnailcreator.h \
        ../../inc/transform/cnttransformsynctarget.h \
        ../../inc/transform/cnttransformgender.h \
        ../../inc/transform/cnttransformanniversary.h \
        ../../inc/transform/cnttransformanniversarysimple.h \
        ../../inc/transform/cnttransformgeolocation.h \
        ../../inc/transform/cnttransformnote.h \
        ../../inc/transform/cnttransformfamily.h \
        ../../inc/transform/cnttransformempty.h \
        ../../inc/filtering/cntabstractcontactfilter.h \
        ../../inc/filtering/cntsymbianfilterdbms.h \
        ../../inc/filtering/cntsymbianfiltersql.h \
        ../../inc/filtering/cntsymbiansorterdbms.h \
        ../../inc/filtering/cntabstractcontactsorter.h \
        ../../inc/cntrelationship.h \
        ../../inc/cntabstractrelationship.h \
        ../../inc/cntrelationshipgroup.h \
        ../../inc/filtering/cntsymbiansrvconnection.h \
        ../../inc/cntsymbiantransformerror.h \
        ../../inc/cntsymbiandatabase.h \
        ../../inc/cntdisplaylabel.h \
        ../../inc/filtering/cntdisplaylabelsqlfilter.h \
        ../../inc/filtering/cntsqlsearch.h \
        ../../inc/filtering/cntdbinfo.h \
        ../../inc/filtering/cntfilterdetail.h \
        ../../inc/filtering/cntfilterdefault.h \
        ../../inc/filtering/cntfilterintersection.h \
        ../../inc/filtering/cntfilterunion.h \
        ../../inc/filtering/cntfilterrelationship.h \
        ../../inc/filtering/cntfilterdetaildisplaylabel.h \

SYMBIAN_SOURCES += \
        ../../src/cntsymbianengine.cpp \
        ../../src/transform/cnttransformcontact.cpp \
        ../../src/transform/cnttransformcontactdata.cpp \
        ../../src/transform/cnttransformname.cpp \
        ../../src/transform/cnttransformnickname.cpp \
        ../../src/transform/cnttransformphonenumber.cpp \
        ../../src/transform/cnttransformemail.cpp \
        ../../src/transform/cnttransformaddress.cpp \
        ../../src/transform/cnttransformurl.cpp \
        ../../src/transform/cnttransformbirthday.cpp \
        ../../src/transform/cnttransformonlineaccount.cpp \
        ../../src/transform/cnttransformonlineaccountsimple.cpp \
        ../../src/transform/cnttransformorganisation.cpp \
        ../../src/transform/cnttransformpresence.cpp \
        ../../src/transform/cnttransformringtone.cpp \
        ../../src/transform/cnttransformthumbnail.cpp \
        ../../src/transform/cnttransformavatar.cpp \
        ../../src/transform/cntthumbnailcreator.cpp \
        ../../src/transform/cnttransformsynctarget.cpp \
        ../../src/transform/cnttransformgender.cpp \
        ../../src/transform/cnttransformanniversarysimple.cpp \
        ../../src/transform/cnttransformanniversary.cpp \
        ../../src/transform/cnttransformgeolocation.cpp \
        ../../src/transform/cnttransformnote.cpp \
        ../../src/transform/cnttransformfamily.cpp \
        ../../src/transform/cnttransformempty.cpp \
        ../../src/filtering/cntsymbianfilterdbms.cpp \
        ../../src/filtering/cntsymbiansorterdbms.cpp \
        ../../src/filtering/cntsymbianfiltersql.cpp \
        ../../src/cntrelationship.cpp \
        ../../src/cntabstractrelationship.cpp \
        ../../src/cntrelationshipgroup.cpp \
        ../../src/filtering/cntsymbiansrvconnection.cpp \
        ../../src/cntsymbiantransformerror.cpp \
        ../../src/cntsymbiandatabase.cpp \
        ../../src/cntdisplaylabel.cpp \
        ../../src/filtering/cntdisplaylabelsqlfilter.cpp \
        ../../src/filtering/cntsqlsearch.cpp \
        ../../src/filtering/cntdbinfo.cpp \
        ../../src/filtering/cntfilterdetail.cpp \
        ../../src/filtering/cntfilterdefault.cpp \
        ../../src/filtering/cntfilterintersection.cpp \
        ../../src/filtering/cntfilterunion.cpp \
        ../../src/filtering/cntfilterrelationship.cpp \
        ../../src/filtering/cntfilterdetaildisplaylabel.cpp \

SYMBIAN_LIBS += \
        -lcntmodel \
        -lQtContacts \
        -lcentralrepository \
        -lestor \
        -lefsrv \
        -lfbscli \
        -limageconversion \
        -lbitmaptransforms \
        -lbafl \
        -lplatformenv
        -ltzclient


Jolla: Set NDEBUG for release build and not for debug build

dll {
    DEFINES += YAML_LIB
} else {
    DEFINES += YAML_STATIC_LIB
}

CONFIG(release, debug|release): DEFINES += NDEBUG

INCLUDEPATH += \
    $$PWD \
    $$PWD/libyaml-stable \
    $$PWD/libyaml-stable/include

QT -= gui network

SOURCES += \
    $$PWD/libyaml-stable/src/api.c \
    $$PWD/libyaml-stable/src/dumper.c \
    $$PWD/libyaml-stable/src/emitter.c \
    $$PWD/libyaml-stable/src/loader.c \
    $$PWD/libyaml-stable/src/parser.c \
    $$PWD/libyaml-stable/src/reader.c \
    $$PWD/libyaml-stable/src/scanner.c \
    $$PWD/libyaml-stable/src/writer.c

HEADERS += \
    $$PWD/libyaml-stable/src/yaml_private.h \
    $$PWD/libyaml-stable/include/yaml.h \
    $$PWD/yaml_global.h

dll {
    DEFINES += YAML_LIB
} else {
    DEFINES += YAML_STATIC_LIB
}

CONFIG(debug, debug|release): DEFINES += NDEBUG

INCLUDEPATH += \
    $$PWD \
    $$PWD/libyaml-stable \
    $$PWD/libyaml-stable/include

QT -= gui network

SOURCES += \
    $$PWD/libyaml-stable/src/api.c \
    $$PWD/libyaml-stable/src/dumper.c \
    $$PWD/libyaml-stable/src/emitter.c \
    $$PWD/libyaml-stable/src/loader.c \
    $$PWD/libyaml-stable/src/parser.c \
    $$PWD/libyaml-stable/src/reader.c \
    $$PWD/libyaml-stable/src/scanner.c \
    $$PWD/libyaml-stable/src/writer.c

HEADERS += \
    $$PWD/libyaml-stable/src/yaml_private.h \
    $$PWD/libyaml-stable/include/yaml.h \
    $$PWD/yaml_global.h


made Windows paths more generic

made Windows paths more generic

# Modify these paths to your needs and then build the project

# Add here the paths that are not in the global PATH or INCLUDEPATH
# environment variables usually for mobile OS
android: {
    ZEROMQ_INCLUDE_PATH = /opt/zeromq-android/include
    ZEROMQ_LIB_PATH = /opt/zeromq-android/lib
    ZEROMQ_LIB_FLAGS = -Bstatic
    PROTOBUF_INCLUDE_PATH = /opt/protobuf-android/include
    PROTOBUF_LIB_PATH = /opt/protobuf-android/lib
    PROTOBUF_LIB_FLAGS = -Bstatic
}
ios: {
    ZEROMQ_INCLUDE_PATH = /opt/zeromq-ios/include
    ZEROMQ_LIB_PATH = /opt/zeromq-ios/lib
    ZEROMQ_LIB_FLAGS = -Bstatic
    PROTOBUF_INCLUDE_PATH = /opt/protobuf-ios/include
    PROTOBUF_LIB_PATH = /opt/protobuf-ios/lib
    PROTOBUF_LIB_FLAGS = -Bstatic
    PROTOBUF_PROTOC = /opt/protobuf-ios/bin/protoc
    LIBSODIUM_LIB_PATH = /opt/libsodium-ios/lib
}
macx: {
    ZEROMQ_INCLUDE_PATH = /opt/local/include
    ZEROMQ_LIB_PATH = /opt/local/lib
    ZEROMQ_LIB_FLAGS = -Bstatic
    PROTOBUF_INCLUDE_PATH = /opt/local/include
    PROTOBUF_LIB_PATH = /opt/local/lib
    PROTOBUF_PROTOC = /opt/local/bin/protoc
    PROTOBUF_LIB_FLAGS = -Bstatic
}
win32-msvc2013: {
    PROTOBUF_INCLUDE_PATH = $$(HOMEDRIVE)$$(HOMEPATH)\bin\protobuf\src
    ZEROMQ_INCLUDE_PATH = $$(HOMEDRIVE)$$(HOMEPATH)\bin\zeromq4-x\include
    contains(QMAKE_TARGET.arch, x86_64) {
        ZEROMQ_LIB_PATH = $$(HOMEDRIVE)$$(HOMEPATH)\bin\zeromq4-x\lib\x64
        PROTOBUF_LIB_PATH = $$(HOMEDRIVE)$$(HOMEPATH)\bin\protobuf\vsprojects\x64\Release
        PROTOBUF_PROTOC = $$(HOMEDRIVE)$$(HOMEPATH)\bin\protobuf\vsprojects\x64\Release\protoc.exe
    }
    else {
        ZEROMQ_LIB_PATH = $$(HOMEDRIVE)$$(HOMEPATH)\bin\zeromq4-x\lib\Win32
        PROTOBUF_LIB_PATH = $$(HOMEDRIVE)$$(HOMEPATH)\bin\protobuf\vsprojects\Release
        PROTOBUF_PROTOC = $$(HOMEDRIVE)$$(HOMEPATH)\bin\protobuf\vsprojects\Release\protoc.exe
    }
}
win32-g++: {
    ZEROMQ_INCLUDE_PATH = $$(HOMEDRIVE)$$(HOMEPATH)\bin\MinGW\include
    ZEROMQ_LIB_PATH = $$(HOMEDRIVE)$$(HOMEPATH)\bin\MinGW\lib
    PROTOBUF_INCLUDE_PATH =  $$(HOMEDRIVE)$$(HOMEPATH)\bin\MinGW\include
    PROTOBUF_LIB_PATH =  $$(HOMEDRIVE)$$(HOMEPATH)\bin\MinGW\lib
    PROTOBUF_PROTOC =  $$(HOMEDRIVE)$$(HOMEPATH)\bin\MinGW\bin\protoc.exe
}
linux: !android: {
    PROTOBUF_INCLUDE_PATH=/usr/include
}

# Qt SDK directory - autodetected based on qmake path
QTSDK_DIR=$$absolute_path($$[QT_INSTALL_PREFIX]/../..)

# Qt Creator paths for the Qt Quick Designer plugin
# Path to the Qt Creator source - not needed anymore
# QTCREATOR_SOURCE_DIR=/home/alexander/bin/qt-creator
# Path to installed Qt Creator (where the plugin should be installed to)
QTCREATOR_INSTALL_DIR=$$QTSDK_DIR/Tools/QtCreator

# Qt documentation directory containing Qt documentation with .index files
# -> somehow only the Android toolchain comes with .index files
# install one of the Android toolchains to work properly
QT_DOC_DIR = $$[QT_INSTALL_DOCS]

# Modify these paths to your needs and then build the project

# Add here the paths that are not in the global PATH or INCLUDEPATH
# environment variables usually for mobile OS
android: {
    ZEROMQ_INCLUDE_PATH = /opt/zeromq-android/include
    ZEROMQ_LIB_PATH = /opt/zeromq-android/lib
    ZEROMQ_LIB_FLAGS = -Bstatic
    PROTOBUF_INCLUDE_PATH = /opt/protobuf-android/include
    PROTOBUF_LIB_PATH = /opt/protobuf-android/lib
    PROTOBUF_LIB_FLAGS = -Bstatic
}
ios: {
    ZEROMQ_INCLUDE_PATH = /opt/zeromq-ios/include
    ZEROMQ_LIB_PATH = /opt/zeromq-ios/lib
    ZEROMQ_LIB_FLAGS = -Bstatic
    PROTOBUF_INCLUDE_PATH = /opt/protobuf-ios/include
    PROTOBUF_LIB_PATH = /opt/protobuf-ios/lib
    PROTOBUF_LIB_FLAGS = -Bstatic
    PROTOBUF_PROTOC = /opt/protobuf-ios/bin/protoc
    LIBSODIUM_LIB_PATH = /opt/libsodium-ios/lib
}
macx: {
    ZEROMQ_INCLUDE_PATH = /opt/local/include
    ZEROMQ_LIB_PATH = /opt/local/lib
    ZEROMQ_LIB_FLAGS = -Bstatic
    PROTOBUF_INCLUDE_PATH = /opt/local/include
    PROTOBUF_LIB_PATH = /opt/local/lib
    PROTOBUF_PROTOC = /opt/local/bin/protoc
    PROTOBUF_LIB_FLAGS = -Bstatic
}
win32-msvc2013: {
    PROTOBUF_INCLUDE_PATH = E:\protobuf\src
    ZEROMQ_INCLUDE_PATH = "E:\zeromq4-x\include"
    contains(QMAKE_TARGET.arch, x86_64) {
        ZEROMQ_LIB_PATH = "E:\zeromq4-x\lib\x64"
        PROTOBUF_LIB_PATH = E:\protobuf\vsprojects\x64\Release
        PROTOBUF_PROTOC = E:\protobuf\vsprojects\x64\Release\protoc.exe
    }
    else {
        ZEROMQ_LIB_PATH = "E:\zeromq4-x\lib\Win32"
        PROTOBUF_LIB_PATH = E:\protobuf\vsprojects\Release
        PROTOBUF_PROTOC = E:\protobuf\vsprojects\Release\protoc.exe
    }
}
win32-g++: {
    ZEROMQ_INCLUDE_PATH = E:\MinGW\include
    ZEROMQ_LIB_PATH = E:\MinGW\lib
    PROTOBUF_INCLUDE_PATH =  E:\MinGW\include
    PROTOBUF_LIB_PATH =  E:\MinGW\lib
    PROTOBUF_PROTOC =  E:\MinGW\bin\protoc.exe
}
linux: !android: {
    PROTOBUF_INCLUDE_PATH=/usr/include
}

# Qt SDK directory - autodetected based on qmake path
QTSDK_DIR=$$absolute_path($$[QT_INSTALL_PREFIX]/../..)

# Qt Creator paths for the Qt Quick Designer plugin
# Path to the Qt Creator source - not needed anymore
# QTCREATOR_SOURCE_DIR=/home/alexander/bin/qt-creator
# Path to installed Qt Creator (where the plugin should be installed to)
QTCREATOR_INSTALL_DIR=$$QTSDK_DIR/Tools/QtCreator

# Qt documentation directory containing Qt documentation with .index files
# -> somehow only the Android toolchain comes with .index files
# install one of the Android toolchains to work properly
QT_DOC_DIR = $$[QT_INSTALL_DOCS]


Also use -gstabs for C code.

Also use -gstabs for C code.

unix:!mac {
	debug {
		# google-breakpad supports only stabs symbols on GNU/Linux and *BSD for now
		QMAKE_CFLAGS_DEBUG +=-gstabs
		QMAKE_CXXFLAGS_DEBUG +=-gstabs
	}
}

# test config
LIST = thread exceptions rtti stl
for(f, LIST) {
	!CONFIG($$f) {
		warning("Add '$$f' to CONFIG, or you will find yourself in 'funny' problems.")
	}
}

INCLUDEPATH += $$PWD/handler/
HEADERS += $$PWD/handler/BreakpadHandler.h

unix:!mac {
	debug {
		# google-breakpad supports only stabs symbols on GNU/Linux and *BSD for now
		QMAKE_CXXFLAGS_DEBUG +=-gstabs
	}
}

# test config
LIST = thread exceptions rtti stl
for(f, LIST) {
	!CONFIG($$f) {
		warning("Add '$$f' to CONFIG, or you will find yourself in 'funny' problems.")
	}
}

INCLUDEPATH += $$PWD/handler/
HEADERS += $$PWD/handler/BreakpadHandler.h


added lib for s60 3.1 platform

added lib for s60 3.1 platform

INCLUDEPATH += $$PWD

exists($${EPOCROOT}epoc32\include\ecamadvancedsettings.h) {
    symbian:LIBS += -lecamadvsettings
    DEFINES += USE_S60_32_ECAM_ADVANCED_SETTINGS_HEADER
    message("Using from s60 3.2 CCameraAdvancedSettings header")
}
exists($${EPOCROOT}epoc32\include\ecamadvsettings.h) {
    symbian:LIBS += -lecamadvsettings
    DEFINES += USE_S60_50_ECAM_ADVANCED_SETTINGS_HEADER
    message("Using from s60 5.0 CCameraAdvancedSettings header")
}

symbian:LIBS += -lcamerawrapper \
    -lfbscli \
    -lmediaclientvideo

HEADERS += $$PWD/s60camerafocuscontrol.h \
    $$PWD/s60cameraexposurecontrol.h \
    $$PWD/s60cameracontrol.h \
    $$PWD/s60mediacontrol.h \
    $$PWD/s60camerasession.h \
    $$PWD/s60mediacontainercontrol.h \
    $$PWD/s60videoencoder.h \
    $$PWD/s60cameraservice.h \
    $$PWD/s60cameraimageprocessingcontrol.h \
    $$PWD/s60cameraimagecapturecontrol.h \
    $$PWD/s60cameravideodevicecontrol.h \
    $$PWD/s60cameraimageencodercontrol.h \
    $$PWD/s60viewfinderwidget.h \
    $$PWD/s60camerasettings.h
SOURCES += $$PWD/s60camerafocuscontrol.cpp \
    $$PWD/s60cameraexposurecontrol.cpp \
    $$PWD/s60cameracontrol.cpp \
    $$PWD/s60mediacontrol.cpp \
    $$PWD/s60camerasession.cpp \
    $$PWD/s60mediacontainercontrol.cpp \
    $$PWD/s60videoencoder.cpp \
    $$PWD/s60cameraservice.cpp \
    $$PWD/s60cameraimageprocessingcontrol.cpp \
    $$PWD/s60cameraimagecapturecontrol.cpp \
    $$PWD/s60cameravideodevicecontrol.cpp \
    $$PWD/s60cameraimageencodercontrol.cpp \
    $$PWD/s60viewfinderwidget.cpp \
    $$PWD/s60camerasettings.cpp

INCLUDEPATH += $$PWD

exists($${EPOCROOT}epoc32\include\ecamadvancedsettings.h) {
    symbian:LIBS += -lecamadvsettings
    DEFINES += USE_S60_32_ECAM_ADVANCED_SETTINGS_HEADER
    message("Using from s60 3.2 CCameraAdvancedSettings header")
}
exists($${EPOCROOT}epoc32\include\ecamadvsettings.h) {
    symbian:LIBS += -lecamadvsettings
    DEFINES += USE_S60_50_ECAM_ADVANCED_SETTINGS_HEADER
    message("Using from s60 5.0 CCameraAdvancedSettings header")
}

symbian:LIBS += -lcamerawrapper \
    -lfbscli

HEADERS += $$PWD/s60camerafocuscontrol.h \
    $$PWD/s60cameraexposurecontrol.h \
    $$PWD/s60cameracontrol.h \
    $$PWD/s60mediacontrol.h \
    $$PWD/s60camerasession.h \
    $$PWD/s60mediacontainercontrol.h \
    $$PWD/s60videoencoder.h \
    $$PWD/s60cameraservice.h \
    $$PWD/s60cameraimageprocessingcontrol.h \
    $$PWD/s60cameraimagecapturecontrol.h \
    $$PWD/s60cameravideodevicecontrol.h \
    $$PWD/s60cameraimageencodercontrol.h \
    $$PWD/s60viewfinderwidget.h \
    $$PWD/s60camerasettings.h
SOURCES += $$PWD/s60camerafocuscontrol.cpp \
    $$PWD/s60cameraexposurecontrol.cpp \
    $$PWD/s60cameracontrol.cpp \
    $$PWD/s60mediacontrol.cpp \
    $$PWD/s60camerasession.cpp \
    $$PWD/s60mediacontainercontrol.cpp \
    $$PWD/s60videoencoder.cpp \
    $$PWD/s60cameraservice.cpp \
    $$PWD/s60cameraimageprocessingcontrol.cpp \
    $$PWD/s60cameraimagecapturecontrol.cpp \
    $$PWD/s60cameravideodevicecontrol.cpp \
    $$PWD/s60cameraimageencodercontrol.cpp \
    $$PWD/s60viewfinderwidget.cpp \
    $$PWD/s60camerasettings.cpp


BUILDING_MEMORY flag is commented out by default

#-------------------------------------------------
#  SKIRT -- an advanced radiative transfer code
#  © Astronomical Observatory, Ghent University
#-------------------------------------------------

#-------------------------------------------------------------------------
# This qmake include file defines the build options for the SKIRT projects.
# Customize the lines below to configure the appropriate build options.
#-------------------------------------------------------------------------

# to skip building the GUI, precede this line with a # comment character
# to build the GUI on systems other than Mac OS X, remove the "macx:" prefix from this line
macx:CONFIG *= BUILDING_GUI

# to build without MPI support even on systems that offer MPI, precede this line with a # comment character
CONFIG *= BUILDING_WITH_MPI

# to build the SkirtMemory subproject, remove the # character from the following line
#CONFIG *= BUILDING_MEMORY

#-------------------------------------------------
#  SKIRT -- an advanced radiative transfer code
#  © Astronomical Observatory, Ghent University
#-------------------------------------------------

#-------------------------------------------------------------------------
# This qmake include file defines the build options for the SKIRT projects.
# Customize the lines below to configure the appropriate build options.
#-------------------------------------------------------------------------

# to skip building the GUI, precede this line with a # comment character
# to build the GUI on systems other than Mac OS X, remove the "macx:" prefix from this line
macx:CONFIG *= BUILDING_GUI

# to build without MPI support even on systems that offer MPI, precede this line with a # comment character
CONFIG *= BUILDING_WITH_MPI

# to build the SkirtMemory subproject, remove the # character from the following line
CONFIG *= BUILDING_MEMORY


Use PKGCONFIG environment variable in qmake file to point to the correct libcurl file

greaterThan(QT_MAJOR_VERSION, 4) {
    QT += widgets
    DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
}

# for boost 1.37, add -mt to the boost libraries
# use: qmake BOOST_LIB_SUFFIX=-mt
# for boost thread win32 with _win32 sufix
# use: BOOST_THREAD_LIB_SUFFIX=_win32-...
# or when linking against a specific BerkelyDB version: BDB_LIB_SUFFIX=-4.8

BOOST_LIB_SUFFIX=
windows:BOOST_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include/boost
windows:BOOST_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/lib
macx:BOOST_LIB_PATH=/usr/local/opt/boost@1.60/lib
windows:BDB_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:BDB_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/lib
macx:BDB_LIB_PATH=/usr/local/Cellar/berkeley-db\@4/4.8.30/lib/
windows:OPENSSL_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include/openssl
windows:OPENSSL_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/lib
macx:OPENSSL_LIB_PATH=/usr/local/opt/openssl/lib
MINIUPNPC_LIB_SUFFIX=-miniupnpc
windows:MINIUPNPC_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:MINIUPNPC_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/libc
macx:MINIUPNPC_INCLUDE_PATH=/usr/local/Cellar/miniupnpc/2.0.20170509/include
macx:MINIUPNPC_LIB_PATH=/usr/local/Cellar/miniupnpc/2.0.20170509/lib
macx:QRENCODE_INCLUDE_PATH=/usr/local/Cellar/qrencode/3.4.4/include
macx:QRENCODE_LIB_PATH=/usr/local/Cellar/qrencode/3.4.4/lib
macx:CURL_LIB_PATH=/usr/local/opt/curl/lib
windows:QRENCODE_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:QRENCODE_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/libc

# Dependency library locations can be customized with:
#    BOOST_INCLUDE_PATH, BOOST_LIB_PATH, BDB_INCLUDE_PATH,
#    BDB_LIB_PATH, OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively

OBJECTS_DIR = build
MOC_DIR = build
UI_DIR = build

# fixes an issue with boost 1.66 and the number of template parameters of basic_socket_acceptor
DEFINES += BOOST_ASIO_ENABLE_OLD_SERVICES
# TODO: Move to the new standard of boost as current code is deprecated

# use: qmake "RELEASE=1"
contains(RELEASE, 1) {
    # Mac: compile for maximum compatibility (10.5, 32-bit)
    macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.5 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk

    !windows:!macx {
        # Linux: static link
        LIBS += -Wl,-Bstatic
    }
}

!win32 {
# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
QMAKE_CXXFLAGS *= -fstack-protector-all
QMAKE_LFLAGS *= -fstack-protector-all
# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable!
# This can be enabled for Windows, when we switch to MinGW >= 4.4.x.
}
# for extra security (see: https://wiki.debian.org/Hardening)
QMAKE_CXXFLAGS *= -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now
# for extra security on Windows: enable ASLR and DEP via GCC linker flags
win32:QMAKE_LFLAGS *= -Wl,--dynamicbase -Wl,--nxcompat
win32:QMAKE_LFLAGS *= -Wl,--large-address-aware -static
#win32:QMAKE_LFLAGS += -static-libgcc -static-libstdc++

# use: qmake "USE_QRCODE=1"
# libqrencode (http://fukuchi.org/works/qrencode/index.en.html) must be installed for support
contains(USE_QRCODE, 1) {
    message(Building with QRCode support)
    DEFINES += USE_QRCODE
    LIBS += -lqrencode
    windows:LIBS += -lpthread
}

# use: qmake "USE_UPNP=1" ( enabled by default; default)
#  or: qmake "USE_UPNP=0" (disabled by default)
#  or: qmake "USE_UPNP=-" (not supported)
# miniupnpc (http://miniupnp.free.fr/files/) must be installed for support
contains(USE_UPNP, -) {
    message(Building without UPNP support)
} else {
    message(Building with UPNP support)
    count(USE_UPNP, 0) {
        USE_UPNP=1
    }
    DEFINES += USE_UPNP=$$USE_UPNP STATICLIB
    INCLUDEPATH += $$MINIUPNPC_INCLUDE_PATH
    LIBS += $$join(MINIUPNPC_LIB_PATH,,-L,) -lminiupnpc
    win32:LIBS += -liphlpapi
}

# use: qmake "USE_DBUS=1" or qmake "USE_DBUS=0"
linux:count(USE_DBUS, 0) {
    USE_DBUS=1
}
contains(USE_DBUS, 1) {
    message(Building with DBUS (Freedesktop notifications) support)
    DEFINES += USE_DBUS
    QT += dbus
}

contains(BITCOIN_NEED_QT_PLUGINS, 1) {
    DEFINES += BITCOIN_NEED_QT_PLUGINS
    QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets
}

INCLUDEPATH += $$PWD/leveldb/include $$PWD/leveldb/helpers
macx: INCLUDEPATH += /usr/include /usr/local/opt/berkeley-db@4/include /usr/local/opt/boost/include /usr/local/opt/openssl/include
LIBS += $$PWD/leveldb/libleveldb.a $$PWD/leveldb/libmemenv.a
SOURCES += txdb-leveldb.cpp

#NEBLIO_CONFIG += LEVELDB_TESTS

!win32 {
    # we use QMAKE_CXXFLAGS_RELEASE even without RELEASE=1 because we use RELEASE to indicate linking preferences not -O preferences
    genleveldb.commands = cd $$PWD/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a
    contains( NEBLIO_CONFIG, LEVELDB_TESTS ) {
        genleveldb.commands += ./arena_test && ./cache_test && ./env_test && ./table_test && ./write_batch_test && ./coding_test && ./db_bench && ./fault_injection_test && ./issue178_test && ./autocompact_test && ./dbformat_test && ./filename_test && ./issue200_test && ./log_test && ./bloom_test && ./corruption_test && ./db_test && ./filter_block_test && ./recovery_test && ./version_edit_test && ./crc32c_test && ./hash_test && ./memenv_test && ./skiplist_test && ./version_set_test && ./c_test && ./env_posix_test
    }
} else {
    # make an educated guess about what the ranlib command is called
    isEmpty(QMAKE_RANLIB) {
        QMAKE_RANLIB = $$replace(QMAKE_STRIP, strip, ranlib)
    }
    LIBS += -lshlwapi
   # genleveldb.commands = cd $$PWD/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/leveldb/libmemenv.a
}
genleveldb.target = $$PWD/leveldb/libleveldb.a
genleveldb.depends = FORCE
PRE_TARGETDEPS += $$PWD/leveldb/libleveldb.a
QMAKE_EXTRA_TARGETS += genleveldb
# Gross ugly hack that depends on qmake internals, unfortunately there is no other way to do it.
QMAKE_CLEAN += $$PWD/leveldb/libleveldb.a; cd $$PWD/leveldb ; $(MAKE) clean

# regenerate build.h
!windows|contains(USE_BUILD_INFO, 1) {
    genbuild.depends = FORCE
    genbuild.commands = cd $$PWD; /bin/sh ../share/genbuild.sh $$OUT_PWD/build/build.h
    genbuild.target = $$OUT_PWD/build/build.h
    PRE_TARGETDEPS += $$OUT_PWD/build/build.h
    QMAKE_EXTRA_TARGETS += genbuild
    DEFINES += HAVE_BUILD_INFO
}

contains(USE_O3, 1) {
    message(Building O3 optimization flag)
    QMAKE_CXXFLAGS_RELEASE -= -O2
    QMAKE_CFLAGS_RELEASE -= -O2
    QMAKE_CXXFLAGS += -O3
    QMAKE_CFLAGS += -O3
}

*-g++-32 {
    message("32 platform, adding -msse2 flag")

    QMAKE_CXXFLAGS += -msse2
    QMAKE_CFLAGS += -msse2
}

QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector

CODECFORTR = UTF-8

# for lrelease/lupdate
# also add new translations to qt/bitcoin.qrc under translations/
TRANSLATIONS = $$files(qt/locale/bitcoin_*.ts)

isEmpty(QMAKE_LRELEASE) {
    QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
isEmpty(QM_DIR):QM_DIR = $$PWD/qt/locale
# automatically build translations, so they can be included in resource file
TSQM.name = lrelease ${QMAKE_FILE_IN}
TSQM.input = TRANSLATIONS
TSQM.output = $$QM_DIR/${QMAKE_FILE_BASE}.qm
TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT}
TSQM.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += TSQM

# "Other files" to show in Qt Creator
OTHER_FILES += \
    doc/*.rst doc/*.txt doc/README README.md res/bitcoin-qt.rc

# platform specific defaults, if not overridden on command line
isEmpty(BOOST_LIB_SUFFIX) {
    macx:BOOST_LIB_SUFFIX = -mt
    windows:BOOST_LIB_SUFFIX = -mt
}

isEmpty(BOOST_THREAD_LIB_SUFFIX) {
    win32:BOOST_THREAD_LIB_SUFFIX = _win32$$BOOST_LIB_SUFFIX
    else:BOOST_THREAD_LIB_SUFFIX = $$BOOST_LIB_SUFFIX
}

isEmpty(BDB_LIB_PATH) {
    macx:BDB_LIB_PATH = /opt/local/lib/db48
}

isEmpty(BDB_LIB_SUFFIX) {
    macx:BDB_LIB_SUFFIX = -4.8
}

isEmpty(BDB_INCLUDE_PATH) {
    macx:BDB_INCLUDE_PATH = /opt/local/include/db48
}

isEmpty(BOOST_LIB_PATH) {
    macx:BOOST_LIB_PATH = /opt/local/lib
}

isEmpty(BOOST_INCLUDE_PATH) {
    #macx:BOOST_INCLUDE_PATH = /opt/local/include
    macx:BOOST_INCLUDE_PATH = /usr/local/include
}

windows:DEFINES += WIN32

windows:!contains(MINGW_THREAD_BUGFIX, 0) {
    # At least qmake's win32-g++-cross profile is missing the -lmingwthrd
    # thread-safety flag. GCC has -mthreads to enable this, but it doesn't
    # work with static linking. -lmingwthrd must come BEFORE -lmingw, so
    # it is prepended to QMAKE_LIBS_QT_ENTRY.
    # It can be turned off with MINGW_THREAD_BUGFIX=0, just in case it causes
    # any problems on some untested qmake profile now or in the future.
    DEFINES += _MT BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
    QMAKE_LIBS_QT_ENTRY = -lmingwthrd $$QMAKE_LIBS_QT_ENTRY
}

macx:HEADERS += qt/macdockiconhandler.h qt/macnotificationhandler.h
macx:OBJECTIVE_SOURCES += qt/macdockiconhandler.mm qt/macnotificationhandler.mm
macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
macx:TARGET = "neblio-Qt"
macx:QMAKE_CFLAGS_THREAD += -pthread
macx:QMAKE_LFLAGS_THREAD += -pthread
macx:QMAKE_CXXFLAGS_THREAD += -pthread

# do not include resources while testing
!contains( NEBLIO_TEST, TRUE ) {
    macx:ICON = qt/res/icons/bitcoin.icns
    windows:RC_FILE = qt/res/bitcoin-qt.rc
}

# Set libraries and includes at end, to use platform-defined defaults if not overridden
INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH
LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,)
macx: LIBS += $$join(CURL_LIB_PATH,,-L,)
LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX
# -lgdi32 has to happen after -lcrypto (see  #681)
windows:LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32
LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX -lboost_regex$$BOOST_LIB_SUFFIX
windows:LIBS += -lboost_chrono$$BOOST_LIB_SUFFIX
macx: LIBS += -lcurl

# For Fedora
unix:INCLUDEPATH += /usr/include/libdb4/
unix:LIBS        += -L/usr/lib64/libdb4/

!macx {
    pkgConfPathEnvVar = $$(PKG_CONFIG_PATH)
    isEmpty(pkgConfPathEnvVar) {
        message("PKGCONFIG enviroment variable is not set")
        pkgConfPrefix = ""
    } else {
        message("PKGCONFIG enviroment variable is found to be set to: \"$${pkgConfPathEnvVar}\"; it will be used for pkg-config")
        pkgConfPrefix = "PKGCONFIG=$${pkgConfPathEnvVar}"
    }

    pkgconf_exec = "$${pkgConfPrefix} $${CROSS_COMPILE}pkg-config"

    INCLUDEPATH += $$system("$${pkgconf_exec} --cflags-only-I")
    QMAKE_CFLAGS += $$system("$${pkgconf_exec} libcurl --cflags-only-other")
    QMAKE_CXXFLAGS += $$system("$${pkgconf_exec} libcurl --cflags-only-other")
    # static when release
    contains(RELEASE, 1) {
        libcurlPkgconfCmd = "$${pkgconf_exec} libcurl --libs --static"
    } else {
        libcurlPkgconfCmd = "$${pkgconf_exec} libcurl --libs"
    }
    # the testing whether system() has a zero exit code with the third parameter of system() doesn't work on all Qt versions
#    cURL_LIBS = system($$libcurlPkgconfCmd,, curlPkgConfSuccess)
    cURL_LIBS = $$system($$libcurlPkgconfCmd)
#    isEqual(curlPkgConfSuccess, 0) {
    LIBS += $$cURL_LIBS
#    } else {
#        error(Failed to run pkg-config to find curl libs. Failed to run: $${libcurlPkgconfCmd})
#    }
}

contains(RELEASE, 1) {
    !windows:!macx {
        # Linux: turn dynamic linking back on for c/c++ runtime libraries
        LIBS += -Wl,-Bdynamic
    }
}

!windows:!macx {
    DEFINES += LINUX
    LIBS += -lrt -ldl
}

greaterThan(QT_MAJOR_VERSION, 4) {
    QT += widgets
    DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
}

# for boost 1.37, add -mt to the boost libraries
# use: qmake BOOST_LIB_SUFFIX=-mt
# for boost thread win32 with _win32 sufix
# use: BOOST_THREAD_LIB_SUFFIX=_win32-...
# or when linking against a specific BerkelyDB version: BDB_LIB_SUFFIX=-4.8

BOOST_LIB_SUFFIX=
windows:BOOST_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include/boost
windows:BOOST_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/lib
macx:BOOST_LIB_PATH=/usr/local/opt/boost@1.60/lib
windows:BDB_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:BDB_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/lib
macx:BDB_LIB_PATH=/usr/local/Cellar/berkeley-db\@4/4.8.30/lib/
windows:OPENSSL_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include/openssl
windows:OPENSSL_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/lib
macx:OPENSSL_LIB_PATH=/usr/local/opt/openssl/lib
MINIUPNPC_LIB_SUFFIX=-miniupnpc
windows:MINIUPNPC_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:MINIUPNPC_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/libc
macx:MINIUPNPC_INCLUDE_PATH=/usr/local/Cellar/miniupnpc/2.0.20170509/include
macx:MINIUPNPC_LIB_PATH=/usr/local/Cellar/miniupnpc/2.0.20170509/lib
macx:QRENCODE_INCLUDE_PATH=/usr/local/Cellar/qrencode/3.4.4/include
macx:QRENCODE_LIB_PATH=/usr/local/Cellar/qrencode/3.4.4/lib
macx:CURL_LIB_PATH=/usr/local/opt/curl/lib
windows:QRENCODE_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:QRENCODE_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/libc

# Dependency library locations can be customized with:
#    BOOST_INCLUDE_PATH, BOOST_LIB_PATH, BDB_INCLUDE_PATH,
#    BDB_LIB_PATH, OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively

OBJECTS_DIR = build
MOC_DIR = build
UI_DIR = build

# fixes an issue with boost 1.66 and the number of template parameters of basic_socket_acceptor
DEFINES += BOOST_ASIO_ENABLE_OLD_SERVICES
# TODO: Move to the new standard of boost as current code is deprecated

# use: qmake "RELEASE=1"
contains(RELEASE, 1) {
    # Mac: compile for maximum compatibility (10.5, 32-bit)
    macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.5 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk

    !windows:!macx {
        # Linux: static link
        LIBS += -Wl,-Bstatic
    }
}

!win32 {
# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
QMAKE_CXXFLAGS *= -fstack-protector-all
QMAKE_LFLAGS *= -fstack-protector-all
# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable!
# This can be enabled for Windows, when we switch to MinGW >= 4.4.x.
}
# for extra security (see: https://wiki.debian.org/Hardening)
QMAKE_CXXFLAGS *= -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now
# for extra security on Windows: enable ASLR and DEP via GCC linker flags
win32:QMAKE_LFLAGS *= -Wl,--dynamicbase -Wl,--nxcompat
win32:QMAKE_LFLAGS *= -Wl,--large-address-aware -static
#win32:QMAKE_LFLAGS += -static-libgcc -static-libstdc++

# use: qmake "USE_QRCODE=1"
# libqrencode (http://fukuchi.org/works/qrencode/index.en.html) must be installed for support
contains(USE_QRCODE, 1) {
    message(Building with QRCode support)
    DEFINES += USE_QRCODE
    LIBS += -lqrencode
    windows:LIBS += -lpthread
}

# use: qmake "USE_UPNP=1" ( enabled by default; default)
#  or: qmake "USE_UPNP=0" (disabled by default)
#  or: qmake "USE_UPNP=-" (not supported)
# miniupnpc (http://miniupnp.free.fr/files/) must be installed for support
contains(USE_UPNP, -) {
    message(Building without UPNP support)
} else {
    message(Building with UPNP support)
    count(USE_UPNP, 0) {
        USE_UPNP=1
    }
    DEFINES += USE_UPNP=$$USE_UPNP STATICLIB
    INCLUDEPATH += $$MINIUPNPC_INCLUDE_PATH
    LIBS += $$join(MINIUPNPC_LIB_PATH,,-L,) -lminiupnpc
    win32:LIBS += -liphlpapi
}

# use: qmake "USE_DBUS=1" or qmake "USE_DBUS=0"
linux:count(USE_DBUS, 0) {
    USE_DBUS=1
}
contains(USE_DBUS, 1) {
    message(Building with DBUS (Freedesktop notifications) support)
    DEFINES += USE_DBUS
    QT += dbus
}

contains(BITCOIN_NEED_QT_PLUGINS, 1) {
    DEFINES += BITCOIN_NEED_QT_PLUGINS
    QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets
}

INCLUDEPATH += $$PWD/leveldb/include $$PWD/leveldb/helpers
macx: INCLUDEPATH += /usr/include /usr/local/opt/berkeley-db@4/include /usr/local/opt/boost/include /usr/local/opt/openssl/include
LIBS += $$PWD/leveldb/libleveldb.a $$PWD/leveldb/libmemenv.a
SOURCES += txdb-leveldb.cpp

#NEBLIO_CONFIG += LEVELDB_TESTS

!win32 {
    # we use QMAKE_CXXFLAGS_RELEASE even without RELEASE=1 because we use RELEASE to indicate linking preferences not -O preferences
    genleveldb.commands = cd $$PWD/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a
    contains( NEBLIO_CONFIG, LEVELDB_TESTS ) {
        genleveldb.commands += ./arena_test && ./cache_test && ./env_test && ./table_test && ./write_batch_test && ./coding_test && ./db_bench && ./fault_injection_test && ./issue178_test && ./autocompact_test && ./dbformat_test && ./filename_test && ./issue200_test && ./log_test && ./bloom_test && ./corruption_test && ./db_test && ./filter_block_test && ./recovery_test && ./version_edit_test && ./crc32c_test && ./hash_test && ./memenv_test && ./skiplist_test && ./version_set_test && ./c_test && ./env_posix_test
    }
} else {
    # make an educated guess about what the ranlib command is called
    isEmpty(QMAKE_RANLIB) {
        QMAKE_RANLIB = $$replace(QMAKE_STRIP, strip, ranlib)
    }
    LIBS += -lshlwapi
   # genleveldb.commands = cd $$PWD/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/leveldb/libmemenv.a
}
genleveldb.target = $$PWD/leveldb/libleveldb.a
genleveldb.depends = FORCE
PRE_TARGETDEPS += $$PWD/leveldb/libleveldb.a
QMAKE_EXTRA_TARGETS += genleveldb
# Gross ugly hack that depends on qmake internals, unfortunately there is no other way to do it.
QMAKE_CLEAN += $$PWD/leveldb/libleveldb.a; cd $$PWD/leveldb ; $(MAKE) clean

# regenerate build.h
!windows|contains(USE_BUILD_INFO, 1) {
    genbuild.depends = FORCE
    genbuild.commands = cd $$PWD; /bin/sh ../share/genbuild.sh $$OUT_PWD/build/build.h
    genbuild.target = $$OUT_PWD/build/build.h
    PRE_TARGETDEPS += $$OUT_PWD/build/build.h
    QMAKE_EXTRA_TARGETS += genbuild
    DEFINES += HAVE_BUILD_INFO
}

contains(USE_O3, 1) {
    message(Building O3 optimization flag)
    QMAKE_CXXFLAGS_RELEASE -= -O2
    QMAKE_CFLAGS_RELEASE -= -O2
    QMAKE_CXXFLAGS += -O3
    QMAKE_CFLAGS += -O3
}

*-g++-32 {
    message("32 platform, adding -msse2 flag")

    QMAKE_CXXFLAGS += -msse2
    QMAKE_CFLAGS += -msse2
}

QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector

CODECFORTR = UTF-8

# for lrelease/lupdate
# also add new translations to qt/bitcoin.qrc under translations/
TRANSLATIONS = $$files(qt/locale/bitcoin_*.ts)

isEmpty(QMAKE_LRELEASE) {
    QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
isEmpty(QM_DIR):QM_DIR = $$PWD/qt/locale
# automatically build translations, so they can be included in resource file
TSQM.name = lrelease ${QMAKE_FILE_IN}
TSQM.input = TRANSLATIONS
TSQM.output = $$QM_DIR/${QMAKE_FILE_BASE}.qm
TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT}
TSQM.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += TSQM

# "Other files" to show in Qt Creator
OTHER_FILES += \
    doc/*.rst doc/*.txt doc/README README.md res/bitcoin-qt.rc

# platform specific defaults, if not overridden on command line
isEmpty(BOOST_LIB_SUFFIX) {
    macx:BOOST_LIB_SUFFIX = -mt
    windows:BOOST_LIB_SUFFIX = -mt
}

isEmpty(BOOST_THREAD_LIB_SUFFIX) {
    win32:BOOST_THREAD_LIB_SUFFIX = _win32$$BOOST_LIB_SUFFIX
    else:BOOST_THREAD_LIB_SUFFIX = $$BOOST_LIB_SUFFIX
}

isEmpty(BDB_LIB_PATH) {
    macx:BDB_LIB_PATH = /opt/local/lib/db48
}

isEmpty(BDB_LIB_SUFFIX) {
    macx:BDB_LIB_SUFFIX = -4.8
}

isEmpty(BDB_INCLUDE_PATH) {
    macx:BDB_INCLUDE_PATH = /opt/local/include/db48
}

isEmpty(BOOST_LIB_PATH) {
    macx:BOOST_LIB_PATH = /opt/local/lib
}

isEmpty(BOOST_INCLUDE_PATH) {
    #macx:BOOST_INCLUDE_PATH = /opt/local/include
    macx:BOOST_INCLUDE_PATH = /usr/local/include
}

windows:DEFINES += WIN32

windows:!contains(MINGW_THREAD_BUGFIX, 0) {
    # At least qmake's win32-g++-cross profile is missing the -lmingwthrd
    # thread-safety flag. GCC has -mthreads to enable this, but it doesn't
    # work with static linking. -lmingwthrd must come BEFORE -lmingw, so
    # it is prepended to QMAKE_LIBS_QT_ENTRY.
    # It can be turned off with MINGW_THREAD_BUGFIX=0, just in case it causes
    # any problems on some untested qmake profile now or in the future.
    DEFINES += _MT BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
    QMAKE_LIBS_QT_ENTRY = -lmingwthrd $$QMAKE_LIBS_QT_ENTRY
}

macx:HEADERS += qt/macdockiconhandler.h qt/macnotificationhandler.h
macx:OBJECTIVE_SOURCES += qt/macdockiconhandler.mm qt/macnotificationhandler.mm
macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
macx:TARGET = "neblio-Qt"
macx:QMAKE_CFLAGS_THREAD += -pthread
macx:QMAKE_LFLAGS_THREAD += -pthread
macx:QMAKE_CXXFLAGS_THREAD += -pthread

# do not include resources while testing
!contains( NEBLIO_TEST, TRUE ) {
    macx:ICON = qt/res/icons/bitcoin.icns
    windows:RC_FILE = qt/res/bitcoin-qt.rc
}

# Set libraries and includes at end, to use platform-defined defaults if not overridden
INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH
LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,)
macx: LIBS += $$join(CURL_LIB_PATH,,-L,)
LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX
# -lgdi32 has to happen after -lcrypto (see  #681)
windows:LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32
LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX -lboost_regex$$BOOST_LIB_SUFFIX
windows:LIBS += -lboost_chrono$$BOOST_LIB_SUFFIX
macx: LIBS += -lcurl

# For Fedora
unix:INCLUDEPATH += /usr/include/libdb4/
unix:LIBS        += -L/usr/lib64/libdb4/

!macx {
    INCLUDEPATH += $$system("$${CROSS_COMPILE}pkg-config libcurl --cflags-only-I")
    QMAKE_CFLAGS += $$system("$${CROSS_COMPILE}pkg-config libcurl --cflags-only-other")
    QMAKE_CXXFLAGS += $$system("$${CROSS_COMPILE}pkg-config libcurl --cflags-only-other")
    # static when release
    contains(RELEASE, 1) {
        libcurlPkgconfCmd = "$${CROSS_COMPILE}pkg-config libcurl --libs --static"
    } else {
        libcurlPkgconfCmd = "$${CROSS_COMPILE}pkg-config libcurl --libs"
    }
    # the testing whether system() has a zero exit code with the third parameter of system() doesn't work on all Qt versions
#    cURL_LIBS = system($$libcurlPkgconfCmd,, curlPkgConfSuccess)
    cURL_LIBS = $$system($$libcurlPkgconfCmd)
#    isEqual(curlPkgConfSuccess, 0) {
    LIBS += $$cURL_LIBS
#    } else {
#        error(Failed to run pkg-config to find curl libs. Failed to run: $${libcurlPkgconfCmd})
#    }
}

contains(RELEASE, 1) {
    !windows:!macx {
        # Linux: turn dynamic linking back on for c/c++ runtime libraries
        LIBS += -Wl,-Bdynamic
    }
}

!windows:!macx {
    DEFINES += LINUX
    LIBS += -lrt -ldl
}


Really fixed windows build path.

Really fixed windows build path.

DEFINES += HAVE_UPNP STATICLIB

android:DEFINES += sun # Atleast needed for android
else:linux:DEFINES += _GNU_SOURCE
mac:DEFINES += _DARWIN_C_SOURCE
win32:DEFINES += _CRT_SECURE_NO_WARNINGS

#linux:LIBS += -lminiupnpc

android|mac|win32|linux {
    INCLUDEPATH += $$PWD/miniupnp
    win32:INCLUDEPATH += $$PWD/miniupnp_windows_fixes
}

win32 {
    CONFIG(release, debug|release):BUILDCONFIG = "release"
    else:BUILDCONFIG = "debug"

    LIBS += -L../../3rdparty/$$BUILDCONFIG -lminiupnp
    PRE_TARGETDEPS = ../../3rdparty/$$BUILDCONFIG/miniupnp.lib
} else {
    LIBS += ../../3rdparty/libminiupnp.a
    PRE_TARGETDEPS = ../../3rdparty/libminiupnp.a
}

DEFINES += HAVE_UPNP STATICLIB

android:DEFINES += sun # Atleast needed for android
else:linux:DEFINES += _GNU_SOURCE
mac:DEFINES += _DARWIN_C_SOURCE
win32:DEFINES += _CRT_SECURE_NO_WARNINGS

#linux:LIBS += -lminiupnpc

android|mac|win32|linux {
    INCLUDEPATH += $$PWD/miniupnp
    win32:INCLUDEPATH += $$PWD/miniupnp_windows_fixes
}

win32 {
    CONFIG(release, debug|release):BUILDCONFIG = "release"
    else:BUILDCONFIG = "debug"

    LIBS += -L../../3rdparty/$$BUILDCONFIG -lminiupnp
    PRE_TARGETDEPS = ../../3rdparty/miniupnp.lib
} else {
    LIBS += ../../3rdparty/libminiupnp.a
    PRE_TARGETDEPS = ../../3rdparty/libminiupnp.a
}


Fix the rpath for auto tests.

Fix the rpath for auto tests.

TEMPLATE = app
CONFIG += qt debug warn_on console depend_includepath testcase

qtAddLibrary(QtTest)

QMAKE_LIBS += -Wl,-rpath,$$QT_SYSTEMKIT_BUILD_TREE/lib

INCLUDEPATH += $$QT_SYSTEMKIT_SOURCE_TREE/src/systeminfo
LIBS        += -L$$QT_SYSTEMKIT_BUILD_TREE/lib -lQtSystemInfo

TEMPLATE = app
CONFIG += qt debug warn_on console depend_includepath testcase

qtAddLibrary(QtTest)

QMAKE_LIBS += -Wl,-rpath,$$BUILD_TREE/lib

INCLUDEPATH += $$QT_SYSTEMKIT_SOURCE_TREE/src/systeminfo
LIBS        += -L$$QT_SYSTEMKIT_BUILD_TREE/lib -lQtSystemInfo


Fixed compile on Windows in release mode.

It is not valid to unconditionally enable debug mode on platforms where
debug/release affects linkage.  On these platforms, debug mode can only
be used if the debug libraries are enabled, and release mode can only be
used if the release libraries are enabled.

Let the build system set the correct mode.

Change-Id: I1a4869a47b158049de2e8c71a62c3df059a70281
Sanity-Review: Qt Sanity Bot <5581206bb7e0307f0d99eb71898ae6b694149ca5@ovi.com>
Reviewed-by: Alex <3f9b327efd0f2b2e684d51660e829d1496ae5581@nokia.com>
Reviewed-by: Jaakko Korpela <e59103a1c277ec3b68ce05cd471407d3819eb337@nokia.com>

TEMPLATE = app
CONFIG += qt warn_on console depend_includepath testcase

qtAddLibrary(QtTest)

TEMPLATE = app
CONFIG += qt debug warn_on console depend_includepath testcase

qtAddLibrary(QtTest)


Remove dependency from older & bad implementation of trilateration algorithm.

HEADERS += \
    $$PWD/qbeacon.h \
    $$PWD/qtrilateration.h \
    $$PWD/qmeasure.h

SOURCES += \
    $$PWD/qbeacon.cpp \
    $$PWD/qtrilateration.cpp \
    $$PWD/qmeasure.cpp

testing {
    SOURCES += $$PWD/test/qbeacontest.cpp \
        $$PWD/test/qtrilaterationtest.cpp \
        $$PWD/test/qmeasuretest.cpp
}

HEADERS += \
    $$PWD/../dependencies/trilateration/navigation/trilateteration/src/beacon.h \
    $$PWD/../dependencies/trilateration/navigation/trilateteration/src/trilateration.h \
    $$PWD/qbeacon.h \
    $$PWD/qtrilateration.h \
    $$PWD/qmeasure.h

SOURCES += \
    $$PWD/../dependencies/trilateration/navigation/trilateteration/src/beacon.cpp \
    $$PWD/../dependencies/trilateration/navigation/trilateteration/src/trilateration.cpp \
    $$PWD/qbeacon.cpp \
    $$PWD/qtrilateration.cpp \
    $$PWD/qmeasure.cpp

# For quick include, add dependencies as dependency path.
INCLUDEPATH += $$PWD/../dependencies/trilateration/navigation/trilateteration/src/
DEPENDPATH +=  $$PWD/../dependencies/trilateration/navigation/trilateteration/src/

testing {
    SOURCES += $$PWD/test/qbeacontest.cpp \
        $$PWD/test/qtrilaterationtest.cpp \
        $$PWD/test/qmeasuretest.cpp
}


includes

includes

greaterThan(QT_MAJOR_VERSION, 4) {
    QT += widgets
    DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
}

# for boost 1.37, add -mt to the boost libraries
# use: qmake BOOST_LIB_SUFFIX=-mt
# for boost thread win32 with _win32 sufix
# use: BOOST_THREAD_LIB_SUFFIX=_win32-...
# or when linking against a specific BerkelyDB version: BDB_LIB_SUFFIX=-4.8

BOOST_LIB_SUFFIX=
windows:BOOST_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include/boost
windows:BOOST_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/lib
macx:BOOST_LIB_PATH=/usr/local/opt/boost@1.60/lib
macx:BOOST_INCLUDE_PATH=/usr/local/opt/boost@1.60/include
windows:BDB_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:BDB_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/lib
macx:BDB_LIB_PATH=/usr/local/opt/berkeley-db\@4/lib/
MINIUPNPC_LIB_SUFFIX=-miniupnpc
windows:MINIUPNPC_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:MINIUPNPC_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/libc
macx:OPENSSL_LIB_PATH=/usr/local/opt/openssl/lib
macx:MINIUPNPC_INCLUDE_PATH=/usr/local/opt/miniupnpc/include
macx:MINIUPNPC_LIB_PATH=/usr/local/opt/miniupnpc/lib
macx:QRENCODE_INCLUDE_PATH=/usr/local/opt/qrencode/include
macx:QRENCODE_LIB_PATH=/usr/local/opt/qrencode/lib
macx:CURL_LIB_PATH=/usr/local/opt/curl/lib
windows:QRENCODE_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:QRENCODE_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/libc

# Dependency library locations can be customized with:
#    BOOST_INCLUDE_PATH, BOOST_LIB_PATH, BDB_INCLUDE_PATH,
#    BDB_LIB_PATH, OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively

OBJECTS_DIR = build
MOC_DIR = build
UI_DIR = build

# fixes an issue with boost 1.66 and the number of template parameters of basic_socket_acceptor
#DEFINES += BOOST_ASIO_ENABLE_OLD_SERVICES
# TODO: Move to the new standard of boost as current code is deprecated

# use: qmake "RELEASE=1"
contains(RELEASE, 1) {
    # Mac: compile for maximum compatibility (10.12, 32-bit)
    macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.12 -arch x86_64 -Wno-nullability-completeness -Wno-unused-command-line-argument

    !windows:!macx {
        # Linux: static link
        LIBS += -Wl,-Bstatic
    }
}

!win32 {
# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
QMAKE_CXXFLAGS *= -fstack-protector-all
QMAKE_LFLAGS *= -fstack-protector-all
# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable!
# This can be enabled for Windows, when we switch to MinGW >= 4.4.x.
}
# for extra security (see: https://wiki.debian.org/Hardening)
QMAKE_CXXFLAGS *= -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now
# for extra security on Windows: enable ASLR and DEP via GCC linker flags
win32:QMAKE_LFLAGS *= -Wl,--dynamicbase -Wl,--nxcompat
win32:QMAKE_LFLAGS *= -Wl,--large-address-aware -static
#win32:QMAKE_LFLAGS += -static-libgcc -static-libstdc++

# use: qmake "USE_QRCODE=1"
# libqrencode (http://fukuchi.org/works/qrencode/index.en.html) must be installed for support
contains(USE_QRCODE, 1) {
    message(Building with QRCode support)
    DEFINES += USE_QRCODE
    LIBS += -lqrencode
    windows:LIBS += -lpthread
}

# use: qmake "USE_UPNP=1" ( enabled by default; default)
#  or: qmake "USE_UPNP=0" (disabled by default)
#  or: qmake "USE_UPNP=-" (not supported)
# miniupnpc (http://miniupnp.free.fr/files/) must be installed for support
contains(USE_UPNP, -) {
    message(Building without UPNP support)
} else {
    message(Building with UPNP support)
    count(USE_UPNP, 0) {
        USE_UPNP=1
    }
    DEFINES += USE_UPNP=$$USE_UPNP STATICLIB
    INCLUDEPATH += $$MINIUPNPC_INCLUDE_PATH
    LIBS += $$join(MINIUPNPC_LIB_PATH,,-L,) -lminiupnpc
    win32:LIBS += -liphlpapi
}

# use: qmake "USE_DBUS=1" or qmake "USE_DBUS=0"
linux:count(USE_DBUS, 0) {
    USE_DBUS=1
}
contains(USE_DBUS, 1) {
    message(Building with DBUS (Freedesktop notifications) support)
    DEFINES += USE_DBUS
    QT += dbus
}

contains(BITCOIN_NEED_QT_PLUGINS, 1) {
    DEFINES += BITCOIN_NEED_QT_PLUGINS
    QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets
}

INCLUDEPATH += $$PWD/leveldb/include $$PWD/leveldb/helpers
macx: INCLUDEPATH += /usr/local/opt/berkeley-db@4/include /usr/local/opt/boost@1.60/include /usr/local/opt/openssl/include
LIBS += $$PWD/leveldb/libleveldb.a $$PWD/leveldb/libmemenv.a
SOURCES += txdb-leveldb.cpp

#NEBLIO_CONFIG += LEVELDB_TESTS

!win32 {
    # we use QMAKE_CXXFLAGS_RELEASE even without RELEASE=1 because we use RELEASE to indicate linking preferences not -O preferences
    genleveldb.commands = cd $$PWD/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a
    contains( NEBLIO_CONFIG, LEVELDB_TESTS ) {
        genleveldb.commands += ./arena_test && ./cache_test && ./env_test && ./table_test && ./write_batch_test && ./coding_test && ./db_bench && ./fault_injection_test && ./issue178_test && ./autocompact_test && ./dbformat_test && ./filename_test && ./issue200_test && ./log_test && ./bloom_test && ./corruption_test && ./db_test && ./filter_block_test && ./recovery_test && ./version_edit_test && ./crc32c_test && ./hash_test && ./memenv_test && ./skiplist_test && ./version_set_test && ./c_test && ./env_posix_test
    }
} else {
    # make an educated guess about what the ranlib command is called
    isEmpty(QMAKE_RANLIB) {
        QMAKE_RANLIB = $$replace(QMAKE_STRIP, strip, ranlib)
    }
    LIBS += -lshlwapi
   # genleveldb.commands = cd $$PWD/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/leveldb/libmemenv.a
}
genleveldb.target = $$PWD/leveldb/libleveldb.a
genleveldb.depends = FORCE
PRE_TARGETDEPS += $$PWD/leveldb/libleveldb.a
QMAKE_EXTRA_TARGETS += genleveldb
# Gross ugly hack that depends on qmake internals, unfortunately there is no other way to do it.
QMAKE_CLEAN += $$PWD/leveldb/libleveldb.a; cd $$PWD/leveldb ; $(MAKE) clean

# regenerate build.h
!windows|contains(USE_BUILD_INFO, 1) {
    genbuild.depends = FORCE
    genbuild.commands = cd $$PWD; /bin/sh ../share/genbuild.sh $$OUT_PWD/build/build.h
    genbuild.target = $$OUT_PWD/build/build.h
    PRE_TARGETDEPS += $$OUT_PWD/build/build.h
    QMAKE_EXTRA_TARGETS += genbuild
    DEFINES += HAVE_BUILD_INFO
}

contains(USE_O3, 1) {
    message(Building O3 optimization flag)
    QMAKE_CXXFLAGS_RELEASE -= -O2
    QMAKE_CFLAGS_RELEASE -= -O2
    QMAKE_CXXFLAGS += -O3
    QMAKE_CFLAGS += -O3
}

*-g++-32 {
    message("32 platform, adding -msse2 flag")

    QMAKE_CXXFLAGS += -msse2
    QMAKE_CFLAGS += -msse2
}

QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector

CODECFORTR = UTF-8

# for lrelease/lupdate
# also add new translations to qt/bitcoin.qrc under translations/
TRANSLATIONS = $$files(qt/locale/bitcoin_*.ts)

isEmpty(QMAKE_LRELEASE) {
    QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
isEmpty(QM_DIR):QM_DIR = $$PWD/qt/locale
# automatically build translations, so they can be included in resource file
TSQM.name = lrelease ${QMAKE_FILE_IN}
TSQM.input = TRANSLATIONS
TSQM.output = $$QM_DIR/${QMAKE_FILE_BASE}.qm
TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT}
TSQM.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += TSQM

# "Other files" to show in Qt Creator
OTHER_FILES += \
    doc/*.rst doc/*.txt doc/README README.md res/bitcoin-qt.rc

# platform specific defaults, if not overridden on command line
isEmpty(BOOST_LIB_SUFFIX) {
    macx:BOOST_LIB_SUFFIX = -mt
    windows:BOOST_LIB_SUFFIX = -mt
}

isEmpty(BOOST_THREAD_LIB_SUFFIX) {
    win32:BOOST_THREAD_LIB_SUFFIX = _win32$$BOOST_LIB_SUFFIX
    else:BOOST_THREAD_LIB_SUFFIX = $$BOOST_LIB_SUFFIX
}

windows:DEFINES += WIN32

windows:!contains(MINGW_THREAD_BUGFIX, 0) {
    # At least qmake's win32-g++-cross profile is missing the -lmingwthrd
    # thread-safety flag. GCC has -mthreads to enable this, but it doesn't
    # work with static linking. -lmingwthrd must come BEFORE -lmingw, so
    # it is prepended to QMAKE_LIBS_QT_ENTRY.
    # It can be turned off with MINGW_THREAD_BUGFIX=0, just in case it causes
    # any problems on some untested qmake profile now or in the future.
    DEFINES += _MT BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
    QMAKE_LIBS_QT_ENTRY = -lmingwthrd $$QMAKE_LIBS_QT_ENTRY
}

macx:HEADERS += qt/macdockiconhandler.h qt/macnotificationhandler.h
macx:OBJECTIVE_SOURCES += qt/macdockiconhandler.mm qt/macnotificationhandler.mm
macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
macx:TARGET = "neblio-Qt"
macx:QMAKE_CFLAGS_THREAD += -pthread
macx:QMAKE_LFLAGS_THREAD += -pthread
macx:QMAKE_CXXFLAGS_THREAD += -pthread

# do not include resources while testing
!contains( NEBLIO_TEST, TRUE ) {
    macx:ICON = qt/res/icons/bitcoin.icns
    windows:RC_FILE = qt/res/bitcoin-qt.rc
}

# Set libraries and includes at end, to use platform-defined defaults if not overridden
INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH
LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,)
macx: LIBS += $$join(CURL_LIB_PATH,,-L,)
LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX
# -lgdi32 has to happen after -lcrypto (see  #681)
windows:LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32
LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX -lboost_regex$$BOOST_LIB_SUFFIX
windows:LIBS += -lboost_chrono$$BOOST_LIB_SUFFIX
macx: LIBS += -lcurl

# For Fedora
unix:INCLUDEPATH += /usr/include/libdb4/
unix:LIBS        += -L/usr/lib64/libdb4/

!macx {
    PKG_CONFIG_ENV_VAR = $$(PKG_CONFIG_PATH)
    !isEmpty(PKG_CONFIG_ENV_VAR) {
        PKG_CONFIG_PATH = $$(PKG_CONFIG_PATH)
    }
    isEmpty(PKG_CONFIG_PATH_ENV_VAR) {
        message("PKGCONFIG enviroment variable is not set")
        pkgConfPrefix = ""
    } else {
        message("PKGCONFIG enviroment variable is found to be set to: \"$${PKG_CONFIG_ENV_VAR}\"; it will be used for pkg-config")
        pkgConfPrefix = "PKGCONFIG=$${PKG_CONFIG_PATH}"
    }

    !isEmpty(PKG_CONFIG_PATH) {
        message("Setting PKG_CONFIG_PATH to $${PKG_CONFIG_PATH}")
    }

        pkgconf_exec = "$${pkgConfPrefix} $${CROSS_COMPILE}pkg-config"

    QMAKE_CFLAGS += $$system("$${pkgconf_exec} libcurl --cflags")
    QMAKE_CXXFLAGS += $$system("$${pkgconf_exec} libcurl --cflags")

    # static when release
    contains(RELEASE, 1) {
        libcurlPkgconfCmd = "$${pkgconf_exec} libcurl --libs --static"
    } else {
        libcurlPkgconfCmd = "$${pkgconf_exec} libcurl --libs"
    }
    # the testing whether system() has a zero exit code with the third parameter of system() doesn't work on all Qt versions
    libcURL_LIBS = $$system($$libcurlPkgconfCmd)
    # OpenSSL linking is not necessary as it comes with curl
    # openssl_LIBS = $$system($$opensslPkgconfCmd)
    LIBS += $$libcURL_LIBS $$openssl_LIBS
}

contains(RELEASE, 1) {
    !windows:!macx {
        # Linux: turn dynamic linking back on for c/c++ runtime libraries
        LIBS += -Wl,-Bdynamic
    }
}

!windows:!macx {
    DEFINES += LINUX
    LIBS += -lrt -ldl
}

greaterThan(QT_MAJOR_VERSION, 4) {
    QT += widgets
    DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
}

# for boost 1.37, add -mt to the boost libraries
# use: qmake BOOST_LIB_SUFFIX=-mt
# for boost thread win32 with _win32 sufix
# use: BOOST_THREAD_LIB_SUFFIX=_win32-...
# or when linking against a specific BerkelyDB version: BDB_LIB_SUFFIX=-4.8

BOOST_LIB_SUFFIX=
windows:BOOST_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include/boost
windows:BOOST_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/lib
macx:BOOST_LIB_PATH=/usr/local/opt/boost@1.60/lib
macx:BOOST_INCLUDE_PATH=/usr/local/opt/boost@1.60/include
windows:BDB_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:BDB_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/lib
macx:BDB_LIB_PATH=/usr/local/opt/berkeley-db\@4/lib/
MINIUPNPC_LIB_SUFFIX=-miniupnpc
windows:MINIUPNPC_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:MINIUPNPC_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/libc
macx:OPENSSL_LIB_PATH=/usr/local/opt/openssl/lib
macx:MINIUPNPC_INCLUDE_PATH=/usr/local/opt/miniupnpc/include
macx:MINIUPNPC_LIB_PATH=/usr/local/opt/miniupnpc/lib
macx:QRENCODE_INCLUDE_PATH=/usr/local/opt/qrencode/include
macx:QRENCODE_LIB_PATH=/usr/local/opt/qrencode/lib
macx:CURL_LIB_PATH=/usr/local/opt/curl/lib
windows:QRENCODE_INCLUDE_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/include
windows:QRENCODE_LIB_PATH=/home/build/Documents/mxe/usr/i686-w64-mingw32.static/libc

# Dependency library locations can be customized with:
#    BOOST_INCLUDE_PATH, BOOST_LIB_PATH, BDB_INCLUDE_PATH,
#    BDB_LIB_PATH, OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively

OBJECTS_DIR = build
MOC_DIR = build
UI_DIR = build

# fixes an issue with boost 1.66 and the number of template parameters of basic_socket_acceptor
#DEFINES += BOOST_ASIO_ENABLE_OLD_SERVICES
# TODO: Move to the new standard of boost as current code is deprecated

# use: qmake "RELEASE=1"
contains(RELEASE, 1) {
    # Mac: compile for maximum compatibility (10.12, 32-bit)
    macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.12 -arch x86_64 -Wno-nullability-completeness -Wno-unused-command-line-argument

    !windows:!macx {
        # Linux: static link
        LIBS += -Wl,-Bstatic
    }
}

!win32 {
# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
QMAKE_CXXFLAGS *= -fstack-protector-all
QMAKE_LFLAGS *= -fstack-protector-all
# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable!
# This can be enabled for Windows, when we switch to MinGW >= 4.4.x.
}
# for extra security (see: https://wiki.debian.org/Hardening)
QMAKE_CXXFLAGS *= -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now
# for extra security on Windows: enable ASLR and DEP via GCC linker flags
win32:QMAKE_LFLAGS *= -Wl,--dynamicbase -Wl,--nxcompat
win32:QMAKE_LFLAGS *= -Wl,--large-address-aware -static
#win32:QMAKE_LFLAGS += -static-libgcc -static-libstdc++

# use: qmake "USE_QRCODE=1"
# libqrencode (http://fukuchi.org/works/qrencode/index.en.html) must be installed for support
contains(USE_QRCODE, 1) {
    message(Building with QRCode support)
    DEFINES += USE_QRCODE
    LIBS += -lqrencode
    windows:LIBS += -lpthread
}

# use: qmake "USE_UPNP=1" ( enabled by default; default)
#  or: qmake "USE_UPNP=0" (disabled by default)
#  or: qmake "USE_UPNP=-" (not supported)
# miniupnpc (http://miniupnp.free.fr/files/) must be installed for support
contains(USE_UPNP, -) {
    message(Building without UPNP support)
} else {
    message(Building with UPNP support)
    count(USE_UPNP, 0) {
        USE_UPNP=1
    }
    DEFINES += USE_UPNP=$$USE_UPNP STATICLIB
    INCLUDEPATH += $$MINIUPNPC_INCLUDE_PATH
    LIBS += $$join(MINIUPNPC_LIB_PATH,,-L,) -lminiupnpc
    win32:LIBS += -liphlpapi
}

# use: qmake "USE_DBUS=1" or qmake "USE_DBUS=0"
linux:count(USE_DBUS, 0) {
    USE_DBUS=1
}
contains(USE_DBUS, 1) {
    message(Building with DBUS (Freedesktop notifications) support)
    DEFINES += USE_DBUS
    QT += dbus
}

contains(BITCOIN_NEED_QT_PLUGINS, 1) {
    DEFINES += BITCOIN_NEED_QT_PLUGINS
    QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets
}

INCLUDEPATH += $$PWD/leveldb/include $$PWD/leveldb/helpers
LIBS += $$PWD/leveldb/libleveldb.a $$PWD/leveldb/libmemenv.a
SOURCES += txdb-leveldb.cpp

#NEBLIO_CONFIG += LEVELDB_TESTS

!win32 {
    # we use QMAKE_CXXFLAGS_RELEASE even without RELEASE=1 because we use RELEASE to indicate linking preferences not -O preferences
    genleveldb.commands = cd $$PWD/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a
    contains( NEBLIO_CONFIG, LEVELDB_TESTS ) {
        genleveldb.commands += ./arena_test && ./cache_test && ./env_test && ./table_test && ./write_batch_test && ./coding_test && ./db_bench && ./fault_injection_test && ./issue178_test && ./autocompact_test && ./dbformat_test && ./filename_test && ./issue200_test && ./log_test && ./bloom_test && ./corruption_test && ./db_test && ./filter_block_test && ./recovery_test && ./version_edit_test && ./crc32c_test && ./hash_test && ./memenv_test && ./skiplist_test && ./version_set_test && ./c_test && ./env_posix_test
    }
} else {
    # make an educated guess about what the ranlib command is called
    isEmpty(QMAKE_RANLIB) {
        QMAKE_RANLIB = $$replace(QMAKE_STRIP, strip, ranlib)
    }
    LIBS += -lshlwapi
   # genleveldb.commands = cd $$PWD/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/leveldb/libmemenv.a
}
genleveldb.target = $$PWD/leveldb/libleveldb.a
genleveldb.depends = FORCE
PRE_TARGETDEPS += $$PWD/leveldb/libleveldb.a
QMAKE_EXTRA_TARGETS += genleveldb
# Gross ugly hack that depends on qmake internals, unfortunately there is no other way to do it.
QMAKE_CLEAN += $$PWD/leveldb/libleveldb.a; cd $$PWD/leveldb ; $(MAKE) clean

# regenerate build.h
!windows|contains(USE_BUILD_INFO, 1) {
    genbuild.depends = FORCE
    genbuild.commands = cd $$PWD; /bin/sh ../share/genbuild.sh $$OUT_PWD/build/build.h
    genbuild.target = $$OUT_PWD/build/build.h
    PRE_TARGETDEPS += $$OUT_PWD/build/build.h
    QMAKE_EXTRA_TARGETS += genbuild
    DEFINES += HAVE_BUILD_INFO
}

contains(USE_O3, 1) {
    message(Building O3 optimization flag)
    QMAKE_CXXFLAGS_RELEASE -= -O2
    QMAKE_CFLAGS_RELEASE -= -O2
    QMAKE_CXXFLAGS += -O3
    QMAKE_CFLAGS += -O3
}

*-g++-32 {
    message("32 platform, adding -msse2 flag")

    QMAKE_CXXFLAGS += -msse2
    QMAKE_CFLAGS += -msse2
}

QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector

CODECFORTR = UTF-8

# for lrelease/lupdate
# also add new translations to qt/bitcoin.qrc under translations/
TRANSLATIONS = $$files(qt/locale/bitcoin_*.ts)

isEmpty(QMAKE_LRELEASE) {
    QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
isEmpty(QM_DIR):QM_DIR = $$PWD/qt/locale
# automatically build translations, so they can be included in resource file
TSQM.name = lrelease ${QMAKE_FILE_IN}
TSQM.input = TRANSLATIONS
TSQM.output = $$QM_DIR/${QMAKE_FILE_BASE}.qm
TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT}
TSQM.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += TSQM

# "Other files" to show in Qt Creator
OTHER_FILES += \
    doc/*.rst doc/*.txt doc/README README.md res/bitcoin-qt.rc

# platform specific defaults, if not overridden on command line
isEmpty(BOOST_LIB_SUFFIX) {
    macx:BOOST_LIB_SUFFIX = -mt
    windows:BOOST_LIB_SUFFIX = -mt
}

isEmpty(BOOST_THREAD_LIB_SUFFIX) {
    win32:BOOST_THREAD_LIB_SUFFIX = _win32$$BOOST_LIB_SUFFIX
    else:BOOST_THREAD_LIB_SUFFIX = $$BOOST_LIB_SUFFIX
}

windows:DEFINES += WIN32

windows:!contains(MINGW_THREAD_BUGFIX, 0) {
    # At least qmake's win32-g++-cross profile is missing the -lmingwthrd
    # thread-safety flag. GCC has -mthreads to enable this, but it doesn't
    # work with static linking. -lmingwthrd must come BEFORE -lmingw, so
    # it is prepended to QMAKE_LIBS_QT_ENTRY.
    # It can be turned off with MINGW_THREAD_BUGFIX=0, just in case it causes
    # any problems on some untested qmake profile now or in the future.
    DEFINES += _MT BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN
    QMAKE_LIBS_QT_ENTRY = -lmingwthrd $$QMAKE_LIBS_QT_ENTRY
}

macx:HEADERS += qt/macdockiconhandler.h qt/macnotificationhandler.h
macx:OBJECTIVE_SOURCES += qt/macdockiconhandler.mm qt/macnotificationhandler.mm
macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
macx:TARGET = "neblio-Qt"
macx:QMAKE_CFLAGS_THREAD += -pthread
macx:QMAKE_LFLAGS_THREAD += -pthread
macx:QMAKE_CXXFLAGS_THREAD += -pthread

# do not include resources while testing
!contains( NEBLIO_TEST, TRUE ) {
    macx:ICON = qt/res/icons/bitcoin.icns
    windows:RC_FILE = qt/res/bitcoin-qt.rc
}

# Set libraries and includes at end, to use platform-defined defaults if not overridden
INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH
LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,)
macx: LIBS += $$join(CURL_LIB_PATH,,-L,)
LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX
# -lgdi32 has to happen after -lcrypto (see  #681)
windows:LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32
LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX -lboost_regex$$BOOST_LIB_SUFFIX
windows:LIBS += -lboost_chrono$$BOOST_LIB_SUFFIX
macx: LIBS += -lcurl

# For Fedora
unix:INCLUDEPATH += /usr/include/libdb4/
unix:LIBS        += -L/usr/lib64/libdb4/

!macx {
    PKG_CONFIG_ENV_VAR = $$(PKG_CONFIG_PATH)
    !isEmpty(PKG_CONFIG_ENV_VAR) {
        PKG_CONFIG_PATH = $$(PKG_CONFIG_PATH)
    }
    isEmpty(PKG_CONFIG_PATH_ENV_VAR) {
        message("PKGCONFIG enviroment variable is not set")
        pkgConfPrefix = ""
    } else {
        message("PKGCONFIG enviroment variable is found to be set to: \"$${PKG_CONFIG_ENV_VAR}\"; it will be used for pkg-config")
        pkgConfPrefix = "PKGCONFIG=$${PKG_CONFIG_PATH}"
    }

    !isEmpty(PKG_CONFIG_PATH) {
        message("Setting PKG_CONFIG_PATH to $${PKG_CONFIG_PATH}")
    }

        pkgconf_exec = "$${pkgConfPrefix} $${CROSS_COMPILE}pkg-config"

    QMAKE_CFLAGS += $$system("$${pkgconf_exec} libcurl --cflags")
    QMAKE_CXXFLAGS += $$system("$${pkgconf_exec} libcurl --cflags")

    # static when release
    contains(RELEASE, 1) {
        libcurlPkgconfCmd = "$${pkgconf_exec} libcurl --libs --static"
    } else {
        libcurlPkgconfCmd = "$${pkgconf_exec} libcurl --libs"
    }
    # the testing whether system() has a zero exit code with the third parameter of system() doesn't work on all Qt versions
    libcURL_LIBS = $$system($$libcurlPkgconfCmd)
    # OpenSSL linking is not necessary as it comes with curl
    # openssl_LIBS = $$system($$opensslPkgconfCmd)
    LIBS += $$libcURL_LIBS $$openssl_LIBS
}

contains(RELEASE, 1) {
    !windows:!macx {
        # Linux: turn dynamic linking back on for c/c++ runtime libraries
        LIBS += -Wl,-Bdynamic
    }
}

!windows:!macx {
    DEFINES += LINUX
    LIBS += -lrt -ldl
}