summaryrefslogtreecommitdiff
blob: 403b3d351299d2e2f1c185e72788f0a6c4485f6c (plain)
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
--- configure.ac.orig	2012-06-21 07:34:18.000000000 +0200
+++ configure.ac	2012-06-21 07:34:42.000000000 +0200
@@ -45,8 +45,24 @@
 AC_SUBST(GZIP)
 AC_SUBST(LDCONFIG)
 
+AC_MSG_CHECKING(--enable-ncurses argument)
+AC_ARG_ENABLE(ncurses,
+    [  --enable-ncurses       Include curses based Morse code Tutor],
+    [enable_ncurses=$enableval],
+    [enable_ncurses="no"])
+AC_MSG_RESULT($enable_ncurses)
+
+AC_MSG_CHECKING(--enable-qt4 argument)
+AC_ARG_ENABLE(qt4,
+    [  --enable-qt4       Include QT based Morse code Tutor],
+    [enable_qt=$enableval],
+    [enable_qt="no"])
+AC_MSG_RESULT($enable_qt)
+
+if test "$enable_ncurses" = 'yes'; then
 # Checks for libraries.
 AC_CHECK_LIB(curses, initscr)
+fi
 AC_CHECK_LIB(asound, snd_pcm_open)
 AC_CHECK_LIB(pthread, pthread_create)
 AC_CHECK_LIB(m, floor)
@@ -102,121 +118,40 @@
 # Decide on which subdirectories to build; substitute into SUBDIRS.  Build
 # cwcp if curses is available, and xcwcp if Qt is available.
 SUBDIRS="libcw cwutils cw cwgen"
+
+if test "$enable_ncurses" = 'yes'; then
 # Simple test for curses based on prior library check.
 if test $ac_cv_lib_curses_initscr = 'yes' ; then
   SUBDIRS="$SUBDIRS cwcp"
 else
   AC_MSG_WARN([Cannot find libcurses - unable to build cwcp])
 fi
+fi
 
