~ubuntu-branches/ubuntu/edgy/psi/edgy

« back to all changes in this revision

Viewing changes to configure

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2004-06-15 00:10:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040615001041-enywb6pcpe4sjsw6
Tags: 0.9.2-1
* New upstream release
* Set KDEDIR for ./configure so kde specific files get installed
* Don't install libpsiwidgets.so. It got installed in /usr/share
  where it doesn't belong. May be included (at a better location)
  later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
show_usage() {
 
4
cat <<EOT
 
5
Usage: ./configure [OPTION]...
 
6
 
 
7
This script creates necessary configuration files to build/install.
 
8
 
 
9
Main options:
 
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.
 
16
 
 
17
Dependency options:
 
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
 
24
 
 
25
EOT
 
26
}
 
27
 
 
28
while [ $# -gt 0 ]; do
 
29
        case "$1" in
 
30
                --prefix=*)
 
31
                        PREFIX="${1#--prefix=}"
 
32
                        shift
 
33
                        ;;
 
34
 
 
35
                --bindir=*)
 
36
                        BINDIR="${1#--bindir=}"
 
37
                        shift
 
38
                        ;;
 
39
 
 
40
                --libdir=*)
 
41
                        LIBDIR="${1#--libdir=}"
 
42
                        shift
 
43
                        ;;
 
44
 
 
45
                --qtdir=*)
 
46
                        QTDIR="${1#--qtdir=}"
 
47
                        shift
 
48
                        ;;
 
49
 
 
50
                --with-zlib-inc=*)
 
51
                        QC_WITH_ZLIB_INC="${1#--with-zlib-inc=}"
 
52
                        shift
 
53
                        ;;
 
54
 
 
55
                --with-zlib-lib=*)
 
56
                        QC_WITH_ZLIB_LIB="${1#--with-zlib-lib=}"
 
57
                        shift
 
58
                        ;;
 
59
 
 
60
                --disable-xss)
 
61
                        QC_DISABLE_xss="Y"
 
62
                        shift
 
63
                        ;;
 
64
 
 
65
                --disable-dnotify)
 
66
                        QC_DISABLE_dnotify="Y"
 
67
                        shift
 
68
                        ;;
 
69
 
 
70
                --disable-ghbnr)
 
71
                        QC_DISABLE_ghbnr="Y"
 
72
                        shift
 
73
                        ;;
 
74
 
 
75
                --disable-kde)
 
76
                        QC_DISABLE_kde="Y"
 
77
                        shift
 
78
                        ;;
 
79
 
 
80
                --debug)
 
81
                        QC_DEBUG="Y"
 
82
                        shift
 
83
                        ;;
 
84
                --help) show_usage; exit ;;
 
85
                *) show_usage; exit ;;
 
86
        esac
 
87
done
 
88
 
 
89
PREFIX=${PREFIX:-/usr/local}
 
90
BINDIR=${BINDIR:-$PREFIX/bin}
 
91
LIBDIR=${LIBDIR:-$PREFIX/share/psi}
 
92
 
 
93
echo "Configuring Psi ..."
 
94
 
 
95
if [ "$QC_DEBUG" = "Y" ]; then
 
96
echo
 
97
echo PREFIX=$PREFIX
 
98
echo BINDIR=$BINDIR
 
99
echo LIBDIR=$LIBDIR
 
100
echo QTDIR=$QTDIR
 
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
 
107
echo
 
108
fi
 
109
 
 
110
printf "Verifying Qt 3.x Multithreaded (MT) build environment ... "
 
111
 
 
112
if [ -z "$QTDIR" ]; then
 
113
        if [ "$QC_DEBUG" = "Y" ]; then
 
114
                echo \$QTDIR not set... trying to find Qt manually
 
115
        fi
 
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
 
118
                        QTDIR=$p
 
119
                        break;
 
120
                fi;
 
121
        done
 
122
        if [ -z "$QTDIR" ]; then
 
123
                echo fail
 
124
                echo
 
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/"
 
129
                echo
 
130
                echo "If you're sure you have the Qt development utilities"
 
