always off for muc roster's horizontal scrollbar
[psi.git] / configure
blob354ea5e54ffba1ef5058838bec4c1e3e6d9a56ad
1 #!/bin/sh
3 # Generated by qconf 1.5 ( http://delta.affinix.com/qconf/ )
6 show_usage() {
7 cat <<EOT
8 Usage: $0 [OPTION]...
10 This script creates necessary configuration files to build/install.
12 Main options:
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.
21 Project options:
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
29 (bundled QCA only)
31 Dependency options:
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
37 only)
38 --with-openssl-lib=[path] Path to OpenSSL library files (bundled QCA
39 only)
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
53 EOT
56 # which/make detection adapted from Qt
57 which_command() {
58 OLD_HOME=$HOME
59 HOME=/dev/null
60 export HOME
62 WHICH=`which which 2>/dev/null`
63 if echo $WHICH | grep 'shell built-in command' >/dev/null 2>&1; then
64 WHICH=which
65 elif [ -z "$WHICH" ]; then
66 if which which >/dev/null 2>&1; then
67 WHICH=which
68 else
69 for a in /usr/ucb /usr/bin /bin /usr/local/bin; do
70 if [ -x $a/which ]; then
71 WHICH=$a/which
72 break;
74 done
78 if [ -z "$WHICH" ]; then
79 OLD_IFS=$IFS
80 IFS=:
81 for a in $PATH; do
82 if [ -x $a/$1 ]; then
83 echo "$a/$1"
84 IFS=$OLD_IFS
85 export IFS
86 HOME=$OLD_HOME
87 export HOME
88 return 0
90 done
91 IFS=$OLD_IFS
92 export IFS
93 else
94 a=`"$WHICH" "$1" 2>/dev/null`
95 if [ ! -z "$a" -a -x "$a" ]; then
96 echo "$a"
97 HOME=$OLD_HOME
98 export HOME
99 return 0
102 HOME=$OLD_HOME
103 export HOME
104 return 1
106 WHICH=which_command
108 # find a make command
109 if [ -z "$MAKE" ]; then
110 MAKE=
111 for mk in gmake make; do
112 if $WHICH $mk >/dev/null 2>&1; then
113 MAKE=`$WHICH $mk`
114 break
116 done
117 if [ -z "$MAKE" ]; then
118 echo "You don't seem to have 'make' or 'gmake' in your PATH."
119 echo "Cannot proceed."
120 exit 1
124 show_qt_info() {
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"
128 printf "\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"
133 printf "\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"
138 printf "\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"
142 printf "\n"
145 while [ $# -gt 0 ]; do
146 optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
147 case "$1" in
148 --prefix=*)
149 PREFIX=$optarg
150 shift
153 --bindir=*)
154 BINDIR=$optarg
155 shift
158 --libdir=*)
159 LIBDIR=$optarg
160 shift
163 --datadir=*)
164 DATADIR=$optarg
165 shift
168 --qtdir=*)
169 EX_QTDIR=$optarg
170 shift
173 --release)
174 QC_RELEASE="Y"
175 shift
178 --debug)
179 QC_DEBUG="Y"
180 shift
183 --no-separate-debug-info)
184 QC_NO_SEPARATE_DEBUG_INFO="Y"
185 shift
188 --separate-debug-info)
189 QC_SEPARATE_DEBUG_INFO="Y"
190 shift
193 --certstore-path=*)
194 QC_CERTSTORE_PATH=$optarg
195 shift
198 --disable-bundled-qca)
199 QC_DISABLE_bundled_qca="Y"
200 shift
203 --with-qca=*)
204 QC_WITH_QCA=$optarg
205 shift
208 --disable-openssl)
209 QC_DISABLE_openssl="Y"
210 shift
213 --with-openssl-inc=*)
214 QC_WITH_OPENSSL_INC=$optarg
215 shift
218 --with-openssl-lib=*)
219 QC_WITH_OPENSSL_LIB=$optarg
220 shift
223 --with-zlib-inc=*)
224 QC_WITH_ZLIB_INC=$optarg
225 shift
228 --with-zlib-lib=*)
229 QC_WITH_ZLIB_LIB=$optarg
230 shift
233 --enable-universal)
234 QC_ENABLE_universal="Y"
235 shift
238 --disable-qdbus)
239 QC_DISABLE_qdbus="Y"
240 shift
243 --disable-growl)
244 QC_DISABLE_growl="Y"
245 shift
248 --with-growl=*)
249 QC_WITH_GROWL=$optarg
250 shift
253 --enable-whiteboarding)
254 QC_ENABLE_whiteboarding="Y"
255 shift
258 --disable-xss)
259 QC_DISABLE_xss="Y"
260 shift
263 --disable-aspell)
264 QC_DISABLE_aspell="Y"
265 shift
268 --with-aspell-inc=*)
269 QC_WITH_ASPELL_INC=$optarg
270 shift
273 --with-aspell-lib=*)
274 QC_WITH_ASPELL_LIB=$optarg
275 shift
278 --disable-enchant)
279 QC_DISABLE_enchant="Y"
280 shift
283 --verbose)
284 QC_VERBOSE="Y"
285 shift
287 --help) show_usage; exit ;;
288 *) show_usage; exit ;;
289 esac
290 done
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
300 echo
301 echo PREFIX=$PREFIX
302 echo BINDIR=$BINDIR
303 echo LIBDIR=$LIBDIR
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
328 echo
331 printf "Verifying Qt 4 build environment ... "
333 # run qmake -v and check version
334 qmake_check_v4() {
335 if [ -x "$1" ]; then
336 if echo `$1 -v 2>&1` | grep "Qt version 4\." >/dev/null 2>&1; then
337 return 0
338 elif [ "$QC_VERBOSE" = "Y" ]; then
339 echo "Warning: $1 not for Qt 4"
342 return 1
345 if [ "$QC_VERBOSE" = "Y" ]; then
346 echo
349 qm=""
350 names="qmake-qt4 qmake4 qmake"
352 # qt4 check: --qtdir
353 if [ -z "$qm" ] && [ ! -z "$EX_QTDIR" ]; then
354 for n in $names; do
355 qstr=$EX_QTDIR/bin/$n
356 if qmake_check_v4 "$qstr"; then
357 qm=$qstr
358 break;
360 done
362 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
363 echo "Warning: qmake not found via --qtdir"
366 # qt4 check: QTDIR
367 if [ -z "$qm" ] && [ ! -z "$QTDIR" ]; then
368 for n in $names; do
369 qstr=$QTDIR/bin/$n
370 if qmake_check_v4 "$qstr"; then
371 qm=$qstr
372 break;
374 done
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
384 for n in $names; do
385 qstr=$str/bin/$n
386 if qmake_check_v4 "$qstr"; then
387 qm=$qstr
388 break;
390 done
393 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
394 echo "Warning: qmake not found via pkg-config"
397 # qt4 check: PATH
398 if [ -z "$qm" ]; then
399 for n in $names; do
400 qstr=`$WHICH $n 2>/dev/null`
401 if qmake_check_v4 "$qstr"; then
402 qm=$qstr
403 break;
405 done
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
413 echo " -> fail"
414 else
415 echo "fail"
417 printf "\n"
418 printf "Reason: Unable to find the 'qmake' tool for Qt 4.\n"
419 printf "\n"
420 show_qt_info
421 exit 1;
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
445 qm_spec=""
446 # if the makespec is macx-xcode, force macx-g++
447 if [ "$defmakespec" = "macx-xcode" ]; then
448 qm_spec=macx-g++
449 QMAKESPEC=$qm_spec
450 export QMAKESPEC
451 if [ "$QC_VERBOSE" = "Y" ]; then
452 echo overriding makespec to $qm_spec
456 gen_files() {
457 cat >$1/modules.cpp <<EOT
458 #line 1 "qt4.qcm"
460 -----BEGIN QCMOD-----
461 name: Qt >= 4.4.0
462 -----END QCMOD-----
464 class qc_qt4 : public ConfObj
466 public:
467 qc_qt4(Conf *c) : ConfObj(c) {}
468 QString name() const { return "Qt >= 4.4.0"; }
469 QString shortname() const { return "qt4"; }
470 bool exec()
472 return(QT_VERSION >= 0x040400);
475 #line 1 "buildmodeapp.qcm"
477 -----BEGIN QCMOD-----
478 name: buildmodeapp
479 section: project
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).
484 -----END QCMOD-----
485 arg: debug-and-release,Build two versions, with and without debugging turned on (mac only).
488 #define QC_BUILDMODE
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
495 public:
496 qc_buildmodeapp(Conf *c) : ConfObj(c) {}
497 QString name() const { return "buildmodeapp"; }
498 QString shortname() const { return "buildmodeapp"; }
500 // no output
501 QString checkString() const { return QString(); }
503 bool exec()
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")
513 opt_release = true;
514 if(conf->getenv("QC_DEBUG") == "Y")
515 opt_debug = true;
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")
525 staticmode = true;
527 #ifndef Q_OS_MAC
528 if(opt_debug_and_release)
530 printf("\nError: The --debug-and-release option is for mac only.\n");
531 exit(1);
533 #endif
535 // sanity check exclusive options
536 int x;
538 // build mode
539 x = 0;
540 if(opt_release)
541 ++x;
542 if(opt_debug)
543 ++x;
544 if(opt_debug_and_release)
545 ++x;
546 if(x > 1)
548 printf("\nError: Use only one of --release, --debug, or --debug-and-release.\n");
549 exit(1);
552 // debug info
553 x = 0;
554 if(opt_no_separate_debug_info)
555 ++x;
556 if(opt_separate_debug_info)
557 ++x;
558 if(x > 1)
560 printf("\nError: Use only one of --separate-debug-info or --no-separate-debug-info\n");
561 exit(1);
564 // now process the options
566 if(opt_release)
567 qc_buildmode_release = true;
568 else if(opt_debug)
569 qc_buildmode_debug = true;
570 else if(opt_debug_and_release)
572 qc_buildmode_release = true;
573 qc_buildmode_debug = true;
575 else // default
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)
582 // nothing to do
584 else // default
586 #ifndef Q_OS_MAC
587 qc_buildmode_separate_debug_info = true;
588 #endif
591 // make the string
592 QStringList opts;
593 QString other;
595 if(qc_buildmode_release && qc_buildmode_debug)
597 opts += "debug_and_release";
598 opts += "build_all";
600 else if(qc_buildmode_release)
601 opts += "release";
602 else // qc_buildmode_debug
603 opts += "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';
613 conf->addExtra(str);
615 if(!other.isEmpty())
616 conf->addExtra(other);
618 return true;
621 #line 1 "bundled-qca.qcm"
623 -----BEGIN QCMOD-----
624 name: bundled QCA
625 -----END QCMOD-----
628 //----------------------------------------------------------------------------
629 // qc_bundled_qca
630 //----------------------------------------------------------------------------
631 class qc_bundled_qca : public ConfObj
633 public:
634 qc_bundled_qca(Conf *c) : ConfObj(c) {}
635 QString name() const { return "bundled QCA 2.0"; }
636 QString shortname() const { return "bundled_qca"; }
638 bool exec()
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");
644 #ifndef Q_OS_WIN
645 // HAVE_SYS_FILIO_H
646 QString str;
647 if(conf->findHeader("sys/filio.h", QStringList(), &str))
649 if(!str.isEmpty())
650 conf->addIncludePath(str);
651 conf->addDefine("HAVE_SYS_FILIO_H");
653 #endif
654 return true;
656 else {
657 return false;
661 #line 1 "qca.qcm"
663 -----BEGIN QCMOD-----
664 name: QCA >= 2.0
665 arg: with-qca=[path],Specify path to QCA tree, mainly for building against an uninstalled QCA.
666 -----END QCMOD-----
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(
673 "QCA_INCDIR = %1\n"
674 "QCA_LIBDIR = %2\n"
675 "\n"
676 "CONFIG *= qt\n"
677 "\n"
678 "LINKAGE =\n"
679 "\n"
680 "# on mac, if qca was built as a framework, link against it\n"
681 "mac: {\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"
688 " }\n"
689 "}\n"
690 "\n"
691 "# else, link normally\n"
692 "isEmpty(LINKAGE) {\n"
693 " INCLUDEPATH += \$\$QCA_INCDIR/QtCrypto\n"
694 " LIBS += -L\$\$QCA_LIBDIR\n"
695 " LINKAGE = -lqca\n"
696 " CONFIG(debug, debug|release) {\n"
697 " windows:LINKAGE = -lqcad\n"
698 " mac:LINKAGE = -lqca_debug\n"
699 " }\n"
700 "}\n"
701 "\n"
702 "LIBS += \$\$LINKAGE\n"
703 ).arg(incdir, libdir);
704 return out;
707 //----------------------------------------------------------------------------
708 // qc_qca
709 //----------------------------------------------------------------------------
710 class qc_qca : public ConfObj
712 public:
713 qc_qca(Conf *c) : ConfObj(c) {}
714 QString name() const { return "QCA >= 2.0"; }
715 QString shortname() const { return "qca"; }
717 // BEGIN PSI
718 QString checkString() const
720 if(QFile::exists("third-party/qca/qca") && conf->getenv("QC_DISABLE_bundled_qca").isEmpty())
721 return "";
722 else
723 return ConfObj::checkString();
725 // END PSI
727 bool exec()
729 // BEGIN PSI
730 // Check if we have a bundled version
731 if(QFile::exists("third-party/qca/qca") && conf->getenv("QC_DISABLE_bundled_qca").isEmpty())
732 return true;
733 // END PSI
735 // get the build mode
736 #ifdef QC_BUILDMODE
737 bool release = qc_buildmode_release;
738 bool debug = qc_buildmode_debug;
739 #else
740 // else, default to just release mode
741 bool release = true;
742 bool debug = false;
743 #endif
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");
749 QString proextra;
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);
754 proextra =
755 "CONFIG += qt\n"
756 "QT -= gui\n";
757 proextra += qca_crypto_prf;
758 } else {
759 proextra =
760 "CONFIG += qt crypto\n"
761 "QT -= gui\n";
764 QString str =
765 "#include <QtCrypto>\n"
766 "\n"
767 "int main()\n"
768 "{\n"
769 " unsigned long x = QCA_VERSION;\n"
770 " if(x >= 0x020000 && x < 0x030000) return 0; else return 1;\n"
771 "}\n";
773 if(release)
775 int ret;
776 if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra + "CONFIG += release\n", &ret))
777 return false;
778 if(ret != 0)
779 return false;
782 if(debug)
784 int ret;
785 if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra + "CONFIG += debug\n", &ret))
786 return false;
787 if(ret != 0)
788 return false;
791 if(!qca_prefix.isEmpty())
792 conf->addExtra(qca_crypto_prf);
793 else
794 conf->addExtra("CONFIG += crypto\n");
796 return true;
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)
805 -----END QCMOD-----
807 class qc_openssl : public ConfObj
809 public:
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())
816 return "";
817 else
818 return ConfObj::checkString();
821 bool exec()
823 if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty() || !QFile::exists("third-party/qca/qca-ossl"))
824 return false;
826 #ifdef Q_OS_WIN
827 QString ossl_inc = conf->getenv("QC_WITH_OPENSSL_INC");
828 if(ossl_inc.isEmpty())
829 return false;
831 QString ossl_lib = conf->getenv("QC_WITH_OPENSSL_LIB");
832 if(ossl_lib.isEmpty())
833 return false;
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)
845 QString str =
846 "#include<openssl/opensslv.h>\n"
847 "int main()\n"
848 "{\n"
849 " unsigned long x = OPENSSL_VERSION_NUMBER;\n"
850 " if(x >= 0x00907000) return 0; else return 1;\n"
851 "}\n";
852 QString ext;
853 QStringList incs;
854 incs += ossl_inc;
855 ext += QString("-L") + ossl_lib + " " + libname;
856 int ret;
857 if(conf->doCompileAndLink(str, incs, ext, QString(), &ret))
859 success = true;
860 libname_success = libname;
861 if(ret == 0)
862 conf->addDefine("OSSL_097");
863 break;
867 if(!success)
868 return false;
870 conf->addIncludePath(ossl_inc);
871 conf->addLib(QString("-L") + ossl_lib);
872 conf->addLib(libname_success);
874 conf->addDefine("HAVE_OPENSSL");
876 return true;
877 #else
878 QString inc, lib;
879 QString s;
880 bool kb = false;
881 QString kbdir = "/usr/kerberos/include";
883 // Redhat 9?
884 if(QFileInfo(kbdir).exists())
885 kb = true;
887 s = conf->getenv("QC_WITH_OPENSSL_INC");
888 if(!s.isEmpty()) {
889 if(!conf->checkHeader(s, "openssl/ssl.h"))
890 return false;
891 inc = s;
893 else {
894 if(!conf->findHeader("openssl/ssl.h", QStringList(), &s))
895 return false;
896 inc = s;
899 s = conf->getenv("QC_WITH_OPENSSL_LIB");
900 if(!s.isEmpty()) {
901 if(!conf->checkLibrary(s, "ssl"))
902 return false;
903 lib = s;
905 else {
906 if(!conf->findLibrary("ssl", &s))
907 return false;
908 lib = s;
911 // is it at least openssl 0.9.7?
912 QString str =
913 "#include<openssl/opensslv.h>\n"
914 "int main()\n"
915 "{\n"
916 " unsigned long x = OPENSSL_VERSION_NUMBER;\n"
917 " if(x >= 0x00907000) return 0; else return 1;\n"
918 "}\n";
919 QString ext;
920 QStringList incs;
921 if(!inc.isEmpty())
922 incs += inc;
923 if(kb)
924 incs += kbdir;
925 if(!lib.isEmpty())
926 ext += QString("-L") + lib + " -lssl -lcrypto ";
927 int ret;
928 if(!conf->doCompileAndLink(str, incs, ext, QString(), &ret))
929 return false;
930 if(ret == 0)
931 conf->addDefine("OSSL_097");
933 if(!inc.isEmpty())
934 conf->addIncludePath(inc);
935 if(kb)
936 conf->addIncludePath(kbdir);
937 if(!lib.isEmpty())
938 conf->addLib(QString("-L") + s);
939 conf->addLib("-lssl -lcrypto");
941 conf->addDefine("HAVE_OPENSSL");
943 return true;
944 #endif
947 #line 1 "zlib.qcm"
949 -----BEGIN QCMOD-----
950 name: zlib
951 arg: with-zlib-inc=[path],Path to zlib include files
952 arg: with-zlib-lib=[path],Path to zlib library files
953 -----END QCMOD-----
956 //----------------------------------------------------------------------------
957 // qc_zlib
958 //----------------------------------------------------------------------------
959 class qc_zlib : public ConfObj
961 public:
962 qc_zlib(Conf *c) : ConfObj(c) {}
963 QString name() const { return "zlib"; }
964 QString shortname() const { return "zlib"; }
965 #ifdef Q_OS_WIN
966 QString resultString() const
968 return "using bundled";
970 #endif
972 bool exec()
974 #ifdef Q_OS_WIN
975 // HACK: on windows, always use psi's bundled zlib
976 conf->addExtra("CONFIG += psi-winzlib psi-minizip");
977 return true;
978 #else
979 QStringList incs;
980 QString version, libs, other;
981 QString s;
983 if(!conf->findPkgConfig("zlib", VersionAny, "", &version, &incs, &libs, &other)) {
985 s = conf->getenv("QC_WITH_ZLIB_INC");
986 if(!s.isEmpty()) {
987 if(!conf->checkHeader(s, "zlib.h"))
988 return false;
990 else {
991 if(!conf->findHeader("zlib.h", QStringList(), &s))
992 return false;
994 incs.append(s);
996 s = conf->getenv("QC_WITH_ZLIB_LIB");
997 if(!s.isEmpty()) {
998 if(!conf->checkLibrary(s, "z"))
999 return false;
1001 else {
1002 if(!conf->findLibrary("z", &s))
1003 return false;
1005 libs = QString("-L%1 -lz").arg(s);
1008 foreach(const QString &inc, incs) {
1009 conf->addIncludePath(inc);
1011 conf->addLib(libs);
1013 incs.clear();
1014 libs.clear();
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))) {
1020 incs.append(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);
1034 conf->addLib(libs);
1035 } else {
1036 conf->addExtra("CONFIG += psi-minizip");
1039 return true;
1040 #endif
1043 #line 1 "x11.qcm"
1045 -----BEGIN QCMOD-----
1046 name: Xorg X11
1047 -----END QCMOD-----
1050 //----------------------------------------------------------------------------
1051 // qc_x11
1052 //----------------------------------------------------------------------------
1053 class qc_x11 : public ConfObj
1055 public:
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(); }
1062 bool exec()
1064 QString str =
1065 "int main()\n"
1066 "{\n"
1067 " return 0;\n"
1068 "}\n";
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
1078 -----END QCMOD-----
1081 //----------------------------------------------------------------------------
1082 // qc_universal
1083 //----------------------------------------------------------------------------
1084 class qc_universal : public ConfObj
1086 public:
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(); }
1092 bool exec()
1094 #ifdef Q_WS_MAC
1095 conf->addExtra("CONFIG += qc_universal");
1096 #endif
1097 return true;
1100 #line 1 "certstore.qcm"
1102 -----BEGIN QCMOD-----
1103 name: certstore
1104 section: project
1105 arg: certstore-path=[path],Path to the SSL/X509 Certificate store file (bundled QCA only)
1106 -----END QCMOD-----
1109 class qc_certstore : public ConfObj
1111 public:
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())
1118 return "";
1119 else
1120 return ConfObj::checkString();
1123 bool exec()
1125 if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty() || !QFile::exists("third-party/qca/qca-ossl")) {
1126 return true;
1129 bundled = false;
1131 #if defined(Q_OS_WIN) || defined(Q_OS_MAC)
1132 // use built-in
1133 return true;
1134 #else
1135 QStringList pathsToTry;
1137 path = conf->getenv("QC_CERTSTORE_PATH");
1138 if(!path.isEmpty())
1140 if(QFile::exists(path))
1142 QString certPathString =
1143 "QCA_SYSTEMSTORE_PATH=\\\\\\\\\\\\\"" + path + "\\\\\\\\\\\\\"";
1144 conf->addDefine(certPathString);
1145 return true;
1147 return false;
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];
1165 break;
1169 // fall back to bundled
1170 if(path.isEmpty())
1172 // --prefix=\$pwd ?
1173 if(QFile::exists(conf->getenv("PREFIX") + "/certs/rootcerts.pem"))
1174 path = "\$\$PREFIX/certs/rootcerts.pem";
1175 else
1176 path = "\$\$DATADIR/psi/certs/rootcerts.pem";
1178 QString extra =
1179 "qcasharedfiles.path = \$\$DATADIR/psi\n"
1180 "qcasharedfiles.files = third-party/qca/qca/certs\n"
1181 "INSTALLS += qcasharedfiles\n";
1182 conf->addExtra(extra);
1183 bundled = true;
1186 // Qt<4.2 workaround
1187 QString certPathString =
1188 "QCA_SYSTEMSTORE_PATH=\\\\\\\\\\\\\"" + path + "\\\\\\\\\\\\\"";
1189 conf->addDefine(certPathString);
1191 return true;
1192 #endif
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";
1201 #else
1202 if(success)
1204 if(bundled)
1205 return "using bundled";
1206 else
1207 return path;
1209 else
1210 return ConfObj::resultString();
1211 #endif
1214 private:
1215 QString path;
1216 bool bundled;
1218 #line 1 "qdbus.qcm"
1220 -----BEGIN QCMOD-----
1221 name: QDBUS
1222 -----END QCMOD-----
1225 //----------------------------------------------------------------------------
1226 // qc_qdbus
1227 //----------------------------------------------------------------------------
1228 class qc_qdbus : public ConfObj
1230 public:
1231 qc_qdbus(Conf *c) : ConfObj(c) {}
1232 QString name() const { return "QDBUS"; }
1233 QString shortname() const { return "qdbus"; }
1234 bool exec()
1236 if (!conf->getenv("QC_DISABLE_qdbus").isEmpty())
1237 return false;
1239 // test for "qdbus" feature
1241 QString proextra =
1242 "CONFIG += qt qdbus\n"
1243 "QT -= gui\n";
1245 QString str =
1246 "\n"
1247 "int main()\n"
1248 "{\n"
1249 " return 0;\n"
1250 "}\n";
1252 int ret;
1253 if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra, &ret))
1254 return false;
1255 if(ret != 0)
1256 return false;
1258 conf->addExtra("CONFIG += dbus");
1259 return true;
1262 #line 1 "growl.qcm"
1264 -----BEGIN QCMOD-----
1265 name: Growl
1266 arg: with-growl=[path],Path to the Growl framework
1267 -----END QCMOD-----
1270 //----------------------------------------------------------------------------
1271 // qc_growl
1272 //----------------------------------------------------------------------------
1273 class qc_growl : public ConfObj
1275 public:
1276 qc_growl(Conf *c) : ConfObj(c) {}
1277 QString name() const { return "Growl"; }
1278 QString shortname() const { return "growl"; }
1279 #ifndef Q_OS_MAC
1280 QString checkString() const { return QString(); }
1281 #endif
1283 // TODO: This should go into ConfObj
1284 bool checkFramework(const QString &path, const QString &name)
1286 QString str =
1287 "int main()\n"
1288 "{\n"
1289 " return 0;\n"
1290 "}\n";
1292 QString extra;
1293 if(!path.isEmpty())
1294 extra += QString("-F") + path + ' ';
1295 extra += QString("-framework ") + name;
1296 if(!conf->doCompileAndLink(str, QStringList(), extra, "", NULL))
1297 return false;
1298 return true;
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);
1308 bool exec()
1310 #ifdef Q_OS_MAC
1311 QString growl_path = conf->getenv("QC_WITH_GROWL");
1312 if(!checkFramework(growl_path, "Growl"))
1313 return false;
1315 if(!growl_path.isEmpty())
1316 addFrameworkPath(growl_path);
1317 conf->addLib("-framework Growl");
1318 conf->addDefine("HAVE_GROWL");
1320 return true;
1321 #else
1322 return false;
1323 #endif
1326 #line 1 "whiteboarding.qcm"
1328 -----BEGIN QCMOD-----
1329 name: White Board support
1330 -----END QCMOD-----
1333 //----------------------------------------------------------------------------
1334 // qc_whiteboarding
1335 //----------------------------------------------------------------------------
1336 class qc_whiteboarding : public ConfObj
1338 public:
1339 qc_whiteboarding(Conf *c) : ConfObj(c) {}
1340 QString name() const { return "White Board support"; }
1341 QString shortname() const { return "whiteboarding"; }
1342 bool exec()
1344 conf->addDefine("WHITEBOARDING");
1346 // Finish
1347 conf->addExtra("CONFIG += whiteboarding");
1349 qWarning("");
1350 qWarning("");
1351 qWarning(" !!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!");
1352 qWarning(" WHITEBOARDING SUPPORT IS STILL UNFINISHED !!!");
1353 qWarning(" USE AT YOUR OWN RISK !!!");
1355 return true;
1358 #line 1 "xss.qcm"
1360 -----BEGIN QCMOD-----
1361 name: the XScreenSaver extension
1362 -----END QCMOD-----
1365 //----------------------------------------------------------------------------
1366 // qc_xss
1367 //----------------------------------------------------------------------------
1368 class qc_xss : public ConfObj
1370 public:
1371 qc_xss(Conf *c) : ConfObj(c) {}
1373 QString name() const { return "the XScreenSaver extension"; }
1374 QString shortname() const { return "xss"; }
1375 #ifdef Q_OS_WIN
1376 QString checkString() const { return QString(); }
1377 #endif
1379 bool exec()
1381 #ifdef Q_OS_WIN
1382 // skip XSS support on windows
1383 return false;
1384 #else
1385 QString str =
1386 "#include<X11/Xlib.h>\n"
1387 "#include<X11/Xutil.h>\n"
1388 "#include<X11/extensions/scrnsaver.h>\n"
1389 "\n"
1390 "int main()\n"
1391 "{\n"
1392 " XScreenSaverQueryExtension(NULL, NULL, NULL);\n"
1393 " return 0;\n"
1394 "}\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)) {
1399 return false;
1402 else {
1403 conf->addLib("-lXss");
1406 conf->addDefine("HAVE_XSS");
1407 return true;
1408 #endif
1411 #line 1 "aspell.qcm"
1413 -----BEGIN QCMOD-----
1414 name: aspell
1415 arg: with-aspell-inc=[path],Path to Aspell include files
1416 arg: with-aspell-lib=[path],Path to Aspell library files
1417 -----END QCMOD-----
1420 #define QC_ASPELL
1421 bool qc_aspell_have = false;
1422 QStringList qc_aspell_defs;
1423 QStringList qc_aspell_incs;
1424 QStringList qc_aspell_libs;
1426 //----------------------------------------------------------------------------
1427 // qc_aspell
1428 //----------------------------------------------------------------------------
1429 class qc_aspell : public ConfObj
1431 public:
1432 qc_aspell(Conf *c) : ConfObj(c) {}
1433 QString name() const { return "aspell"; }
1434 QString shortname() const { return "aspell"; }
1436 // no output
1437 QString checkString() const { return QString(); }
1439 bool exec()
1441 // on mac, always use built-in spell check
1442 #ifdef Q_OS_MAC
1443 return false;
1444 #else
1445 qc_aspell_have = false;
1446 qc_aspell_defs.clear();
1447 qc_aspell_incs.clear();
1448 qc_aspell_libs.clear();
1450 QString s;
1452 #ifdef Q_OS_WIN
1453 s = conf->getenv("QC_WITH_ASPELL_INC");
1454 if(!s.isEmpty()) {
1455 if(!conf->checkHeader(s, "aspell.h")) {
1456 conf->debug("Aspell includes not found!");
1457 return false;
1459 qc_aspell_incs += s;
1461 else
1462 return false;
1464 QString a_lib = conf->getenv("QC_WITH_ASPELL_LIB");
1465 if(a_lib.isEmpty())
1466 return false;
1468 QStringList libnames;
1469 libnames += "aspell-15";
1470 libnames += "aspell";
1472 bool success;
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)) {
1477 success = true;
1478 libname_success = libname;
1479 break;
1483 if(!success)
1484 return false;
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;
1490 #else
1491 s = conf->getenv("QC_WITH_ASPELL_INC");
1492 if(!s.isEmpty()) {
1493 if(!conf->checkHeader(s, "aspell.h")) {
1494 conf->debug("Aspell includes not found!");
1495 return false;
1497 qc_aspell_incs += s;
1499 else {
1500 QStringList sl;
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!");
1506 return false;
1508 qc_aspell_incs += s;
1511 s = conf->getenv("QC_WITH_ASPELL_LIB");
1512 if(!s.isEmpty()) {
1513 if(!conf->checkLibrary(s, "aspell")) {
1514 conf->debug("Aspell libraries not found!");
1515 return false;
1517 qc_aspell_libs += QString("-L") + s;
1519 else {
1520 if(!conf->findLibrary("aspell", &s)) {
1521 conf->debug("Aspell libraries not found!");
1522 return false;
1524 if (!s.isEmpty())
1525 qc_aspell_libs += QString("-L") + s;
1528 qc_aspell_defs += "HAVE_ASPELL";
1529 qc_aspell_libs += "-laspell";
1530 qc_aspell_have = true;
1531 #endif
1533 return true;
1534 #endif
1537 #line 1 "enchant.qcm"
1539 -----BEGIN QCMOD-----
1540 name: enchant
1541 -----END QCMOD-----
1544 #define QC_ENCHANT
1545 bool qc_enchant_have = false;
1546 QStringList qc_enchant_defs;
1547 QStringList qc_enchant_incs;
1548 QStringList qc_enchant_libs;
1550 //----------------------------------------------------------------------------
1551 // qc_enchant
1552 //----------------------------------------------------------------------------
1553 class qc_enchant : public ConfObj
1555 public:
1556 qc_enchant(Conf *c) : ConfObj(c) {}
1557 QString name() const { return "enchant"; }
1558 QString shortname() const { return "enchant"; }
1560 // no output
1561 QString checkString() const { return QString(); }
1563 bool exec()
1565 // on mac, always use built-in spell check
1566 #ifdef Q_OS_MAC
1567 return false;
1568 #endif
1570 qc_enchant_have = false;
1571 qc_enchant_defs.clear();
1572 qc_enchant_incs.clear();
1573 qc_enchant_libs.clear();
1575 QStringList incs;
1576 QString version, libs, other;
1577 if(!conf->findPkgConfig("enchant", VersionMin, "1.3.0", &version, &incs, &libs, &other))
1578 return false;
1580 qc_enchant_defs += "HAVE_ENCHANT";
1581 qc_enchant_incs += incs;
1582 qc_enchant_libs += libs;
1583 qc_enchant_have = true;
1585 return true;
1588 #line 1 "spell.qcm"
1590 -----BEGIN QCMOD-----
1591 name: spellcheck engine
1592 -----END QCMOD-----
1595 //----------------------------------------------------------------------------
1596 // qc_spell
1597 //----------------------------------------------------------------------------
1598 class qc_spell : public ConfObj
1600 public:
1601 QString engine;
1603 qc_spell(Conf *c) : ConfObj(c) {}
1604 QString name() const { return "spellcheck engine"; }
1605 QString shortname() const { return "spell"; }
1607 bool exec()
1609 // on mac, always use built-in spell check
1610 #ifdef Q_OS_MAC
1611 engine = "using Mac built-in";
1612 return true;
1613 #endif
1615 bool have = false;
1616 QStringList defs, incs, libs;
1618 #ifdef QC_ENCHANT
1619 if(!have && qc_enchant_have)
1621 defs = qc_enchant_defs;
1622 incs = qc_enchant_incs;
1623 libs = qc_enchant_libs;
1624 engine = "enchant";
1625 have = true;
1627 #endif
1628 #ifdef QC_ASPELL
1629 if(!have && qc_aspell_have)
1631 defs = qc_aspell_defs;
1632 incs = qc_aspell_incs;
1633 libs = qc_aspell_libs;
1634 engine = "aspell";
1635 have = true;
1637 #endif
1639 if(!have)
1640 return true;
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]);
1649 return true;
1652 QString resultString() const
1654 if(!engine.isEmpty())
1655 return engine;
1656 else
1657 return "no";
1660 #line 1 "conf.qcm"
1662 -----BEGIN QCMOD-----
1663 name: Psi Configuration
1664 -----END QCMOD-----
1667 //----------------------------------------------------------------------------
1668 // qc_conf
1669 //----------------------------------------------------------------------------
1670 class qc_conf : public ConfObj
1672 public:
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(); }
1677 bool exec()
1679 #ifdef Q_OS_WIN
1680 return true;
1681 #else
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");
1694 return true;
1695 #endif
1698 #line 1 "recursiveprl.qcm"
1700 -----BEGIN QCMOD-----
1701 name: Generate .prl files
1702 -----END QCMOD-----
1705 //----------------------------------------------------------------------------
1706 // qc_recursiveprl
1707 //----------------------------------------------------------------------------
1708 class qc_recursiveprl : public ConfObj
1710 public:
1711 bool success;
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
1724 if(success)
1725 return "ok";
1726 else
1727 return "fail";
1730 bool exec()
1732 success = true;
1734 if(!writeConf())
1736 success = false;
1737 return false;
1740 QStringList args;
1741 args += "-prl";
1742 args += "-r";
1743 args += qc_getenv("QC_PROFILE");
1744 if(conf->doCommand(conf->qmake_path, args) != 0)
1746 success = false;
1747 return false;
1750 return true;
1753 bool writeConf()
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
1757 // to copy code
1758 QFile f("conf.pri");
1759 if(!f.open(QFile::WriteOnly | QFile::Truncate))
1761 conf->debug(QString("Error writing %1").arg(f.fileName()));
1762 return false;
1765 QString str;
1766 str += "# qconf\n\n";
1768 QString var;
1769 var = qc_getenv("PREFIX");
1770 if(!var.isEmpty())
1771 str += QString("PREFIX = %1\n").arg(var);
1772 var = qc_getenv("BINDIR");
1773 if(!var.isEmpty())
1774 str += QString("BINDIR = %1\n").arg(var);
1775 var = qc_getenv("INCDIR");
1776 if(!var.isEmpty())
1777 str += QString("INCDIR = %1\n").arg(var);
1778 var = qc_getenv("LIBDIR");
1779 if(!var.isEmpty())
1780 str += QString("LIBDIR = %1\n").arg(var);
1781 var = qc_getenv("DATADIR");
1782 if(!var.isEmpty())
1783 str += QString("DATADIR = %1\n").arg(var);
1784 str += '\n';
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())
1796 str += conf->extra;
1797 str += '\n';
1799 QByteArray cs = str.toLatin1();
1800 f.write(cs);
1801 f.close();
1803 return true;
1808 cat >$1/modules_new.cpp <<EOT
1809 o = new qc_qt4(conf);
1810 o->required = true;
1811 o->disabled = false;
1812 o = new qc_buildmodeapp(conf);
1813 o->required = true;
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);
1819 o->required = true;
1820 o->disabled = false;
1821 o = new qc_openssl(conf);
1822 o->required = false;
1823 o->disabled = false;
1824 o = new qc_zlib(conf);
1825 o->required = true;
1826 o->disabled = false;
1827 o = new qc_x11(conf);
1828 o->required = true;
1829 o->disabled = false;
1830 o = new qc_universal(conf);
1831 o->required = false;
1832 o->disabled = true;
1833 o = new qc_certstore(conf);
1834 o->required = true;
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;
1844 o->disabled = true;
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);
1855 o->required = true;
1856 o->disabled = false;
1857 o = new qc_conf(conf);
1858 o->required = true;
1859 o->disabled = false;
1860 o = new qc_recursiveprl(conf);
1861 o->required = true;
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
1871 preserved.
1874 #ifndef QC_CONF4_H
1875 #define QC_CONF4_H
1877 #include <QtCore>
1879 class Conf;
1881 enum VersionMode { VersionMin, VersionExact, VersionMax, VersionAny };
1883 // ConfObj
1885 // Subclass ConfObj to create a new configuration module.
1886 class ConfObj
1888 public:
1889 Conf *conf;
1890 bool required;
1891 bool disabled;
1892 bool success;
1894 ConfObj(Conf *c);
1895 virtual ~ConfObj();
1897 // long or descriptive name of what is being checked/performed
1898 // example: "KDE >= 3.3"
1899 virtual QString name() const = 0;
1901 // short name
1902 // example: "kde"
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;
1917 // Conf
1919 // Interact with this class from your ConfObj to perform detection
1920 // operations and to output configuration parameters.
1921 class Conf
1923 public:
1924 bool debug_enabled;
1925 QString qmake_path;
1926 QString qmakespec;
1927 QString maketool;
1929 QString DEFINES;
1930 QString INCLUDEPATH;
1931 QString LIBS;
1932 QString extra;
1934 QList<ConfObj*> list;
1935 QMap<QString,QString> vars;
1937 Conf();
1938 ~Conf();
1940 QString getenv(const QString &var);
1941 QString qvar(const QString &s);
1943 bool exec();
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);
1968 private:
1969 bool first_debug;
1971 friend class ConfObj;
1972 void added(ConfObj *o);
1975 #endif
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
1984 preserved.
1987 #include "conf4.h"
1989 #include <stdio.h>
1990 #include <stdlib.h>
1992 class MocTestObject : public QObject
1994 Q_OBJECT
1995 public:
1996 MocTestObject() {}
1999 QString qc_getenv(const QString &var)
2001 char *p = ::getenv(var.toLatin1().data());
2002 if(!p)
2003 return QString();
2004 return QString(p);
2007 QStringList qc_pathlist()
2009 QStringList list;
2010 QString path = qc_getenv("PATH");
2011 if(!path.isEmpty())
2013 #ifdef Q_OS_WIN
2014 list = path.split(';', QString::SkipEmptyParts);
2015 #else
2016 list = path.split(':', QString::SkipEmptyParts);
2017 #endif
2019 #ifdef Q_OS_WIN
2020 list.prepend(".");
2021 #endif
2022 return list;
2025 QString qc_findprogram(const QString &prog)
2027 QString out;
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();
2035 break;
2038 #ifdef Q_OS_WIN
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();
2046 break;
2049 #endif
2051 return out;
2054 QString qc_findself(const QString &argv0)
2056 #ifdef Q_OS_WIN
2057 if(argv0.contains('\\\\'))
2058 #else
2059 if(argv0.contains('/'))
2060 #endif
2061 return argv0;
2062 else
2063 return qc_findprogram(argv0);
2066 int qc_runcommand(const QString &command, QByteArray *out, bool showOutput)
2068 QString fullcmd = command;
2069 if(!showOutput)
2071 #ifdef Q_OS_WIN
2072 fullcmd += " 2>NUL";
2073 #else
2074 fullcmd += " 2>/dev/null";
2075 #endif
2078 #ifdef Q_OS_WIN
2079 FILE *f = _popen(fullcmd.toLatin1().data(), "r");
2080 #else
2081 FILE *f = popen(fullcmd.toLatin1().data(), "r");
2082 #endif
2083 if(!f)
2084 return -1;
2085 if(out)
2086 out->clear();
2087 while(1)
2089 char c = (char)fgetc(f);
2090 if(feof(f))
2091 break;
2092 if(out)
2093 out->append(c);
2094 if(showOutput)
2095 fputc(c, stdout);
2097 #ifdef Q_OS_WIN
2098 int ret = _pclose(f);
2099 #else
2100 int ret = pclose(f);
2101 #endif
2102 if(ret == -1)
2103 return -1;
2104 return ret;
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
2117 QProcess process;
2118 if(showOutput)
2119 process.setReadChannelMode(ForwardedChannels);
2120 process.start(prog, args);
2121 process.waitForFinished(-1);
2122 return process.exitCode();
2126 bool qc_removedir(const QString &dirPath)
2128 QDir dir(dirPath);
2129 if(!dir.exists())
2130 return false;
2131 QStringList list = dir.entryList();
2132 foreach(QString s, list)
2134 if(s == "." || s == "..")
2135 continue;
2136 QFileInfo fi(dir.filePath(s));
2137 if(fi.isDir())
2139 if(!qc_removedir(fi.filePath()))
2140 return false;
2142 else
2144 if(!dir.remove(s))
2145 return false;
2148 QString dirName = dir.dirName();
2149 if(!dir.cdUp())
2150 return false;
2151 if(!dir.rmdir(dirName))
2152 return false;
2153 return true;
2156 void qc_splitcflags(const QString &cflags, QStringList *incs, QStringList *otherflags)
2158 incs->clear();
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));
2170 else
2172 // we want whatever is left
2173 otherflags->append(str);
2178 QString qc_escapeArg(const QString &str)
2180 QString out;
2181 for(int n = 0; n < (int)str.length(); ++n) {
2182 if(str[n] == '-')
2183 out += '_';
2184 else
2185 out += str[n];
2187 return out;
2190 //----------------------------------------------------------------------------
2191 // ConfObj
2192 //----------------------------------------------------------------------------
2193 ConfObj::ConfObj(Conf *c)
2195 conf = c;
2196 conf->added(this);
2197 required = false;
2198 disabled = false;
2199 success = false;
2202 ConfObj::~ConfObj()
2206 QString ConfObj::checkString() const
2208 return QString("Checking for %1 ...").arg(name());
2211 QString ConfObj::resultString() const
2213 if(success)
2214 return "yes";
2215 else
2216 return "no";
2219 //----------------------------------------------------------------------------
2220 // qc_internal_pkgconfig
2221 //----------------------------------------------------------------------------
2222 class qc_internal_pkgconfig : public ConfObj
2224 public:
2225 QString pkgname, desc;
2226 VersionMode mode;
2227 QString req_ver;
2229 qc_internal_pkgconfig(Conf *c, const QString &_name, const QString &_desc, VersionMode _mode, const QString &_req_ver) : ConfObj(c)
2231 pkgname = _name;
2232 desc = _desc;
2233 mode = _mode;
2234 req_ver = _req_ver;
2237 QString name() const { return desc; }
2238 QString shortname() const { return pkgname; }
2240 bool exec()
2242 QStringList incs;
2243 QString version, libs, other;
2244 if(!conf->findPkgConfig(pkgname, mode, req_ver, &version, &incs, &libs, &other))
2245 return false;
2247 for(int n = 0; n < incs.count(); ++n)
2248 conf->addIncludePath(incs[n]);
2249 if(!libs.isEmpty())
2250 conf->addLib(libs);
2251 //if(!other.isEmpty())
2252 // conf->addExtra(QString("QMAKE_CFLAGS += %1\n").arg(other));
2253 return true;
2257 //----------------------------------------------------------------------------
2258 // Conf
2259 //----------------------------------------------------------------------------
2260 Conf::Conf()
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;
2271 Conf::~Conf()
2273 qDeleteAll(list);
2276 void Conf::added(ConfObj *o)
2278 list.append(o);
2281 QString Conf::getenv(const QString &var)
2283 return qc_getenv(var);
2286 void Conf::debug(const QString &s)
2288 if(debug_enabled)
2290 if(first_debug)
2291 printf("\n");
2292 first_debug = false;
2293 printf(" * %s\n", qPrintable(s));
2297 bool Conf::exec()
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
2304 if(o->disabled)
2306 QString v = QString("QC_ENABLE_") + qc_escapeArg(o->shortname());
2307 if(getenv(v) != "Y")
2308 continue;
2310 // and the opposite?
2311 else
2313 QString v = QString("QC_DISABLE_") + qc_escapeArg(o->shortname());
2314 if(getenv(v) == "Y")
2315 continue;
2318 bool output = true;
2319 QString check = o->checkString();
2320 if(check.isEmpty())
2321 output = false;
2323 if(output)
2325 printf("%s", check.toLatin1().data());
2326 fflush(stdout);
2329 first_debug = true;
2330 bool ok = o->exec();
2331 o->success = ok;
2333 if(output)
2335 QString result = o->resultString();
2336 if(!first_debug)
2337 printf(" -> %s\n", result.toLatin1().data());
2338 else
2339 printf(" %s\n", result.toLatin1().data());
2342 if(!ok && o->required)
2344 printf("\nError: need %s!\n", o->name().toLatin1().data());
2345 return false;
2348 return true;
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));
2371 return 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));
2383 return r;
2386 bool Conf::doCompileAndLink(const QString &filedata, const QStringList &incs, const QString &libs, const QString &proextra, int *retcode)
2388 #ifdef Q_OS_WIN
2389 QDir tmp("qconftemp");
2390 #else
2391 QDir tmp(".qconftemp");
2392 #endif
2394 if(!tmp.mkdir("atest"))
2396 debug("unable to create atest dir");
2397 return false;
2399 QDir dir(tmp.filePath("atest"));
2400 if(!dir.exists())
2402 debug("atest dir does not exist");
2403 return false;
2406 QString fname = dir.filePath("atest.cpp");
2407 QString out = "atest";
2408 QFile f(fname);
2409 if(!f.open(QFile::WriteOnly | QFile::Truncate))
2411 debug("unable to open atest.cpp for writing");
2412 return false;
2414 if(f.write(filedata.toLatin1()) == -1)
2416 debug("error writing to atest.cpp");
2417 return false;
2419 f.close();
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(" ");
2429 if(!inc.isEmpty())
2430 pro += "INCLUDEPATH += " + inc + '\n';
2431 if(!libs.isEmpty())
2432 pro += "LIBS += " + libs + '\n';
2433 pro += proextra;
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");
2440 return false;
2442 if(f.write(pro.toLatin1()) == -1)
2444 debug("error writing to atest.pro");
2445 return false;
2447 f.close();
2449 debug(QString("Wrote atest.pro:\n%1").arg(pro));
2451 QString oldpath = QDir::currentPath();
2452 QDir::setCurrent(dir.path());
2454 bool ok = false;
2455 int r = doCommand(qmake_path, QStringList() << "atest.pro");
2456 if(r == 0)
2458 r = doCommand(maketool, QStringList());
2459 if(r == 0)
2461 ok = true;
2462 if(retcode)
2464 QString runatest = out;
2465 #ifdef Q_OS_UNIX
2466 runatest.prepend("./");
2467 #endif
2468 *retcode = doCommand(runatest, QStringList());
2471 r = doCommand(maketool, QStringList() << "distclean");
2472 if(r != 0)
2473 debug("error during atest distclean");
2476 QDir::setCurrent(oldpath);
2478 // cleanup
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"));
2486 if(!ok)
2487 return false;
2488 return true;
2491 bool Conf::checkHeader(const QString &path, const QString &h)
2493 QFileInfo fi(path + '/' + h);
2494 if(fi.exists())
2495 return true;
2496 return false;
2499 bool Conf::findHeader(const QString &h, const QStringList &ext, QString *inc)
2501 if(checkHeader("/usr/include", h))
2503 *inc = "";
2504 return true;
2506 QStringList dirs;
2507 dirs += "/usr/local/include";
2508 dirs += ext;
2509 for(QStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it)
2511 if(checkHeader(*it, h))
2513 *inc = *it;
2514 return true;
2517 return false;
2520 bool Conf::checkLibrary(const QString &path, const QString &name)
2522 QString str =
2523 //"#include <stdio.h>\n"
2524 "int main()\n"
2525 "{\n"
2526 //" printf(\"library checker running\\\\n\");\n"
2527 " return 0;\n"
2528 "}\n";
2530 QString libs;
2531 if(!path.isEmpty())
2532 libs += QString("-L") + path + ' ';
2533 libs += QString("-l") + name;
2534 if(!doCompileAndLink(str, QStringList(), libs, QString()))
2535 return false;
2536 return true;
2539 bool Conf::findLibrary(const QString &name, QString *lib)
2541 if(checkLibrary("", name))
2543 *lib = "";
2544 return true;
2546 if(checkLibrary("/usr/local/lib", name))
2548 *lib = "/usr/local/lib";
2549 return true;
2551 return false;
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)
2561 QString inc, lib;
2562 QString s;
2564 s = getenv(incvar);
2565 if(!s.isEmpty()) {
2566 if(!checkHeader(s, incname))
2567 return false;
2568 inc = s;
2570 else {
2571 if(!findHeader(incname, QStringList(), &s))
2572 return false;
2573 inc = s;
2576 s = getenv(libvar);
2577 if(!s.isEmpty()) {
2578 if(!checkLibrary(s, libname))
2579 return false;
2580 lib = s;
2582 else {
2583 if(!findLibrary(libname, &s))
2584 return false;
2585 lib = s;
2588 QString lib_out;
2589 if(!lib.isEmpty())
2590 lib_out += QString("-L") + s;
2591 lib_out += QString("-l") + libname;
2593 *incpath = inc;
2594 *libs = lib_out;
2595 return true;
2598 bool Conf::findFooConfig(const QString &path, QString *version, QStringList *incs, QString *libs, QString *otherflags)
2600 QStringList args;
2601 QByteArray out;
2602 int ret;
2604 args += "--version";
2605 ret = doCommand(path, args, &out);
2606 if(ret != 0)
2607 return false;
2609 QString version_out = QString::fromLatin1(out).trimmed();
2611 args.clear();
2612 args += "--libs";
2613 ret = doCommand(path, args, &out);
2614 if(ret != 0)
2615 return false;
2617 QString libs_out = QString::fromLatin1(out).trimmed();
2619 args.clear();
2620 args += "--cflags";
2621 ret = doCommand(path, args, &out);
2622 if(ret != 0)
2623 return false;
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;
2631 *incs = incs_out;
2632 *libs = libs_out;
2633 *otherflags = otherflags_out.join(" ");
2634 return true;
2637 bool Conf::findPkgConfig(const QString &name, VersionMode mode, const QString &req_version, QString *version, QStringList *incs, QString *libs, QString *otherflags)
2639 QStringList args;
2640 QByteArray out;
2641 int ret;
2643 args += name;
2644 args += "--exists";
2645 ret = doCommand("pkg-config", args, &out);
2646 if(ret != 0)
2647 return false;
2649 if(mode != VersionAny)
2651 args.clear();
2652 args += name;
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);
2657 else
2658 args += QString("--exact-version=%1").arg(req_version);
2659 ret = doCommand("pkg-config", args, &out);
2660 if(ret != 0)
2661 return false;
2664 args.clear();
2665 args += name;
2666 args += "--modversion";
2667 ret = doCommand("pkg-config", args, &out);
2668 if(ret != 0)
2669 return false;
2671 QString version_out = QString::fromLatin1(out).trimmed();
2673 args.clear();
2674 args += name;
2675 args += "--libs";
2676 ret = doCommand("pkg-config", args, &out);
2677 if(ret != 0)
2678 return false;
2680 QString libs_out = QString::fromLatin1(out).trimmed();
2682 args.clear();
2683 args += name;
2684 args += "--cflags";
2685 ret = doCommand("pkg-config", args, &out);
2686 if(ret != 0)
2687 return false;
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;
2695 *incs = incs_out;
2696 *libs = libs_out;
2697 *otherflags = otherflags_out.join(" ");
2698 return true;
2701 void Conf::addDefine(const QString &str)
2703 if(DEFINES.isEmpty())
2704 DEFINES = str;
2705 else
2706 DEFINES += QString(" ") + str;
2707 debug(QString("DEFINES += %1").arg(str));
2710 void Conf::addLib(const QString &str)
2712 if(LIBS.isEmpty())
2713 LIBS = str;
2714 else
2715 LIBS += QString(" ") + str;
2716 debug(QString("LIBS += %1").arg(str));
2719 void Conf::addIncludePath(const QString &str)
2721 if(INCLUDEPATH.isEmpty())
2722 INCLUDEPATH = str;
2723 else
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 //----------------------------------------------------------------------------
2735 // main
2736 //----------------------------------------------------------------------------
2737 #include "conf4.moc"
2739 #ifdef HAVE_MODULES
2740 # include"modules.cpp"
2741 #endif
2743 int main()
2745 Conf *conf = new Conf;
2746 ConfObj *o;
2747 o = 0;
2748 #ifdef HAVE_MODULES
2749 # include"modules_new.cpp"
2750 #endif
2752 conf->debug_enabled = (qc_getenv("QC_VERBOSE") == "Y") ? true: false;
2753 if(conf->debug_enabled)
2754 printf(" -> ok\n");
2755 else
2756 printf("ok\n");
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");
2771 return 1;
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));
2787 printf("\n");
2790 bool success = false;
2791 if(conf->exec())
2793 QFile f("conf.pri");
2794 if(!f.open(QFile::WriteOnly | QFile::Truncate))
2796 printf("Error writing %s\n", qPrintable(f.fileName()));
2797 return 1;
2800 QString str;
2801 str += "# qconf\n\n";
2803 QString var;
2804 var = qc_getenv("PREFIX");
2805 if(!var.isEmpty())
2806 str += QString("PREFIX = %1\n").arg(var);
2807 var = qc_getenv("BINDIR");
2808 if(!var.isEmpty())
2809 str += QString("BINDIR = %1\n").arg(var);
2810 var = qc_getenv("INCDIR");
2811 if(!var.isEmpty())
2812 str += QString("INCDIR = %1\n").arg(var);
2813 var = qc_getenv("LIBDIR");
2814 if(!var.isEmpty())
2815 str += QString("LIBDIR = %1\n").arg(var);
2816 var = qc_getenv("DATADIR");
2817 if(!var.isEmpty())
2818 str += QString("DATADIR = %1\n").arg(var);
2819 str += '\n';
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())
2834 str += conf->extra;
2835 str += '\n';
2837 QByteArray cs = str.toLatin1();
2838 f.write(cs);
2839 f.close();
2840 success = true;
2842 QString qmake_path = conf->qmake_path;
2843 QString qmakespec = conf->qmakespec;
2844 delete conf;
2846 if(!success)
2847 return 1;
2849 // run qmake on the project file
2850 QStringList args;
2851 if(!qmakespec.isEmpty())
2853 args += "-spec";
2854 args += qmakespec;
2856 args += proPath;
2857 int ret = qc_runprogram(qmake_path, args, 0, true);
2858 if(ret != 0)
2859 return 1;
2861 return 0;
2865 cat >$1/conf4.pro <<EOT
2866 CONFIG += console
2867 CONFIG -= app_bundle
2868 QT -= gui
2869 TARGET = conf
2870 DESTDIR = \$\$PWD
2872 HEADERS += conf4.h
2873 SOURCES += conf4.cpp
2876 DEFINES += HAVE_MODULES
2881 export PREFIX
2882 export BINDIR
2883 export LIBDIR
2884 export DATADIR
2885 export EX_QTDIR
2886 export QC_RELEASE
2887 export QC_DEBUG
2888 export QC_NO_SEPARATE_DEBUG_INFO
2889 export QC_SEPARATE_DEBUG_INFO
2890 export QC_CERTSTORE_PATH
2891 export QC_DISABLE_bundled_qca
2892 export QC_WITH_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
2908 export QC_VERBOSE
2909 rm -rf .qconftemp
2911 mkdir .qconftemp
2912 gen_files .qconftemp
2913 cd .qconftemp
2914 if [ ! -z "$qm_spec" ]; then
2915 $qm -spec $qm_spec conf4.pro >/dev/null
2916 else
2917 $qm conf4.pro >/dev/null
2919 $MAKE clean >/dev/null 2>&1
2920 $MAKE >../conf.log 2>&1
2923 if [ "$?" != "0" ]; then
2924 rm -rf .qconftemp
2925 if [ "$QC_VERBOSE" = "Y" ]; then
2926 echo " -> fail"
2927 else
2928 echo "fail"
2930 printf "\n"
2931 printf "Reason: There was an error compiling 'conf'. See conf.log for details.\n"
2932 printf "\n"
2933 show_qt_info
2934 if [ "$QC_VERBOSE" = "Y" ]; then
2935 echo "conf.log:"
2936 cat conf.log
2938 exit 1;
2941 QC_COMMAND=$0
2942 export QC_COMMAND
2943 QC_PROFILE=psi.pro
2944 export QC_PROFILE
2945 QC_QMAKE=$qm
2946 export QC_QMAKE
2947 QC_QMAKESPEC=$qm_spec
2948 export QC_QMAKESPEC
2949 QC_MAKETOOL=$MAKE
2950 export QC_MAKETOOL
2951 .qconftemp/conf
2952 ret="$?"
2953 if [ "$ret" = "1" ]; then
2954 rm -rf .qconftemp
2955 echo
2956 exit 1;
2957 else
2958 if [ "$ret" != "0" ]; then
2959 rm -rf .qconftemp
2960 if [ "$QC_VERBOSE" = "Y" ]; then
2961 echo " -> fail"
2962 else
2963 echo "fail"
2965 echo
2966 echo "Reason: Unexpected error launching 'conf'"
2967 echo
2968 exit 1;
2971 rm -rf .qconftemp
2973 echo
2974 echo "Good, your configure finished. Now run $MAKE."
2975 echo