Fixed: choose filetransfer transport by priority (thanks Dealer_WeARE)
[iris.git] / configure
blob88f99541654e995d93fe2169cff9f1d3d4f17b58
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 --qtdir=[path] Directory where Qt is installed.
14 --static Create a static library instead of shared.
15 --verbose Show extra configure output.
16 --help This help text.
18 Project options:
19 --release Build with debugging turned off (default).
20 --debug Build with debugging turned on.
21 --debug-and-release Build two versions, with and without debugging
22 turned on (mac only).
23 --no-separate-debug-info Do not store debug information in a separate
24 file (default for mac).
25 --separate-debug-info Strip debug information into a separate .debug
26 file (default for non-mac).
27 --no-framework Do not build as a Mac framework.
28 --framework Build as a Mac framework (default).
29 --universal Build with Mac universal binary support.
30 --mac-sdk=[path] Path to Mac universal SDK (PPC host only).
31 --disable-tests Don't build examples and unittests.
33 Dependency options:
34 --with-qca=[path] Specify path to QCA tree, mainly for building
35 against an uninstalled QCA.
36 --with-zlib-inc=[path] Path to zlib include files
37 --with-zlib-lib=[path] Path to zlib library files
39 EOT
42 # which/make detection adapted from Qt
43 which_command() {
44 OLD_HOME=$HOME
45 HOME=/dev/null
46 export HOME
48 WHICH=`which which 2>/dev/null`
49 if echo $WHICH | grep 'shell built-in command' >/dev/null 2>&1; then
50 WHICH=which
51 elif [ -z "$WHICH" ]; then
52 if which which >/dev/null 2>&1; then
53 WHICH=which
54 else
55 for a in /usr/ucb /usr/bin /bin /usr/local/bin; do
56 if [ -x $a/which ]; then
57 WHICH=$a/which
58 break;
60 done
64 if [ -z "$WHICH" ]; then
65 OLD_IFS=$IFS
66 IFS=:
67 for a in $PATH; do
68 if [ -x $a/$1 ]; then
69 echo "$a/$1"
70 IFS=$OLD_IFS
71 export IFS
72 HOME=$OLD_HOME
73 export HOME
74 return 0
76 done
77 IFS=$OLD_IFS
78 export IFS
79 else
80 a=`"$WHICH" "$1" 2>/dev/null`
81 if [ ! -z "$a" -a -x "$a" ]; then
82 echo "$a"
83 HOME=$OLD_HOME
84 export HOME
85 return 0
88 HOME=$OLD_HOME
89 export HOME
90 return 1
92 WHICH=which_command
94 # find a make command
95 if [ -z "$MAKE" ]; then
96 MAKE=
97 for mk in gmake make; do
98 if $WHICH $mk >/dev/null 2>&1; then
99 MAKE=`$WHICH $mk`
100 break
102 done
103 if [ -z "$MAKE" ]; then
104 echo "You don't seem to have 'make' or 'gmake' in your PATH."
105 echo "Cannot proceed."
106 exit 1
110 show_qt_info() {
111 printf "Be sure you have a proper Qt 4.0 build environment set up. This means not\n"
112 printf "just Qt, but also a C++ compiler, a make tool, and any other packages\n"
113 printf "necessary for compiling C++ programs.\n"
114 printf "\n"
115 printf "If you are certain everything is installed, then it could be that Qt 4 is not\n"
116 printf "being recognized or that a different version of Qt is being detected by\n"
117 printf "mistake (for example, this could happen if \$QTDIR is pointing to a Qt 3\n"
118 printf "installation). At least one of the following conditions must be satisfied:\n"
119 printf "\n"
120 printf " 1) --qtdir is set to the location of Qt\n"
121 printf " 2) \$QTDIR is set to the location of Qt\n"
122 printf " 3) QtCore is in the pkg-config database\n"
123 printf " 4) qmake is in the \$PATH\n"
124 printf "\n"
125 printf "This script will use the first one it finds to be true, checked in the above\n"
126 printf "order. #3 and #4 are the recommended options. #1 and #2 are mainly for\n"
127 printf "overriding the system configuration.\n"
128 printf "\n"
131 while [ $# -gt 0 ]; do
132 optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
133 case "$1" in
134 --qtdir=*)
135 EX_QTDIR=$optarg
136 shift
139 --static)
140 QC_STATIC="Y"
141 shift
144 --release)
145 QC_RELEASE="Y"
146 shift
149 --debug)
150 QC_DEBUG="Y"
151 shift
154 --debug-and-release)
155 QC_DEBUG_AND_RELEASE="Y"
156 shift
159 --no-separate-debug-info)
160 QC_NO_SEPARATE_DEBUG_INFO="Y"
161 shift
164 --separate-debug-info)
165 QC_SEPARATE_DEBUG_INFO="Y"
166 shift
169 --no-framework)
170 QC_NO_FRAMEWORK="Y"
171 shift
174 --framework)
175 QC_FRAMEWORK="Y"
176 shift
179 --universal)
180 QC_UNIVERSAL="Y"
181 shift
184 --mac-sdk=*)
185 QC_MAC_SDK=$optarg
186 shift
189 --disable-tests)
190 QC_DISABLE_TESTS="Y"
191 shift
194 --with-qca=*)
195 QC_WITH_QCA=$optarg
196 shift
199 --with-zlib-inc=*)
200 QC_WITH_ZLIB_INC=$optarg
201 shift
204 --with-zlib-lib=*)
205 QC_WITH_ZLIB_LIB=$optarg
206 shift
209 --verbose)
210 QC_VERBOSE="Y"
211 shift
213 --help) show_usage; exit ;;
214 *) show_usage; exit ;;
215 esac
216 done
219 echo "Configuring Iris ..."
221 if [ "$QC_VERBOSE" = "Y" ]; then
222 echo
223 echo EX_QTDIR=$EX_QTDIR
224 echo QC_STATIC=$QC_STATIC
225 echo QC_RELEASE=$QC_RELEASE
226 echo QC_DEBUG=$QC_DEBUG
227 echo QC_DEBUG_AND_RELEASE=$QC_DEBUG_AND_RELEASE
228 echo QC_NO_SEPARATE_DEBUG_INFO=$QC_NO_SEPARATE_DEBUG_INFO
229 echo QC_SEPARATE_DEBUG_INFO=$QC_SEPARATE_DEBUG_INFO
230 echo QC_NO_FRAMEWORK=$QC_NO_FRAMEWORK
231 echo QC_FRAMEWORK=$QC_FRAMEWORK
232 echo QC_UNIVERSAL=$QC_UNIVERSAL
233 echo QC_MAC_SDK=$QC_MAC_SDK
234 echo QC_DISABLE_TESTS=$QC_DISABLE_TESTS
235 echo QC_WITH_QCA=$QC_WITH_QCA
236 echo QC_WITH_ZLIB_INC=$QC_WITH_ZLIB_INC
237 echo QC_WITH_ZLIB_LIB=$QC_WITH_ZLIB_LIB
238 echo
241 printf "Verifying Qt 4 build environment ... "
243 # run qmake -v and check version
244 qmake_check_v4() {
245 if [ -x "$1" ]; then
246 if echo `$1 -v 2>&1` | grep "Qt version 4\." >/dev/null 2>&1; then
247 return 0
248 elif [ "$QC_VERBOSE" = "Y" ]; then
249 echo "Warning: $1 not for Qt 4"
252 return 1
255 if [ "$QC_VERBOSE" = "Y" ]; then
256 echo
259 qm=""
260 names="qmake-qt4 qmake4 qmake"
262 # qt4 check: --qtdir
263 if [ -z "$qm" ] && [ ! -z "$EX_QTDIR" ]; then
264 for n in $names; do
265 qstr=$EX_QTDIR/bin/$n
266 if qmake_check_v4 "$qstr"; then
267 qm=$qstr
268 break;
270 done
272 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
273 echo "Warning: qmake not found via --qtdir"
276 # qt4 check: QTDIR
277 if [ -z "$qm" ] && [ ! -z "$QTDIR" ]; then
278 for n in $names; do
279 qstr=$QTDIR/bin/$n
280 if qmake_check_v4 "$qstr"; then
281 qm=$qstr
282 break;
284 done
286 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
287 echo "Warning: qmake not found via \$QTDIR"
290 # qt4 check: pkg-config
291 if [ -z "$qm" ]; then
292 str=`pkg-config QtCore --variable=exec_prefix 2>/dev/null`
293 if [ ! -z "$str" ]; then
294 for n in $names; do
295 qstr=$str/bin/$n
296 if qmake_check_v4 "$qstr"; then
297 qm=$qstr
298 break;
300 done
303 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
304 echo "Warning: qmake not found via pkg-config"
307 # qt4 check: PATH
308 if [ -z "$qm" ]; then
309 for n in $names; do
310 qstr=`$WHICH $n 2>/dev/null`
311 if qmake_check_v4 "$qstr"; then
312 qm=$qstr
313 break;
315 done
317 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
318 echo "Warning: qmake not found via \$PATH"
321 if [ -z "$qm" ]; then
322 if [ "$QC_VERBOSE" = "Y" ]; then
323 echo " -> fail"
324 else
325 echo "fail"
327 printf "\n"
328 printf "Reason: Unable to find the 'qmake' tool for Qt 4.\n"
329 printf "\n"
330 show_qt_info
331 exit 1;
333 if [ "$QC_VERBOSE" = "Y" ]; then
334 echo qmake found in $qm
337 # try to determine the active makespec
338 defmakespec=$QMAKESPEC
339 if [ -z "$defmakespec" ]; then
340 if $WHICH readlink >/dev/null 2>&1; then
341 READLINK=`$WHICH readlink`
343 if [ ! -z "$READLINK" ]; then
344 qt_mkspecsdir=`$qm -query QT_INSTALL_DATA`/mkspecs
345 if [ -d "$qt_mkspecsdir" ] && [ -h "$qt_mkspecsdir/default" ]; then
346 defmakespec=`$READLINK $qt_mkspecsdir/default`
351 if [ "$QC_VERBOSE" = "Y" ]; then
352 echo makespec is $defmakespec
355 qm_spec=""
356 # if the makespec is macx-xcode, force macx-g++
357 if [ "$defmakespec" = "macx-xcode" ]; then
358 qm_spec=macx-g++
359 QMAKESPEC=$qm_spec
360 export QMAKESPEC
361 if [ "$QC_VERBOSE" = "Y" ]; then
362 echo overriding makespec to $qm_spec
366 gen_files() {
367 cat >$1/modules.cpp <<EOT
368 #line 1 "qt42.qcm"
370 -----BEGIN QCMOD-----
371 name: Qt >= 4.2
372 -----END QCMOD-----
374 class qc_qt42 : public ConfObj
376 public:
377 qc_qt42(Conf *c) : ConfObj(c) {}
378 QString name() const { return "Qt >= 4.2"; }
379 QString shortname() const { return "qt42"; }
380 bool exec()
382 conf->debug(QString("QT_VERSION = 0x%1").arg(QString::number(QT_VERSION, 16)));
383 if(QT_VERSION >= 0x040200)
384 return true;
385 else
386 return false;
389 #line 1 "buildmode.qcm"
391 -----BEGIN QCMOD-----
392 name: buildmode
393 section: project
394 arg: release,Build with debugging turned off (default).
395 arg: debug,Build with debugging turned on.
396 arg: debug-and-release,Build two versions, with and without debugging turned on (mac only).
397 arg: no-separate-debug-info,Do not store debug information in a separate file (default for mac).
398 arg: separate-debug-info,Strip debug information into a separate .debug file (default for non-mac).
399 arg: no-framework,Do not build as a Mac framework.
400 arg: framework,Build as a Mac framework (default).
401 -----END QCMOD-----
404 #define QC_BUILDMODE
405 bool qc_buildmode_release = false;
406 bool qc_buildmode_debug = false;
407 bool qc_buildmode_framework = false;
408 bool qc_buildmode_separate_debug_info = false;
410 class qc_buildmode : public ConfObj
412 public:
413 qc_buildmode(Conf *c) : ConfObj(c) {}
414 QString name() const { return "buildmode"; }
415 QString shortname() const { return "buildmode"; }
417 // no output
418 QString checkString() const { return QString(); }
420 bool exec()
422 // first, parse out the options
423 bool opt_release = false;
424 bool opt_debug = false;
425 bool opt_debug_and_release = false;
426 bool opt_no_framework = false;
427 bool opt_framework = false;
428 bool opt_no_separate_debug_info = false;
429 bool opt_separate_debug_info = false;
431 if(conf->getenv("QC_RELEASE") == "Y")
432 opt_release = true;
433 if(conf->getenv("QC_DEBUG") == "Y")
434 opt_debug = true;
435 if(conf->getenv("QC_DEBUG_AND_RELEASE") == "Y")
436 opt_debug_and_release = true;
437 if(conf->getenv("QC_NO_FRAMEWORK") == "Y")
438 opt_no_framework = true;
439 if(conf->getenv("QC_FRAMEWORK") == "Y")
440 opt_framework = true;
441 if(conf->getenv("QC_NO_SEPARATE_DEBUG_INFO") == "Y")
442 opt_no_separate_debug_info = true;
443 if(conf->getenv("QC_SEPARATE_DEBUG_INFO") == "Y")
444 opt_separate_debug_info = true;
446 bool staticmode = false;
447 if(conf->getenv("QC_STATIC") == "Y")
448 staticmode = true;
450 #ifndef Q_OS_MAC
451 if(opt_debug_and_release)
453 printf("\nError: The --debug-and-release option is for mac only.\n");
454 exit(1);
457 if(opt_framework)
459 printf("\nError: The --framework option is for mac only.\n");
460 exit(1);
462 #endif
464 if(opt_framework && opt_debug)
466 printf("\nError: Cannot use both --framework and --debug.\n");
467 exit(1);
470 // sanity check exclusive options
471 int x;
473 // build mode
474 x = 0;
475 if(opt_release)
476 ++x;
477 if(opt_debug)
478 ++x;
479 if(opt_debug_and_release)
480 ++x;
481 if(x > 1)
483 printf("\nError: Use only one of --release, --debug, or --debug-and-release.\n");
484 exit(1);
487 // framework
488 if(opt_framework && staticmode)
490 printf("\nError: Cannot use both --framework and --static.\n");
491 exit(1);
494 x = 0;
495 if(opt_no_framework)
496 ++x;
497 if(opt_framework)
498 ++x;
499 if(x > 1)
501 printf("\nError: Use only one of --framework or --no-framework.\n");
502 exit(1);
505 // debug info
506 x = 0;
507 if(opt_no_separate_debug_info)
508 ++x;
509 if(opt_separate_debug_info)
510 ++x;
511 if(x > 1)
513 printf("\nError: Use only one of --separate-debug-info or --no-separate-debug-info\n");
514 exit(1);
517 // now process the options
519 if(opt_release)
520 qc_buildmode_release = true;
521 else if(opt_debug)
522 qc_buildmode_debug = true;
523 else if(opt_debug_and_release)
525 qc_buildmode_release = true;
526 qc_buildmode_debug = true;
528 else // default
529 qc_buildmode_release = true;
531 if(opt_framework)
532 qc_buildmode_framework = true;
533 else if(opt_no_framework)
535 // nothing to do
537 else // default
539 if(!staticmode && !opt_debug)
540 qc_buildmode_framework = true;
543 if(opt_separate_debug_info)
544 qc_buildmode_separate_debug_info = true;
545 else if(opt_no_separate_debug_info)
547 // nothing to do
549 else // default
551 #ifndef Q_OS_MAC
552 qc_buildmode_separate_debug_info = true;
553 #endif
556 // make the string
557 QStringList opts;
558 QString other;
560 if(qc_buildmode_release && qc_buildmode_debug)
562 opts += "debug_and_release";
563 opts += "build_all";
565 else if(qc_buildmode_release)
566 opts += "release";
567 else // qc_buildmode_debug
568 opts += "debug";
570 #ifdef Q_OS_MAC
571 if(qc_buildmode_framework)
572 opts += "lib_bundle";
573 #endif
575 if(qc_buildmode_separate_debug_info)
577 opts += "separate_debug_info";
578 other += "QMAKE_CFLAGS += -g\n";
579 other += "QMAKE_CXXFLAGS += -g\n";
582 QString str = QString("CONFIG += ") + opts.join(" ") + '\n';
583 conf->addExtra(str);
585 if(!other.isEmpty())
586 conf->addExtra(other);
588 return true;
591 #line 1 "universal.qcm"
593 -----BEGIN QCMOD-----
594 name: Mac universal binary support
595 section: project
596 arg: universal,Build with Mac universal binary support.
597 arg: mac-sdk=[path],Path to Mac universal SDK (PPC host only).
598 -----END QCMOD-----
601 #define QC_UNIVERSAL
602 bool qc_universal_enabled = false;
603 QString qc_universal_sdk;
605 //----------------------------------------------------------------------------
606 // qc_universal
607 //----------------------------------------------------------------------------
608 class qc_universal : public ConfObj
610 public:
611 qc_universal(Conf *c) : ConfObj(c) {}
612 QString name() const { return "Mac universal binary support"; }
613 QString shortname() const { return "universal"; }
614 QString checkString() const { return QString(); }
616 bool exec()
618 #ifdef Q_OS_MAC
619 if(qc_getenv("QC_UNIVERSAL") == "Y")
621 qc_universal_enabled = true;
623 QString str =
624 "contains(QT_CONFIG,x86):contains(QT_CONFIG,ppc) {\n"
625 " CONFIG += x86 ppc\n"
626 "}\n";
628 QString sdk = qc_getenv("QC_MAC_SDK");
629 if(!sdk.isEmpty())
631 str += QString("QMAKE_MAC_SDK = %1\n").arg(sdk);
632 qc_universal_sdk = sdk;
635 conf->addExtra(str);
637 #endif
638 return true;
641 #line 1 "qca.qcm"
643 -----BEGIN QCMOD-----
644 name: QCA >= 2.0
645 arg: with-qca=[path],Specify path to QCA tree, mainly for building against an uninstalled QCA.
646 -----END QCMOD-----
649 // based on crypto.prf. any changes made to that file need to be tracked here.
650 static QString internal_crypto_prf(const QString &incdir, const QString &libdir)
652 QString out = QString(
653 "QCA_INCDIR = %1\n"
654 "QCA_LIBDIR = %2\n"
655 "\n"
656 "CONFIG *= qt\n"
657 "\n"
658 "LINKAGE =\n"
659 "\n"
660 "# on mac, if qca was built as a framework, link against it\n"
661 "mac: {\n"
662 " framework_dir = \$\$QCA_LIBDIR\n"
663 " exists(\$\$framework_dir/qca.framework) {\n"
664 " #QMAKE_FRAMEWORKPATH *= \$\$framework_dir\n"
665 " LIBS += -F\$\$framework_dir\n"
666 " INCLUDEPATH += \$\$framework_dir/qca.framework/Headers\n"
667 " LINKAGE = -framework qca\n"
668 " }\n"
669 "}\n"
670 "\n"
671 "# else, link normally\n"
672 "isEmpty(LINKAGE) {\n"
673 " INCLUDEPATH += \$\$QCA_INCDIR/QtCrypto\n"
674 " LIBS += -L\$\$QCA_LIBDIR\n"
675 " LINKAGE = -lqca\n"
676 " CONFIG(debug, debug|release) {\n"
677 " windows:LINKAGE = -lqcad\n"
678 " mac:LINKAGE = -lqca_debug\n"
679 " }\n"
680 "}\n"
681 "\n"
682 "LIBS += \$\$LINKAGE\n"
683 ).arg(incdir, libdir);
684 return out;
687 #define QC_QCA
688 QString qc_qca_procode;
690 //----------------------------------------------------------------------------
691 // qc_qca
692 //----------------------------------------------------------------------------
693 class qc_qca : public ConfObj
695 public:
696 qc_qca(Conf *c) : ConfObj(c) {}
697 QString name() const { return "QCA >= 2.0"; }
698 QString shortname() const { return "qca"; }
699 bool exec()
701 // get the build mode
702 #ifdef QC_BUILDMODE
703 bool release = qc_buildmode_release;
704 bool debug = qc_buildmode_debug;
705 #else
706 // else, default to just release mode
707 bool release = true;
708 bool debug = false;
709 #endif
711 // test for "crypto" feature and check qca version number
712 QString qca_prefix, qca_incdir, qca_libdir, qca_crypto_prf;
713 qca_prefix = conf->getenv("QC_WITH_QCA");
715 QString proextra;
716 if(!qca_prefix.isEmpty()) {
717 qca_incdir = qca_prefix + "/include";
718 qca_libdir = qca_prefix + "/lib";
719 qca_crypto_prf = internal_crypto_prf(qca_incdir, qca_libdir);
720 proextra =
721 "CONFIG += qt\n"
722 "QT -= gui\n";
723 proextra += qca_crypto_prf;
724 } else {
725 proextra =
726 "CONFIG += qt crypto\n"
727 "QT -= gui\n";
730 QString str =
731 "#include <QtCrypto>\n"
732 "\n"
733 "int main()\n"
734 "{\n"
735 " unsigned long x = QCA_VERSION;\n"
736 " if(x >= 0x020000 && x < 0x030000) return 0; else return 1;\n"
737 "}\n";
739 if(release)
741 int ret;
742 if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra + "CONFIG += release\n", &ret))
743 return false;
744 if(ret != 0)
745 return false;
748 if(debug)
750 int ret;
751 if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra + "CONFIG += debug\n", &ret))
752 return false;
753 if(ret != 0)
754 return false;
757 if(!qca_prefix.isEmpty())
758 str = qca_crypto_prf;
759 else
760 str = "CONFIG += crypto\n";
762 qc_qca_procode = str;
763 conf->addExtra(str);
765 return true;
768 #line 1 "zlib.qcm"
770 -----BEGIN QCMOD-----
771 name: zlib
772 arg: with-zlib-inc=[path],Path to zlib include files
773 arg: with-zlib-lib=[path],Path to zlib library files
774 -----END QCMOD-----
777 //----------------------------------------------------------------------------
778 // qc_zlib
779 //----------------------------------------------------------------------------
780 class qc_zlib : public ConfObj
782 public:
783 qc_zlib(Conf *c) : ConfObj(c) {}
784 QString name() const { return "zlib"; }
785 QString shortname() const { return "zlib"; }
786 bool exec()
788 QString inc, lib;
789 QString s;
791 s = conf->getenv("QC_WITH_ZLIB_INC");
792 if(!s.isEmpty()) {
793 if(!conf->checkHeader(s, "zlib.h"))
794 return false;
795 inc = s;
797 else {
798 if(!conf->findHeader("zlib.h", QStringList(), &s))
799 return false;
800 inc = s;
803 s = conf->getenv("QC_WITH_ZLIB_LIB");
804 if(!s.isEmpty()) {
805 if(!conf->checkLibrary(s, "z"))
806 return false;
807 lib = s;
809 else {
810 if(!conf->findLibrary("z", &s))
811 return false;
812 lib = s;
815 if(!inc.isEmpty())
816 conf->addIncludePath(inc);
817 if(!lib.isEmpty())
818 conf->addLib(QString("-L") + s);
819 conf->addLib("-lz");
821 return true;
824 #line 1 "extra.qcm"
826 -----BEGIN QCMOD-----
827 name: extra
828 section: project
829 arg: disable-tests,Don't build examples and unittests.
830 -----END QCMOD-----
833 class qc_extra : public ConfObj
835 public:
836 qc_extra(Conf *c) : ConfObj(c) {}
837 QString name() const { return "extra"; }
838 QString shortname() const { return "extra"; }
840 // no output
841 QString checkString() const { return QString(); }
843 bool exec()
845 QString str;
846 QFile f;
848 if(conf->getenv("QC_DISABLE_TESTS") == "Y")
849 str += "CONFIG += no_tests\n";
851 conf->addExtra(str);
853 bool release = true;
854 bool debug = false;
855 bool debug_info = false;
856 bool universal = false;
857 QString sdk;
859 #ifdef QC_BUILDMODE
860 release = qc_buildmode_release;
861 debug = qc_buildmode_debug;
862 debug_info = qc_buildmode_separate_debug_info;
863 #endif
865 #ifdef QC_UNIVERSAL
866 universal = qc_universal_enabled;
867 sdk = qc_universal_sdk;
868 #endif
870 // write confapp_unix.pri
871 str = QString();
872 QString var = conf->getenv("BINDIR");
873 if(!var.isEmpty())
874 str += QString("BINDIR = %1\n").arg(var);
875 if(debug) // debug or debug-and-release
876 str += QString("CONFIG += debug\n");
877 else // release
878 str += QString("CONFIG += release\n");
879 if(debug_info)
881 str += QString("CONFIG += separate_debug_info\n");
882 str += "QMAKE_CFLAGS += -g\n";
883 str += "QMAKE_CXXFLAGS += -g\n";
885 if(universal)
887 str +=
888 "contains(QT_CONFIG,x86):contains(QT_CONFIG,ppc) {\n"
889 " CONFIG += x86 ppc\n"
890 "}\n";
892 if(!sdk.isEmpty())
893 str += QString("QMAKE_MAC_SDK = %1\n").arg(sdk);
895 #ifdef QC_QCA
896 if(!qc_qca_procode.isEmpty())
897 str += qc_qca_procode;
898 #endif
899 f.setFileName("confapp_unix.pri");
900 if(f.open(QFile::WriteOnly | QFile::Truncate))
901 f.write(str.toLatin1());
902 f.close();
904 return true;
907 QString makeEscapedDefine(const QString &var, const QString &val)
909 QString str = QString(
910 "DEFINES += %1=\\\\\\\\\\\\\\"%2\\\\\\\\\\\\\\"\n"
911 ).arg(var).arg(val);
912 return str;
917 cat >$1/modules_new.cpp <<EOT
918 o = new qc_qt42(conf);
919 o->required = true;
920 o->disabled = false;
921 o = new qc_buildmode(conf);
922 o->required = true;
923 o->disabled = false;
924 o = new qc_universal(conf);
925 o->required = true;
926 o->disabled = false;
927 o = new qc_qca(conf);
928 o->required = true;
929 o->disabled = false;
930 o = new qc_zlib(conf);
931 o->required = true;
932 o->disabled = false;
933 o = new qc_extra(conf);
934 o->required = true;
935 o->disabled = false;
938 cat >$1/conf4.h <<EOT
940 Copyright (C) 2004-2008 Justin Karneges
942 This file is free software; unlimited permission is given to copy and/or
943 distribute it, with or without modifications, as long as this notice is
944 preserved.
947 #ifndef QC_CONF4_H
948 #define QC_CONF4_H
950 #include <QtCore>
952 class Conf;
954 enum VersionMode { VersionMin, VersionExact, VersionMax, VersionAny };
956 // ConfObj
958 // Subclass ConfObj to create a new configuration module.
959 class ConfObj
961 public:
962 Conf *conf;
963 bool required;
964 bool disabled;
965 bool success;
967 ConfObj(Conf *c);
968 virtual ~ConfObj();
970 // long or descriptive name of what is being checked/performed
971 // example: "KDE >= 3.3"
972 virtual QString name() const = 0;
974 // short name
975 // example: "kde"
976 virtual QString shortname() const = 0;
978 // string to display during check
979 // default: "Checking for [name] ..."
980 virtual QString checkString() const;
982 // string to display after check
983 // default: "yes" or "no", based on result of exec()
984 virtual QString resultString() const;
986 // this is where the checking code goes
987 virtual bool exec() = 0;
990 // Conf
992 // Interact with this class from your ConfObj to perform detection
993 // operations and to output configuration parameters.
994 class Conf
996 public:
997 bool debug_enabled;
998 QString qmake_path;
999 QString qmakespec;
1000 QString maketool;
1002 QString DEFINES;
1003 QString INCLUDEPATH;
1004 QString LIBS;
1005 QString extra;
1007 QList<ConfObj*> list;
1008 QMap<QString,QString> vars;
1010 Conf();
1011 ~Conf();
1013 QString getenv(const QString &var);
1014 QString qvar(const QString &s);
1016 bool exec();
1018 void debug(const QString &s);
1020 QString expandIncludes(const QString &inc);
1021 QString expandLibs(const QString &lib);
1023 int doCommand(const QString &s, QByteArray *out = 0);
1024 int doCommand(const QString &prog, const QStringList &args, QByteArray *out = 0);
1026 bool doCompileAndLink(const QString &filedata, const QStringList &incs, const QString &libs, const QString &proextra, int *retcode = 0);
1027 bool checkHeader(const QString &path, const QString &h);
1028 bool findHeader(const QString &h, const QStringList &ext, QString *inc);
1029 bool checkLibrary(const QString &path, const QString &name);
1030 bool findLibrary(const QString &name, QString *lib);
1031 QString findProgram(const QString &prog);
1032 bool findSimpleLibrary(const QString &incvar, const QString &libvar, const QString &incname, const QString &libname, QString *incpath, QString *libs);
1033 bool findFooConfig(const QString &path, QString *version, QStringList *incs, QString *libs, QString *otherflags);
1034 bool findPkgConfig(const QString &name, VersionMode mode, const QString &req_version, QString *version, QStringList *incs, QString *libs, QString *otherflags);
1036 void addDefine(const QString &str);
1037 void addLib(const QString &str);
1038 void addIncludePath(const QString &str);
1039 void addExtra(const QString &str);
1041 private:
1042 bool first_debug;
1044 friend class ConfObj;
1045 void added(ConfObj *o);
1048 #endif
1051 cat >$1/conf4.cpp <<EOT
1053 Copyright (C) 2004-2008 Justin Karneges
1055 This file is free software; unlimited permission is given to copy and/or
1056 distribute it, with or without modifications, as long as this notice is
1057 preserved.
1060 #include "conf4.h"
1062 #include <stdio.h>
1063 #include <stdlib.h>
1065 class MocTestObject : public QObject
1067 Q_OBJECT
1068 public:
1069 MocTestObject() {}
1072 QString qc_getenv(const QString &var)
1074 char *p = ::getenv(var.toLatin1().data());
1075 if(!p)
1076 return QString();
1077 return QString(p);
1080 QStringList qc_pathlist()
1082 QStringList list;
1083 QString path = qc_getenv("PATH");
1084 if(!path.isEmpty())
1085 list = path.split(':', QString::SkipEmptyParts);
1086 return list;
1089 QString qc_findprogram(const QString &prog)
1091 QString out;
1092 QStringList list = qc_pathlist();
1093 for(int n = 0; n < list.count(); ++n)
1095 QFileInfo fi(list[n] + '/' + prog);
1096 if(fi.exists() && fi.isExecutable())
1098 out = fi.filePath();
1099 break;
1102 return out;
1105 QString qc_findself(const QString &argv0)
1107 if(argv0.contains('/'))
1108 return argv0;
1109 else
1110 return qc_findprogram(argv0);
1113 int qc_runcommand(const QString &command, QByteArray *out, bool showOutput)
1115 QString fullcmd = command;
1116 if(!showOutput)
1117 fullcmd += " 2>/dev/null";
1118 FILE *f = popen(fullcmd.toLatin1().data(), "r");
1119 if(!f)
1120 return -1;
1121 if(out)
1122 out->clear();
1123 while(1)
1125 char c = (char)fgetc(f);
1126 if(feof(f))
1127 break;
1128 if(out)
1129 out->append(c);
1130 if(showOutput)
1131 fputc(c, stdout);
1133 int ret = pclose(f);
1134 if(ret == -1)
1135 return -1;
1136 return ret;
1139 int qc_runprogram(const QString &prog, const QStringList &args, QByteArray *out, bool showOutput)
1141 QString fullcmd = prog;
1142 QString argstr = args.join(" ");
1143 if(!argstr.isEmpty())
1144 fullcmd += QString(" ") + argstr;
1145 return qc_runcommand(fullcmd, out, showOutput);
1147 // TODO: use QProcess once it is fixed
1149 QProcess process;
1150 if(showOutput)
1151 process.setReadChannelMode(ForwardedChannels);
1152 process.start(prog, args);
1153 process.waitForFinished(-1);
1154 return process.exitCode();
1158 bool qc_removedir(const QString &dirPath)
1160 QDir dir(dirPath);
1161 if(!dir.exists())
1162 return false;
1163 QStringList list = dir.entryList();
1164 foreach(QString s, list)
1166 if(s == "." || s == "..")
1167 continue;
1168 QFileInfo fi(dir.filePath(s));
1169 if(fi.isDir())
1171 if(!qc_removedir(fi.filePath()))
1172 return false;
1174 else
1176 if(!dir.remove(s))
1177 return false;
1180 QString dirName = dir.dirName();
1181 if(!dir.cdUp())
1182 return false;
1183 if(!dir.rmdir(dirName))
1184 return false;
1185 return true;
1188 void qc_splitcflags(const QString &cflags, QStringList *incs, QStringList *otherflags)
1190 incs->clear();
1191 otherflags->clear();
1193 QStringList cflagsList = cflags.split(" ");
1194 for(int n = 0; n < cflagsList.count(); ++n)
1196 QString str = cflagsList[n];
1197 if(str.startsWith("-I"))
1199 // we want everything except the leading "-I"
1200 incs->append(str.remove(0, 2));
1202 else
1204 // we want whatever is left
1205 otherflags->append(str);
1210 QString qc_escapeArg(const QString &str)
1212 QString out;
1213 for(int n = 0; n < (int)str.length(); ++n) {
1214 if(str[n] == '-')
1215 out += '_';
1216 else
1217 out += str[n];
1219 return out;
1222 //----------------------------------------------------------------------------
1223 // ConfObj
1224 //----------------------------------------------------------------------------
1225 ConfObj::ConfObj(Conf *c)
1227 conf = c;
1228 conf->added(this);
1229 required = false;
1230 disabled = false;
1231 success = false;
1234 ConfObj::~ConfObj()
1238 QString ConfObj::checkString() const
1240 return QString("Checking for %1 ...").arg(name());
1243 QString ConfObj::resultString() const
1245 if(success)
1246 return "yes";
1247 else
1248 return "no";
1251 //----------------------------------------------------------------------------
1252 // qc_internal_pkgconfig
1253 //----------------------------------------------------------------------------
1254 class qc_internal_pkgconfig : public ConfObj
1256 public:
1257 QString pkgname, desc;
1258 VersionMode mode;
1259 QString req_ver;
1261 qc_internal_pkgconfig(Conf *c, const QString &_name, const QString &_desc, VersionMode _mode, const QString &_req_ver) : ConfObj(c)
1263 pkgname = _name;
1264 desc = _desc;
1265 mode = _mode;
1266 req_ver = _req_ver;
1269 QString name() const { return desc; }
1270 QString shortname() const { return pkgname; }
1272 bool exec()
1274 QStringList incs;
1275 QString version, libs, other;
1276 if(!conf->findPkgConfig(pkgname, mode, req_ver, &version, &incs, &libs, &other))
1277 return false;
1279 for(int n = 0; n < incs.count(); ++n)
1280 conf->addIncludePath(incs[n]);
1281 if(!libs.isEmpty())
1282 conf->addLib(libs);
1283 //if(!other.isEmpty())
1284 // conf->addExtra(QString("QMAKE_CFLAGS += %1\n").arg(other));
1285 return true;
1289 //----------------------------------------------------------------------------
1290 // Conf
1291 //----------------------------------------------------------------------------
1292 Conf::Conf()
1294 // TODO: no more vars?
1295 //vars.insert("QMAKE_INCDIR_X11", new QString(X11_INC));
1296 //vars.insert("QMAKE_LIBDIR_X11", new QString(X11_LIBDIR));
1297 //vars.insert("QMAKE_LIBS_X11", new QString(X11_LIB));
1298 //vars.insert("QMAKE_CC", CC);
1300 debug_enabled = false;
1303 Conf::~Conf()
1305 qDeleteAll(list);
1308 void Conf::added(ConfObj *o)
1310 list.append(o);
1313 QString Conf::getenv(const QString &var)
1315 return qc_getenv(var);
1318 void Conf::debug(const QString &s)
1320 if(debug_enabled)
1322 if(first_debug)
1323 printf("\n");
1324 first_debug = false;
1325 printf(" * %s\n", qPrintable(s));
1329 bool Conf::exec()
1331 for(int n = 0; n < list.count(); ++n)
1333 ConfObj *o = list[n];
1335 // if this was a disabled-by-default option, check if it was enabled
1336 if(o->disabled)
1338 QString v = QString("QC_ENABLE_") + qc_escapeArg(o->shortname());
1339 if(getenv(v) != "Y")
1340 continue;
1342 // and the opposite?
1343 else
1345 QString v = QString("QC_DISABLE_") + qc_escapeArg(o->shortname());
1346 if(getenv(v) == "Y")
1347 continue;
1350 bool output = true;
1351 QString check = o->checkString();
1352 if(check.isEmpty())
1353 output = false;
1355 if(output)
1357 printf("%s", check.toLatin1().data());
1358 fflush(stdout);
1361 first_debug = true;
1362 bool ok = o->exec();
1363 o->success = ok;
1365 if(output)
1367 QString result = o->resultString();
1368 if(!first_debug)
1369 printf(" -> %s\n", result.toLatin1().data());
1370 else
1371 printf(" %s\n", result.toLatin1().data());
1374 if(!ok && o->required)
1376 printf("\nError: need %s!\n", o->name().toLatin1().data());
1377 return false;
1380 return true;
1383 QString Conf::qvar(const QString &s)
1385 return vars.value(s);
1388 QString Conf::expandIncludes(const QString &inc)
1390 return QString("-I") + inc;
1393 QString Conf::expandLibs(const QString &lib)
1395 return QString("-L") + lib;
1398 int Conf::doCommand(const QString &s, QByteArray *out)
1400 debug(QString("[%1]").arg(s));
1401 int r = qc_runcommand(s, out, debug_enabled);
1402 debug(QString("returned: %1").arg(r));
1403 return r;
1406 int Conf::doCommand(const QString &prog, const QStringList &args, QByteArray *out)
1408 QString fullcmd = prog;
1409 QString argstr = args.join(" ");
1410 if(!argstr.isEmpty())
1411 fullcmd += QString(" ") + argstr;
1412 debug(QString("[%1]").arg(fullcmd));
1413 int r = qc_runprogram(prog, args, out, debug_enabled);
1414 debug(QString("returned: %1").arg(r));
1415 return r;
1418 bool Conf::doCompileAndLink(const QString &filedata, const QStringList &incs, const QString &libs, const QString &proextra, int *retcode)
1420 QDir tmp(".qconftemp");
1421 if(!tmp.mkdir("atest"))
1423 debug("unable to create atest dir");
1424 return false;
1426 QDir dir(tmp.filePath("atest"));
1427 if(!dir.exists())
1429 debug("atest dir does not exist");
1430 return false;
1433 QString fname = dir.filePath("atest.cpp");
1434 QString out = "atest";
1435 QFile f(fname);
1436 if(!f.open(QFile::WriteOnly | QFile::Truncate))
1438 debug("unable to open atest.cpp for writing");
1439 return false;
1441 if(f.write(filedata.toLatin1()) == -1)
1443 debug("error writing to atest.cpp");
1444 return false;
1446 f.close();
1448 debug(QString("Wrote atest.cpp:\n%1").arg(filedata));
1450 QString pro = QString(
1451 "CONFIG += console\n"
1452 "CONFIG -= qt app_bundle\n"
1453 "SOURCES += atest.cpp\n");
1454 QString inc = incs.join(" ");
1455 if(!inc.isEmpty())
1456 pro += "INCLUDEPATH += " + inc + '\n';
1457 if(!libs.isEmpty())
1458 pro += "LIBS += " + libs + '\n';
1459 pro += proextra;
1461 fname = dir.filePath("atest.pro");
1462 f.setFileName(fname);
1463 if(!f.open(QFile::WriteOnly | QFile::Truncate))
1465 debug("unable to open atest.pro for writing");
1466 return false;
1468 if(f.write(pro.toLatin1()) == -1)
1470 debug("error writing to atest.pro");
1471 return false;
1473 f.close();
1475 debug(QString("Wrote atest.pro:\n%1").arg(pro));
1477 QString oldpath = QDir::currentPath();
1478 QDir::setCurrent(dir.path());
1480 bool ok = false;
1481 int r = doCommand(qmake_path, QStringList() << "atest.pro");
1482 if(r == 0)
1484 r = doCommand(maketool, QStringList());
1485 if(r == 0)
1487 ok = true;
1488 if(retcode)
1489 *retcode = doCommand(QString("./") + out, QStringList());
1491 r = doCommand(maketool, QStringList() << "distclean");
1492 if(r != 0)
1493 debug("error during atest distclean");
1496 QDir::setCurrent(oldpath);
1498 // cleanup
1499 //dir.remove("atest.pro");
1500 //dir.remove("atest.cpp");
1501 //tmp.rmdir("atest");
1503 // remove whole dir since distclean doesn't always work
1504 qc_removedir(tmp.filePath("atest"));
1506 if(!ok)
1507 return false;
1508 return true;
1511 bool Conf::checkHeader(const QString &path, const QString &h)
1513 QFileInfo fi(path + '/' + h);
1514 if(fi.exists())
1515 return true;
1516 return false;
1519 bool Conf::findHeader(const QString &h, const QStringList &ext, QString *inc)
1521 if(checkHeader("/usr/include", h))
1523 *inc = "";
1524 return true;
1526 QStringList dirs;
1527 dirs += "/usr/local/include";
1528 dirs += ext;
1529 for(QStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it)
1531 if(checkHeader(*it, h))
1533 *inc = *it;
1534 return true;
1537 return false;
1540 bool Conf::checkLibrary(const QString &path, const QString &name)
1542 QString str =
1543 //"#include <stdio.h>\n"
1544 "int main()\n"
1545 "{\n"
1546 //" printf(\"library checker running\\\\n\");\n"
1547 " return 0;\n"
1548 "}\n";
1550 QString libs;
1551 if(!path.isEmpty())
1552 libs += QString("-L") + path + ' ';
1553 libs += QString("-l") + name;
1554 if(!doCompileAndLink(str, QStringList(), libs, QString()))
1555 return false;
1556 return true;
1559 bool Conf::findLibrary(const QString &name, QString *lib)
1561 if(checkLibrary("", name))
1563 *lib = "";
1564 return true;
1566 if(checkLibrary("/usr/local/lib", name))
1568 *lib = "/usr/local/lib";
1569 return true;
1571 return false;
1574 QString Conf::findProgram(const QString &prog)
1576 return qc_findprogram(prog);
1579 bool Conf::findSimpleLibrary(const QString &incvar, const QString &libvar, const QString &incname, const QString &libname, QString *incpath, QString *libs)
1581 QString inc, lib;
1582 QString s;
1584 s = getenv(incvar);
1585 if(!s.isEmpty()) {
1586 if(!checkHeader(s, incname))
1587 return false;
1588 inc = s;
1590 else {
1591 if(!findHeader(incname, QStringList(), &s))
1592 return false;
1593 inc = s;
1596 s = getenv(libvar);
1597 if(!s.isEmpty()) {
1598 if(!checkLibrary(s, libname))
1599 return false;
1600 lib = s;
1602 else {
1603 if(!findLibrary(libname, &s))
1604 return false;
1605 lib = s;
1608 QString lib_out;
1609 if(!lib.isEmpty())
1610 lib_out += QString("-L") + s;
1611 lib_out += QString("-l") + libname;
1613 *incpath = inc;
1614 *libs = lib_out;
1615 return true;
1618 bool Conf::findFooConfig(const QString &path, QString *version, QStringList *incs, QString *libs, QString *otherflags)
1620 QStringList args;
1621 QByteArray out;
1622 int ret;
1624 args += "--version";
1625 ret = doCommand(path, args, &out);
1626 if(ret != 0)
1627 return false;
1629 QString version_out = QString::fromLatin1(out).trimmed();
1631 args.clear();
1632 args += "--libs";
1633 ret = doCommand(path, args, &out);
1634 if(ret != 0)
1635 return false;
1637 QString libs_out = QString::fromLatin1(out).trimmed();
1639 args.clear();
1640 args += "--cflags";
1641 ret = doCommand(path, args, &out);
1642 if(ret != 0)
1643 return false;
1645 QString cflags = QString::fromLatin1(out).trimmed();
1647 QStringList incs_out, otherflags_out;
1648 qc_splitcflags(cflags, &incs_out, &otherflags_out);
1650 *version = version_out;
1651 *incs = incs_out;
1652 *libs = libs_out;
1653 *otherflags = otherflags_out.join(" ");
1654 return true;
1657 bool Conf::findPkgConfig(const QString &name, VersionMode mode, const QString &req_version, QString *version, QStringList *incs, QString *libs, QString *otherflags)
1659 QStringList args;
1660 QByteArray out;
1661 int ret;
1663 args += name;
1664 args += "--exists";
1665 ret = doCommand("pkg-config", args, &out);
1666 if(ret != 0)
1667 return false;
1669 if(mode != VersionAny)
1671 args.clear();
1672 args += name;
1673 if(mode == VersionMin)
1674 args += QString("--atleast-version=%1").arg(req_version);
1675 else if(mode == VersionMax)
1676 args += QString("--max-version=%1").arg(req_version);
1677 else
1678 args += QString("--exact-version=%1").arg(req_version);
1679 ret = doCommand("pkg-config", args, &out);
1680 if(ret != 0)
1681 return false;
1684 args.clear();
1685 args += name;
1686 args += "--modversion";
1687 ret = doCommand("pkg-config", args, &out);
1688 if(ret != 0)
1689 return false;
1691 QString version_out = QString::fromLatin1(out).trimmed();
1693 args.clear();
1694 args += name;
1695 args += "--libs";
1696 ret = doCommand("pkg-config", args, &out);
1697 if(ret != 0)
1698 return false;
1700 QString libs_out = QString::fromLatin1(out).trimmed();
1702 args.clear();
1703 args += name;
1704 args += "--cflags";
1705 ret = doCommand("pkg-config", args, &out);
1706 if(ret != 0)
1707 return false;
1709 QString cflags = QString::fromLatin1(out).trimmed();
1711 QStringList incs_out, otherflags_out;
1712 qc_splitcflags(cflags, &incs_out, &otherflags_out);
1714 *version = version_out;
1715 *incs = incs_out;
1716 *libs = libs_out;
1717 *otherflags = otherflags_out.join(" ");
1718 return true;
1721 void Conf::addDefine(const QString &str)
1723 if(DEFINES.isEmpty())
1724 DEFINES = str;
1725 else
1726 DEFINES += QString(" ") + str;
1727 debug(QString("DEFINES += %1").arg(str));
1730 void Conf::addLib(const QString &str)
1732 if(LIBS.isEmpty())
1733 LIBS = str;
1734 else
1735 LIBS += QString(" ") + str;
1736 debug(QString("LIBS += %1").arg(str));
1739 void Conf::addIncludePath(const QString &str)
1741 if(INCLUDEPATH.isEmpty())
1742 INCLUDEPATH = str;
1743 else
1744 INCLUDEPATH += QString(" ") + str;
1745 debug(QString("INCLUDEPATH += %1").arg(str));
1748 void Conf::addExtra(const QString &str)
1750 extra += str + '\n';
1751 debug(QString("extra += %1").arg(str));
1754 //----------------------------------------------------------------------------
1755 // main
1756 //----------------------------------------------------------------------------
1757 #include "conf4.moc"
1759 #ifdef HAVE_MODULES
1760 # include"modules.cpp"
1761 #endif
1763 int main()
1765 Conf *conf = new Conf;
1766 ConfObj *o;
1767 o = 0;
1768 #ifdef HAVE_MODULES
1769 # include"modules_new.cpp"
1770 #endif
1772 conf->debug_enabled = (qc_getenv("QC_VERBOSE") == "Y") ? true: false;
1773 if(conf->debug_enabled)
1774 printf(" -> ok\n");
1775 else
1776 printf("ok\n");
1778 QString confCommand = qc_getenv("QC_COMMAND");
1779 QString proName = qc_getenv("QC_PROFILE");
1780 conf->qmake_path = qc_getenv("QC_QMAKE");
1781 conf->qmakespec = qc_getenv("QC_QMAKESPEC");
1782 conf->maketool = qc_getenv("QC_MAKETOOL");
1784 if(conf->debug_enabled)
1785 printf("conf command: [%s]\n", qPrintable(confCommand));
1787 QString confPath = qc_findself(confCommand);
1788 if(confPath.isEmpty())
1790 printf("Error: cannot find myself; rerun with an absolute path\n");
1791 return 1;
1794 QString srcdir = QFileInfo(confPath).absolutePath();
1795 QString builddir = QDir::current().absolutePath();
1796 QString proPath = QDir(srcdir).filePath(proName);
1798 if(conf->debug_enabled)
1800 printf("conf path: [%s]\n", qPrintable(confPath));
1801 printf("srcdir: [%s]\n", qPrintable(srcdir));
1802 printf("builddir: [%s]\n", qPrintable(builddir));
1803 printf("profile: [%s]\n", qPrintable(proPath));
1804 printf("qmake path: [%s]\n", qPrintable(conf->qmake_path));
1805 printf("qmakespec: [%s]\n", qPrintable(conf->qmakespec));
1806 printf("make tool: [%s]\n", qPrintable(conf->maketool));
1807 printf("\n");
1810 bool success = false;
1811 if(conf->exec())
1813 QFile f("conf.pri");
1814 if(!f.open(QFile::WriteOnly | QFile::Truncate))
1816 printf("Error writing %s\n", qPrintable(f.fileName()));
1817 return 1;
1820 QString str;
1821 str += "# qconf\n\n";
1823 QString var;
1824 var = qc_getenv("PREFIX");
1825 if(!var.isEmpty())
1826 str += QString("PREFIX = %1\n").arg(var);
1827 var = qc_getenv("BINDIR");
1828 if(!var.isEmpty())
1829 str += QString("BINDIR = %1\n").arg(var);
1830 var = qc_getenv("INCDIR");
1831 if(!var.isEmpty())
1832 str += QString("INCDIR = %1\n").arg(var);
1833 var = qc_getenv("LIBDIR");
1834 if(!var.isEmpty())
1835 str += QString("LIBDIR = %1\n").arg(var);
1836 var = qc_getenv("DATADIR");
1837 if(!var.isEmpty())
1838 str += QString("DATADIR = %1\n").arg(var);
1839 str += '\n';
1841 if(qc_getenv("QC_STATIC") == "Y")
1842 str += "CONFIG += staticlib\n";
1844 // TODO: don't need this?
1845 //str += "QT_PATH_PLUGINS = " + QString(qInstallPathPlugins()) + '\n';
1847 if(!conf->DEFINES.isEmpty())
1848 str += "DEFINES += " + conf->DEFINES + '\n';
1849 if(!conf->INCLUDEPATH.isEmpty())
1850 str += "INCLUDEPATH += " + conf->INCLUDEPATH + '\n';
1851 if(!conf->LIBS.isEmpty())
1852 str += "LIBS += " + conf->LIBS + '\n';
1853 if(!conf->extra.isEmpty())
1854 str += conf->extra;
1855 str += '\n';
1857 QByteArray cs = str.toLatin1();
1858 f.write(cs);
1859 f.close();
1860 success = true;
1862 QString qmake_path = conf->qmake_path;
1863 QString qmakespec = conf->qmakespec;
1864 delete conf;
1866 if(!success)
1867 return 1;
1869 // run qmake on the project file
1870 QStringList args;
1871 if(!qmakespec.isEmpty())
1873 args += "-spec";
1874 args += qmakespec;
1876 args += proPath;
1877 int ret = qc_runprogram(qmake_path, args, 0, true);
1878 if(ret != 0)
1879 return 1;
1881 return 0;
1885 cat >$1/conf4.pro <<EOT
1886 CONFIG += console
1887 CONFIG -= app_bundle
1888 QT -= gui
1889 TARGET = conf
1891 HEADERS += conf4.h
1892 SOURCES += conf4.cpp
1895 DEFINES += HAVE_MODULES
1900 export EX_QTDIR
1901 export QC_STATIC
1902 export QC_RELEASE
1903 export QC_DEBUG
1904 export QC_DEBUG_AND_RELEASE
1905 export QC_NO_SEPARATE_DEBUG_INFO
1906 export QC_SEPARATE_DEBUG_INFO
1907 export QC_NO_FRAMEWORK
1908 export QC_FRAMEWORK
1909 export QC_UNIVERSAL
1910 export QC_MAC_SDK
1911 export QC_DISABLE_TESTS
1912 export QC_WITH_QCA
1913 export QC_WITH_ZLIB_INC
1914 export QC_WITH_ZLIB_LIB
1915 export QC_VERBOSE
1916 rm -rf .qconftemp
1918 mkdir .qconftemp
1919 gen_files .qconftemp
1920 cd .qconftemp
1921 if [ ! -z "$qm_spec" ]; then
1922 $qm -spec $qm_spec conf4.pro >/dev/null
1923 else
1924 $qm conf4.pro >/dev/null
1926 $MAKE clean >/dev/null 2>&1
1927 $MAKE >../conf.log 2>&1
1930 if [ "$?" != "0" ]; then
1931 rm -rf .qconftemp
1932 if [ "$QC_VERBOSE" = "Y" ]; then
1933 echo " -> fail"
1934 else
1935 echo "fail"
1937 printf "\n"
1938 printf "Reason: There was an error compiling 'conf'. See conf.log for details.\n"
1939 printf "\n"
1940 show_qt_info
1941 if [ "$QC_VERBOSE" = "Y" ]; then
1942 echo "conf.log:"
1943 cat conf.log
1945 exit 1;
1948 QC_COMMAND=$0
1949 export QC_COMMAND
1950 QC_PROFILE=iris.pro
1951 export QC_PROFILE
1952 QC_QMAKE=$qm
1953 export QC_QMAKE
1954 QC_QMAKESPEC=$qm_spec
1955 export QC_QMAKESPEC
1956 QC_MAKETOOL=$MAKE
1957 export QC_MAKETOOL
1958 .qconftemp/conf
1959 ret="$?"
1960 if [ "$ret" = "1" ]; then
1961 rm -rf .qconftemp
1962 echo
1963 exit 1;
1964 else
1965 if [ "$ret" != "0" ]; then
1966 rm -rf .qconftemp
1967 if [ "$QC_VERBOSE" = "Y" ]; then
1968 echo " -> fail"
1969 else
1970 echo "fail"
1972 echo
1973 echo "Reason: Unexpected error launching 'conf'"
1974 echo
1975 exit 1;
1978 rm -rf .qconftemp
1980 echo
1981 echo "Good, your configure finished. Now run $MAKE."
1982 echo