3 # Generated by qconf 1.5 ( http://delta.affinix.com/qconf/ )
10 This script creates necessary configuration files to build/install.
13 --prefix=[path] Base path for build/install. Default: /usr/local
14 --bindir=[path] Directory for binaries. Default: PREFIX/bin
15 --libdir=[path] Directory for libraries. Default: PREFIX/lib
16 --datadir=[path] Directory for data. Default: PREFIX/share
17 --qtdir=[path] Directory where Qt is installed.
18 --verbose Show extra configure output.
19 --help This help text.
22 --release Build with debugging turned off (default).
23 --debug Build with debugging turned on.
24 --no-separate-debug-info Do not store debug information in a separate
25 file (default for mac).
26 --separate-debug-info Strip debug information into a separate .debug
27 file (default for non-mac).
28 --certstore-path=[path] Path to the SSL/X509 Certificate store file
32 --disable-bundled-qca Disable use of bundled QCA
33 --with-qca=[path] Specify path to QCA tree, mainly for building
34 against an uninstalled QCA.
35 --disable-openssl Disable use of OpenSSL (bundled QCA only)
36 --with-openssl-inc=[path] Path to OpenSSL include files (bundled QCA
38 --with-openssl-lib=[path] Path to OpenSSL library files (bundled QCA
40 --with-zlib-inc=[path] Path to zlib include files
41 --with-zlib-lib=[path] Path to zlib library files
42 --enable-universal Enable use of Mac OS X universal binary support
43 --disable-qdbus Disable use of QDBUS
44 --disable-growl Disable use of Growl
45 --with-growl=[path] Path to the Growl framework
46 --enable-whiteboarding Enable use of White Board support
47 --disable-xss Disable use of the XScreenSaver extension
48 --disable-aspell Disable use of aspell
49 --with-aspell-inc=[path] Path to Aspell include files
50 --with-aspell-lib=[path] Path to Aspell library files
51 --disable-enchant Disable use of enchant
56 # which/make detection adapted from Qt
62 WHICH
=`which which 2>/dev/null`
63 if echo $WHICH |
grep 'shell built-in command' >/dev
/null
2>&1; then
65 elif [ -z "$WHICH" ]; then
66 if which which >/dev
/null
2>&1; then
69 for a
in /usr
/ucb
/usr
/bin
/bin
/usr
/local
/bin
; do
70 if [ -x $a/which ]; then
78 if [ -z "$WHICH" ]; then
94 a
=`"$WHICH" "$1" 2>/dev/null`
95 if [ ! -z "$a" -a -x "$a" ]; then
108 # find a make command
109 if [ -z "$MAKE" ]; then
111 for mk
in gmake
make; do
112 if $WHICH $mk >/dev
/null
2>&1; then
117 if [ -z "$MAKE" ]; then
118 echo "You don't seem to have 'make' or 'gmake' in your PATH."
119 echo "Cannot proceed."
125 printf "Be sure you have a proper Qt 4.0 build environment set up. This means not\n"
126 printf "just Qt, but also a C++ compiler, a make tool, and any other packages\n"
127 printf "necessary for compiling C++ programs.\n"
129 printf "If you are certain everything is installed, then it could be that Qt 4 is not\n"
130 printf "being recognized or that a different version of Qt is being detected by\n"
131 printf "mistake (for example, this could happen if \$QTDIR is pointing to a Qt 3\n"
132 printf "installation). At least one of the following conditions must be satisfied:\n"
134 printf " 1) --qtdir is set to the location of Qt\n"
135 printf " 2) \$QTDIR is set to the location of Qt\n"
136 printf " 3) QtCore is in the pkg-config database\n"
137 printf " 4) qmake is in the \$PATH\n"
139 printf "This script will use the first one it finds to be true, checked in the above\n"
140 printf "order. #3 and #4 are the recommended options. #1 and #2 are mainly for\n"
141 printf "overriding the system configuration.\n"
145 while [ $# -gt 0 ]; do
146 optarg
=`expr "x$1" : 'x[^=]*=\(.*\)'`
183 --no-separate-debug-info)
184 QC_NO_SEPARATE_DEBUG_INFO
="Y"
188 --separate-debug-info)
189 QC_SEPARATE_DEBUG_INFO
="Y"
194 QC_CERTSTORE_PATH
=$optarg
198 --disable-bundled-qca)
199 QC_DISABLE_bundled_qca
="Y"
209 QC_DISABLE_openssl
="Y"
213 --with-openssl-inc=*)
214 QC_WITH_OPENSSL_INC
=$optarg
218 --with-openssl-lib=*)
219 QC_WITH_OPENSSL_LIB
=$optarg
224 QC_WITH_ZLIB_INC
=$optarg
229 QC_WITH_ZLIB_LIB
=$optarg
234 QC_ENABLE_universal
="Y"
249 QC_WITH_GROWL
=$optarg
253 --enable-whiteboarding)
254 QC_ENABLE_whiteboarding
="Y"
264 QC_DISABLE_aspell
="Y"
269 QC_WITH_ASPELL_INC
=$optarg
274 QC_WITH_ASPELL_LIB
=$optarg
279 QC_DISABLE_enchant
="Y"
287 --help) show_usage
; exit ;;
288 *) show_usage
; exit ;;
292 PREFIX
=${PREFIX:-/usr/local}
293 BINDIR
=${BINDIR:-$PREFIX/bin}
294 LIBDIR
=${LIBDIR:-$PREFIX/lib}
295 DATADIR
=${DATADIR:-$PREFIX/share}
297 echo "Configuring Psi ..."
299 if [ "$QC_VERBOSE" = "Y" ]; then
304 echo DATADIR
=$DATADIR
305 echo EX_QTDIR
=$EX_QTDIR
306 echo QC_RELEASE
=$QC_RELEASE
307 echo QC_DEBUG
=$QC_DEBUG
308 echo QC_NO_SEPARATE_DEBUG_INFO
=$QC_NO_SEPARATE_DEBUG_INFO
309 echo QC_SEPARATE_DEBUG_INFO
=$QC_SEPARATE_DEBUG_INFO
310 echo QC_CERTSTORE_PATH
=$QC_CERTSTORE_PATH
311 echo QC_DISABLE_bundled_qca
=$QC_DISABLE_bundled_qca
312 echo QC_WITH_QCA
=$QC_WITH_QCA
313 echo QC_DISABLE_openssl
=$QC_DISABLE_openssl
314 echo QC_WITH_OPENSSL_INC
=$QC_WITH_OPENSSL_INC
315 echo QC_WITH_OPENSSL_LIB
=$QC_WITH_OPENSSL_LIB
316 echo QC_WITH_ZLIB_INC
=$QC_WITH_ZLIB_INC
317 echo QC_WITH_ZLIB_LIB
=$QC_WITH_ZLIB_LIB
318 echo QC_ENABLE_universal
=$QC_ENABLE_universal
319 echo QC_DISABLE_qdbus
=$QC_DISABLE_qdbus
320 echo QC_DISABLE_growl
=$QC_DISABLE_growl
321 echo QC_WITH_GROWL
=$QC_WITH_GROWL
322 echo QC_ENABLE_whiteboarding
=$QC_ENABLE_whiteboarding
323 echo QC_DISABLE_xss
=$QC_DISABLE_xss
324 echo QC_DISABLE_aspell
=$QC_DISABLE_aspell
325 echo QC_WITH_ASPELL_INC
=$QC_WITH_ASPELL_INC
326 echo QC_WITH_ASPELL_LIB
=$QC_WITH_ASPELL_LIB
327 echo QC_DISABLE_enchant
=$QC_DISABLE_enchant
331 printf "Verifying Qt 4 build environment ... "
333 # run qmake -v and check version
336 if echo `$1 -v 2>&1` |
grep "Qt version 4\." >/dev
/null
2>&1; then
338 elif [ "$QC_VERBOSE" = "Y" ]; then
339 echo "Warning: $1 not for Qt 4"
345 if [ "$QC_VERBOSE" = "Y" ]; then
350 names
="qmake-qt4 qmake4 qmake"
353 if [ -z "$qm" ] && [ ! -z "$EX_QTDIR" ]; then
355 qstr
=$EX_QTDIR/bin
/$n
356 if qmake_check_v4
"$qstr"; then
362 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
363 echo "Warning: qmake not found via --qtdir"
367 if [ -z "$qm" ] && [ ! -z "$QTDIR" ]; then
370 if qmake_check_v4
"$qstr"; then
376 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
377 echo "Warning: qmake not found via \$QTDIR"
380 # qt4 check: pkg-config
381 if [ -z "$qm" ]; then
382 str
=`pkg-config QtCore --variable=exec_prefix 2>/dev/null`
383 if [ ! -z "$str" ]; then
386 if qmake_check_v4
"$qstr"; then
393 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
394 echo "Warning: qmake not found via pkg-config"
398 if [ -z "$qm" ]; then
400 qstr
=`$WHICH $n 2>/dev/null`
401 if qmake_check_v4
"$qstr"; then
407 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
408 echo "Warning: qmake not found via \$PATH"
411 if [ -z "$qm" ]; then
412 if [ "$QC_VERBOSE" = "Y" ]; then
418 printf "Reason: Unable to find the 'qmake' tool for Qt 4.\n"
423 if [ "$QC_VERBOSE" = "Y" ]; then
424 echo qmake found
in $qm
427 # try to determine the active makespec
428 defmakespec
=$QMAKESPEC
429 if [ -z "$defmakespec" ]; then
430 if $WHICH readlink
>/dev
/null
2>&1; then
431 READLINK
=`$WHICH readlink`
433 if [ ! -z "$READLINK" ]; then
434 qt_mkspecsdir
=`$qm -query QT_INSTALL_DATA`/mkspecs
435 if [ -d "$qt_mkspecsdir" ] && [ -h "$qt_mkspecsdir/default" ]; then
436 defmakespec
=`$READLINK $qt_mkspecsdir/default`
441 if [ "$QC_VERBOSE" = "Y" ]; then
442 echo makespec is
$defmakespec
446 # if the makespec is macx-xcode, force macx-g++
447 if [ "$defmakespec" = "macx-xcode" ]; then
451 if [ "$QC_VERBOSE" = "Y" ]; then
452 echo overriding makespec to
$qm_spec
457 cat >$1/modules.cpp
<<EOT
460 -----BEGIN QCMOD-----
464 class qc_qt4 : public ConfObj
467 qc_qt4(Conf *c) : ConfObj(c) {}
468 QString name() const { return "Qt >= 4.4.0"; }
469 QString shortname() const { return "qt4"; }
472 return(QT_VERSION >= 0x040400);
475 #line 1 "buildmodeapp.qcm"
477 -----BEGIN QCMOD-----
480 arg: release,Build with debugging turned off (default).
481 arg: debug,Build with debugging turned on.
482 arg: no-separate-debug-info,Do not store debug information in a separate file (default for mac).
483 arg: separate-debug-info,Strip debug information into a separate .debug file (default for non-mac).
485 arg: debug-and-release,Build two versions, with and without debugging turned on (mac only).
489 bool qc_buildmode_release = false;
490 bool qc_buildmode_debug = false;
491 bool qc_buildmode_separate_debug_info = false;
493 class qc_buildmodeapp : public ConfObj
496 qc_buildmodeapp(Conf *c) : ConfObj(c) {}
497 QString name() const { return "buildmodeapp"; }
498 QString shortname() const { return "buildmodeapp"; }
501 QString checkString() const { return QString(); }
505 // first, parse out the options
506 bool opt_release = false;
507 bool opt_debug = false;
508 bool opt_debug_and_release = false;
509 bool opt_no_separate_debug_info = false;
510 bool opt_separate_debug_info = false;
512 if(conf->getenv("QC_RELEASE") == "Y")
514 if(conf->getenv("QC_DEBUG") == "Y")
516 if(conf->getenv("QC_DEBUG_AND_RELEASE") == "Y")
517 opt_debug_and_release = true;
518 if(conf->getenv("QC_NO_SEPARATE_DEBUG_INFO") == "Y")
519 opt_no_separate_debug_info = true;
520 if(conf->getenv("QC_SEPARATE_DEBUG_INFO") == "Y")
521 opt_separate_debug_info = true;
523 bool staticmode = false;
524 if(conf->getenv("QC_STATIC") == "Y")
528 if(opt_debug_and_release)
530 printf("\nError: The --debug-and-release option is for mac only.\n");
535 // sanity check exclusive options
544 if(opt_debug_and_release)
548 printf("\nError: Use only one of --release, --debug, or --debug-and-release.\n");
554 if(opt_no_separate_debug_info)
556 if(opt_separate_debug_info)
560 printf("\nError: Use only one of --separate-debug-info or --no-separate-debug-info\n");
564 // now process the options
567 qc_buildmode_release = true;
569 qc_buildmode_debug = true;
570 else if(opt_debug_and_release)
572 qc_buildmode_release = true;
573 qc_buildmode_debug = true;
576 qc_buildmode_release = true;
578 if(opt_separate_debug_info)
579 qc_buildmode_separate_debug_info = true;
580 else if(opt_no_separate_debug_info)
587 qc_buildmode_separate_debug_info = true;
595 if(qc_buildmode_release && qc_buildmode_debug)
597 opts += "debug_and_release";
600 else if(qc_buildmode_release)
602 else // qc_buildmode_debug
605 if(qc_buildmode_separate_debug_info)
607 opts += "separate_debug_info";
608 other += "*-g++*:QMAKE_CFLAGS += -g\n";
609 other += "*-g++*:QMAKE_CXXFLAGS += -g\n";
612 QString str = QString("CONFIG += ") + opts.join(" ") + '\n';
616 conf->addExtra(other);
621 #line 1 "bundled-qca.qcm"
623 -----BEGIN QCMOD-----
628 //----------------------------------------------------------------------------
630 //----------------------------------------------------------------------------
631 class qc_bundled_qca : public ConfObj
634 qc_bundled_qca(Conf *c) : ConfObj(c) {}
635 QString name() const { return "bundled QCA 2.0"; }
636 QString shortname() const { return "bundled_qca"; }
640 // FIXME: Check QCA version number
641 if (QFile::exists("third-party/qca/qca")) {
642 conf->addExtra("CONFIG += qca-static");
643 conf->addDefine("QCA_NO_PLUGINS");
647 if(conf->findHeader("sys/filio.h", QStringList(), &str))
650 conf->addIncludePath(str);
651 conf->addDefine("HAVE_SYS_FILIO_H");
663 -----BEGIN QCMOD-----
665 arg: with-qca=[path],Specify path to QCA tree, mainly for building against an uninstalled QCA.
669 // based on crypto.prf. any changes made to that file need to be tracked here.
670 static QString internal_crypto_prf(const QString &incdir, const QString &libdir)
672 QString out = QString(
680 "# on mac, if qca was built as a framework, link against it\n"
682 " framework_dir = \$\$QCA_LIBDIR\n"
683 " exists(\$\$framework_dir/qca.framework) {\n"
684 " #QMAKE_FRAMEWORKPATH *= \$\$framework_dir\n"
685 " LIBS += -F\$\$framework_dir\n"
686 " INCLUDEPATH += \$\$framework_dir/qca.framework/Headers\n"
687 " LINKAGE = -framework qca\n"
691 "# else, link normally\n"
692 "isEmpty(LINKAGE) {\n"
693 " INCLUDEPATH += \$\$QCA_INCDIR/QtCrypto\n"
694 " LIBS += -L\$\$QCA_LIBDIR\n"
696 " CONFIG(debug, debug|release) {\n"
697 " windows:LINKAGE = -lqcad\n"
698 " mac:LINKAGE = -lqca_debug\n"
702 "LIBS += \$\$LINKAGE\n"
703 ).arg(incdir, libdir);
707 //----------------------------------------------------------------------------
709 //----------------------------------------------------------------------------
710 class qc_qca : public ConfObj
713 qc_qca(Conf *c) : ConfObj(c) {}
714 QString name() const { return "QCA >= 2.0"; }
715 QString shortname() const { return "qca"; }
718 QString checkString() const
720 if(QFile::exists("third-party/qca/qca") && conf->getenv("QC_DISABLE_bundled_qca").isEmpty())
723 return ConfObj::checkString();
730 // Check if we have a bundled version
731 if(QFile::exists("third-party/qca/qca") && conf->getenv("QC_DISABLE_bundled_qca").isEmpty())
735 // get the build mode
737 bool release = qc_buildmode_release;
738 bool debug = qc_buildmode_debug;
740 // else, default to just release mode
745 // test for "crypto" feature and check qca version number
746 QString qca_prefix, qca_incdir, qca_libdir, qca_crypto_prf;
747 qca_prefix = conf->getenv("QC_WITH_QCA");
750 if(!qca_prefix.isEmpty()) {
751 qca_incdir = qca_prefix + "/include";
752 qca_libdir = qca_prefix + "/lib";
753 qca_crypto_prf = internal_crypto_prf(qca_incdir, qca_libdir);
757 proextra += qca_crypto_prf;
760 "CONFIG += qt crypto\n"
765 "#include <QtCrypto>\n"
769 " unsigned long x = QCA_VERSION;\n"
770 " if(x >= 0x020000 && x < 0x030000) return 0; else return 1;\n"
776 if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra + "CONFIG += release\n", &ret))
785 if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra + "CONFIG += debug\n", &ret))
791 if(!qca_prefix.isEmpty())
792 conf->addExtra(qca_crypto_prf);
794 conf->addExtra("CONFIG += crypto\n");
799 #line 1 "openssl.qcm"
801 -----BEGIN QCMOD-----
802 name: OpenSSL (bundled QCA only)
803 arg: with-openssl-inc=[path],Path to OpenSSL include files (bundled QCA only)
804 arg: with-openssl-lib=[path],Path to OpenSSL library files (bundled QCA only)
807 class qc_openssl : public ConfObj
810 qc_openssl(Conf *c) : ConfObj(c) {}
811 QString name() const { return "OpenSSL"; }
812 QString shortname() const { return "openssl"; }
814 QString checkString() const {
815 if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty())
818 return ConfObj::checkString();
823 if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty() || !QFile::exists("third-party/qca/qca-ossl"))
827 QString ossl_inc = conf->getenv("QC_WITH_OPENSSL_INC");
828 if(ossl_inc.isEmpty())
831 QString ossl_lib = conf->getenv("QC_WITH_OPENSSL_LIB");
832 if(ossl_lib.isEmpty())
835 QStringList libnames;
836 libnames += "-lssl.dll -lcrypto.dll";
837 libnames += "-llibeay32 -lssleay32";
838 libnames += "-leay32 -lssl32";
839 libnames += "-leay32 " + ossl_lib + "/ssleay32.a";
841 bool success = false;
842 QString libname_success;
843 foreach(const QString &libname, libnames)
846 "#include<openssl/opensslv.h>\n"
849 " unsigned long x = OPENSSL_VERSION_NUMBER;\n"
850 " if(x >= 0x00907000) return 0; else return 1;\n"
855 ext += QString("-L") + ossl_lib + " " + libname;
857 if(conf->doCompileAndLink(str, incs, ext, QString(), &ret))
860 libname_success = libname;
862 conf->addDefine("OSSL_097");
870 conf->addIncludePath(ossl_inc);
871 conf->addLib(QString("-L") + ossl_lib);
872 conf->addLib(libname_success);
874 conf->addDefine("HAVE_OPENSSL");
881 QString kbdir = "/usr/kerberos/include";
884 if(QFileInfo(kbdir).exists())
887 s = conf->getenv("QC_WITH_OPENSSL_INC");
889 if(!conf->checkHeader(s, "openssl/ssl.h"))
894 if(!conf->findHeader("openssl/ssl.h", QStringList(), &s))
899 s = conf->getenv("QC_WITH_OPENSSL_LIB");
901 if(!conf->checkLibrary(s, "ssl"))
906 if(!conf->findLibrary("ssl", &s))
911 // is it at least openssl 0.9.7?
913 "#include<openssl/opensslv.h>\n"
916 " unsigned long x = OPENSSL_VERSION_NUMBER;\n"
917 " if(x >= 0x00907000) return 0; else return 1;\n"
926 ext += QString("-L") + lib + " -lssl -lcrypto ";
928 if(!conf->doCompileAndLink(str, incs, ext, QString(), &ret))
931 conf->addDefine("OSSL_097");
934 conf->addIncludePath(inc);
936 conf->addIncludePath(kbdir);
938 conf->addLib(QString("-L") + s);
939 conf->addLib("-lssl -lcrypto");
941 conf->addDefine("HAVE_OPENSSL");
949 -----BEGIN QCMOD-----
951 arg: with-zlib-inc=[path],Path to zlib include files
952 arg: with-zlib-lib=[path],Path to zlib library files
956 //----------------------------------------------------------------------------
958 //----------------------------------------------------------------------------
959 class qc_zlib : public ConfObj
962 qc_zlib(Conf *c) : ConfObj(c) {}
963 QString name() const { return "zlib"; }
964 QString shortname() const { return "zlib"; }
966 QString resultString() const
968 return "using bundled";
975 // HACK: on windows, always use psi's bundled zlib
976 conf->addExtra("CONFIG += psi-winzlib psi-minizip");
980 QString version, libs, other;
983 if(!conf->findPkgConfig("zlib", VersionAny, "", &version, &incs, &libs, &other)) {
985 s = conf->getenv("QC_WITH_ZLIB_INC");
987 if(!conf->checkHeader(s, "zlib.h"))
991 if(!conf->findHeader("zlib.h", QStringList(), &s))
996 s = conf->getenv("QC_WITH_ZLIB_LIB");
998 if(!conf->checkLibrary(s, "z"))
1002 if(!conf->findLibrary("z", &s))
1005 libs = QString("-L%1 -lz").arg(s);
1008 foreach(const QString &inc, incs) {
1009 conf->addIncludePath(inc);
1015 if(!conf->findPkgConfig("minizip", VersionAny, "", &version, &incs, &libs, &other)) {
1017 s = conf->getenv("QC_WITH_MINIZIP_INC");
1018 if ((!s.isEmpty() && conf->checkHeader(s, "unzip.h")) ||
1019 (s.isEmpty() && conf->findHeader("unzip.h", QStringList(), &s))) {
1023 s = conf->getenv("QC_WITH_MINIZIP_LIB");
1024 if((!s.isEmpty() && conf->checkLibrary(s, "minizip")) ||
1025 (s.isEmpty() && conf->findLibrary("minizip", &s))) {
1026 libs = QString("-L%1 -lminizip").arg(s);
1030 if (!incs.isEmpty() && !libs.isEmpty()) {
1031 foreach(const QString &inc, incs) {
1032 conf->addIncludePath(inc);
1036 conf->addExtra("CONFIG += psi-minizip");
1045 -----BEGIN QCMOD-----
1050 //----------------------------------------------------------------------------
1052 //----------------------------------------------------------------------------
1053 class qc_x11 : public ConfObj
1056 qc_x11(Conf *c) : ConfObj(c) {}
1058 QString name() const { return "Xorg X11"; }
1059 QString shortname() const { return "x11"; }
1060 QString checkString() const { return QString(); }
1069 QString proextra = "CONFIG += x11\n";
1071 return conf->doCompileAndLink(str, QStringList(), QString(), proextra, NULL);
1074 #line 1 "universal.qcm"
1076 -----BEGIN QCMOD-----
1077 name: Mac OS X universal binary support
1081 //----------------------------------------------------------------------------
1083 //----------------------------------------------------------------------------
1084 class qc_universal : public ConfObj
1087 qc_universal(Conf *c) : ConfObj(c) {}
1088 QString name() const { return "universal binary support"; }
1089 QString shortname() const { return "universal"; }
1090 QString checkString() const { return QString(); }
1095 conf->addExtra("CONFIG += qc_universal");
1100 #line 1 "certstore.qcm"
1102 -----BEGIN QCMOD-----
1105 arg: certstore-path=[path],Path to the SSL/X509 Certificate store file (bundled QCA only)
1109 class qc_certstore : public ConfObj
1112 qc_certstore(Conf *c) : ConfObj(c) {}
1113 QString name() const { return "certstore"; }
1114 QString shortname() const { return "certstore"; }
1116 QString checkString() const {
1117 if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty())
1120 return ConfObj::checkString();
1125 if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty() || !QFile::exists("third-party/qca/qca-ossl")) {
1131 #if defined(Q_OS_WIN) || defined(Q_OS_MAC)
1135 QStringList pathsToTry;
1137 path = conf->getenv("QC_CERTSTORE_PATH");
1140 if(QFile::exists(path))
1142 QString certPathString =
1143 "QCA_SYSTEMSTORE_PATH=\\\\\\\\\\\\\"" + path + "\\\\\\\\\\\\\"";
1144 conf->addDefine(certPathString);
1150 // This is from Debian
1151 pathsToTry.append( QString("/etc/ssl/certs/ca-certificates.crt") );
1153 // Fedora Core 2 uses these
1154 pathsToTry.append( QString("/usr/share/ssl/cert.pem") );
1155 pathsToTry.append( QString("/usr/share/ssl/certs/ca-bundle.crt") );
1157 // Fedora Core 5 changes to this
1158 pathsToTry.append( QString("/etc/pki/tls/cert.pem") );
1160 for(int n = 0; n < pathsToTry.count(); ++n)
1162 if(QFile::exists(pathsToTry[n]))
1164 path = pathsToTry[n];
1169 // fall back to bundled
1173 if(QFile::exists(conf->getenv("PREFIX") + "/certs/rootcerts.pem"))
1174 path = "\$\$PREFIX/certs/rootcerts.pem";
1176 path = "\$\$DATADIR/psi/certs/rootcerts.pem";
1179 "qcasharedfiles.path = \$\$DATADIR/psi\n"
1180 "qcasharedfiles.files = third-party/qca/qca/certs\n"
1181 "INSTALLS += qcasharedfiles\n";
1182 conf->addExtra(extra);
1186 // Qt<4.2 workaround
1187 QString certPathString =
1188 "QCA_SYSTEMSTORE_PATH=\\\\\\\\\\\\\"" + path + "\\\\\\\\\\\\\"";
1189 conf->addDefine(certPathString);
1195 QString resultString() const
1197 #if defined(Q_OS_WIN)
1198 return "using Windows built-in";
1199 #elif defined(Q_OS_MAC)
1200 return "using Mac built-in";
1205 return "using bundled";
1210 return ConfObj::resultString();
1220 -----BEGIN QCMOD-----
1225 //----------------------------------------------------------------------------
1227 //----------------------------------------------------------------------------
1228 class qc_qdbus : public ConfObj
1231 qc_qdbus(Conf *c) : ConfObj(c) {}
1232 QString name() const { return "QDBUS"; }
1233 QString shortname() const { return "qdbus"; }
1236 if (!conf->getenv("QC_DISABLE_qdbus").isEmpty())
1239 // test for "qdbus" feature
1242 "CONFIG += qt qdbus\n"
1253 if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra, &ret))
1258 conf->addExtra("CONFIG += dbus");
1264 -----BEGIN QCMOD-----
1266 arg: with-growl=[path],Path to the Growl framework
1270 //----------------------------------------------------------------------------
1272 //----------------------------------------------------------------------------
1273 class qc_growl : public ConfObj
1276 qc_growl(Conf *c) : ConfObj(c) {}
1277 QString name() const { return "Growl"; }
1278 QString shortname() const { return "growl"; }
1280 QString checkString() const { return QString(); }
1283 // TODO: This should go into ConfObj
1284 bool checkFramework(const QString &path, const QString &name)
1294 extra += QString("-F") + path + ' ';
1295 extra += QString("-framework ") + name;
1296 if(!conf->doCompileAndLink(str, QStringList(), extra, "", NULL))
1301 // TODO: This should go into ConfObj
1302 void addFrameworkPath(const QString& str)
1304 conf->addExtra("QMAKE_CXXFLAGS += -F" + str);
1305 conf->addLib("-F" + str);
1311 QString growl_path = conf->getenv("QC_WITH_GROWL");
1312 if(!checkFramework(growl_path, "Growl"))
1315 if(!growl_path.isEmpty())
1316 addFrameworkPath(growl_path);
1317 conf->addLib("-framework Growl");
1318 conf->addDefine("HAVE_GROWL");
1326 #line 1 "whiteboarding.qcm"
1328 -----BEGIN QCMOD-----
1329 name: White Board support
1333 //----------------------------------------------------------------------------
1335 //----------------------------------------------------------------------------
1336 class qc_whiteboarding : public ConfObj
1339 qc_whiteboarding(Conf *c) : ConfObj(c) {}
1340 QString name() const { return "White Board support"; }
1341 QString shortname() const { return "whiteboarding"; }
1344 conf->addDefine("WHITEBOARDING");
1347 conf->addExtra("CONFIG += whiteboarding");
1351 qWarning(" !!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!");
1352 qWarning(" WHITEBOARDING SUPPORT IS STILL UNFINISHED !!!");
1353 qWarning(" USE AT YOUR OWN RISK !!!");
1360 -----BEGIN QCMOD-----
1361 name: the XScreenSaver extension
1365 //----------------------------------------------------------------------------
1367 //----------------------------------------------------------------------------
1368 class qc_xss : public ConfObj
1371 qc_xss(Conf *c) : ConfObj(c) {}
1373 QString name() const { return "the XScreenSaver extension"; }
1374 QString shortname() const { return "xss"; }
1376 QString checkString() const { return QString(); }
1382 // skip XSS support on windows
1386 "#include<X11/Xlib.h>\n"
1387 "#include<X11/Xutil.h>\n"
1388 "#include<X11/extensions/scrnsaver.h>\n"
1392 " XScreenSaverQueryExtension(NULL, NULL, NULL);\n"
1395 QString proextra = "CONFIG += x11\n";
1397 if (!conf->doCompileAndLink(str, QStringList(), "-lXss", proextra, NULL)) {
1398 if (!conf->doCompileAndLink(str, QStringList(), QString(), proextra, NULL)) {
1403 conf->addLib("-lXss");
1406 conf->addDefine("HAVE_XSS");
1411 #line 1 "aspell.qcm"
1413 -----BEGIN QCMOD-----
1415 arg: with-aspell-inc=[path],Path to Aspell include files
1416 arg: with-aspell-lib=[path],Path to Aspell library files
1421 bool qc_aspell_have = false;
1422 QStringList qc_aspell_defs;
1423 QStringList qc_aspell_incs;
1424 QStringList qc_aspell_libs;
1426 //----------------------------------------------------------------------------
1428 //----------------------------------------------------------------------------
1429 class qc_aspell : public ConfObj
1432 qc_aspell(Conf *c) : ConfObj(c) {}
1433 QString name() const { return "aspell"; }
1434 QString shortname() const { return "aspell"; }
1437 QString checkString() const { return QString(); }
1441 // on mac, always use built-in spell check
1445 qc_aspell_have = false;
1446 qc_aspell_defs.clear();
1447 qc_aspell_incs.clear();
1448 qc_aspell_libs.clear();
1453 s = conf->getenv("QC_WITH_ASPELL_INC");
1455 if(!conf->checkHeader(s, "aspell.h")) {
1456 conf->debug("Aspell includes not found!");
1459 qc_aspell_incs += s;
1464 QString a_lib = conf->getenv("QC_WITH_ASPELL_LIB");
1468 QStringList libnames;
1469 libnames += "aspell-15";
1470 libnames += "aspell";
1473 QString libname_success;
1474 foreach(const QString &libname, libnames) {
1475 conf->debug(QString("Trying %1").arg(libname));
1476 if(conf->checkLibrary(a_lib, libname)) {
1478 libname_success = libname;
1486 qc_aspell_defs += "HAVE_ASPELL";
1487 qc_aspell_libs += QString("-L") + a_lib;
1488 qc_aspell_libs += QString("-l") + libname_success;
1489 qc_aspell_have = true;
1491 s = conf->getenv("QC_WITH_ASPELL_INC");
1493 if(!conf->checkHeader(s, "aspell.h")) {
1494 conf->debug("Aspell includes not found!");
1497 qc_aspell_incs += s;
1501 sl += "/usr/include";
1502 sl += "/usr/local/include";
1503 sl += "/sw/include";
1504 if(!conf->findHeader("aspell.h", sl, &s)) {
1505 conf->debug("Aspell includes not found!");
1508 qc_aspell_incs += s;
1511 s = conf->getenv("QC_WITH_ASPELL_LIB");
1513 if(!conf->checkLibrary(s, "aspell")) {
1514 conf->debug("Aspell libraries not found!");
1517 qc_aspell_libs += QString("-L") + s;
1520 if(!conf->findLibrary("aspell", &s)) {
1521 conf->debug("Aspell libraries not found!");
1525 qc_aspell_libs += QString("-L") + s;
1528 qc_aspell_defs += "HAVE_ASPELL";
1529 qc_aspell_libs += "-laspell";
1530 qc_aspell_have = true;
1537 #line 1 "enchant.qcm"
1539 -----BEGIN QCMOD-----
1545 bool qc_enchant_have = false;
1546 QStringList qc_enchant_defs;
1547 QStringList qc_enchant_incs;
1548 QStringList qc_enchant_libs;
1550 //----------------------------------------------------------------------------
1552 //----------------------------------------------------------------------------
1553 class qc_enchant : public ConfObj
1556 qc_enchant(Conf *c) : ConfObj(c) {}
1557 QString name() const { return "enchant"; }
1558 QString shortname() const { return "enchant"; }
1561 QString checkString() const { return QString(); }
1565 // on mac, always use built-in spell check
1570 qc_enchant_have = false;
1571 qc_enchant_defs.clear();
1572 qc_enchant_incs.clear();
1573 qc_enchant_libs.clear();
1576 QString version, libs, other;
1577 if(!conf->findPkgConfig("enchant", VersionMin, "1.3.0", &version, &incs, &libs, &other))
1580 qc_enchant_defs += "HAVE_ENCHANT";
1581 qc_enchant_incs += incs;
1582 qc_enchant_libs += libs;
1583 qc_enchant_have = true;
1590 -----BEGIN QCMOD-----
1591 name: spellcheck engine
1595 //----------------------------------------------------------------------------
1597 //----------------------------------------------------------------------------
1598 class qc_spell : public ConfObj
1603 qc_spell(Conf *c) : ConfObj(c) {}
1604 QString name() const { return "spellcheck engine"; }
1605 QString shortname() const { return "spell"; }
1609 // on mac, always use built-in spell check
1611 engine = "using Mac built-in";
1616 QStringList defs, incs, libs;
1619 if(!have && qc_enchant_have)
1621 defs = qc_enchant_defs;
1622 incs = qc_enchant_incs;
1623 libs = qc_enchant_libs;
1629 if(!have && qc_aspell_have)
1631 defs = qc_aspell_defs;
1632 incs = qc_aspell_incs;
1633 libs = qc_aspell_libs;
1642 for(int n = 0; n < defs.count(); ++n)
1643 conf->addDefine(defs[n]);
1644 for(int n = 0; n < incs.count(); ++n)
1645 conf->addIncludePath(incs[n]);
1646 for(int n = 0; n < libs.count(); ++n)
1647 conf->addLib(libs[n]);
1652 QString resultString() const
1654 if(!engine.isEmpty())
1662 -----BEGIN QCMOD-----
1663 name: Psi Configuration
1667 //----------------------------------------------------------------------------
1669 //----------------------------------------------------------------------------
1670 class qc_conf : public ConfObj
1673 qc_conf(Conf *c) : ConfObj(c) {}
1674 QString name() const { return "Psi Configuration"; }
1675 QString shortname() const { return "conf"; }
1676 QString checkString() const { return QString(); }
1682 conf->addExtra(QString("PSI_LIBDIR=%1/psi").arg(conf->getenv("LIBDIR")));
1683 conf->addExtra(QString("PSI_DATADIR=%1/psi").arg(conf->getenv("DATADIR")));
1685 QFile file("src/config.h");
1686 if ( file.open(QIODevice::WriteOnly | QIODevice::Text) ) {
1687 QTextStream stream( &file );
1688 stream << "#define PSI_LIBDIR \"" << conf->getenv("LIBDIR") << "/psi\"" << endl;
1689 stream << "#define PSI_DATADIR \"" << conf->getenv("DATADIR") << "/psi\"" << endl;
1692 conf->addDefine("HAVE_CONFIG");
1698 #line 1 "recursiveprl.qcm"
1700 -----BEGIN QCMOD-----
1701 name: Generate .prl files
1705 //----------------------------------------------------------------------------
1707 //----------------------------------------------------------------------------
1708 class qc_recursiveprl : public ConfObj
1713 qc_recursiveprl(Conf *c) : ConfObj(c) {}
1714 QString name() const { return "Generate .prl files"; }
1715 QString shortname() const { return "recursiveprl"; }
1717 QString checkString() const
1719 return "Generating .prl files ...";
1722 QString resultString() const
1743 args += qc_getenv("QC_PROFILE");
1744 if(conf->doCommand(conf->qmake_path, args) != 0)
1755 // adapted from conf4.cpp. probably a future version of qconf
1756 // should just have a function to do this so we don't have
1758 QFile f("conf.pri");
1759 if(!f.open(QFile::WriteOnly | QFile::Truncate))
1761 conf->debug(QString("Error writing %1").arg(f.fileName()));
1766 str += "# qconf\n\n";
1769 var = qc_getenv("PREFIX");
1771 str += QString("PREFIX = %1\n").arg(var);
1772 var = qc_getenv("BINDIR");
1774 str += QString("BINDIR = %1\n").arg(var);
1775 var = qc_getenv("INCDIR");
1777 str += QString("INCDIR = %1\n").arg(var);
1778 var = qc_getenv("LIBDIR");
1780 str += QString("LIBDIR = %1\n").arg(var);
1781 var = qc_getenv("DATADIR");
1783 str += QString("DATADIR = %1\n").arg(var);
1786 if(qc_getenv("QC_STATIC") == "Y")
1787 str += "CONFIG += staticlib\n";
1789 if(!conf->DEFINES.isEmpty())
1790 str += "DEFINES += " + conf->DEFINES + '\n';
1791 if(!conf->INCLUDEPATH.isEmpty())
1792 str += "INCLUDEPATH += " + conf->INCLUDEPATH + '\n';
1793 if(!conf->LIBS.isEmpty())
1794 str += "LIBS += " + conf->LIBS + '\n';
1795 if(!conf->extra.isEmpty())
1799 QByteArray cs = str.toLatin1();
1808 cat >$1/modules_new.cpp
<<EOT
1809 o = new qc_qt4(conf);
1811 o->disabled = false;
1812 o = new qc_buildmodeapp(conf);
1814 o->disabled = false;
1815 o = new qc_bundled_qca(conf);
1816 o->required = false;
1817 o->disabled = false;
1818 o = new qc_qca(conf);
1820 o->disabled = false;
1821 o = new qc_openssl(conf);
1822 o->required = false;
1823 o->disabled = false;
1824 o = new qc_zlib(conf);
1826 o->disabled = false;
1827 o = new qc_x11(conf);
1829 o->disabled = false;
1830 o = new qc_universal(conf);
1831 o->required = false;
1833 o = new qc_certstore(conf);
1835 o->disabled = false;
1836 o = new qc_qdbus(conf);
1837 o->required = false;
1838 o->disabled = false;
1839 o = new qc_growl(conf);
1840 o->required = false;
1841 o->disabled = false;
1842 o = new qc_whiteboarding(conf);
1843 o->required = false;
1845 o = new qc_xss(conf);
1846 o->required = false;
1847 o->disabled = false;
1848 o = new qc_aspell(conf);
1849 o->required = false;
1850 o->disabled = false;
1851 o = new qc_enchant(conf);
1852 o->required = false;
1853 o->disabled = false;
1854 o = new qc_spell(conf);
1856 o->disabled = false;
1857 o = new qc_conf(conf);
1859 o->disabled = false;
1860 o = new qc_recursiveprl(conf);
1862 o->disabled = false;
1865 cat >$1/conf4.h
<<EOT
1867 Copyright (C) 2004-2008 Justin Karneges
1869 This file is free software; unlimited permission is given to copy and/or
1870 distribute it, with or without modifications, as long as this notice is
1881 enum VersionMode { VersionMin, VersionExact, VersionMax, VersionAny };
1885 // Subclass ConfObj to create a new configuration module.
1897 // long or descriptive name of what is being checked/performed
1898 // example: "KDE >= 3.3"
1899 virtual QString name() const = 0;
1903 virtual QString shortname() const = 0;
1905 // string to display during check
1906 // default: "Checking for [name] ..."
1907 virtual QString checkString() const;
1909 // string to display after check
1910 // default: "yes" or "no", based on result of exec()
1911 virtual QString resultString() const;
1913 // this is where the checking code goes
1914 virtual bool exec() = 0;
1919 // Interact with this class from your ConfObj to perform detection
1920 // operations and to output configuration parameters.
1930 QString INCLUDEPATH;
1934 QList<ConfObj*> list;
1935 QMap<QString,QString> vars;
1940 QString getenv(const QString &var);
1941 QString qvar(const QString &s);
1945 void debug(const QString &s);
1947 QString expandIncludes(const QString &inc);
1948 QString expandLibs(const QString &lib);
1950 int doCommand(const QString &s, QByteArray *out = 0);
1951 int doCommand(const QString &prog, const QStringList &args, QByteArray *out = 0);
1953 bool doCompileAndLink(const QString &filedata, const QStringList &incs, const QString &libs, const QString &proextra, int *retcode = 0);
1954 bool checkHeader(const QString &path, const QString &h);
1955 bool findHeader(const QString &h, const QStringList &ext, QString *inc);
1956 bool checkLibrary(const QString &path, const QString &name);
1957 bool findLibrary(const QString &name, QString *lib);
1958 QString findProgram(const QString &prog);
1959 bool findSimpleLibrary(const QString &incvar, const QString &libvar, const QString &incname, const QString &libname, QString *incpath, QString *libs);
1960 bool findFooConfig(const QString &path, QString *version, QStringList *incs, QString *libs, QString *otherflags);
1961 bool findPkgConfig(const QString &name, VersionMode mode, const QString &req_version, QString *version, QStringList *incs, QString *libs, QString *otherflags);
1963 void addDefine(const QString &str);
1964 void addLib(const QString &str);
1965 void addIncludePath(const QString &str);
1966 void addExtra(const QString &str);
1971 friend class ConfObj;
1972 void added(ConfObj *o);
1978 cat >$1/conf4.cpp
<<EOT
1980 Copyright (C) 2004-2008 Justin Karneges
1982 This file is free software; unlimited permission is given to copy and/or
1983 distribute it, with or without modifications, as long as this notice is
1992 class MocTestObject : public QObject
1999 QString qc_getenv(const QString &var)
2001 char *p = ::getenv(var.toLatin1().data());
2007 QStringList qc_pathlist()
2010 QString path = qc_getenv("PATH");
2014 list = path.split(';', QString::SkipEmptyParts);
2016 list = path.split(':', QString::SkipEmptyParts);
2025 QString qc_findprogram(const QString &prog)
2028 QStringList list = qc_pathlist();
2029 for(int n = 0; n < list.count(); ++n)
2031 QFileInfo fi(list[n] + '/' + prog);
2032 if(fi.exists() && fi.isExecutable())
2034 out = fi.filePath();
2039 // on windows, be sure to look for .exe
2040 if(prog.right(4).toLower() != ".exe")
2042 fi = QFileInfo(list[n] + '/' + prog + ".exe");
2043 if(fi.exists() && fi.isExecutable())
2045 out = fi.filePath();
2054 QString qc_findself(const QString &argv0)
2057 if(argv0.contains('\\\\'))
2059 if(argv0.contains('/'))
2063 return qc_findprogram(argv0);
2066 int qc_runcommand(const QString &command, QByteArray *out, bool showOutput)
2068 QString fullcmd = command;
2072 fullcmd += " 2>NUL";
2074 fullcmd += " 2>/dev/null";
2079 FILE *f = _popen(fullcmd.toLatin1().data(), "r");
2081 FILE *f = popen(fullcmd.toLatin1().data(), "r");
2089 char c = (char)fgetc(f);
2098 int ret = _pclose(f);
2100 int ret = pclose(f);
2107 int qc_runprogram(const QString &prog, const QStringList &args, QByteArray *out, bool showOutput)
2109 QString fullcmd = prog;
2110 QString argstr = args.join(" ");
2111 if(!argstr.isEmpty())
2112 fullcmd += QString(" ") + argstr;
2113 return qc_runcommand(fullcmd, out, showOutput);
2115 // TODO: use QProcess once it is fixed
2119 process.setReadChannelMode(ForwardedChannels);
2120 process.start(prog, args);
2121 process.waitForFinished(-1);
2122 return process.exitCode();
2126 bool qc_removedir(const QString &dirPath)
2131 QStringList list = dir.entryList();
2132 foreach(QString s, list)
2134 if(s == "." || s == "..")
2136 QFileInfo fi(dir.filePath(s));
2139 if(!qc_removedir(fi.filePath()))
2148 QString dirName = dir.dirName();
2151 if(!dir.rmdir(dirName))
2156 void qc_splitcflags(const QString &cflags, QStringList *incs, QStringList *otherflags)
2159 otherflags->clear();
2161 QStringList cflagsList = cflags.split(" ");
2162 for(int n = 0; n < cflagsList.count(); ++n)
2164 QString str = cflagsList[n];
2165 if(str.startsWith("-I"))
2167 // we want everything except the leading "-I"
2168 incs->append(str.remove(0, 2));
2172 // we want whatever is left
2173 otherflags->append(str);
2178 QString qc_escapeArg(const QString &str)
2181 for(int n = 0; n < (int)str.length(); ++n) {
2190 //----------------------------------------------------------------------------
2192 //----------------------------------------------------------------------------
2193 ConfObj::ConfObj(Conf *c)
2206 QString ConfObj::checkString() const
2208 return QString("Checking for %1 ...").arg(name());
2211 QString ConfObj::resultString() const
2219 //----------------------------------------------------------------------------
2220 // qc_internal_pkgconfig
2221 //----------------------------------------------------------------------------
2222 class qc_internal_pkgconfig : public ConfObj
2225 QString pkgname, desc;
2229 qc_internal_pkgconfig(Conf *c, const QString &_name, const QString &_desc, VersionMode _mode, const QString &_req_ver) : ConfObj(c)
2237 QString name() const { return desc; }
2238 QString shortname() const { return pkgname; }
2243 QString version, libs, other;
2244 if(!conf->findPkgConfig(pkgname, mode, req_ver, &version, &incs, &libs, &other))
2247 for(int n = 0; n < incs.count(); ++n)
2248 conf->addIncludePath(incs[n]);
2251 //if(!other.isEmpty())
2252 // conf->addExtra(QString("QMAKE_CFLAGS += %1\n").arg(other));
2257 //----------------------------------------------------------------------------
2259 //----------------------------------------------------------------------------
2262 // TODO: no more vars?
2263 //vars.insert("QMAKE_INCDIR_X11", new QString(X11_INC));
2264 //vars.insert("QMAKE_LIBDIR_X11", new QString(X11_LIBDIR));
2265 //vars.insert("QMAKE_LIBS_X11", new QString(X11_LIB));
2266 //vars.insert("QMAKE_CC", CC);
2268 debug_enabled = false;
2276 void Conf::added(ConfObj *o)
2281 QString Conf::getenv(const QString &var)
2283 return qc_getenv(var);
2286 void Conf::debug(const QString &s)
2292 first_debug = false;
2293 printf(" * %s\n", qPrintable(s));
2299 for(int n = 0; n < list.count(); ++n)
2301 ConfObj *o = list[n];
2303 // if this was a disabled-by-default option, check if it was enabled
2306 QString v = QString("QC_ENABLE_") + qc_escapeArg(o->shortname());
2307 if(getenv(v) != "Y")
2310 // and the opposite?
2313 QString v = QString("QC_DISABLE_") + qc_escapeArg(o->shortname());
2314 if(getenv(v) == "Y")
2319 QString check = o->checkString();
2325 printf("%s", check.toLatin1().data());
2330 bool ok = o->exec();
2335 QString result = o->resultString();
2337 printf(" -> %s\n", result.toLatin1().data());
2339 printf(" %s\n", result.toLatin1().data());
2342 if(!ok && o->required)
2344 printf("\nError: need %s!\n", o->name().toLatin1().data());
2351 QString Conf::qvar(const QString &s)
2353 return vars.value(s);
2356 QString Conf::expandIncludes(const QString &inc)
2358 return QString("-I") + inc;
2361 QString Conf::expandLibs(const QString &lib)
2363 return QString("-L") + lib;
2366 int Conf::doCommand(const QString &s, QByteArray *out)
2368 debug(QString("[%1]").arg(s));
2369 int r = qc_runcommand(s, out, debug_enabled);
2370 debug(QString("returned: %1").arg(r));
2374 int Conf::doCommand(const QString &prog, const QStringList &args, QByteArray *out)
2376 QString fullcmd = prog;
2377 QString argstr = args.join(" ");
2378 if(!argstr.isEmpty())
2379 fullcmd += QString(" ") + argstr;
2380 debug(QString("[%1]").arg(fullcmd));
2381 int r = qc_runprogram(prog, args, out, debug_enabled);
2382 debug(QString("returned: %1").arg(r));
2386 bool Conf::doCompileAndLink(const QString &filedata, const QStringList &incs, const QString &libs, const QString &proextra, int *retcode)
2389 QDir tmp("qconftemp");
2391 QDir tmp(".qconftemp");
2394 if(!tmp.mkdir("atest"))
2396 debug("unable to create atest dir");
2399 QDir dir(tmp.filePath("atest"));
2402 debug("atest dir does not exist");
2406 QString fname = dir.filePath("atest.cpp");
2407 QString out = "atest";
2409 if(!f.open(QFile::WriteOnly | QFile::Truncate))
2411 debug("unable to open atest.cpp for writing");
2414 if(f.write(filedata.toLatin1()) == -1)
2416 debug("error writing to atest.cpp");
2421 debug(QString("Wrote atest.cpp:\n%1").arg(filedata));
2423 QString pro = QString(
2424 "CONFIG += console\n"
2425 "CONFIG -= qt app_bundle\n"
2426 "DESTDIR = \$\$PWD\n"
2427 "SOURCES += atest.cpp\n");
2428 QString inc = incs.join(" ");
2430 pro += "INCLUDEPATH += " + inc + '\n';
2432 pro += "LIBS += " + libs + '\n';
2435 fname = dir.filePath("atest.pro");
2436 f.setFileName(fname);
2437 if(!f.open(QFile::WriteOnly | QFile::Truncate))
2439 debug("unable to open atest.pro for writing");
2442 if(f.write(pro.toLatin1()) == -1)
2444 debug("error writing to atest.pro");
2449 debug(QString("Wrote atest.pro:\n%1").arg(pro));
2451 QString oldpath = QDir::currentPath();
2452 QDir::setCurrent(dir.path());
2455 int r = doCommand(qmake_path, QStringList() << "atest.pro");
2458 r = doCommand(maketool, QStringList());
2464 QString runatest = out;
2466 runatest.prepend("./");
2468 *retcode = doCommand(runatest, QStringList());
2471 r = doCommand(maketool, QStringList() << "distclean");
2473 debug("error during atest distclean");
2476 QDir::setCurrent(oldpath);
2479 //dir.remove("atest.pro");
2480 //dir.remove("atest.cpp");
2481 //tmp.rmdir("atest");
2483 // remove whole dir since distclean doesn't always work
2484 qc_removedir(tmp.filePath("atest"));
2491 bool Conf::checkHeader(const QString &path, const QString &h)
2493 QFileInfo fi(path + '/' + h);
2499 bool Conf::findHeader(const QString &h, const QStringList &ext, QString *inc)
2501 if(checkHeader("/usr/include", h))
2507 dirs += "/usr/local/include";
2509 for(QStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it)
2511 if(checkHeader(*it, h))
2520 bool Conf::checkLibrary(const QString &path, const QString &name)
2523 //"#include <stdio.h>\n"
2526 //" printf(\"library checker running\\\\n\");\n"
2532 libs += QString("-L") + path + ' ';
2533 libs += QString("-l") + name;
2534 if(!doCompileAndLink(str, QStringList(), libs, QString()))
2539 bool Conf::findLibrary(const QString &name, QString *lib)
2541 if(checkLibrary("", name))
2546 if(checkLibrary("/usr/local/lib", name))
2548 *lib = "/usr/local/lib";
2554 QString Conf::findProgram(const QString &prog)
2556 return qc_findprogram(prog);
2559 bool Conf::findSimpleLibrary(const QString &incvar, const QString &libvar, const QString &incname, const QString &libname, QString *incpath, QString *libs)
2566 if(!checkHeader(s, incname))
2571 if(!findHeader(incname, QStringList(), &s))
2578 if(!checkLibrary(s, libname))
2583 if(!findLibrary(libname, &s))
2590 lib_out += QString("-L") + s;
2591 lib_out += QString("-l") + libname;
2598 bool Conf::findFooConfig(const QString &path, QString *version, QStringList *incs, QString *libs, QString *otherflags)
2604 args += "--version";
2605 ret = doCommand(path, args, &out);
2609 QString version_out = QString::fromLatin1(out).trimmed();
2613 ret = doCommand(path, args, &out);
2617 QString libs_out = QString::fromLatin1(out).trimmed();
2621 ret = doCommand(path, args, &out);
2625 QString cflags = QString::fromLatin1(out).trimmed();
2627 QStringList incs_out, otherflags_out;
2628 qc_splitcflags(cflags, &incs_out, &otherflags_out);
2630 *version = version_out;
2633 *otherflags = otherflags_out.join(" ");
2637 bool Conf::findPkgConfig(const QString &name, VersionMode mode, const QString &req_version, QString *version, QStringList *incs, QString *libs, QString *otherflags)
2645 ret = doCommand("pkg-config", args, &out);
2649 if(mode != VersionAny)
2653 if(mode == VersionMin)
2654 args += QString("--atleast-version=%1").arg(req_version);
2655 else if(mode == VersionMax)
2656 args += QString("--max-version=%1").arg(req_version);
2658 args += QString("--exact-version=%1").arg(req_version);
2659 ret = doCommand("pkg-config", args, &out);
2666 args += "--modversion";
2667 ret = doCommand("pkg-config", args, &out);
2671 QString version_out = QString::fromLatin1(out).trimmed();
2676 ret = doCommand("pkg-config", args, &out);
2680 QString libs_out = QString::fromLatin1(out).trimmed();
2685 ret = doCommand("pkg-config", args, &out);
2689 QString cflags = QString::fromLatin1(out).trimmed();
2691 QStringList incs_out, otherflags_out;
2692 qc_splitcflags(cflags, &incs_out, &otherflags_out);
2694 *version = version_out;
2697 *otherflags = otherflags_out.join(" ");
2701 void Conf::addDefine(const QString &str)
2703 if(DEFINES.isEmpty())
2706 DEFINES += QString(" ") + str;
2707 debug(QString("DEFINES += %1").arg(str));
2710 void Conf::addLib(const QString &str)
2715 LIBS += QString(" ") + str;
2716 debug(QString("LIBS += %1").arg(str));
2719 void Conf::addIncludePath(const QString &str)
2721 if(INCLUDEPATH.isEmpty())
2724 INCLUDEPATH += QString(" ") + str;
2725 debug(QString("INCLUDEPATH += %1").arg(str));
2728 void Conf::addExtra(const QString &str)
2730 extra += str + '\n';
2731 debug(QString("extra += %1").arg(str));
2734 //----------------------------------------------------------------------------
2736 //----------------------------------------------------------------------------
2737 #include "conf4.moc"
2740 # include"modules.cpp"
2745 Conf *conf = new Conf;
2749 # include"modules_new.cpp"
2752 conf->debug_enabled = (qc_getenv("QC_VERBOSE") == "Y") ? true: false;
2753 if(conf->debug_enabled)
2758 QString confCommand = qc_getenv("QC_COMMAND");
2759 QString proName = qc_getenv("QC_PROFILE");
2760 conf->qmake_path = qc_getenv("QC_QMAKE");
2761 conf->qmakespec = qc_getenv("QC_QMAKESPEC");
2762 conf->maketool = qc_getenv("QC_MAKETOOL");
2764 if(conf->debug_enabled)
2765 printf("conf command: [%s]\n", qPrintable(confCommand));
2767 QString confPath = qc_findself(confCommand);
2768 if(confPath.isEmpty())
2770 printf("Error: cannot find myself; rerun with an absolute path\n");
2774 QString srcdir = QFileInfo(confPath).absolutePath();
2775 QString builddir = QDir::current().absolutePath();
2776 QString proPath = QDir(srcdir).filePath(proName);
2778 if(conf->debug_enabled)
2780 printf("conf path: [%s]\n", qPrintable(confPath));
2781 printf("srcdir: [%s]\n", qPrintable(srcdir));
2782 printf("builddir: [%s]\n", qPrintable(builddir));
2783 printf("profile: [%s]\n", qPrintable(proPath));
2784 printf("qmake path: [%s]\n", qPrintable(conf->qmake_path));
2785 printf("qmakespec: [%s]\n", qPrintable(conf->qmakespec));
2786 printf("make tool: [%s]\n", qPrintable(conf->maketool));
2790 bool success = false;
2793 QFile f("conf.pri");
2794 if(!f.open(QFile::WriteOnly | QFile::Truncate))
2796 printf("Error writing %s\n", qPrintable(f.fileName()));
2801 str += "# qconf\n\n";
2804 var = qc_getenv("PREFIX");
2806 str += QString("PREFIX = %1\n").arg(var);
2807 var = qc_getenv("BINDIR");
2809 str += QString("BINDIR = %1\n").arg(var);
2810 var = qc_getenv("INCDIR");
2812 str += QString("INCDIR = %1\n").arg(var);
2813 var = qc_getenv("LIBDIR");
2815 str += QString("LIBDIR = %1\n").arg(var);
2816 var = qc_getenv("DATADIR");
2818 str += QString("DATADIR = %1\n").arg(var);
2821 if(qc_getenv("QC_STATIC") == "Y")
2822 str += "CONFIG += staticlib\n";
2824 // TODO: don't need this?
2825 //str += "QT_PATH_PLUGINS = " + QString(qInstallPathPlugins()) + '\n';
2827 if(!conf->DEFINES.isEmpty())
2828 str += "DEFINES += " + conf->DEFINES + '\n';
2829 if(!conf->INCLUDEPATH.isEmpty())
2830 str += "INCLUDEPATH += " + conf->INCLUDEPATH + '\n';
2831 if(!conf->LIBS.isEmpty())
2832 str += "LIBS += " + conf->LIBS + '\n';
2833 if(!conf->extra.isEmpty())
2837 QByteArray cs = str.toLatin1();
2842 QString qmake_path = conf->qmake_path;
2843 QString qmakespec = conf->qmakespec;
2849 // run qmake on the project file
2851 if(!qmakespec.isEmpty())
2857 int ret = qc_runprogram(qmake_path, args, 0, true);
2865 cat >$1/conf4.pro
<<EOT
2867 CONFIG -= app_bundle
2873 SOURCES += conf4.cpp
2876 DEFINES += HAVE_MODULES
2888 export QC_NO_SEPARATE_DEBUG_INFO
2889 export QC_SEPARATE_DEBUG_INFO
2890 export QC_CERTSTORE_PATH
2891 export QC_DISABLE_bundled_qca
2893 export QC_DISABLE_openssl
2894 export QC_WITH_OPENSSL_INC
2895 export QC_WITH_OPENSSL_LIB
2896 export QC_WITH_ZLIB_INC
2897 export QC_WITH_ZLIB_LIB
2898 export QC_ENABLE_universal
2899 export QC_DISABLE_qdbus
2900 export QC_DISABLE_growl
2901 export QC_WITH_GROWL
2902 export QC_ENABLE_whiteboarding
2903 export QC_DISABLE_xss
2904 export QC_DISABLE_aspell
2905 export QC_WITH_ASPELL_INC
2906 export QC_WITH_ASPELL_LIB
2907 export QC_DISABLE_enchant
2912 gen_files .qconftemp
2914 if [ ! -z "$qm_spec" ]; then
2915 $qm -spec $qm_spec conf4.pro
>/dev
/null
2917 $qm conf4.pro
>/dev
/null
2919 $MAKE clean
>/dev
/null
2>&1
2920 $MAKE >..
/conf.log
2>&1
2923 if [ "$?" != "0" ]; then
2925 if [ "$QC_VERBOSE" = "Y" ]; then
2931 printf "Reason: There was an error compiling 'conf'. See conf.log for details.\n"
2934 if [ "$QC_VERBOSE" = "Y" ]; then
2947 QC_QMAKESPEC
=$qm_spec
2953 if [ "$ret" = "1" ]; then
2958 if [ "$ret" != "0" ]; then
2960 if [ "$QC_VERBOSE" = "Y" ]; then
2966 echo "Reason: Unexpected error launching 'conf'"
2974 echo "Good, your configure finished. Now run $MAKE."