summaryrefslogtreecommitdiffstats
path: root/configure.pri
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2016-11-18 18:17:49 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2016-12-08 12:40:53 +0000
commite2978d6097be2313e49c57ec14618033cbfa7414 (patch)
treeb9ccc2e78f1869ed0d94c6569649c7de1488719b /configure.pri
parentf882d2f443a8950a2f784fa91b3ff10a645577f7 (diff)
move license check to qmake-based configure system
this also removes the need for passing pre-processed options via configure.cfg, so get rid of that. a somewhat unfortunate side effect is that the android-style-assets feature had to move back to the top level, as the licensing options depend on it. Started-by: Lars Knoll <lars.knoll@qt.io> Change-Id: Id4d1e0ba18b3e3104400293b8f0c7f2f65e68dea Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'configure.pri')
-rw-r--r--configure.pri166
1 files changed, 163 insertions, 3 deletions
diff --git a/configure.pri b/configure.pri
index dc749cd6d4..526b09e965 100644
--- a/configure.pri
+++ b/configure.pri
@@ -1,3 +1,7 @@
+# this must be done outside any function
+QT_SOURCE_TREE = $$PWD
+QT_BUILD_TREE = $$shadowed($$PWD)
+
# custom command line handling
defineTest(qtConfCommandline_qmakeArgs) {
@@ -63,6 +67,165 @@ defineReplace(qtConfFunc_crossCompile) {
return(false)
}
+defineReplace(qtConfFunc_licenseCheck) {
+ exists($$QT_SOURCE_TREE/LICENSE.LGPL3)|exists($$QT_SOURCE_TREE/LICENSE.GPL2): \
+ hasOpenSource = true
+ else: \
+ hasOpenSource = false
+ exists($$QT_SOURCE_TREE/LICENSE.PREVIEW.COMMERCIAL)|exists($$QT_SOURCE_TREE/bin/licheck*): \
+ hasCommercial = true
+ else: \
+ hasCommercial = false
+
+ commercial = $$config.input.commercial
+ isEmpty(commercial) {
+ $$hasOpenSource {
+ $$hasCommercial {
+ logn()
+ logn("Selecting Qt Edition.")
+ logn()
+ logn("Type 'c' if you want to use the Commercial Edition.")
+ logn("Type 'o' if you want to use the Open Source Edition.")
+ logn()
+ for(ever) {
+ val = $$lower($$prompt("Which edition of Qt do you want to use? ", false))
+ equals(val, c) {
+ commercial = yes
+ } else: equals(val, o) {
+ commercial = no
+ } else {
+ next()
+ }
+ break()
+ }
+ } else {
+ commercial = no
+ }
+ } else {
+ !$$hasCommercial: \
+ qtConfFatalError("No license files and no licheck executables found." \
+ "Cannot proceed. Try re-installing Qt.")
+ commercial = yes
+ }
+ }
+
+ equals(commercial, no) {
+ !$$hasOpenSource: \
+ qtConfFatalError("This is the Qt Commercial Edition." \
+ "Cannot proceed with -opensource.")
+
+ logn()
+ logn("This is the Qt Open Source Edition.")
+
+ EditionString = "Open Source"
+ config.input.qt_edition = OpenSource
+ export(config.input.qt_edition)
+ } else {
+ !$$hasCommercial: \
+ qtConfFatalError("This is the Qt Open Source Edition." \
+ "Cannot proceed with -commercial.")
+
+ exists($$QT_SOURCE_TREE/LICENSE.PREVIEW.COMMERCIAL) {
+ logn()
+ logn("This is the Qt Technology Preview Edition.")
+
+ EditionString = "Technology Preview"
+ config.input.qt_edition = Preview
+ export(config.input.qt_edition)
+ } else {
+ equals(QMAKE_HOST.os, Linux) {
+ equals(QMAKE_HOST.arch, x86): \
+ Licheck = licheck32
+ else: \
+ Licheck = licheck64
+ } else: equals(QMAKE_HOST.os, Darwin) {
+ Licheck = licheck_mac
+ } else: equals(QMAKE_HOST.os, Windows) {
+ Licheck = licheck.exe
+ } else {
+ qtConfFatalError("Host operating system not supported by this edition of Qt.")
+ }
+
+ !qtRunLoggedCommand("$$system_quote($$QT_SOURCE_TREE/bin/$$Licheck) \
+ $$eval(config.input.confirm-license) \
+ $$system_quote($$QT_SOURCE_TREE) $$system_quote($$QT_BUILD_TREE) \
+ $$[QMAKE_SPEC] $$[QMAKE_XSPEC]", \
+ LicheckOutput): \
+ return(false)
+ eval($$LicheckOutput)
+ config.input.qt_edition = $$Edition
+ config.input.qt_licheck = $$Licheck
+ config.input.qt_release_date = $$ReleaseDate
+ export(config.input.qt_edition)
+ export(config.input.qt_licheck)
+ export(config.input.qt_release_date)
+ return(true)
+ }
+ }
+
+ !isEmpty(config.input.confirm-license) {
+ logn()
+ logn("You have already accepted the terms of the $$EditionString license.")
+ return(true)
+ }
+
+ affix = the
+ equals(commercial, no) {
+ theLicense = "GNU Lesser General Public License (LGPL) version 3"
+ showWhat = "Type 'L' to view the GNU Lesser General Public License version 3 (LGPLv3)."
+ gpl2Ok = false
+ winrt {
+ notTheLicense = "Note: GPL version 2 is not available on WinRT."
+ } else: $$qtConfEvaluate("features.android-style-assets") {
+ notTheLicense = "Note: GPL version 2 is not available due to using Android style assets."
+ } else {
+ theLicense += "or the GNU General Public License (GPL) version 2"
+ showWhat += "Type 'G' to view the GNU General Public License version 2 (GPLv2)."
+ gpl2Ok = true
+ affix = either
+ }
+ } else {
+ theLicense = $$cat($$QT_SOURCE_TREE/LICENSE.PREVIEW.COMMERCIAL, lines)
+ theLicense = $$first(theLicense)
+ showWhat = "Type '?' to view the $${theLicense}."
+ }
+ msg = \
+ " " \
+ "You are licensed to use this software under the terms of" \
+ "the "$$theLicense"." \
+ $$notTheLicense \
+ " " \
+ $$showWhat \
+ "Type 'y' to accept this license offer." \
+ "Type 'n' to decline this license offer." \
+ " "
+
+ for(ever) {
+ logn($$join(msg, $$escape_expand(\\n)))
+ for(ever) {
+ val = $$lower($$prompt("Do you accept the terms of $$affix license? ", false))
+ equals(val, y)|equals(val, yes) {
+ logn()
+ return(true)
+ } else: equals(val, n)|equals(val, no) {
+ return(false)
+ } else: equals(commercial, yes):equals(val, ?) {
+ licenseFile = $$QT_SOURCE_TREE/LICENSE.PREVIEW.COMMERCIAL
+ } else: equals(commercial, no):equals(val, l) {
+ licenseFile = $$QT_SOURCE_TREE/LICENSE.LGPL3
+ } else: equals(commercial, no):equals(val, g):$$gpl2Ok {
+ licenseFile = $$QT_SOURCE_TREE/LICENSE.GPL2
+ } else {
+ next()
+ }
+ break()
+ }
+ system("more $$system_quote($$system_path($$licenseFile))")
+ logn()
+ logn()
+ }
+}
+
# custom tests
defineTest(qtConfTest_architecture) {
@@ -559,6 +722,3 @@ discard_from($$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)
QMAKE_POST_CONFIGURE += \
"include(\$\$[QT_HOST_DATA/get]/mkspecs/qconfig.pri)" \
"include(\$\$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)"
-
-# load and process input from configure.sh/.exe
-include($$shadowed($$PWD)/config.tests/configure.cfg)