-
-
-
-# autodetection of QT4 dependencies
-
-MOC_MAJOR_EARLIEST=4
-
-# possible locations of Qt4 headers
-QT4HEADER_DIRS="/usr/include/qt4 \ # Debian
-               /usr/include"      # Arch (?)
-
-# possible locations of Qt4 moc (a.k.a. moc-qt4)
-QT4BIN_DIRS=$PATH # pretty standard
-
-# QT4DIR="" # for testing purposes
-QT4INC=""  # full path to directory with QT4 QtCore + QtGui subdirs and include files, e.g. /usr/include/qt4/
-QT4MOC=""  # full path to QT4 moc executable
-
-if [[[ $QT4DIR = "" ]]] ; then
-
-    # look for QT4 include directories
-    for dir in $QT4HEADER_DIRS; do
-	if test -d "$dir/QtGui" && test -d "$dir/QtCore" ; then
-            QT4INC=$dir;
-	fi
-    done
-
-    # look for QT4 moc binary
-    AC_PATH_PROG(QT4MOC, moc-qt4, , $PATH)
-    if test -n "$QT4MOC" ; then
-        MOC_MAJOR="`$QT4MOC -v 2>&1 | sed -e 's;.\+ (Qt \([[0-9]]\).\+;\1;g'`"
-	if [[[ $MOC_MAJOR != $MOC_MAJOR_EARLIEST ]]] ; then
-	   QT4MOC=""
-	fi
-    fi
-
-    if [[[ "$QT4MOC" = "" ]]] ; then
-        QT4MOC_2=""
-        AC_PATH_PROG(QT4MOC_2, moc, , $PATH)
-        if test -n "$QT4MOC_2" ; then
-            MOC_MAJOR="`$QT4MOC_2 -v 2>&1 | sed -e 's;.\+ (Qt \([[0-9]]\).\+;\1;g'`"
-	    if [[[ $MOC_MAJOR = $MOC_MAJOR_EARLIEST ]]] ; then
-	        QT4MOC=$QT4MOC_2
-	    fi
-        fi
-    fi
-
-
-    if [[[ $QT4INC != "" && $QT4MOC != "" ]]] ; then
-
-	# we have moc4 and path to QT4 include files,
-	# so we can build xcwcp
-	SUBDIRS="$SUBDIRS xcwcp"
-
-	AC_SUBST(QT4INC)
-	AC_SUBST(QT4MOC)
-    else
-	if [[[ $QT4INC = "" ]]] ; then
-	    AC_MSG_WARN([Can't find directory with QT4 header files - unable to build xcwcp])
-	fi
-
-	if [[[ $QT4MOC = "" ]]] ; then
-	    AC_MSG_WARN([Can't find QT moc version == $MOC_MAJOR_EARLIEST - unable to build xcwcp])
+if test "$enable_qt4" = 'yes'; then
+	dnl Look for Qt4 libs
+	PKG_CHECK_MODULES([QT4], ["QtCore QtGui Qt3Support"], [
+		AC_SUBST(QT4INC,$QT4_CFLAGS)
+		AC_SUBST(QT4LIBS)
+		], [
+			AC_MSG_ERROR([Qt4 libs not found])
+		])
+	dnl Look for moc, either on $PATH or in $QTDIR/bin
+	AC_PATH_PROG(QT4MOC, moc, , $PATH:$QTDIR/bin)
+	if test -n "$QT4MOC" ; then
+		dnl if libs and moc found
+		SUBDIRS="$SUBDIRS xcwcp"
+		AC_DEFINE([WANT_QT4], 1, [Want Qt4])
+		echo "enabling Qt4 support"
+	else
+		AC_MSG_ERROR([Cannot find 'moc'])
+		AC_DEFINE([WANT_QT4], 0, [No Qt4])
 	fi
-
-	AC_MSG_WARN([Hint: try setting QT4DIR env variable per instructions in unixcw/INSTALLATION])
-
-	QT4INC=""
-   	QT4MOC=""
-    fi
-
-
 else
-
-
-# Look for $QT4DIR.  If found, then look for moc, either on $PATH, or
-# in $QT4DIR/bin.
-
-  AC_PATH_PROG(QT4MOC, moc, , $QT4DIR/bin:$PATH)
-  if test -n "$QT4MOC" ; then
-    MOC_VERSION="`$QT4MOC -v 2>&1 | sed -e 's;.*(Qt ;;' -e 's;).*;;'`"
-    if test -n "$MOC_VERSION" ; then
-      MOC_MAJOR="`echo $MOC_VERSION | sed -e 's;\..*;;'`"
-      expr "$MOC_MAJOR" + 0 >/dev/null 2>/dev/null
-      status=$?
-      if test -n "$MOC_MAJOR" -a $status -eq 0 ; then
-        if test "$MOC_MAJOR" -ge $MOC_MAJOR_EARLIEST ; then
-          SUBDIRS="$SUBDIRS xcwcp"
-	  QT4INC="$QT4DIR/include"
-          AC_SUBST(QT4INC)
-          AC_SUBST(QT4MOC)
-        else
-          AC_MSG_WARN([Found 'moc' $MOC_VERSION - unable to build xcwcp])
-          AC_MSG_WARN([Hint: xcwcp requires 'moc' version >= $MOC_MAJOR_EARLIEST])
-        fi
-      else
-        AC_MSG_WARN([Cannot find 'moc' version - unable to build xcwcp])
-        AC_MSG_WARN([Hint: ensure 'moc' is in QT4DIR/bin on your PATH])
-      fi
-    else
-      AC_MSG_WARN([Cannot find 'moc' version - unable to build xcwcp])
-      AC_MSG_WARN([Hint: ensure 'moc' is in QT4DIR/bin on your PATH])
-    fi
-  else
-    AC_MSG_WARN([Cannot find 'moc' - unable to build xcwcp])
-    AC_MSG_WARN([Hint: ensure 'moc' is in QT4DIR/bin on your PATH])
-  fi
+    AC_DEFINE([WANT_QT4], 0, [No Qt4])
+	echo "disabling Qt4 support"
 fi
+
 AC_SUBST(SUBDIRS)
 
 if [[[ $QT4INC != "" && $QT4MOC != "" ]]] ; then
--- Makefile.inc.in.orig	2012-06-21 07:59:31.000000000 +0200
+++ Makefile.inc.in	2012-06-21 08:00:01.000000000 +0200
@@ -31,6 +31,7 @@
 # AC_QTMOC	= @QTMOC@
 AC_QT4INC	= @QT4INC@
 AC_QT4MOC	= @QT4MOC@
+AC_QT4LIBS	= @QT4_LIBS@
 AC_CFLAG_PIC	= @CFLAG_PIC@
 AC_SUBDIRS	= @SUBDIRS@
 AC_CC_LINKS_SO	= @CC_LINKS_SO@