131
                echo "installed, you might try using the --qtdir option."
 
132
                echo
 
133
                exit 1;
 
134
        fi
 
135
        if [ ! -x "$QTDIR/bin/moc" ]; then
 
136
                m=`which moc 2>/dev/null`
 
137
                if [ ! -x "$m" ]; then
 
138
                        echo fail
 
139
                        echo
 
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."
 
144
                        echo
 
145
                        exit 1;
 
146
                fi
 
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`
 
148
                ret="$?"
 
149
                if [ "$ret" != "0" ]; then
 
150
                        echo fail
 
151
                        echo
 
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."
 
156
                        echo
 
157
                        exit 1;
 
158
                fi
 
159
                QTDIR=$qtpre
 
160
        fi
 
161
fi
 
162
 
 
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
 
167
        fi
 
168
        qm=`which qmake 2>/dev/null`
 
169
        if [ -x "$qm" ]; then
 
170
                if [ "$QC_DEBUG" = "Y" ]; then
 
171
                        echo qmake found in $qm
 
172
                fi
 
173
        else
 
174
                echo fail
 
175
                echo
 
176
                echo Sorry, you seem to have a very unusual setup,
 
177
                echo or I missdetected \$QTDIR=$QTDIR
 
178
                echo
 
179
                echo Please set \$QTDIR manually and make sure that
 
180
                echo \$QTDIR/bin/qmake exists.
 
181
                echo
 
182
                exit 1;
 
183
        fi
 
184
else
 
185
        qm=$QTDIR/bin/qmake
 
186
fi
 
187
 
 
188
gen_files() {
 
189
cat >$1/modules.cpp <<EOT
 
190
#line 1 "qt31.qcm"
 
191
/*
 
192
-----BEGIN QCMOD-----
 
193
name: Qt >= 3.1
 
194
-----END QCMOD-----
 
195
*/
 
196
class qc_qt31 : public ConfObj
 
197
{
 
198
public:
 
199
        qc_qt31(Conf *c) : ConfObj(c) {}
 
200
        QString name() const { return "Qt >= 3.1"; }
 
201
        QString shortname() const { return "qt31"; }
 
202
        bool exec()
 
203
        {
 
204
                if(QT_VERSION >= 0x030100) {
 
205
                        if(QT_VERSION < 0x030300)
 
206
                                conf->addExtra("QXML_STATIC = Y");
 
207
                        return true;
 
208
                }
 
209
                else
 
210
                        return false;
 
211
        }
 
212
};
 
213
#line 1 "zlib.qcm"
 
214
/*
 
215
-----BEGIN QCMOD-----
 
216
name: zlib
 
217
arg: with-zlib-inc=[path],Path to zlib include files
 
218
arg: with-zlib-lib=[path],Path to zlib library files
 
219
-----END QCMOD-----
 
220
*/
 
221
 
 
222
//----------------------------------------------------------------------------
 
223
// qc_zlib
 
224
//----------------------------------------------------------------------------
 
225
class qc_zlib : public ConfObj
 
226
{
 
227
public:
 
228
        qc_zlib(Conf *c) : ConfObj(c) {}
 
229
        QString name() const { return "zlib"; }
 
230
        QString shortname() const { return "zlib"; }
 
231
        bool exec()
 
232
        {
 
233
                QString inc, lib;
 
234
                QString s;
 
235
 
 
236
                s = conf->getenv("QC_WITH_ZLIB_INC");
 
237
                if(!s.isEmpty()) {
 
238
                        if(!conf->checkHeader(s, "zlib.h"))
 
239
                                return false;
 
240
                        inc = s;
 
241
                }
 
242
                else {
 
243
                        if(!conf->findHeader("zlib.h", QStringList(), &s))
 
244
                                return false;
 
245
                        inc = s;
 
246
                }
 
247
 
 
248
                s = conf->getenv("QC_WITH_ZLIB_LIB");
 
249
                if(!s.isEmpty()) {
 
250
                        if(!conf->checkLibrary(s, "z"))
 
251
                                return false;
 
252
                        lib = s;
 
253
                }
 
254
                else {
 
255
                        if(!conf->findLibrary("z", &s))
 
256
                                return false;
 
257
                        lib = s;
 
258
                }
 
259
 
 
260
                if(!inc.isEmpty())
 
261
                        conf->addIncludePath(inc);
 
262
                if(!lib.isEmpty())
 
263
                        conf->addLib(QString("-L") + s);
 
264
                conf->addLib("-lz");
 
265
 
 
266
                return true;
 
267
        }
 
268
};
 
269
#line 1 "xss.qcm"
 
270
/*
 
271
-----BEGIN QCMOD-----
 
272
name: the XScreenSaver extension
 
273
-----END QCMOD-----
 
274
*/
 
275
 
 
276
//----------------------------------------------------------------------------
 
277
// qc_xss
 
278
//----------------------------------------------------------------------------
 
279
class qc_xss : public ConfObj
 
280
{
 
281
public:
 
282
        enum { OK, NEEDLIB, FAIL };
 
283
        qc_xss(Conf *c) : ConfObj(c)
 
284
        {
 
285
        }
 
286
 
 
287
        ~qc_xss()
 
288
        {
 
289
                remove("xssprobe_test.c");
 
290
                remove("xssprobe_test.o");
 
291
                remove("xssprobe_test");
 
292
        }
 
293
 
 
294
        QString name() const
 
295
        {
 
296
                return "the XScreenSaver extension";
 
297
        }
 
298
 
 
299
        QString shortname() const { return "xss"; }
 
300
 
 
301
        int do_write()
 
302
        {
 
303
                char *xsstest =
 
304
                        "#include<X11/Xlib.h>\n"
 
305
                        "#include<X11/Xutil.h>\n"
 
306
                        "#include<X11/extensions/scrnsaver.h>\n"
 
307
                        "\n"
 
308
                        "int main()\n"
 
309
                        "{\n"
 
310
                        "    XScreenSaverQueryExtension(NULL, NULL, NULL);\n"
 
311
                        "    return 0;\n"
 
312
                        "}\n";
 
313
 
 
314
                FILE *f;
 
315
                f = fopen("xssprobe_test.c", "w");
 
316
                if(!f)
 
317
                        return 0;
 
318
                fwrite(xsstest, strlen(xsstest), 1, f);
 
319
                fclose(f);
 
320
 
 
321
                return 1;
 
322
        }
 
323
 
 
324
        int do_compile()
 
325
        {
 
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);
 
329
                if(r == 0)
 
330
                        return 1;
 
331
                else
 
332
                        return 0;
 
333
        }
 
334
 
 
335
        int do_link()
 
336
        {
 
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);
 
341
                if(r == 0)
 
342
                        return 1;
 
343
                else
 
344
                        return 0;
 
345
        }
 
346
 
 
347
        int do_linkLib()
 
348
        {
 
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);
 
353
                if(r == 0)
 
354
                        return 1;
 
355
                else
 
356
                        return 0;
 
357
        }
 
358
 
 
359
        int do_all()
 
360
        {
 
361
                if(!do_write())
 
362
                        return FAIL;
 
363
                if(!do_compile())
 
364
                        return FAIL;
 
365
                if(do_link())
 
366
                        return OK;
 
367
                if(do_linkLib())
 
368
                        return NEEDLIB;
 
369
                return FAIL;
 
370
        }
 
371
 
 
372
        bool exec()
 
373
        {
 
374
                int r = do_all();
 
375
                if(r == OK)
 
376
                        return true;
 
377
                if(r == NEEDLIB) {
 
378
                        conf->addLib("-lXss");
 
379
                        return true;
 
380
                }
 
381
                else {
 
382
                        conf->addDefine("NO_XSS");
 
383
                        return false;
 
384
                }
 
385
        }
 
386
};
 
387
#line 1 "dnotify.qcm"
 
388
/*
 
389
-----BEGIN QCMOD-----
 
390
name: Linux Directory Notification
 
391
-----END QCMOD-----
 
392
*/
 
393
 
 
394
#include<unistd.h>
 
395
#include<fcntl.h>
 
396
#include<signal.h>
 
397
#include<sys/utsname.h>
 
398
 
 
399
//----------------------------------------------------------------------------
 
400
// qc_dnotify
 
401
//----------------------------------------------------------------------------
 
402
class qc_dnotify : public ConfObj
 
403
{
 
404
public:
 
405
        qc_dnotify(Conf *c) : ConfObj(c)
 
406
        {
 
407
        }
 
408
 
 
409
        ~qc_dnotify()
 
410
        {
 
411
                remove("ftest.c");
 
412
                remove("ftest.o");
 
413
        }
 
414
 
 
415
        QString name() const { return "Linux Directory Notification"; }
 
416
        QString shortname() const { return "dnotify"; }
 
417
 
 
418
        bool do_write()
 
419
        {
 
420
                char *fdata =
 
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"
 
426
                        "\n"
 
427
                        "int main()\n"
 
428
                        "{\n"
 
429
                        "    DN_DELETE|DN_CREATE|DN_RENAME|DN_MULTISHOT|DN_MODIFY|DN_ATTRIB;\n"
 
430
                        "    return 0;\n"
 
431
                        "}\n";
 
432
 
 
433
                FILE *f;
 
434
                f = fopen("ftest.c", "w");
 
435
                if(!f)
 
436
                        return false;
 
437
                fwrite(fdata, strlen(fdata), 1, f);
 
438
                fclose(f);
 
439
 
 
440
                return true;
 
441
        }
 
442
 
 
443
        bool do_compile()
 
444
        {
 
445
                QString str = conf->qvar("QMAKE_CC") + " -c ftest.c -o ftest.o";
 
446
                int r = conf->doCommand(str);
 
447
                if(r == 0)
 
448
                        return true;
 
449
                else
 
450
                        return false;
 
451
        }
 
452
 
 
453
        bool exec()
 
454
        {
 
455
                // taken from KDE
 
456
                bool supports_dnotify = true; // not guilty until proven guilty
 
457
                struct utsname uts;
 
458
                int major, minor, patch;
 
459
                if(uname(&uts) < 0)
 
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)
 
466
                        return false;
 
467
 
 
468
                if(!do_write())
 
469
                        return false;
 
470
                if(!do_compile())
 
471
                        return false;
 
472
 
 
473
                conf->addDefine("HAVE_DNOTIFY");
 
474
                return true;
 
475
        }
 
476
};
 
477
#line 1 "ghbnr.qcm"
 
478
/*
 
479
-----BEGIN QCMOD-----
 
480
name: gethostbyname_r()
 
481
-----END QCMOD-----
 
482
*/
 
483
class qc_ghbnr : public ConfObj
 
484
{
 
485
public:
 
486
        qc_ghbnr(Conf *c) : ConfObj(c)
 
487
        {
 
488
        }
 
489
 
 
490
        ~qc_ghbnr()
 
491
        {
 
492
                remove("ftest.c");
 
493
                remove("ftest");
 
494
        }
 
495
 
 
496
        QString name() const { return "gethostbyname_r()"; }
 
497
        QString shortname() const { return "ghbnr"; }
 
498
 
 
499
        bool exec()
 
500
        {
 
501
                char *fdata =
 
502
                        "#include<netdb.h>\n"
 
503
                        "\n"
 
504
                        "int main()\n"
 
505
                        "{\n"
 
506
                        "    gethostbyname_r(\"\", 0, 0, 0, 0, 0);\n"
 
507
                        "    return 0;\n"
 
508
                        "}\n";
 
509
 
 
510
                FILE *f;
 
511
                f = fopen("ftest.c", "w");      
 
512
                if(!f)
 
513
                        return false;
 
514
                fwrite(fdata, strlen(fdata), 1, f);
 
515
                fclose(f);
 
516
 
 
517
                QString str = conf->qvar("QMAKE_CC") + " ftest.c -o ftest";
 
518
                int r = conf->doCommand(str);
 
519
                if(r == 0) {
 
520
                        conf->addDefine("HAVE_GETHOSTBYNAME_R");
 
521
                        return true;
 
522
                }
 
523
                else
 
524
                        return false;
 
525
        }
 
526
};
 
527
#line 1 "kde.qcm"
 
528
/*
 
529
-----BEGIN QCMOD-----
 
530
name: KDE
 
531
-----END QCMOD-----
 
532
*/
 
533
 
 
534
//----------------------------------------------------------------------------
 
535
// qc_kde
 
536
//----------------------------------------------------------------------------
 
537
class qc_kde : public ConfObj
 
538
{
 
539
public:
 
540
        qc_kde(Conf *c) : ConfObj(c) {}
 
541
        QString name() const { return "KDE"; }
 
542
        QString shortname() const { return "kde"; }
 
543
        bool exec()
 
544
        {
 
545
                char *p = getenv("KDEDIR");
 
546
                if(!p)
 
547
                        return false;
 
548
 
 
549
                conf->addExtra(QString("KDE = %1").arg(p));
 
550
                return true;
 
551
        }
 
552
};
 
553
 
 
554
EOT
 
555
cat >$1/modules_new.cpp <<EOT
 
556
    o = new qc_qt31(conf);
 
557
    o->required = true;
 
558
    o->disabled = false;
 
559
    o = new qc_zlib(conf);
 
560
    o->required = true;
 
561
    o->disabled = false;
 
562
    o = new qc_xss(conf);
 
563
    o->required = false;
 
564
    o->disabled = false;
 
565
    o = new qc_dnotify(conf);
 
566
    o->required = false;
 
567
    o->disabled = false;
 
568
    o = new qc_ghbnr(conf);
 
569
    o->required = false;
 
570
    o->disabled = false;
 
571
    o = new qc_kde(conf);
 
572
    o->required = false;
 
573
    o->disabled = false;
 
574
 
 
575
EOT
 
576
cat >$1/conf.cpp <<EOT
 
577
#include<stdio.h>
 
578
#include<stdlib.h>
 
579
#include<qstring.h>
 
580
#include<qdict.h>
 
581
#include<qptrlist.h>
 
582
#include<qfileinfo.h>
 
583
#include<qfile.h>
 
584
#include<qdir.h>
 
585
#include<qstringlist.h>
 
586
#include<qobject.h>
 
587
 
 
588
class MocTestObject : public QObject
 
589
{
 
590
        Q_OBJECT
 
591
public:
 
592
        MocTestObject() {}
 
593
};
 
594
 
 
595
class Conf;
 
596
 
 
597
class ConfObj
 
598
{
 
599
public:
 
600
        ConfObj(Conf *c);
 
601
        virtual ~ConfObj();
 
602
 
 
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;
 
608
 
 
609
        Conf *conf;
 
610
        bool required;
 
611
        bool disabled;
 
612
};
 
613
 
 
614
typedef QPtrList<ConfObj> ConfObjList;
 
615
typedef QPtrListIterator<ConfObj> ConfObjListIt;
 
616
 
 
617
class Conf
 
618
{
 
619
public:
 
620
        Conf() : vars(17)
 
621
        {
 
622
                list.setAutoDelete(true);
 
623
                vars.setAutoDelete(true);
 
624
 
 
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));
 
629
 
 
630
                do_debug = false;
 
631
                done_debug = false;
 
632
        }
 
633
 
 
634
        ~Conf()
 
635
        {
 
636
        }
 
637
 
 
638
        void added(ConfObj *o)
 
639
        {
 
640
                list.append(o);
 
641
        }
 
642
 
 
643
        QString getenv(const QString &var)
 
644
        {
 
645
                char *p = ::getenv(var.latin1());
 
646
                if(!p)
 
647
                        return QString::null;
 
648
                return QString(p);
 
649
        }
 
650
 
 
651
        void debug(const QString &s)
 
652
        {
 
653
                if(do_debug) {
 
654
                        if(!done_debug)
 
655
                                printf("\n");
 
656
                        done_debug = true;
 
657
                        printf(" * %s\n", s.latin1());
 
658
                }
 
659
        }
 
660
 
 
661
        bool exec()
 
662
        {
 
663
                if(getenv("QC_DEBUG") == "Y")
 
664
                        do_debug = true;
 
665
 
 
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
 
669
                        if(o->disabled) {
 
670
                                QString v = QString("QC_ENABLE_") + o->shortname();
 
671
                                if(getenv(v) != "Y")
 
672
                                        continue;
 
673
                        }
 
674
                        // and the opposite?
 
675
                        else {
 
676
                                QString v = QString("QC_DISABLE_") + o->shortname();
 
677
                                if(getenv(v) == "Y")
 
678
                                        continue;
 
679
                        }
 
680
 
 
681
                        QString check = o->checkString();
 
682
                        if(check.isEmpty())
 
683
                                check = QString("Checking for %1 ...").arg(o->name());
 
684
                        printf("%s", check.latin1());
 
685
                        fflush(stdout);
 
686
 
 
687
                        done_debug = false;
 
688
                        bool ok = o->exec();
 
689
 
 
690
                        QString result = o->resultString();
 
691
                        if(result.isEmpty()) {
 
692
                                if(ok)
 
693
                                        result = "yes";
 
694
                                else
 
695
                                        result = "no";
 
696
                        }
 
697
                        if(done_debug)
 
698
                                printf(" -> %s\n", result.latin1());
 
699
                        else
 
700
                                printf(" %s\n", result.latin1());
 
701
 
 
702
                        if(!ok && o->required) {
 
703
                                printf("\nError: need %s!\n", o->name().latin1());
 
704
                                return false;
 
705
                        }
 
706
                }
 
707
                return true;
 
708
        }
 
709
 
 
710
        const QString & qvar(const QString &s)
 
711
        {
 
712
                QString *p = vars.find(s);
 
713
                if(p)
 
714
                        return *p;
 
715
                else
 
716
                        return blank;
 
717
        }
 
718
 
 
719
        QString expandIncludes(const QString &inc)
 
720
        {
 
721
                return QString("-I") + inc;
 
722
        }
 
723
 
 
724
        QString expandLibs(const QString &lib)
 
725
        {
 
726
                return QString("-L") + lib;
 
727
        }
 
728
 
 
729
        int doCommand(const QString &s)
 
730
        {
 
731
                debug(QString("[%1]").arg(s));
 
732
                QString fullcmd;
 
733
                if(do_debug)
 
734
                        fullcmd = s;
 
735
                else
 
736
                        fullcmd = s + " 1>/dev/null 2>/dev/null";
 
737
                int r = system(fullcmd.latin1());
 
738
                debug(QString("returned: %1").arg(r));
 
739
                return r;
 
740
        }
 
741
 
 
742
        bool doCompileAndLink(const QString &filedata, const QString &flags, int *retcode=0)
 
743
        {
 
744
                QDir dir(".");
 
745
                QString fname = "atest.c";
 
746
                QString out = "atest";
 
747
                QFile f(fname);
 
748
                QCString cs = filedata.latin1();
 
749
                if(!f.open(IO_WriteOnly | IO_Truncate)) {
 
750
                        debug("unable to open atest.c for writing");
 
751
                        return false;
 
752
                }
 
753
                if(f.writeBlock(cs.data(), cs.length()) == -1) {
 
754
                        debug("error writing to atest.c");
 
755
                        return false;
 
756
                }
 
757
                f.close();
 
758
 
 
759
                debug(QString("Wrote atest.c:\n%1").arg(filedata));
 
760
 
 
761
                QString str = qvar("QMAKE_CC") + ' ' + fname + " -o " + out;
 
762
                if(!flags.isEmpty()) {
 
763
                        str += ' ';
 
764
                        str += flags;
 
765
                }
 
766
 
 
767
                int r = doCommand(str);
 
768
                if(r == 0 && retcode)
 
769
                        *retcode = doCommand(QString("./") + out);
 
770
                dir.remove(fname);
 
771
                dir.remove(out);
 
772
                if(r != 0)
 
773
                        return false;
 
774
                return true;
 
775
        }
 
776
 
 
777
        bool checkHeader(const QString &path, const QString &h)
 
778
        {
 
779
                QFileInfo fi(path + '/' + h);
 
780
                if(fi.exists())
 
781
                        return true;
 
782
                return false;
 
783
        }
 
784
 
 
785
        bool findHeader(const QString &h, const QStringList &ext, QString *inc)
 
786
        {
 
787
                if(checkHeader("/usr/include", h)) {
 
788
                        *inc = "";
 
789
                        return true;
 
790
                }
 
791
                QStringList dirs;
 
792
                dirs += "/usr/local/include";
 
793
                dirs += ext;
 
794
                for(QStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it) {
 
795
                        if(checkHeader(*it, h)) {
 
796
                                *inc = *it;
 
797
                                return true;
 
798
                        }
 
799
                }
 
800
                return false;
 
801
        }
 
802
 
 
803
        bool checkLibrary(const QString &path, const QString &name)
 
804
        {
 
805
                QString str =
 
806
                        "int main()\n"
 
807
                        "{\n"
 
808
                        "    return 0;\n"
 
809
                        "}\n";
 
810
 
 
811
                QString extra;
 
812
                if(!path.isEmpty())
 
813
                        extra += QString("-L") + path + ' ';
 
814
                extra += QString("-l") + name;
 
815
                if(!doCompileAndLink(str, extra))
 
816
                        return false;
 
817
                return true;
 
818
        }
 
819
 
 
820
        bool findLibrary(const QString &name, QString *lib)
 
821
        {
 
822
                if(checkLibrary("", name)) {
 
823
                        *lib = "";
 
824
                        return true;
 
825
                }
 
826
                if(checkLibrary("/usr/local/lib", name)) {
 
827
                        *lib = "/usr/local/lib";
 
828
                        return true;
 
829
                }
 
830
                return false;
 
831
        }
 
832
 
 
833
        void addDefine(const QString &str)
 
834
        {
 
835
                if(DEFINES.isEmpty())
 
836
                        DEFINES = str;
 
837
                else
 
838
                        DEFINES += QString(" ") + str;
 
839
                debug(QString("DEFINES += %1").arg(str));
 
840
        }
 
841
 
 
842
        void addLib(const QString &str)
 
843
        {
 
844
                if(LIBS.isEmpty())
 
845
                        LIBS = str;
 
846
                else
 
847
                        LIBS += QString(" ") + str;
 
848
                debug(QString("LIBS += %1").arg(str));
 
849
        }
 
850
 
 
851
        void addIncludePath(const QString &str)
 
852
        {
 
853
                if(INCLUDEPATH.isEmpty())
 
854
                        INCLUDEPATH = str;
 
855
                else
 
856
                        INCLUDEPATH += QString(" ") + str;
 
857
                debug(QString("INCLUDEPATH += %1").arg(str));
 
858
        }
 
859
 
 
860
        void addExtra(const QString &str)
 
861
        {
 
862
                extra += str + '\n';
 
863
                debug(QString("extra += %1").arg(str));
 
864
        }
 
865
 
 
866
        QString DEFINES;
 
867
        QString INCLUDEPATH;
 
868
        QString LIBS;
 
869
        QString extra;
 
870
 
 
871
private:
 
872
        ConfObjList list;
 
873
        QDict<QString> vars;
 
874
        QString blank;
 
875
        bool do_debug, done_debug;
 
876
};
 
877
 
 
878
ConfObj::ConfObj(Conf *c)
 
879
{
 
880
        conf = c;
 
881
        conf->added(this);
 
882
        required = false;
 
883
        disabled = false;
 
884
}
 
885
 
 
886
ConfObj::~ConfObj()
 
887
{
 
888
}
 
889
 
 
890
QString ConfObj::checkString() const
 
891
{
 
892
        return QString();
 
893
}
 
894
 
 
895
QString ConfObj::resultString() const
 
896
{
 
897
        return QString();
 
898
}
 
899
 
 
900
#include"modules.cpp"
 
901
 
 
902
//----------------------------------------------------------------------------
 
903
// main
 
904
//----------------------------------------------------------------------------
 
905
int main()
 
906
{
 
907
        Conf *conf = new Conf;
 
908
        ConfObj *o;
 
909
        o = 0;
 
910
#include"modules_new.cpp"
 
911
 
 
912
        printf("ok\n");
 
913
        bool success = false;
 
914
        if(conf->exec()) {
 
915
                QFile f("conf.pri");
 
916
                if(!f.open(IO_WriteOnly | IO_Truncate)) {
 
917
                        printf("Error writing %s\n", f.name().latin1());
 
918
                        return 1;
 
919
                }
 
920
 
 
921
                QString str;
 
922
                str += "# qconf\n";
 
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())
 
931
                        str += conf->extra;
 
932
                str += '\n';
 
933
 
 
934
                char *p = getenv("BINDIR");
 
935
                if(p) {
 
936
                        str += QString("target.path = ") + p + '\n';
 
937
                        str += "INSTALLS += target\n";
 
938
                }
 
939
 
 
940
                QCString cs = str.latin1();
 
941
                f.writeBlock(cs.data(), cs.length());
 
942
                f.close();
 
943
                success = true;
 
944
        }
 
945
        delete conf;
 
946
 
 
947
        if(success)
 
948
                return 0;
 
949
        else
 
950
                return 1;
 
951
}
 
952
 
 
953
#include"conf.moc"
 
954
 
 
955
 
 
956
EOT
 
957
cat >$1/conf.pro <<EOT
 
958
TEMPLATE = app
 
959
CONFIG += qt x11 thread console
 
960
TARGET = conf
 
961
 
 
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"'
 
966
 
 
967
SOURCES += conf.cpp
 
968
 
 
969
EOT
 
970
}
 
971
 
 
972
export PREFIX
 
973
export BINDIR
 
974
export LIBDIR
 
975
export QTDIR
 
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
 
982
export QC_DEBUG
 
983
rm -rf .qconftemp
 
984
(
 
985
        mkdir .qconftemp
 
986
        gen_files .qconftemp
 
987
        cd .qconftemp
 
988
        $qm conf.pro >/dev/null
 
989
        QTDIR=$QTDIR make clean >/dev/null 2>&1
 
990
        QTDIR=$QTDIR make >../conf.log 2>&1
 
991
)
 
992
 
 
993
if [ "$?" != "0" ]; then
 
994
        rm -rf .qconftemp
 
995
        echo fail
 
996
        echo
 
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
 
1003
                echo
 
1004
                echo "One possible reason is that you don't have"
 
1005
                echo "libqt-mt.so.3 installed in $QTDIR/lib/."
 
1006
        fi
 
1007
        echo
 
1008
        exit 1;
 
1009
fi
 
1010
 
 
1011
.qconftemp/conf
 
1012
ret="$?"
 
1013
if [ "$ret" = "1" ]; then
 
1014
        rm -rf .qconftemp
 
1015
        echo
 
1016
        exit 1;
 
1017
else
 
1018
        if [ "$ret" != "0" ]; then
 
1019
                rm -rf .qconftemp
 
1020
                echo fail
 
1021
                echo
 
1022
                echo Unexpected error launching 'conf'
 
1023
                echo
 
1024
                exit 1;
 
1025
        fi
 
1026
fi
 
1027
rm -rf .qconftemp
 
1028
 
 
1029
if [ -x "./qcextra" ]; then
 
1030
        ./qcextra
 
1031
fi
 
1032
# run qmake
 
1033
$qm psi.pro
 
1034
if [ "$?" != "0" ]; then
 
1035
        echo
 
1036
        exit 1;
 
1037
fi
 
1038
cat >Makefile.tmp <<EOT
 
1039
export QTDIR = $QTDIR
 
1040
export PATH = $QTDIR/bin:$PATH
 
1041
EOT
 
1042
cat Makefile >> Makefile.tmp
 
1043
rm -f Makefile
 
1044
cp -f Makefile.tmp Makefile
 
1045
rm -f Makefile.tmp
 
1046
 
 
1047
echo
 
1048
echo Good, your configure finished.  Now run \'make\'.
 
1049
echo