3 # Generated by qconf 1.5 ( http://delta.affinix.com/qconf/ )
10 This script creates necessary configuration files to build/install.
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.
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
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.
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
42 # which/make detection adapted from Qt
48 WHICH
=`which which 2>/dev/null`
49 if echo $WHICH |
grep 'shell built-in command' >/dev
/null
2>&1; then
51 elif [ -z "$WHICH" ]; then
52 if which which >/dev
/null
2>&1; then
55 for a
in /usr
/ucb
/usr
/bin
/bin
/usr
/local
/bin
; do
56 if [ -x $a/which ]; then
64 if [ -z "$WHICH" ]; then
80 a
=`"$WHICH" "$1" 2>/dev/null`
81 if [ ! -z "$a" -a -x "$a" ]; then
95 if [ -z "$MAKE" ]; then
97 for mk
in gmake
make; do
98 if $WHICH $mk >/dev
/null
2>&1; then
103 if [ -z "$MAKE" ]; then
104 echo "You don't seem to have 'make' or 'gmake' in your PATH."
105 echo "Cannot proceed."
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"
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"
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"
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"
131 while [ $# -gt 0 ]; do
132 optarg
=`expr "x$1" : 'x[^=]*=\(.*\)'`
155 QC_DEBUG_AND_RELEASE
="Y"
159 --no-separate-debug-info)
160 QC_NO_SEPARATE_DEBUG_INFO
="Y"
164 --separate-debug-info)
165 QC_SEPARATE_DEBUG_INFO
="Y"
200 QC_WITH_ZLIB_INC
=$optarg
205 QC_WITH_ZLIB_LIB
=$optarg
213 --help) show_usage
; exit ;;
214 *) show_usage
; exit ;;
219 echo "Configuring Iris ..."
221 if [ "$QC_VERBOSE" = "Y" ]; then
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
241 printf "Verifying Qt 4 build environment ... "
243 # run qmake -v and check version
246 if echo `$1 -v 2>&1` |
grep "Qt version 4\." >/dev
/null
2>&1; then
248 elif [ "$QC_VERBOSE" = "Y" ]; then
249 echo "Warning: $1 not for Qt 4"
255 if [ "$QC_VERBOSE" = "Y" ]; then
260 names
="qmake-qt4 qmake4 qmake"
263 if [ -z "$qm" ] && [ ! -z "$EX_QTDIR" ]; then
265 qstr
=$EX_QTDIR/bin
/$n
266 if qmake_check_v4
"$qstr"; then
272 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
273 echo "Warning: qmake not found via --qtdir"
277 if [ -z "$qm" ] && [ ! -z "$QTDIR" ]; then
280 if qmake_check_v4
"$qstr"; then
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
296 if qmake_check_v4
"$qstr"; then
303 if [ -z "$qm" ] && [ "$QC_VERBOSE" = "Y" ]; then
304 echo "Warning: qmake not found via pkg-config"
308 if [ -z "$qm" ]; then
310 qstr
=`$WHICH $n 2>/dev/null`
311 if qmake_check_v4
"$qstr"; then
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
328 printf "Reason: Unable to find the 'qmake' tool for Qt 4.\n"
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
356 # if the makespec is macx-xcode, force macx-g++
357 if [ "$defmakespec" = "macx-xcode" ]; then
361 if [ "$QC_VERBOSE" = "Y" ]; then
362 echo overriding makespec to
$qm_spec
367 cat >$1/modules.cpp
<<EOT
370 -----BEGIN QCMOD-----
374 class qc_qt42 : public ConfObj
377 qc_qt42(Conf *c) : ConfObj(c) {}
378 QString name() const { return "Qt >= 4.2"; }
379 QString shortname() const { return "qt42"; }
382 conf->debug(QString("QT_VERSION = 0x%1").arg(QString::number(QT_VERSION, 16)));
383 if(QT_VERSION >= 0x040200)
389 #line 1 "buildmode.qcm"
391 -----BEGIN QCMOD-----
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).
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
413 qc_buildmode(Conf *c) : ConfObj(c) {}
414 QString name() const { return "buildmode"; }
415 QString shortname() const { return "buildmode"; }
418 QString checkString() const { return QString(); }
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")
433 if(conf->getenv("QC_DEBUG") == "Y")
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")
451 if(opt_debug_and_release)
453 printf("\nError: The --debug-and-release option is for mac only.\n");
459 printf("\nError: The --framework option is for mac only.\n");
464 if(opt_framework && opt_debug)
466 printf("\nError: Cannot use both --framework and --debug.\n");
470 // sanity check exclusive options
479 if(opt_debug_and_release)
483 printf("\nError: Use only one of --release, --debug, or --debug-and-release.\n");
488 if(opt_framework && staticmode)
490 printf("\nError: Cannot use both --framework and --static.\n");
501 printf("\nError: Use only one of --framework or --no-framework.\n");
507 if(opt_no_separate_debug_info)
509 if(opt_separate_debug_info)
513 printf("\nError: Use only one of --separate-debug-info or --no-separate-debug-info\n");
517 // now process the options
520 qc_buildmode_release = true;
522 qc_buildmode_debug = true;
523 else if(opt_debug_and_release)
525 qc_buildmode_release = true;
526 qc_buildmode_debug = true;
529 qc_buildmode_release = true;
532 qc_buildmode_framework = true;
533 else if(opt_no_framework)
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)
552 qc_buildmode_separate_debug_info = true;
560 if(qc_buildmode_release && qc_buildmode_debug)
562 opts += "debug_and_release";
565 else if(qc_buildmode_release)
567 else // qc_buildmode_debug
571 if(qc_buildmode_framework)
572 opts += "lib_bundle";
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';
586 conf->addExtra(other);
591 #line 1 "universal.qcm"
593 -----BEGIN QCMOD-----
594 name: Mac universal binary support
596 arg: universal,Build with Mac universal binary support.
597 arg: mac-sdk=[path],Path to Mac universal SDK (PPC host only).
602 bool qc_universal_enabled = false;
603 QString qc_universal_sdk;
605 //----------------------------------------------------------------------------
607 //----------------------------------------------------------------------------
608 class qc_universal : public ConfObj
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(); }
619 if(qc_getenv("QC_UNIVERSAL") == "Y")
621 qc_universal_enabled = true;
624 "contains(QT_CONFIG,x86):contains(QT_CONFIG,ppc) {\n"
625 " CONFIG += x86 ppc\n"
628 QString sdk = qc_getenv("QC_MAC_SDK");
631 str += QString("QMAKE_MAC_SDK = %1\n").arg(sdk);
632 qc_universal_sdk = sdk;
643 -----BEGIN QCMOD-----
645 arg: with-qca=[path],Specify path to QCA tree, mainly for building against an uninstalled QCA.
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(
660 "# on mac, if qca was built as a framework, link against it\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"
671 "# else, link normally\n"
672 "isEmpty(LINKAGE) {\n"
673 " INCLUDEPATH += \$\$QCA_INCDIR/QtCrypto\n"
674 " LIBS += -L\$\$QCA_LIBDIR\n"
676 " CONFIG(debug, debug|release) {\n"
677 " windows:LINKAGE = -lqcad\n"
678 " mac:LINKAGE = -lqca_debug\n"
682 "LIBS += \$\$LINKAGE\n"
683 ).arg(incdir, libdir);
688 QString qc_qca_procode;
690 //----------------------------------------------------------------------------
692 //----------------------------------------------------------------------------
693 class qc_qca : public ConfObj
696 qc_qca(Conf *c) : ConfObj(c) {}
697 QString name() const { return "QCA >= 2.0"; }
698 QString shortname() const { return "qca"; }
701 // get the build mode
703 bool release = qc_buildmode_release;
704 bool debug = qc_buildmode_debug;
706 // else, default to just release mode
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");
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);
723 proextra += qca_crypto_prf;
726 "CONFIG += qt crypto\n"
731 "#include <QtCrypto>\n"
735 " unsigned long x = QCA_VERSION;\n"
736 " if(x >= 0x020000 && x < 0x030000) return 0; else return 1;\n"
742 if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra + "CONFIG += release\n", &ret))
751 if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra + "CONFIG += debug\n", &ret))
757 if(!qca_prefix.isEmpty())
758 str = qca_crypto_prf;
760 str = "CONFIG += crypto\n";
762 qc_qca_procode = str;
770 -----BEGIN QCMOD-----
772 arg: with-zlib-inc=[path],Path to zlib include files
773 arg: with-zlib-lib=[path],Path to zlib library files
777 //----------------------------------------------------------------------------
779 //----------------------------------------------------------------------------
780 class qc_zlib : public ConfObj
783 qc_zlib(Conf *c) : ConfObj(c) {}
784 QString name() const { return "zlib"; }
785 QString shortname() const { return "zlib"; }
791 s = conf->getenv("QC_WITH_ZLIB_INC");
793 if(!conf->checkHeader(s, "zlib.h"))
798 if(!conf->findHeader("zlib.h", QStringList(), &s))
803 s = conf->getenv("QC_WITH_ZLIB_LIB");
805 if(!conf->checkLibrary(s, "z"))
810 if(!conf->findLibrary("z", &s))
816 conf->addIncludePath(inc);
818 conf->addLib(QString("-L") + s);
826 -----BEGIN QCMOD-----
829 arg: disable-tests,Don't build examples and unittests.
833 class qc_extra : public ConfObj
836 qc_extra(Conf *c) : ConfObj(c) {}
837 QString name() const { return "extra"; }
838 QString shortname() const { return "extra"; }
841 QString checkString() const { return QString(); }
848 if(conf->getenv("QC_DISABLE_TESTS") == "Y")
849 str += "CONFIG += no_tests\n";
855 bool debug_info = false;
856 bool universal = false;
860 release = qc_buildmode_release;
861 debug = qc_buildmode_debug;
862 debug_info = qc_buildmode_separate_debug_info;
866 universal = qc_universal_enabled;
867 sdk = qc_universal_sdk;
870 // write confapp_unix.pri
872 QString var = conf->getenv("BINDIR");
874 str += QString("BINDIR = %1\n").arg(var);
875 if(debug) // debug or debug-and-release
876 str += QString("CONFIG += debug\n");
878 str += QString("CONFIG += release\n");
881 str += QString("CONFIG += separate_debug_info\n");
882 str += "QMAKE_CFLAGS += -g\n";
883 str += "QMAKE_CXXFLAGS += -g\n";
888 "contains(QT_CONFIG,x86):contains(QT_CONFIG,ppc) {\n"
889 " CONFIG += x86 ppc\n"
893 str += QString("QMAKE_MAC_SDK = %1\n").arg(sdk);
896 if(!qc_qca_procode.isEmpty())
897 str += qc_qca_procode;
899 f.setFileName("confapp_unix.pri");
900 if(f.open(QFile::WriteOnly | QFile::Truncate))
901 f.write(str.toLatin1());
907 QString makeEscapedDefine(const QString &var, const QString &val)
909 QString str = QString(
910 "DEFINES += %1=\\\\\\\\\\\\\\"%2\\\\\\\\\\\\\\"\n"
917 cat >$1/modules_new.cpp
<<EOT
918 o = new qc_qt42(conf);
921 o = new qc_buildmode(conf);
924 o = new qc_universal(conf);
927 o = new qc_qca(conf);
930 o = new qc_zlib(conf);
933 o = new qc_extra(conf);
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
954 enum VersionMode { VersionMin, VersionExact, VersionMax, VersionAny };
958 // Subclass ConfObj to create a new configuration module.
970 // long or descriptive name of what is being checked/performed
971 // example: "KDE >= 3.3"
972 virtual QString name() const = 0;
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;
992 // Interact with this class from your ConfObj to perform detection
993 // operations and to output configuration parameters.
1003 QString INCLUDEPATH;
1007 QList<ConfObj*> list;
1008 QMap<QString,QString> vars;
1013 QString getenv(const QString &var);
1014 QString qvar(const QString &s);
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);
1044 friend class ConfObj;
1045 void added(ConfObj *o);
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
1065 class MocTestObject : public QObject
1072 QString qc_getenv(const QString &var)
1074 char *p = ::getenv(var.toLatin1().data());
1080 QStringList qc_pathlist()
1083 QString path = qc_getenv("PATH");
1085 list = path.split(':', QString::SkipEmptyParts);
1089 QString qc_findprogram(const QString &prog)
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();
1105 QString qc_findself(const QString &argv0)
1107 if(argv0.contains('/'))
1110 return qc_findprogram(argv0);
1113 int qc_runcommand(const QString &command, QByteArray *out, bool showOutput)
1115 QString fullcmd = command;
1117 fullcmd += " 2>/dev/null";
1118 FILE *f = popen(fullcmd.toLatin1().data(), "r");
1125 char c = (char)fgetc(f);
1133 int ret = pclose(f);
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
1151 process.setReadChannelMode(ForwardedChannels);
1152 process.start(prog, args);
1153 process.waitForFinished(-1);
1154 return process.exitCode();
1158 bool qc_removedir(const QString &dirPath)
1163 QStringList list = dir.entryList();
1164 foreach(QString s, list)
1166 if(s == "." || s == "..")
1168 QFileInfo fi(dir.filePath(s));
1171 if(!qc_removedir(fi.filePath()))
1180 QString dirName = dir.dirName();
1183 if(!dir.rmdir(dirName))
1188 void qc_splitcflags(const QString &cflags, QStringList *incs, QStringList *otherflags)
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));
1204 // we want whatever is left
1205 otherflags->append(str);
1210 QString qc_escapeArg(const QString &str)
1213 for(int n = 0; n < (int)str.length(); ++n) {
1222 //----------------------------------------------------------------------------
1224 //----------------------------------------------------------------------------
1225 ConfObj::ConfObj(Conf *c)
1238 QString ConfObj::checkString() const
1240 return QString("Checking for %1 ...").arg(name());
1243 QString ConfObj::resultString() const
1251 //----------------------------------------------------------------------------
1252 // qc_internal_pkgconfig
1253 //----------------------------------------------------------------------------
1254 class qc_internal_pkgconfig : public ConfObj
1257 QString pkgname, desc;
1261 qc_internal_pkgconfig(Conf *c, const QString &_name, const QString &_desc, VersionMode _mode, const QString &_req_ver) : ConfObj(c)
1269 QString name() const { return desc; }
1270 QString shortname() const { return pkgname; }
1275 QString version, libs, other;
1276 if(!conf->findPkgConfig(pkgname, mode, req_ver, &version, &incs, &libs, &other))
1279 for(int n = 0; n < incs.count(); ++n)
1280 conf->addIncludePath(incs[n]);
1283 //if(!other.isEmpty())
1284 // conf->addExtra(QString("QMAKE_CFLAGS += %1\n").arg(other));
1289 //----------------------------------------------------------------------------
1291 //----------------------------------------------------------------------------
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;
1308 void Conf::added(ConfObj *o)
1313 QString Conf::getenv(const QString &var)
1315 return qc_getenv(var);
1318 void Conf::debug(const QString &s)
1324 first_debug = false;
1325 printf(" * %s\n", qPrintable(s));
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
1338 QString v = QString("QC_ENABLE_") + qc_escapeArg(o->shortname());
1339 if(getenv(v) != "Y")
1342 // and the opposite?
1345 QString v = QString("QC_DISABLE_") + qc_escapeArg(o->shortname());
1346 if(getenv(v) == "Y")
1351 QString check = o->checkString();
1357 printf("%s", check.toLatin1().data());
1362 bool ok = o->exec();
1367 QString result = o->resultString();
1369 printf(" -> %s\n", result.toLatin1().data());
1371 printf(" %s\n", result.toLatin1().data());
1374 if(!ok && o->required)
1376 printf("\nError: need %s!\n", o->name().toLatin1().data());
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));
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));
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");
1426 QDir dir(tmp.filePath("atest"));
1429 debug("atest dir does not exist");
1433 QString fname = dir.filePath("atest.cpp");
1434 QString out = "atest";
1436 if(!f.open(QFile::WriteOnly | QFile::Truncate))
1438 debug("unable to open atest.cpp for writing");
1441 if(f.write(filedata.toLatin1()) == -1)
1443 debug("error writing to atest.cpp");
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(" ");
1456 pro += "INCLUDEPATH += " + inc + '\n';
1458 pro += "LIBS += " + libs + '\n';
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");
1468 if(f.write(pro.toLatin1()) == -1)
1470 debug("error writing to atest.pro");
1475 debug(QString("Wrote atest.pro:\n%1").arg(pro));
1477 QString oldpath = QDir::currentPath();
1478 QDir::setCurrent(dir.path());
1481 int r = doCommand(qmake_path, QStringList() << "atest.pro");
1484 r = doCommand(maketool, QStringList());
1489 *retcode = doCommand(QString("./") + out, QStringList());
1491 r = doCommand(maketool, QStringList() << "distclean");
1493 debug("error during atest distclean");
1496 QDir::setCurrent(oldpath);
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"));
1511 bool Conf::checkHeader(const QString &path, const QString &h)
1513 QFileInfo fi(path + '/' + h);
1519 bool Conf::findHeader(const QString &h, const QStringList &ext, QString *inc)
1521 if(checkHeader("/usr/include", h))
1527 dirs += "/usr/local/include";
1529 for(QStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it)
1531 if(checkHeader(*it, h))
1540 bool Conf::checkLibrary(const QString &path, const QString &name)
1543 //"#include <stdio.h>\n"
1546 //" printf(\"library checker running\\\\n\");\n"
1552 libs += QString("-L") + path + ' ';
1553 libs += QString("-l") + name;
1554 if(!doCompileAndLink(str, QStringList(), libs, QString()))
1559 bool Conf::findLibrary(const QString &name, QString *lib)
1561 if(checkLibrary("", name))
1566 if(checkLibrary("/usr/local/lib", name))
1568 *lib = "/usr/local/lib";
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)
1586 if(!checkHeader(s, incname))
1591 if(!findHeader(incname, QStringList(), &s))
1598 if(!checkLibrary(s, libname))
1603 if(!findLibrary(libname, &s))
1610 lib_out += QString("-L") + s;
1611 lib_out += QString("-l") + libname;
1618 bool Conf::findFooConfig(const QString &path, QString *version, QStringList *incs, QString *libs, QString *otherflags)
1624 args += "--version";
1625 ret = doCommand(path, args, &out);
1629 QString version_out = QString::fromLatin1(out).trimmed();
1633 ret = doCommand(path, args, &out);
1637 QString libs_out = QString::fromLatin1(out).trimmed();
1641 ret = doCommand(path, args, &out);
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;
1653 *otherflags = otherflags_out.join(" ");
1657 bool Conf::findPkgConfig(const QString &name, VersionMode mode, const QString &req_version, QString *version, QStringList *incs, QString *libs, QString *otherflags)
1665 ret = doCommand("pkg-config", args, &out);
1669 if(mode != VersionAny)
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);
1678 args += QString("--exact-version=%1").arg(req_version);
1679 ret = doCommand("pkg-config", args, &out);
1686 args += "--modversion";
1687 ret = doCommand("pkg-config", args, &out);
1691 QString version_out = QString::fromLatin1(out).trimmed();
1696 ret = doCommand("pkg-config", args, &out);
1700 QString libs_out = QString::fromLatin1(out).trimmed();
1705 ret = doCommand("pkg-config", args, &out);
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;
1717 *otherflags = otherflags_out.join(" ");
1721 void Conf::addDefine(const QString &str)
1723 if(DEFINES.isEmpty())
1726 DEFINES += QString(" ") + str;
1727 debug(QString("DEFINES += %1").arg(str));
1730 void Conf::addLib(const QString &str)
1735 LIBS += QString(" ") + str;
1736 debug(QString("LIBS += %1").arg(str));
1739 void Conf::addIncludePath(const QString &str)
1741 if(INCLUDEPATH.isEmpty())
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 //----------------------------------------------------------------------------
1756 //----------------------------------------------------------------------------
1757 #include "conf4.moc"
1760 # include"modules.cpp"
1765 Conf *conf = new Conf;
1769 # include"modules_new.cpp"
1772 conf->debug_enabled = (qc_getenv("QC_VERBOSE") == "Y") ? true: false;
1773 if(conf->debug_enabled)
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");
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));
1810 bool success = false;
1813 QFile f("conf.pri");
1814 if(!f.open(QFile::WriteOnly | QFile::Truncate))
1816 printf("Error writing %s\n", qPrintable(f.fileName()));
1821 str += "# qconf\n\n";
1824 var = qc_getenv("PREFIX");
1826 str += QString("PREFIX = %1\n").arg(var);
1827 var = qc_getenv("BINDIR");
1829 str += QString("BINDIR = %1\n").arg(var);
1830 var = qc_getenv("INCDIR");
1832 str += QString("INCDIR = %1\n").arg(var);
1833 var = qc_getenv("LIBDIR");
1835 str += QString("LIBDIR = %1\n").arg(var);
1836 var = qc_getenv("DATADIR");
1838 str += QString("DATADIR = %1\n").arg(var);
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())
1857 QByteArray cs = str.toLatin1();
1862 QString qmake_path = conf->qmake_path;
1863 QString qmakespec = conf->qmakespec;
1869 // run qmake on the project file
1871 if(!qmakespec.isEmpty())
1877 int ret = qc_runprogram(qmake_path, args, 0, true);
1885 cat >$1/conf4.pro
<<EOT
1887 CONFIG -= app_bundle
1892 SOURCES += conf4.cpp
1895 DEFINES += HAVE_MODULES
1904 export QC_DEBUG_AND_RELEASE
1905 export QC_NO_SEPARATE_DEBUG_INFO
1906 export QC_SEPARATE_DEBUG_INFO
1907 export QC_NO_FRAMEWORK
1911 export QC_DISABLE_TESTS
1913 export QC_WITH_ZLIB_INC
1914 export QC_WITH_ZLIB_LIB
1919 gen_files .qconftemp
1921 if [ ! -z "$qm_spec" ]; then
1922 $qm -spec $qm_spec conf4.pro
>/dev
/null
1924 $qm conf4.pro
>/dev
/null
1926 $MAKE clean
>/dev
/null
2>&1
1927 $MAKE >..
/conf.log
2>&1
1930 if [ "$?" != "0" ]; then
1932 if [ "$QC_VERBOSE" = "Y" ]; then
1938 printf "Reason: There was an error compiling 'conf'. See conf.log for details.\n"
1941 if [ "$QC_VERBOSE" = "Y" ]; then
1954 QC_QMAKESPEC
=$qm_spec
1960 if [ "$ret" = "1" ]; then
1965 if [ "$ret" != "0" ]; then
1967 if [ "$QC_VERBOSE" = "Y" ]; then
1973 echo "Reason: Unexpected error launching 'conf'"
1981 echo "Good, your configure finished. Now run $MAKE."