]> git.lyx.org Git - features.git/blob - config/qt.m4
Welcome my son, welcome ... to the new configure script.
[features.git] / config / qt.m4
1
2 dnl Please leave this alone. I use this file in
3 dnl oprofile.
4 FATAL=0
5
6 dnl find a binary in the path
7 AC_DEFUN(QT_FIND_PATH,
8 [
9         AC_MSG_CHECKING([for $1])
10         AC_CACHE_VAL(qt_cv_path_$1,
11         [
12                 qt_cv_path_$1="NONE"
13                 if test -n "$$2"; then
14                         qt_cv_path_$1="$$2";
15                 else
16                         dirs="$3"
17                         qt_save_IFS=$IFS
18                         IFS=':'
19                         for dir in $PATH; do
20                                 dirs="$dirs $dir"
21                         done
22                         IFS=$qt_save_IFS
23  
24                         for dir in $dirs; do
25                                 if test -x "$dir/$1"; then
26                                         if test -n "$5"; then
27                                                 evalstr="$dir/$1 $5 2>&1 "
28                                                 if eval $evalstr; then
29                                                         qt_cv_path_$1="$dir/$1"
30                                                         break
31                                                 fi
32                                         else
33                                                 qt_cv_path_$1="$dir/$1"
34                                                 break
35                                         fi
36                                 fi
37                         done
38                 fi
39         ])
40  
41         if test -z "$qt_cv_path_$1" || test "$qt_cv_path_$1" = "NONE"; then
42                 AC_MSG_RESULT(not found)
43                 $4
44         else
45                 AC_MSG_RESULT($qt_cv_path_$1)
46                 $2=$qt_cv_path_$1
47         fi
48 ])
49
50 dnl Find the uic compiler on the path or in qt_cv_dir
51 AC_DEFUN(QT_FIND_UIC,
52 [
53         QT_FIND_PATH(uic, ac_uic, $qt_cv_dir/bin)
54         if test -z "$ac_uic" -a "$FATAL" = 1; then
55                 AC_MSG_ERROR([uic binary not found in \$PATH or $qt_cv_dir/bin !])
56         fi
57 ])
58  
59 dnl Find the right moc in path/qt_cv_dir
60 AC_DEFUN(QT_FIND_MOC,
61 [
62         QT_FIND_PATH(moc2, ac_moc2, $qt_cv_dir/bin)
63         QT_FIND_PATH(moc, ac_moc1, $qt_cv_dir/bin)
64
65         if test -n "$ac_moc1" -a -n "$ac_moc2"; then
66                 dnl found both. Prefer Qt3's if it exists else moc2
67                 $ac_moc1 -v 2>&1 | grep "Qt 3" >/dev/null
68                 if test "$?" = 0; then
69                         ac_moc=$ac_moc1;
70                 else
71                         ac_moc=$ac_moc2;
72                 fi
73         else
74                 if test -n "$ac_moc1"; then
75                         ac_moc=$ac_moc1;
76                 else
77                         ac_moc=$ac_moc2;
78                 fi
79         fi
80
81         if test -z "$ac_moc"  -a "$FATAL" = 1; then
82                 AC_MSG_ERROR([moc binary not found in \$PATH or $qt_cv_dir/bin !])
83         fi
84 ])
85
86 dnl check a particular libname
87 AC_DEFUN(QT_TRY_LINK,
88 [
89         CXXFLAGS="$BASE_CXXFLAGS $1"
90         AC_TRY_LINK([
91         #include <qglobal.h>
92         #include <qstring.h>
93                 ],
94         [
95         QString s("mangle_failure");
96         #if (QT_VERSION < 221)
97         break_me_(\\\);
98         #endif
99         ],
100         qt_cv_libname=$1,
101         )
102         CXXFLAGS="$BASE_CXXFLAGS"
103 ])
104  
105 dnl check we can do a compile
106 AC_DEFUN(QT_CHECK_COMPILE,
107 [
108         AC_MSG_CHECKING([for Qt library name])
109  
110         AC_CACHE_VAL(qt_cv_libname,
111         [
112                 AC_LANG_CPLUSPLUS
113                 SAVE_CXXFLAGS=$CXXFLAGS
114                 BASE_CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS" 
115
116                 for libname in -lqt3 -lqt2 -lqt -lqt-mt;
117                 do
118                         QT_TRY_LINK($libname)
119                         if test -n "$qt_cv_libname"; then
120                                 break;
121                         fi
122                 done
123
124                 CXXFLAGS=$SAVE_CXXFLAGS
125         ])
126
127         if test -z "$qt_cv_libname"; then
128                 AC_MSG_RESULT([failed]) 
129                 if test "$FATAL" = 1 ; then
130                         AC_MSG_ERROR([Cannot compile a simple Qt executable. Check you have the right \$QTDIR !])
131                 fi
132         else
133                 AC_MSG_RESULT([$qt_cv_libname])
134         fi
135 ])
136
137 dnl start here 
138 AC_DEFUN(QT_DO_IT_ALL,
139 [
140         AC_ARG_WITH(qt-dir, [  --with-qt-dir           where the root of Qt is installed ],
141                 [ qt_cv_dir=`eval echo "$withval"/` ])
142          
143         AC_ARG_WITH(qt-includes, [  --with-qt-includes      where the Qt includes are. ],
144                 [ qt_cv_includes=`eval echo "$withval"` ])
145  
146         AC_ARG_WITH(qt-libraries, [  --with-qt-libraries     where the Qt library is installed.],
147                 [  qt_cv_libraries=`eval echo "$withval"` ])
148
149         dnl pay attention to $QTDIR unless overridden
150         if test -z "$qt_cv_dir"; then
151                 qt_cv_dir=$QTDIR
152         fi
153  
154         dnl derive inc/lib if needed
155         if test -n "$qt_cv_dir"; then
156                 if test -z "$qt_cv_includes"; then
157                         qt_cv_includes=$qt_cv_dir/include
158                 fi
159                 if test -z "$qt_cv_libraries"; then
160                         qt_cv_libraries=$qt_cv_dir/lib
161                 fi
162         fi
163
164         dnl flags for compilation
165         QT_INCLUDES=
166         QT_LDFLAGS=
167         if test -n "$qt_cv_includes"; then
168                 QT_INCLUDES="-I$qt_cv_includes"
169         fi
170         if test -n "$qt_cv_libraries"; then
171                 QT_LDFLAGS="-L$qt_cv_libraries"
172         fi
173         AC_SUBST(QT_INCLUDES)
174         AC_SUBST(QT_LDFLAGS)
175  
176         QT_FIND_MOC
177         MOC=$ac_moc
178         AC_SUBST(MOC)
179         QT_FIND_UIC
180         UIC=$ac_uic
181         AC_SUBST(UIC)
182
183         QT_CHECK_COMPILE
184  
185         QT_LIB=$qt_cv_libname;
186         AC_SUBST(QT_LIB)
187 ])