IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Outils Discussion :

Utiliser les autotools avec AX_HAVE_QT [Compilation]


Sujet :

Outils

  1. #1
    Membre averti

    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    313
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 313
    Points : 404
    Points
    404
    Billets dans le blog
    14
    Par défaut Utiliser les autotools avec AX_HAVE_QT
    bonjour,

    j'ai vu sur un site que l'on peux utiliser les autotools avec Qt grâce à la macro m4 AX_HAVE_QT
    le fichier m4 ax_have_qt.m4 est le suivant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
     
    # ===========================================================================
    #        http://www.gnu.org/software/autoconf-archive/ax_have_qt.html
    # ===========================================================================
    #
    # SYNOPSIS
    #
    #   AX_HAVE_QT
    #
    # DESCRIPTION
    #
    #   Searches $PATH and queries qmake for Qt include files, libraries and Qt
    #   binary utilities. The macro only supports Qt5 or later.
    #
    #   The following shell variable is set to either "yes" or "no":
    #
    #     have_qt
    #
    #   Additionally, the following variables are exported:
    #
    #     QT_CXXFLAGS
    #     QT_LIBS
    #     QT_MOC
    #     QT_UIC
    #     QT_LRELEASE
    #     QT_LUPDATE
    #     QT_DIR
    #
    #   which respectively contain an "-I" flag pointing to the Qt include
    #   directory, link flags necessary to link with Qt and X, the full path to
    #   the meta object compiler and the user interface compiler both, and
    #   finally the variable QTDIR as Qt likes to see it defined.
    #
    #   Example lines for Makefile.in:
    #
    #     CXXFLAGS = @QT_CXXFLAGS@
    #     MOC      = @QT_MOC@
    #
    #   After the variables have been set, a trial compile and link is performed
    #   to check the correct functioning of the meta object compiler. This test
    #   may fail when the different detected elements stem from different
    #   releases of the Qt framework. In that case, an error message is emitted
    #   and configure stops.
    #
    #   No common variables such as $LIBS or $CFLAGS are polluted.
    #
    # LICENSE
    #
    #   Copyright (c) 2008 Bastiaan Veelo <Bastiaan@Veelo.net>
    #   Copyright (c) 2014 Alex Henrie <alexhenrie24@gmail.com>
    #
    #   Copying and distribution of this file, with or without modification, are
    #   permitted in any medium without royalty provided the copyright notice
    #   and this notice are preserved. This file is offered as-is, without any
    #   warranty.
     
    #serial 12
     
    AU_ALIAS([BNV_HAVE_QT], [AX_HAVE_QT])
    AC_DEFUN([AX_HAVE_QT],
    [
      AC_REQUIRE([AC_PROG_CXX])
      AC_REQUIRE([AC_PATH_X])
      AC_REQUIRE([AC_PATH_XTRA])
     
      AC_MSG_CHECKING(for Qt)
      # If we have Qt5 or later in the path, we're golden
      ver=`qmake --version | grep -o "Qt version ."`
      if test "$ver" ">" "Qt version 4"; then
        have_qt=yes
        # This pro file dumps qmake's variables, but it only works on Qt 5 or later
        am_have_qt_pro=`mktemp`
        am_have_qt_makefile=`mktemp`
        # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt
        cat > $am_have_qt_pro << EOF
    qtHaveModule(axcontainer):       QT += axcontainer
    qtHaveModule(axserver):          QT += axserver
    qtHaveModule(concurrent):        QT += concurrent
    qtHaveModule(core):              QT += core
    qtHaveModule(dbus):              QT += dbus
    qtHaveModule(declarative):       QT += declarative
    qtHaveModule(designer):          QT += designer
    qtHaveModule(gui):               QT += gui
    qtHaveModule(help):              QT += help
    qtHaveModule(multimedia):        QT += multimedia
    qtHaveModule(multimediawidgets): QT += multimediawidgets
    qtHaveModule(network):           QT += network
    qtHaveModule(opengl):            QT += opengl
    qtHaveModule(printsupport):      QT += printsupport
    qtHaveModule(qml):               QT += qml
    qtHaveModule(qmltest):           QT += qmltest
    qtHaveModule(x11extras):         QT += x11extras
    qtHaveModule(script):            QT += script
    qtHaveModule(scripttools):       QT += scripttools
    qtHaveModule(sensors):           QT += sensors
    qtHaveModule(serialport):        QT += serialport
    qtHaveModule(sql):               QT += sql
    qtHaveModule(svg):               QT += svg
    qtHaveModule(testlib):           QT += testlib
    qtHaveModule(uitools):           QT += uitools
    qtHaveModule(webkit):            QT += webkit
    qtHaveModule(webkitwidgets):     QT += webkitwidgets
    qtHaveModule(xml):               QT += xml
    qtHaveModule(xmlpatterns):       QT += xmlpatterns
    percent.target = %
    percent.commands = @echo -n "\$(\$(@))\ "
    QMAKE_EXTRA_TARGETS += percent
    EOF
        qmake $am_have_qt_pro -o $am_have_qt_makefile
        QT_CXXFLAGS=`make -f $am_have_qt_makefile CXXFLAGS INCPATH`
        QT_LIBS=`make -f $am_have_qt_makefile LIBS`
        rm $am_have_qt_pro $am_have_qt_makefile
     
        # Look for specific tools in $PATH
        QT_MOC=`which moc`
        QT_UIC=`which uic`
        QT_LRELEASE=`which lrelease`
        QT_LUPDATE=`which lupdate`
     
        # Get Qt version from qmake
        QT_DIR=`qmake --version | grep -o -E /.+`
     
        # All variables are defined, report the result
        AC_MSG_RESULT([$have_qt:
        QT_CXXFLAGS=$QT_CXXFLAGS
        QT_DIR=$QT_DIR
        QT_LIBS=$QT_LIBS
        QT_UIC=$QT_UIC
        QT_MOC=$QT_MOC
        QT_LRELEASE=$QT_LRELEASE
        QT_LUPDATE=$QT_LUPDATE])
      else
        # Qt was not found
        have_qt=no
        QT_CXXFLAGS=
        QT_DIR=
        QT_LIBS=
        QT_UIC=
        QT_MOC=
        QT_LRELEASE=
        QT_LUPDATE=
        AC_MSG_RESULT($have_qt)
      fi
      AC_SUBST(QT_CXXFLAGS)
      AC_SUBST(QT_DIR)
      AC_SUBST(QT_LIBS)
      AC_SUBST(QT_UIC)
      AC_SUBST(QT_MOC)
      AC_SUBST(QT_LRELEASE)
      AC_SUBST(QT_LUPDATE)
     
      #### Being paranoid:
      if test x"$have_qt" = xyes; then
        AC_MSG_CHECKING(correct functioning of Qt installation)
        AC_CACHE_VAL(ax_cv_qt_test_result,
        [
          cat > ax_qt_test.h << EOF
    #include <qobject.h>
    class Test : public QObject
    {
    Q_OBJECT
    public:
      Test() {}
      ~Test() {}
    public slots:
      void receive() {}
    signals:
      void send();
    };
    EOF
     
          cat > ax_qt_main.$ac_ext << EOF
    #include "ax_qt_test.h"
    #include <qapplication.h>
    int main( int argc, char **argv )
    {
      QApplication app( argc, argv );
      Test t;
      QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) );
    }
    EOF
     
          ax_cv_qt_test_result="failure"
          ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
          AC_TRY_EVAL(ax_try_1)
          if test x"$ac_status" != x0; then
            echo "$ax_err_1" >&AS_MESSAGE_LOG_FD
            echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD
            cat ax_qt_test.h >&AS_MESSAGE_LOG_FD
          else
            ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null"
            AC_TRY_EVAL(ax_try_2)
            if test x"$ac_status" != x0; then
              echo "$ax_err_2" >&AS_MESSAGE_LOG_FD
              echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
              cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD
            else
              ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null"
              AC_TRY_EVAL(ax_try_3)
              if test x"$ac_status" != x0; then
                echo "$ax_err_3" >&AS_MESSAGE_LOG_FD
                echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD
                cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD
              else
                ax_try_4="$CXX -o ax_qt_main ax_qt_main.o moc_ax_qt_test.o $QT_LIBS $LIBS >/dev/null 2>/dev/null"
                AC_TRY_EVAL(ax_try_4)
                if test x"$ac_status" != x0; then
                  echo "$ax_err_4" >&AS_MESSAGE_LOG_FD
                else
                  ax_cv_qt_test_result="success"
                fi
              fi
            fi
          fi
        ])dnl AC_CACHE_VAL ax_cv_qt_test_result
        AC_MSG_RESULT([$ax_cv_qt_test_result])
        if test x"$ax_cv_qt_test_result" = "xfailure"; then
          AC_MSG_ERROR([Failed to find matching components of a complete
                      Qt installation. Try using more options,
                      see ./configure --help.])
        fi
     
        rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \
              ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main
      fi
    ])
    j'ai d'abord copié ce fichier dans /usr/share/autoconf/autoconf/, /usr/share/aclocal-1.14/ et /usr/share/aclocal/

    voici mon configure.ac
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #                                               -*- Autoconf -*-
    # Process this file with autoconf to produce a configure script.
     
    AC_PREREQ([2.69])
    AC_INIT([hello], [1.0], [matser@free.fr])
    AM_INIT_AUTOMAKE
    AC_CONFIG_SRCDIR([src/main.cc])
    AM_CONFIG_HEADER([config.h])
     
    # Checks for programs.
    AC_PROG_CXX
     
    # Checks for libraries.
    AX_HAVE_QT
    # Checks for header files.
     
    # Checks for typedefs, structures, and compiler characteristics.
     
    # Checks for library functions.
     
    AC_OUTPUT(Makefile src/Makefile)
    voici Makefile.am:
    mon src/Makefile
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    bin_PROGRAMS = hello
    hello_SOURCES = main.cc
    mon main.cc:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    #include <QApplication>
    #include <QLabel>
     
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QLabel *label = new QLabel("Hello Qt!");
        label->show();
        return app.exec();
    }
    les commandes aclocal,autoheader et automake fonctionnent correctement:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    $ touch NEWS AUTHORS README ChangeLog
    $ aclocal
    $ autoheader
    $ automake -c -a
    $ autoconf
    avant de faire ./configure:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    $ have_qt=yes
    $ export  QT_CXXFLAGS;export  QT_LIBS;export  QT_MOC;export  QT_UIC;export  QT_LRELEASE;export  QT_LUPDATE;export  QT_DIR
    la sortie de ./configure
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    $ ./configure
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for a thread-safe mkdir -p... /bin/mkdir -p
    checking for gawk... gawk
    checking whether make sets $(MAKE)... yes
    checking whether make supports nested variables... yes
    checking for g++... g++
    checking whether the C++ compiler works... yes
    checking for C++ compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C++ compiler... yes
    checking whether g++ accepts -g... yes
    checking for style of include used by make... GNU
    checking dependency style of g++... gcc3
    checking for gcc... gcc
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking whether gcc understands -c and -o together... yes
    checking dependency style of gcc... gcc3
    checking how to run the C preprocessor... gcc -E
    checking for X... libraries , headers 
    checking for gethostbyname... yes
    checking for connect... yes
    checking for remove... yes
    checking for shmat... yes
    checking for IceConnectionNumber in -lICE... yes
    checking for Qt... yes:
        QT_CXXFLAGS=-pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_PRINTSUPPORT_LIB -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_XML_LIB -DQT_TESTLIB_LIB -DQT_SQL_LIB -DQT_NETWORK_LIB -DQT_DBUS_LIB -DQT_CONCURRENT_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR="/tmp" -I/usr/lib/i386-linux-gnu/qt5/mkspecs/linux-g++ -I. -isystem /usr/include/i386-linux-gnu/qt5 -isystem /usr/include/i386-linux-gnu/qt5/QtPrintSupport -isystem /usr/include/i386-linux-gnu/qt5/QtOpenGL -isystem /usr/include/i386-linux-gnu/qt5/QtWidgets -isystem /usr/include/i386-linux-gnu/qt5/QtXml -isystem /usr/include/i386-linux-gnu/qt5/QtTest -isystem /usr/include/i386-linux-gnu/qt5/QtSql -isystem /usr/include/i386-linux-gnu/qt5/QtNetwork -isystem /usr/include/i386-linux-gnu/qt5/QtDBus -isystem /usr/include/i386-linux-gnu/qt5/QtConcurrent -isystem /usr/include/i386-linux-gnu/qt5/QtGui -isystem /usr/include/i386-linux-gnu/qt5/QtCore -I. 
        QT_DIR=/usr/lib/i386-linux-gnu
        QT_LIBS=-lQt5PrintSupport -lQt5OpenGL -lQt5Widgets -lQt5Xml -lQt5Test -lQt5Sql -lQt5Network -lQt5DBus -lQt5Concurrent -lQt5Gui -lQt5Core -lGL -lpthread  
        QT_UIC=/usr/bin/uic
        QT_MOC=/usr/bin/moc
        QT_LRELEASE=/usr/bin/lrelease
        QT_LUPDATE=/usr/bin/lupdate
    checking correct functioning of Qt installation... success
    checking that generated files are newer than configure... done
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating src/Makefile
    config.status: creating config.h
    config.status: config.h is unchanged
    config.status: executing depfiles commands
    le problème se fait avec make:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    $ make
    make  all-recursive
    make[1]: Entering directory '/home/matser/qt5/hello-1.0'
    Making all in src
    make[2]: Entering directory '/home/matser/qt5/hello-1.0/src'
    g++ -DHAVE_CONFIG_H -I. -I..     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cc
    main.cc:1:24: fatal error: QApplication: Aucun fichier ou dossier de ce type
     #include <QApplication>
                            ^
    compilation terminated.
    Makefile:344: recipe for target 'main.o' failed
    make[2]: *** [main.o] Error 1
    make[2]: Leaving directory '/home/matser/qt5/hello-1.0/src'
    Makefile:356: recipe for target 'all-recursive' failed
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory '/home/matser/qt5/hello-1.0'
    Makefile:296: recipe for target 'all' failed
    make: *** [all] Error 2
    le fichier QApplication est ici:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    $ find / -name QApplication 2>/dev/null
    /usr/include/qt4/QtGui/QApplication
    /usr/include/i386-linux-gnu/qt5/QtWidgets/QApplication
    /opt/Qt/5.5/android_armv7/include/QtWidgets/QApplication
    /opt/Qt/5.5/Src/qtbase/include/QtWidgets/QApplication
    /opt/Qt/5.5/gcc/include/QtWidgets/QApplication
    qu'ai-je oublié de faire?

    quelqu'un a une idée?

  2. #2
    Membre averti

    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    313
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 313
    Points : 404
    Points
    404
    Billets dans le blog
    14
    Par défaut
    voici comment j'ai finalement fait pour que ça marche:
    rendez-vous sur http://tsunanet.net/autotroll/autotroll.m4.html ou :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
     # Build Qt apps with the autotools (Autoconf/Automake).
    # M4 macros.
    # This file is part of AutoTroll.
    # Copyright (C) 2006  Benoit Sigoure <[email protected]>
    #
    # AutoTroll is free software; you can redistribute it and/or
    # modify it under the terms of the GNU General Public License
    # as published by the Free Software Foundation; either version 2
    # of the License, or (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
    # USA.
    #
    # In addition, as a special exception, the copyright holders of AutoTroll
    # give you unlimited permission to copy, distribute and modify the configure
    # scripts that are the output of Autoconf when processing the macros of
    # AutoTroll.  You need not follow the terms of the GNU General Public License
    # when using or distributing such scripts, even though portions of the text of
    # AutoTroll appear in them. The GNU General Public License (GPL) does govern
    # all other use of the material that constitutes AutoTroll.
    #
    # This special exception to the GPL applies to versions of AutoTroll
    # released by the copyright holders of AutoTroll.  Note that people who make
    # modified versions of AutoTroll are not obligated to grant this special
    # exception for their modified versions; it is their choice whether to do so.
    # The GNU General Public License gives permission to release a modified version
    # without this exception; this exception also makes it possible to release a
    # modified version which carries forward this exception.
     
     # ------------- #
     # DOCUMENTATION #
     # ------------- #
     
    # Disclaimer: Never tested with anything else than Qt 4.2! Feedback welcome.
    # Simply invoke AT_WITH_QT in your configure.ac. AT_WITH_QT can take
    # arguments which are documented in depth below. The default arguments are
    # equivalent to the default .pro file generated by qmake.
    #
    # Invoking AT_WITH_QT will do the following:
    #  - Add a --with-qt option to your configure
    #  - Find qmake, moc and uic and save them in the make variables $(QMAKE),
    #    $(MOC), $(UIC).
    #  - Save the path to Qt in $(QT_PATH)
    #  - Find the flags to use Qt, that is:
    #     * $(QT_DEFINES): -D's defined by qmake.
    #     * $(QT_CFLAGS): CFLAGS as defined by qmake (C?!)
    #     * $(QT_CXXFLAGS): CXXFLAGS as defined by qmake.
    #     * $(QT_INCPATH): -I's defined by qmake.
    #     * $(QT_CPPFLAGS): Same as $(QT_DEFINES) + $(QT_INCPATH)
    #     * $(QT_LFLAGS): LFLAGS defined by qmake.
    #     * $(QT_LDFLAGS): Same thing as $(QT_LFLAGS).
    #     * $(QT_LIBS): LIBS defined by qmake.
    #
    # You *MUST* invoke $(MOC) and/or $(UIC) where necessary. AutoTroll provides
    # you with Makerules to ease this, here is a sample Makefile.am to use with
    # AutoTroll which builds the code given in the chapter 7 of the Qt Tutorial:
    # http://doc.trolltech.com/4.2/tutorial-t7.html
    #
    # -------------------------------------------------------------------------
    # include $(top_srcdir)/build-aux/autotroll.mk
    #
    # ACLOCAL_AMFLAGS = -I build-aux
    #
    # bin_PROGRAMS = lcdrange
    # lcdrange_SOURCES =  $(BUILT_SOURCES) lcdrange.cpp lcdrange.h main.cpp
    # lcdrange_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS)
    # lcdrange_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS)
    # lcdrange_LDFLAGS  = $(QT_LDFLAGS) $(LDFLAGS)
    # lcdrange_LDADD    = $(QT_LIBS) $(LDADD)
    #
    # BUILT_SOURCES = lcdrange.moc.cpp
    # -------------------------------------------------------------------------
    #
    # Note that your MOC, UIC and QRC files *MUST* be listed manually in
    # BUILT_SOURCES. If you name them properly (eg: .moc.cc, .qrc.cc, .ui.cc -- of
    # course you can use .cpp or .cxx or .C rather than .cc) AutoTroll will build
    # them automagically for you (using implicit rules defined in autotroll.mk).
     
    m4_define([_AUTOTROLL_SERIAL], [m4_translit([
    # serial 4
    ], [#
    ], [])])
     
     
    m4_ifdef([AX_INSTEAD_IF], [],
    [AC_DEFUN([AX_INSTEAD_IF],
      [m4_ifval([$1],
        [AC_MSG_WARN([$2]); [$1]],
        [AC_MSG_ERROR([$2])])])])
     
    m4_pattern_forbid([^AT_])dnl
    m4_pattern_forbid([^_AT_])dnl
     
    # AT_WITH_QT([QT_modules], [QT_config], [QT_misc], [RUN-IF-FAILED], [RUN-IF-OK])
    # ------------------------------------------------------------------------------
    # Enable Qt support and add an option --with-qt to the configure script.
    #
    # The QT_modules argument is optional and defines extra modules to enable or
    # disable (it's equivalent to the QT variable in .pro files). Modules can be
    # specified as follows:
    #
    # AT_WITH_QT   => No argument -> No QT value.
    #                                Qmake sets it to "core gui" by default.
    # AT_WITH_QT([xml])   => QT += xml
    # AT_WITH_QT([+xml])  => QT += xml
    # AT_WITH_QT([-gui])  => QT -= gui
    # AT_WITH_QT([xml -gui +sql svg])  => QT += xml sql svg
    #                                     QT -= gui
    #
    # The QT_config argument is also optional and follows the same convention as
    # QT_modules. Instead of changing the QT variable, it changes the CONFIG
    # variable, which is used to tweak configuration and compiler options.
    #
    # The last argument, QT_misc (also optional) will be copied as-is the .pro
    # file used to guess how to compile Qt apps. You may use it to further tweak
    # the build process of Qt apps if tweaking the QT or CONFIG variables isn't
    # enough for you.
    #
    # RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or if any
    # problem happens.  If this argument is omitted, then AC_MSG_ERROR will be
    # called.  RUN-IF-OK is arbitrary code to execute if Qt was successfully found.
    AC_DEFUN([AT_WITH_QT],
    [AC_REQUIRE([AC_CANONICAL_HOST])dnl
    AC_REQUIRE([AC_CANONICAL_BUILD])dnl
    AC_REQUIRE([AC_PROG_CXX])dnl
    echo "$as_me: this is autotroll.m4[]_AUTOTROLL_SERIAL" >&AS_MESSAGE_LOG_FD
     
      test x"$TROLL" != x && echo 'ViM rox emacs.'
     
    dnl Memo: AC_ARG_WITH(package, help-string, [if-given], [if-not-given])
      AC_ARG_WITH([qt],
                  [AS_HELP_STRING([--with-qt],
                     [Path to Qt @<:@Look in PATH and /usr/local/Trolltech@:>@])],
                  [QT_PATH=$withval])
     
      # this is a hack to get decent flow control with 'break'
      for _qt_ignored in once; do
     
      # Find Qt.
      AC_ARG_VAR([QT_PATH], [Path to the Qt installation])
      if test -d /usr/local/Trolltech; then
        # Try to find the latest version.
        tmp_qt_paths=`echo /usr/local/Trolltech/*/bin | tr ' ' '\n' | sort -nr \
                                                  | xargs | sed 's/  */:/g'`
      fi
      # Path to which recent MacPorts (~v1.7) install Qt4.
      test -d /opt/local/libexec/qt4-mac/bin \
        && tmp_qt_paths="$tmp_qt_paths:/opt/local/libexec/qt4-mac/bin"
     
      # Find qmake.
      AC_ARG_VAR([QMAKE], [Qt Makefile generator command])
      AC_PATH_PROGS([QMAKE], [qmake qmake-qt4 qmake-qt3], [missing],
                    [$QT_DIR:$QT_PATH:$PATH:$tmp_qt_paths])
      if test x"$QMAKE" = xmissing; then
        AX_INSTEAD_IF([$4], [Cannot find qmake in your PATH. Try using --with-qt.])
        break
      fi
     
      # Find moc (Meta Object Compiler).
      AC_ARG_VAR([MOC], [Qt Meta Object Compiler command])
      AC_PATH_PROGS([MOC], [moc moc-qt4 moc-qt3], [missing],
                    [$QT_PATH:$PATH:$tmp_qt_paths])
      if test x"$MOC" = xmissing; then
        AX_INSTEAD_IF([$4],
       [Cannot find moc (Meta Object Compiler) in your PATH. Try using --with-qt.])
        break
      fi
     
      # Find uic (User Interface Compiler).
      AC_ARG_VAR([UIC], [Qt User Interface Compiler command])
      AC_PATH_PROGS([UIC], [uic uic-qt4 uic-qt3 uic3], [missing],
                    [$QT_PATH:$PATH:$tmp_qt_paths])
      if test x"$UIC" = xmissing; then
        AX_INSTEAD_IF([$4],
    [Cannot find uic (User Interface Compiler) in your PATH. Try using --with-qt.])
        break
      fi
     
      # Find rcc (Qt Resource Compiler).
      AC_ARG_VAR([RCC], [Qt Resource Compiler command])
      AC_PATH_PROGS([RCC], [rcc], [false], [$QT_PATH:$PATH:$tmp_qt_paths])
      if test x"$UIC" = xfalse; then
        AC_MSG_WARN([Cannot find rcc (Qt Resource Compiler) in your PATH.\
      Try using --with-qt.])
      fi
     
      AC_MSG_CHECKING([whether host operating system is Darwin])
      at_darwin=no
      at_qmake_args=
      case $host_os in
        darwin*)
          at_darwin=yes
          at_qmake_args='-spec macx-g++'
          ;;
      esac
      AC_MSG_RESULT([$at_darwin])
     
      # If we don't know the path to Qt, guess it from the path to qmake.
      if test x"$QT_PATH" = x; then
        QT_PATH=`dirname "$QMAKE"`
      fi
      if test x"$QT_PATH" = x; then
        AX_INSTEAD_IF([$4],
                      [Cannot find the path to your Qt install. Use --with-qt.])
        break
      fi
      AC_SUBST([QT_PATH])
     
      # Get ready to build a test-app with Qt.
      if mkdir conftest.dir && cd conftest.dir; then :; else
        AX_INSTEAD_IF([$4], [Cannot mkdir conftest.dir or cd to that directory.])
        break
      fi
     
      cat >conftest.h <<_ASEOF
    #include <QObject>
     
    class Foo: public QObject
    {
      Q_OBJECT;
    public:
      Foo();
      ~Foo() {}
    public Q_SLOTS:
      void setValue(int value);
    Q_SIGNALS:
      void valueChanged(int newValue);
    private:
      int value_;
    };
    _ASEOF
     
      cat >conftest.cpp <<_ASEOF
    #include "conftest.h"
    Foo::Foo()
      : value_ (42)
    {
      connect(this, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
    }
     
    void Foo::setValue(int value)
    {
      value_ = value;
    }
     
    int main()
    {
      Foo f;
    }
    _ASEOF
      if $QMAKE -project; then :; else
        AX_INSTEAD_IF([$4], [Calling $QMAKE -project failed.])
        break
      fi
     
      # Find the .pro file generated by qmake.
      pro_file='conftest.dir.pro'
      test -f $pro_file || pro_file=`echo *.pro`
      if test -f "$pro_file"; then :; else
        AX_INSTEAD_IF([$4], [Can't find the .pro file generated by Qmake.])
        break
      fi
     
    dnl Tweak the value of QT in the .pro if have been the 1st arg.
    m4_ifval([$1], [_AT_TWEAK_PRO_FILE([QT], [$1])])
     
    dnl Tweak the value of CONFIG in the .pro if have been given a 2nd arg.
    m4_ifval([$2], [_AT_TWEAK_PRO_FILE([CONFIG], [$2])])
     
    m4_ifval([$3],
    [ # Add the extra-settings the user wants to set in the .pro
      echo "$3" >>"$pro_file"
    ])
     
      echo "$as_me:$LINENO: Invoking $QMAKE on $pro_file" >&AS_MESSAGE_LOG_FD
      sed 's/^/| /' "$pro_file" >&AS_MESSAGE_LOG_FD
     
      if $QMAKE $at_qmake_args; then :; else
        AX_INSTEAD_IF([$4], [Calling $QMAKE $at_qmake_args failed.])
        break
      fi
     
      # QMake has a very annoying misfeature: sometimes it generates Makefiles
      # where all the references to the files from the Qt installation are
      # relative.  We can't use them as-is because if we take, say, a
      # -I../../usr/include/Qt from that Makefile, the flag is invalid as soon
      # as we use it in another (sub) directory.  So what this perl pass does is
      # that it rewrite all relative paths to absolute paths.  Another problem
      # when building on Cygwin is that QMake mixes paths with blackslashes and
      # forward slashes and paths must be handled with extra care because of the
      # stupid Windows drive letters.
      echo "$as_me:$LINENO: fixing the Makefiles:" Makefile* >&AS_MESSAGE_LOG_FD
      cat >fixmk.pl <<\EOF
    [use strict;
    use Cwd qw(cwd abs_path);
    # This variable is useful on Cygwin for the following reason: Say that you are
    # in `/' (that is, in fact you are in C:/cygwin, or something like that) if you
    # `cd ..' then obviously you remain in `/' (that is in C:/cygwin).  QMake
    # generates paths that are relative to C:/ (or another driver letter, whatever)
    # so the trick to get the `..' resolved properly is to prepend the absolute
    # path of the current working directory in a Windows-style.  C:/cygwin/../ will
    # properly become C:/.
    my $d = "";
    my $r2a = 0;
    my $b2f = 0;
     
    my $cygwin = 0;
    if ($^O eq "cygwin") {
      $cygwin = 1;
      $d = cwd();
      $d = `cygpath --mixed '$d'`;
      chomp($d);
      $d .= "/";
    }
     
    sub rel2abs($)
    {
      my $p = $d . shift;
      # print "r2a p=$p";
      -e $p || return $p;
      if ($cygwin) {
        $p = `cygpath --mixed '$p'`;
        chomp($p);
      }
      else {
        # Do not use abs_path on Cygwin: it incorrectly resolves the paths that are
        # relative to C:/ rather than `/'.
        $p = abs_path($p);
      }
      # print " -> $p\n";
      ++$r2a;
      return $p;
    }
     
    # Only useful on Cygwin.
    sub back2forward($)
    {
      my $p = shift;
      # print "b2f p=$p";
      -e $p || return $p;
      $p = `cygpath --mixed '$p'`;
      chomp($p);
      # print " -> $p\n";
      ++$b2f;
      return $p;
    }
     
    foreach my $mk (@ARGV)
    {
      next if $mk =~ /~$/;
      open(MK, $mk) or die("open $mk: $!");
      # print "mk=$mk\n";
      my $file = join("", <MK>);
      close(MK) or die("close $mk: $!");
      rename $mk, $mk . "~" or die("rename $mk: $!");
      $file =~ s{(?:\.\.[\\/])+(?:[^"'\s:]+)}{rel2abs($&)}gse;
      $file =~ s{(?:[a-zA-Z]:[\\/])?(?:[^"\s]+\\[^"\s:]+)+}
                {back2forward($&)}gse if $cygwin;
      open(MK, ">", $mk) or die("open >$mk: $!");
      print MK $file;
      close(MK) or die("close >$mk: $!");
      print "$mk: updated $r2a relative paths and $b2f backslash-style paths\n";
      $r2a = 0;
      $b2f = 0;
    }]
    EOF
     
      perl >&AS_MESSAGE_LOG_FD -w fixmk.pl Makefile* ||
      AC_MSG_WARN([failed to fix the Makefiles generated by $QMAKE])
      rm -f fixmk.pl
     
      # Try to compile a simple Qt app.
      AC_CACHE_CHECK([whether we can build a simple Qt app], [at_cv_qt_build],
      [at_cv_qt_build=ko
      : ${MAKE=make}
     
      if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
        at_cv_qt_build='ok, looks like Qt 4'
      else
        echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> \
    instead" >&AS_MESSAGE_LOG_FD
        sed 's/<QObject>/<qobject.h>/' conftest.h > tmp.h && mv tmp.h conftest.h
        if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
          at_cv_qt_build='ok, looks like Qt 3'
        else
          # Sometimes (such as on Debian) build will fail because Qt hasn't been
          # installed in debug mode and qmake tries (by default) to build apps in
          # debug mode => Try again in release mode.
          echo "$as_me:$LINENO: Build failed, trying to enforce release mode" \
                >&AS_MESSAGE_LOG_FD
     
          _AT_TWEAK_PRO_FILE([CONFIG], [+release])
     
          sed 's/<qobject.h>/<QObject>/' conftest.h > tmp.h && mv tmp.h conftest.h
          if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
            at_cv_qt_build='ok, looks like Qt 4, release mode forced'
          else
            echo "$as_me:$LINENO: Build failed, trying to #include <qobject.h> \
    instead" >&AS_MESSAGE_LOG_FD
            sed 's/<QObject>/<qobject.h>/' conftest.h >tmp.h && mv tmp.h conftest.h
            if $MAKE >&AS_MESSAGE_LOG_FD 2>&1; then
              at_cv_qt_build='ok, looks like Qt 3, release mode forced'
            else
              at_cv_qt_build=ko
              echo "$as_me:$LINENO: failed program was:" >&AS_MESSAGE_LOG_FD
              sed 's/^/| /' conftest.h >&AS_MESSAGE_LOG_FD
              echo "$as_me:$LINENO: failed program was:" >&AS_MESSAGE_LOG_FD
              sed 's/^/| /' conftest.cpp >&AS_MESSAGE_LOG_FD
            fi # if make with Qt3-style #include and release mode forced.
          fi # if make with Qt4-style #include and release mode forced.
        fi # if make with Qt3-style #include.
      fi # if make with Qt4-style #include.
      ])dnl end: AC_CACHE_CHECK(at_cv_qt_build)
     
      if test x"$at_cv_qt_build" = xko; then
        AX_INSTEAD_IF([$4], [Cannot build a test Qt program])
        break
      fi
      QT_VERSION_MAJOR=`echo "$at_cv_qt_build" | sed 's/[[^0-9]]*//g'`
      AC_SUBST([QT_VERSION_MAJOR])
     
      # This sed filter is applied after an expression of the form: /^FOO.*=/!d;
      # It starts by removing the beginning of the line, removing references to
      # SUBLIBS, removing unnecessary whitespaces at the beginning, and prefixes
      # all variable uses by QT_.
      qt_sed_filter='s///;
                     s/$(SUBLIBS)//g;
                     s/^ *//;
                     s/\$(\(@<:@A-Z_@:>@@<:@A-Z_@:>@*\))/$(QT_\1)/g'
     
      # Find the Makefile (qmake happens to generate a fake Makefile which invokes
      # a Makefile.Debug or Makefile.Release). We we have both, we'll pick the
      # Makefile.Release. The reason is that the main difference is that release
      # uses -Os and debug -g. We can override -Os by passing another -O but we
      # usually don't override -g.
      if test -f Makefile.Release; then
        at_mfile='Makefile.Release'
      else
        at_mfile='Makefile'
      fi
      if test -f $at_mfile; then :; else
        AX_INSTEAD_IF([$4], [Cannot find the Makefile generated by qmake.])
        break
      fi
     
      # Find the DEFINES of Qt (should have been named CPPFLAGS).
      AC_CACHE_CHECK([for the DEFINES to use with Qt], [at_cv_env_QT_DEFINES],
      [at_cv_env_QT_DEFINES=`sed "/^DEFINES@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
      AC_SUBST([QT_DEFINES], [$at_cv_env_QT_DEFINES])
     
      # Find the CFLAGS of Qt (We can use Qt in C?!)
      AC_CACHE_CHECK([for the CFLAGS to use with Qt], [at_cv_env_QT_CFLAGS],
      [at_cv_env_QT_CFLAGS=`sed "/^CFLAGS@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
      AC_SUBST([QT_CFLAGS], [$at_cv_env_QT_CFLAGS])
     
      # Find the CXXFLAGS of Qt.
      AC_CACHE_CHECK([for the CXXFLAGS to use with Qt], [at_cv_env_QT_CXXFLAGS],
      [at_cv_env_QT_CXXFLAGS=`sed "/^CXXFLAGS@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
      AC_SUBST([QT_CXXFLAGS], [$at_cv_env_QT_CXXFLAGS])
     
      # Find the INCPATH of Qt.
      AC_CACHE_CHECK([for the INCPATH to use with Qt], [at_cv_env_QT_INCPATH],
      [at_cv_env_QT_INCPATH=`sed "/^INCPATH@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
      AC_SUBST([QT_INCPATH], [$at_cv_env_QT_INCPATH])
     
      AC_SUBST([QT_CPPFLAGS], ["$at_cv_env_QT_DEFINES $at_cv_env_QT_INCPATH"])
     
      # Find the LFLAGS of Qt (Should have been named LDFLAGS)
      AC_CACHE_CHECK([for the LDFLAGS to use with Qt], [at_cv_env_QT_LDFLAGS],
      [at_cv_env_QT_LDFLAGS=`sed "/^LFLAGS@<:@^A-Z=@:>@*=/!d;$qt_sed_filter" $at_mfile`])
      AC_SUBST([QT_LFLAGS], [$at_cv_env_QT_LDFLAGS])
      AC_SUBST([QT_LDFLAGS], [$at_cv_env_QT_LDFLAGS])
     
      # Find the LIBS of Qt.
      AC_CACHE_CHECK([for the LIBS to use with Qt], [at_cv_env_QT_LIBS],
      [at_cv_env_QT_LIBS=`sed "/^LIBS@<:@^A-Z@:>@*=/!d;$qt_sed_filter" $at_mfile`
       if test x$at_darwin = xyes; then
         # Fix QT_LIBS: as of today Libtool (GNU Libtool 1.5.23a) doesn't handle
         # -F properly. The "bug" has been fixed on 22 October 2006
         # by Peter O'Gorman but we provide backward compatibility here.
         at_cv_env_QT_LIBS=`echo "$at_cv_env_QT_LIBS" \
                                 | sed 's/^-F/-Wl,-F/;s/ -F/ -Wl,-F/g'`
       fi
      ])
      AC_SUBST([QT_LIBS], [$at_cv_env_QT_LIBS])
     
      cd .. && rm -rf conftest.dir
     
      # Run the user code
      $5
     
      done  # end hack (useless for to be able to use break)
    ])
     
    # AT_REQUIRE_QT_VERSION(QT_version, RUN-IF-FAILED, RUN-IF-OK)
    # -----------------------------------------------------------
    # Check (using qmake) that Qt's version "matches" QT_version.
    # Must be run AFTER AT_WITH_QT. Requires autoconf 2.60.
    #
    # RUN-IF-FAILED is arbitrary code to execute if Qt cannot be found or if any
    # problem happens.  If this argument is omitted, then AC_MSG_ERROR will be
    # called.  RUN-IF-OK is arbitrary code to execute if Qt was successfully found.
    AC_DEFUN([AT_REQUIRE_QT_VERSION],
    [ AC_PREREQ([2.60])
      # this is a hack to get decent flow control with 'break'
      for _qt_ignored in once; do
     
      if test x"$QMAKE" = x; then
        AX_INSTEAD_IF([$2],
                      [\$QMAKE is empty.\
      Did you invoke AT@&t@_WITH_QT before AT@&t@_REQUIRE_QT_VERSION?])
        break
      fi
      AC_CACHE_CHECK([for Qt's version], [at_cv_QT_VERSION],
      [echo "$as_me:$LINENO: Running $QMAKE --version:" >&AS_MESSAGE_LOG_FD
      $QMAKE --version >&AS_MESSAGE_LOG_FD 2>&1
      qmake_version_sed=['/^.*\([0-9]\.[0-9]\.[0-9]\).*$/!d;s//\1/']
      at_cv_QT_VERSION=`$QMAKE --version 2>&1 | sed "$qmake_version_sed"`])
      if test x"$at_cv_QT_VERSION" = x; then
        AX_INSTEAD_IF([$2], [Cannot detect Qt's version.])
        break
      fi
      AC_SUBST([QT_VERSION], [$at_cv_QT_VERSION])
      AS_VERSION_COMPARE([$QT_VERSION], [$1],
        [AX_INSTEAD_IF([$2; break;], [This package requires Qt $1 or above.])])
     
      # Run the user code
      $3
     
      done  # end hack (useless for to be able to use break)
    ])
     
    # _AT_TWEAK_PRO_FILE(QT_VAR, VALUE)
    # ---------------------------
    # @internal. Tweak the variable QT_VAR in the .pro.
    # VALUE is an IFS-separated list of value and each value is rewritten
    # as follows:
    #   +value  => QT_VAR += value
    #   -value  => QT_VAR -= value
    #    value  => QT_VAR += value
    AC_DEFUN([_AT_TWEAK_PRO_FILE],
    [ # Tweak the value of $1 in the .pro file for $2.
     
      qt_conf=''
      for at_mod in $2; do
        at_mod=`echo "$at_mod" | sed 's/^-//; tough
                                      s/^+//; beef
                                      :ough
                                      s/^/$1 -= /;n
                                      :eef
                                      s/^/$1 += /'`
        qt_conf="$qt_conf
    $at_mod"
      done
      echo "$qt_conf" | sed 1d >>"$pro_file"
    ])
    selectionez tout (ctrl+A) et copiez (ctrl+C) et collez dans un éditeur de texte (gedit,nano,vim...)
    dans cet éditeur de texte, enregistrez sous, avec créez le dossier "build-aux" à la racine du projet, et le nom du fichier "autotroll.mk"
    je soppose que vous savez faire un fichier Makefile.am. Dans ce dernier (dans chacun qui se trouve dans les dossiers contenant les fichiers source à compiler), si vous avez installé Qt dans /opt/Qt:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    myApp_CXXFLAGS=-I /opt/Qt/5.5/gcc/include
    Le fichier $HOME/helloqt/hello-1.0/configure.ac, ressemblera à ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    AC_PREREQ([2.69])
    AC_INIT([hello], [1.0], [matser1973@free.fr])
    AM_INIT_AUTOMAKE
    AC_CONFIG_SRCDIR([src/main.cc])
    AC_CONFIG_HEADERS([config.h])
     
    # Checks for programs.
    AC_PROG_CXX #car on utilise le langage C++
    AT_WITH_QT
    AM_CXXFLAGS=-I$(top_srcdir)/include # Checks for libraries.
    # Checks for header files.
    # Checks for typedefs, structures, and compiler characteristics.
    # Checks for library functions.
    PKG_PROG_PKG_CONFIG
    # ...
    # Check for Qt libraries
    PKG_CHECK_MODULES(QT, [QtCore, QtGui], [], [AC_MSG_ERROR([Qt libraries are required.])])
    # Retrieve Qt compilation and linker flags
    CPPFLAGS="`$PKG_CONFIG --cflags-only-I QtCore QtGui` $CPPFLAGS"
    LDFLAGS="`$PKG_CONFIG --libs-only-L QtCore QtGui` $LDFLAGS"
    LIBS="`$PKG_CONFIG --libs-only-l QtCore QtGui` $LIBS"
    if ! `$PKG_CONFIG --atleast-version=4.6.0 QtCore`; then
       AC_MSG_ERROR([Qt >= 4.6.0 is required.])
    fi
    AC_CHECK_PROGS(MOC, [moc-qt5 moc-qt4 moc])
    AC_CHECK_PROGS(UIC, [uic-qt5 uic-qt4 uic])
    AC_CHECK_PROGS(RCC, [rcc])
     if test -z "$MOC" || test -z "$UIC" || test -z "$RCC"; then
       AC_MSG_ERROR([Qt utility programs moc, uic, and rcc are required.])
    fi
    AC_CONFIG_FILES([Makefile src/Makefile]) #en supposant que vous avez mis des fichiers sources dans le dossier src
    AC_OUTPUT
    puis on utilise les autotools:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $ cd  $HOME/helloqt/hello-1.0
    créez les fichiers NEWS, README, AUTHORS, ChangeLog, puis tapez ces commandes:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    $ aclocal
    $ autoheader
    $ automake -c -a
    l'argument -c de automake sert à ce que les fichiers qu'il crée ne soient pas des liens symbolique, mais des "vrais" fichiers.
    quant à l'argument -a sert à créer ces fichiers-ci.
    puis ensuite:
    on peut voir que la compilation fonctionne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $ ./configure --prefix=/usr
    $ make
    pour vérifier que cela s'installe correctement, nous allons utiliser la variable DESTDIR
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $make DESTDIR=$HOME/helloqt/hello-1.0-i386 install
    si cela a fonctionné, on devrais obtenir quelque chose de similaire à ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    $ cd $HOME/helloqt/hello-1.0-i386
    $ find
    .
    ./usr
    ./usr/bin
    ./usr/bin/hello
    pour remettre le paquet à neuf:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $ cd $HOME/helloqt/helo-1.0
    $ make distclean
    on peut alors archiver ce dossier pour obtenir le tarball:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $ cd ..
    $ tar jcf hello-1.0.tar.bz2 hello-1.0
    si ça peut aider quelqu'un

  3. #3
    Membre averti

    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    313
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 313
    Points : 404
    Points
    404
    Billets dans le blog
    14
    Par défaut
    dans le configue.ac, il faut remplacer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    AM_CXXFLAGS=-I$(top_srcdir)/include
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    AM_CXXFLAGS=-I@top_srcdir@/include

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 5
    Dernier message: 15/11/2013, 09h35
  2. autotools avec un prog en java
    Par lostsoul dans le forum Applications et environnements graphiques
    Réponses: 4
    Dernier message: 09/04/2012, 05h51
  3. Création package compilable avec Autotools
    Par Moravski dans le forum GTK+ avec C & C++
    Réponses: 20
    Dernier message: 28/09/2010, 17h12
  4. Des problemmes avec Autotools
    Par coyotemk dans le forum Bibliothèques
    Réponses: 0
    Dernier message: 20/03/2010, 06h17
  5. Autotools et compilation avec paramètres
    Par faldir dans le forum Systèmes de compilation
    Réponses: 0
    Dernier message: 09/04/2009, 14h14

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo