5
Usage: ./configure [OPTION]...
7
This script creates necessary configuration files to build/install.
10
--prefix=[path] Base path for build/install. Default: /usr/local
11
--bindir=[path] Directory for binaries. Default: PREFIX/bin
12
--libdir=[path] Directory for libraries. Default: PREFIX/share/psi
13
--qtdir=[path] Directory where Qt is installed.
14
--debug Enable debug output.
15
--help This help text.
18
--with-zlib-inc=[path] Path to zlib include files
19
--with-zlib-lib=[path] Path to zlib library files
20
--disable-xss Disable use of the XScreenSaver extension
21
--disable-dnotify Disable use of Linux Directory Notification
22
--disable-ghbnr Disable use of gethostbyname_r()
23
--disable-kde Disable use of KDE
28
while [ $# -gt 0 ]; do
31
PREFIX="${1#--prefix=}"
36
BINDIR="${1#--bindir=}"
41
LIBDIR="${1#--libdir=}"
51
QC_WITH_ZLIB_INC="${1#--with-zlib-inc=}"
56
QC_WITH_ZLIB_LIB="${1#--with-zlib-lib=}"
66
QC_DISABLE_dnotify="Y"
84
--help) show_usage; exit ;;
85
*) show_usage; exit ;;
89
PREFIX=${PREFIX:-/usr/local}
90
BINDIR=${BINDIR:-$PREFIX/bin}
91
LIBDIR=${LIBDIR:-$PREFIX/share/psi}
93
echo "Configuring Psi ..."
95
if [ "$QC_DEBUG" = "Y" ]; then
101
echo QC_WITH_ZLIB_INC=$QC_WITH_ZLIB_INC
102
echo QC_WITH_ZLIB_LIB=$QC_WITH_ZLIB_LIB
103
echo QC_DISABLE_xss=$QC_DISABLE_xss
104
echo QC_DISABLE_dnotify=$QC_DISABLE_dnotify
105
echo QC_DISABLE_ghbnr=$QC_DISABLE_ghbnr
106
echo QC_DISABLE_kde=$QC_DISABLE_kde
110
printf "Verifying Qt 3.x Multithreaded (MT) build environment ... "
112
if [ -z "$QTDIR" ]; then
113
if [ "$QC_DEBUG" = "Y" ]; then
114
echo \$QTDIR not set... trying to find Qt manually
116
for p in /usr/lib/qt /usr/share/qt /usr/share/qt3 /usr/local/lib/qt /usr/local/share/qt /usr/lib/qt3 /usr/local/lib/qt3 /usr/X11R6/share/qt /usr/qt/3 ; do
117
if [ -d "$p/mkspecs" ]; then
122
if [ -z "$QTDIR" ]; then
125
echo "Unable to find Qt 'mkspecs'. Perhaps you need to"
126
echo "install the Qt 3 development utilities. You may download"
127
echo "them either from the vendor of your operating system"
128
echo "or from http://www.trolltech.com/"
130
echo "If you're sure you have the Qt development utilities"
131
echo "installed, you might try using the --qtdir option."
135
if [ ! -x "$QTDIR/bin/moc" ]; then
136
m=`which moc 2>/dev/null`
137
if [ ! -x "$m" ]; then
140
echo "We found Qt in $QTDIR, but we were unable to locate"
141
echo "the moc utility. It was not found in $QTDIR/bin"
142
echo "nor in PATH. This seems to be a very unusual setup."
143
echo "You might try using the --qtdir option."
147
qtpre=`echo $m | awk '{ n = index($0, "/bin/moc"); if (!n) { exit 1; } print substr($0, 0, n-1); exit 0; }' 2>/dev/null`
149
if [ "$ret" != "0" ]; then
152
echo "We found Qt in $QTDIR, but the location of moc"
153
echo "($m) is not suitable for use with this build system."
154
echo "This is a VERY unusual and likely-broken setup. You"
155
echo "should contact the maintainer of your Qt package."
163
if [ ! -x "$QTDIR/bin/qmake" ]; then
164
if [ "$QC_DEBUG" = "Y" ]; then
165
echo Warning: qmake not in \$QTDIR/bin/qmake
166
echo trying to find it in \$PATH
168
qm=`which qmake 2>/dev/null`
169
if [ -x "$qm" ]; then
170
if [ "$QC_DEBUG" = "Y" ]; then
171
echo qmake found in $qm
176
echo Sorry, you seem to have a very unusual setup,
177
echo or I missdetected \$QTDIR=$QTDIR
179
echo Please set \$QTDIR manually and make sure that
180
echo \$QTDIR/bin/qmake exists.
189
cat >$1/modules.cpp <<EOT
192
-----BEGIN QCMOD-----
196
class qc_qt31 : public ConfObj
199
qc_qt31(Conf *c) : ConfObj(c) {}
200
QString name() const { return "Qt >= 3.1"; }
201
QString shortname() const { return "qt31"; }
204
if(QT_VERSION >= 0x030100) {
205
if(QT_VERSION < 0x030300)
206
conf->addExtra("QXML_STATIC = Y");
215
-----BEGIN QCMOD-----
217
arg: with-zlib-inc=[path],Path to zlib include files
218
arg: with-zlib-lib=[path],Path to zlib library files
222
//----------------------------------------------------------------------------
224
//----------------------------------------------------------------------------
225
class qc_zlib : public ConfObj
228
qc_zlib(Conf *c) : ConfObj(c) {}
229
QString name() const { return "zlib"; }
230
QString shortname() const { return "zlib"; }
236
s = conf->getenv("QC_WITH_ZLIB_INC");
238
if(!conf->checkHeader(s, "zlib.h"))
243
if(!conf->findHeader("zlib.h", QStringList(), &s))
248
s = conf->getenv("QC_WITH_ZLIB_LIB");
250
if(!conf->checkLibrary(s, "z"))
255
if(!conf->findLibrary("z", &s))
261
conf->addIncludePath(inc);
263
conf->addLib(QString("-L") + s);
271
-----BEGIN QCMOD-----
272
name: the XScreenSaver extension
276
//----------------------------------------------------------------------------
278
//----------------------------------------------------------------------------
279
class qc_xss : public ConfObj
282
enum { OK, NEEDLIB, FAIL };
283
qc_xss(Conf *c) : ConfObj(c)
289
remove("xssprobe_test.c");
290
remove("xssprobe_test.o");
291
remove("xssprobe_test");
296
return "the XScreenSaver extension";
299
QString shortname() const { return "xss"; }
304
"#include<X11/Xlib.h>\n"
305
"#include<X11/Xutil.h>\n"
306
"#include<X11/extensions/scrnsaver.h>\n"
310
" XScreenSaverQueryExtension(NULL, NULL, NULL);\n"
315
f = fopen("xssprobe_test.c", "w");
318
fwrite(xsstest, strlen(xsstest), 1, f);
326
QString inc = conf->expandIncludes(conf->qvar("QMAKE_INCDIR_X11"));
327
QString str = conf->qvar("QMAKE_CC") + " -c " + inc + " xssprobe_test.c -o xssprobe_test.o";
328
int r = conf->doCommand(str);
337
QString lib = conf->expandLibs(conf->qvar("QMAKE_LIBDIR_X11"));
338
QString inc = conf->expandIncludes(conf->qvar("QMAKE_INCDIR_X11"));
339
QString str = conf->qvar("QMAKE_CC") + " xssprobe_test.o -o xssprobe_test " + lib + ' ' + conf->qvar("QMAKE_LIBS_X11");
340
int r = conf->doCommand(str);
349
QString lib = conf->expandLibs(conf->qvar("QMAKE_LIBDIR_X11"));
350
QString inc = conf->expandIncludes(conf->qvar("QMAKE_INCDIR_X11"));
351
QString str = conf->qvar("QMAKE_CC") + " xssprobe_test.o -o xssprobe_test " + lib + ' ' + conf->qvar("QMAKE_LIBS_X11") + " -lXss";
352
int r = conf->doCommand(str);
378
conf->addLib("-lXss");
382
conf->addDefine("NO_XSS");
387
#line 1 "dnotify.qcm"
389
-----BEGIN QCMOD-----
390
name: Linux Directory Notification
397
#include<sys/utsname.h>
399
//----------------------------------------------------------------------------
401
//----------------------------------------------------------------------------
402
class qc_dnotify : public ConfObj
405
qc_dnotify(Conf *c) : ConfObj(c)
415
QString name() const { return "Linux Directory Notification"; }
416
QString shortname() const { return "dnotify"; }
421
"#define _GNU_SOURCE\n"
422
"#include<unistd.h>\n"
423
"#include<fcntl.h>\n"
424
"#include<signal.h>\n"
425
"#include<sys/utsname.h>\n"
429
" DN_DELETE|DN_CREATE|DN_RENAME|DN_MULTISHOT|DN_MODIFY|DN_ATTRIB;\n"
434
f = fopen("ftest.c", "w");
437
fwrite(fdata, strlen(fdata), 1, f);
445
QString str = conf->qvar("QMAKE_CC") + " -c ftest.c -o ftest.o";
446
int r = conf->doCommand(str);
456
bool supports_dnotify = true; // not guilty until proven guilty
458
int major, minor, patch;
460
supports_dnotify = false; // *shrug*
461
else if(sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch) != 3)
462
supports_dnotify = false; // *shrug*
463
else if( major * 1000000 + minor * 1000 + patch < 2004019 ) // <2.4.19
464
supports_dnotify = false;
465
if(!supports_dnotify)
473
conf->addDefine("HAVE_DNOTIFY");
479
-----BEGIN QCMOD-----
480
name: gethostbyname_r()
483
class qc_ghbnr : public ConfObj
486
qc_ghbnr(Conf *c) : ConfObj(c)
496
QString name() const { return "gethostbyname_r()"; }
497
QString shortname() const { return "ghbnr"; }
502
"#include<netdb.h>\n"
506
" gethostbyname_r(\"\", 0, 0, 0, 0, 0);\n"
511
f = fopen("ftest.c", "w");
514
fwrite(fdata, strlen(fdata), 1, f);
517
QString str = conf->qvar("QMAKE_CC") + " ftest.c -o ftest";
518
int r = conf->doCommand(str);
520
conf->addDefine("HAVE_GETHOSTBYNAME_R");
529
-----BEGIN QCMOD-----
534
//----------------------------------------------------------------------------
536
//----------------------------------------------------------------------------
537
class qc_kde : public ConfObj
540
qc_kde(Conf *c) : ConfObj(c) {}
541
QString name() const { return "KDE"; }
542
QString shortname() const { return "kde"; }
545
char *p = getenv("KDEDIR");
549
conf->addExtra(QString("KDE = %1").arg(p));
555
cat >$1/modules_new.cpp <<EOT
556
o = new qc_qt31(conf);
559
o = new qc_zlib(conf);
562
o = new qc_xss(conf);
565
o = new qc_dnotify(conf);
568
o = new qc_ghbnr(conf);
571
o = new qc_kde(conf);
576
cat >$1/conf.cpp <<EOT
582
#include<qfileinfo.h>
585
#include<qstringlist.h>
588
class MocTestObject : public QObject
603
virtual QString name() const=0;
604
virtual QString shortname() const=0;
605
virtual QString checkString() const;
606
virtual QString resultString() const;
607
virtual bool exec()=0;
614
typedef QPtrList<ConfObj> ConfObjList;
615
typedef QPtrListIterator<ConfObj> ConfObjListIt;
622
list.setAutoDelete(true);
623
vars.setAutoDelete(true);
625
vars.insert("QMAKE_INCDIR_X11", new QString(X11_INC));
626
vars.insert("QMAKE_LIBDIR_X11", new QString(X11_LIBDIR));
627
vars.insert("QMAKE_LIBS_X11", new QString(X11_LIB));
628
vars.insert("QMAKE_CC", new QString(CC));
638
void added(ConfObj *o)
643
QString getenv(const QString &var)
645
char *p = ::getenv(var.latin1());
647
return QString::null;
651
void debug(const QString &s)
657
printf(" * %s\n", s.latin1());
663
if(getenv("QC_DEBUG") == "Y")
666
ConfObjListIt it(list);
667
for(ConfObj *o; (o = it.current()); ++it) {
668
// if this was a disabled-by-default option, check if it was enabled
670
QString v = QString("QC_ENABLE_") + o->shortname();
676
QString v = QString("QC_DISABLE_") + o->shortname();
681
QString check = o->checkString();
683
check = QString("Checking for %1 ...").arg(o->name());
684
printf("%s", check.latin1());
690
QString result = o->resultString();
691
if(result.isEmpty()) {
698
printf(" -> %s\n", result.latin1());
700
printf(" %s\n", result.latin1());
702
if(!ok && o->required) {
703
printf("\nError: need %s!\n", o->name().latin1());
710
const QString & qvar(const QString &s)
712
QString *p = vars.find(s);
719
QString expandIncludes(const QString &inc)
721
return QString("-I") + inc;
724
QString expandLibs(const QString &lib)
726
return QString("-L") + lib;
729
int doCommand(const QString &s)
731
debug(QString("[%1]").arg(s));
736
fullcmd = s + " 1>/dev/null 2>/dev/null";
737
int r = system(fullcmd.latin1());
738
debug(QString("returned: %1").arg(r));
742
bool doCompileAndLink(const QString &filedata, const QString &flags, int *retcode=0)
745
QString fname = "atest.c";
746
QString out = "atest";
748
QCString cs = filedata.latin1();
749
if(!f.open(IO_WriteOnly | IO_Truncate)) {
750
debug("unable to open atest.c for writing");
753
if(f.writeBlock(cs.data(), cs.length()) == -1) {
754
debug("error writing to atest.c");
759
debug(QString("Wrote atest.c:\n%1").arg(filedata));
761
QString str = qvar("QMAKE_CC") + ' ' + fname + " -o " + out;
762
if(!flags.isEmpty()) {
767
int r = doCommand(str);
768
if(r == 0 && retcode)
769
*retcode = doCommand(QString("./") + out);
777
bool checkHeader(const QString &path, const QString &h)
779
QFileInfo fi(path + '/' + h);
785
bool findHeader(const QString &h, const QStringList &ext, QString *inc)
787
if(checkHeader("/usr/include", h)) {
792
dirs += "/usr/local/include";
794
for(QStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it) {
795
if(checkHeader(*it, h)) {
803
bool checkLibrary(const QString &path, const QString &name)
813
extra += QString("-L") + path + ' ';
814
extra += QString("-l") + name;
815
if(!doCompileAndLink(str, extra))
820
bool findLibrary(const QString &name, QString *lib)
822
if(checkLibrary("", name)) {
826
if(checkLibrary("/usr/local/lib", name)) {
827
*lib = "/usr/local/lib";
833
void addDefine(const QString &str)
835
if(DEFINES.isEmpty())
838
DEFINES += QString(" ") + str;
839
debug(QString("DEFINES += %1").arg(str));
842
void addLib(const QString &str)
847
LIBS += QString(" ") + str;
848
debug(QString("LIBS += %1").arg(str));
851
void addIncludePath(const QString &str)
853
if(INCLUDEPATH.isEmpty())
856
INCLUDEPATH += QString(" ") + str;
857
debug(QString("INCLUDEPATH += %1").arg(str));
860
void addExtra(const QString &str)
863
debug(QString("extra += %1").arg(str));
875
bool do_debug, done_debug;
878
ConfObj::ConfObj(Conf *c)
890
QString ConfObj::checkString() const
895
QString ConfObj::resultString() const
900
#include"modules.cpp"
902
//----------------------------------------------------------------------------
904
//----------------------------------------------------------------------------
907
Conf *conf = new Conf;
910
#include"modules_new.cpp"
913
bool success = false;
916
if(!f.open(IO_WriteOnly | IO_Truncate)) {
917
printf("Error writing %s\n", f.name().latin1());
923
str += "QT_PATH_PLUGINS = " + QString(qInstallPathPlugins()) + '\n';
924
if(!conf->DEFINES.isEmpty())
925
str += "DEFINES += " + conf->DEFINES + '\n';
926
if(!conf->INCLUDEPATH.isEmpty())
927
str += "INCLUDEPATH += " + conf->INCLUDEPATH + '\n';
928
if(!conf->LIBS.isEmpty())
929
str += "LIBS += " + conf->LIBS + '\n';
930
if(!conf->extra.isEmpty())
934
char *p = getenv("BINDIR");
936
str += QString("target.path = ") + p + '\n';
937
str += "INSTALLS += target\n";
940
QCString cs = str.latin1();
941
f.writeBlock(cs.data(), cs.length());
957
cat >$1/conf.pro <<EOT
959
CONFIG += qt x11 thread console
962
DEFINES += X11_INC='"\$\$QMAKE_INCDIR_X11"'
963
DEFINES += X11_LIBDIR='"\$\$QMAKE_LIBDIR_X11"'
964
DEFINES += X11_LIB='"\$\$QMAKE_LIBS_X11"'
965
DEFINES += CC='"\$\$QMAKE_CC"'
976
export QC_WITH_ZLIB_INC
977
export QC_WITH_ZLIB_LIB
978
export QC_DISABLE_xss
979
export QC_DISABLE_dnotify
980
export QC_DISABLE_ghbnr
981
export QC_DISABLE_kde
988
$qm conf.pro >/dev/null
989
QTDIR=$QTDIR make clean >/dev/null 2>&1
990
QTDIR=$QTDIR make >../conf.log 2>&1
993
if [ "$?" != "0" ]; then
997
echo "There was an error compiling 'conf'. Be sure you have a proper"
998
echo "Qt 3.x Multithreaded (MT) build environment set up. This"
999
echo "means not just Qt, but also a C++ compiler, the 'make' command,"
1000
echo "and any other packages necessary to compile C++ programs."
1001
echo "See conf.log for details."
1002
if [ ! -f "$QTDIR/lib/libqt-mt.so.3" ]; then
1004
echo "One possible reason is that you don't have"
1005
echo "libqt-mt.so.3 installed in $QTDIR/lib/."
1013
if [ "$ret" = "1" ]; then
1018
if [ "$ret" != "0" ]; then
1022
echo Unexpected error launching 'conf'
1029
if [ -x "./qcextra" ]; then
1034
if [ "$?" != "0" ]; then
1038
cat >Makefile.tmp <<EOT
1039
export QTDIR = $QTDIR
1040
export PATH = $QTDIR/bin:$PATH
1042
cat Makefile >> Makefile.tmp
1044
cp -f Makefile.tmp Makefile
1048
echo Good, your configure finished. Now run \'make\'.