Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 0fe50fcad340bd984545105d0625a58a26304af3 (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
dnl
dnl configure.in for the Project::OSiRiON world editor
dnl
dnl see also http://qtnode.net/wiki/Qt_with_autotools
dnl

AC_INIT(editor,0.2)

AC_CONFIG_HEADERS(src/config.h)

AM_INIT_AUTOMAKE
AC_PROG_CC
AC_PROG_CXX

dnl
dnl Qt installation prefix
dnl
AC_MSG_CHECKING(Qt installation prefix)
QTDIR=xxx
AC_ARG_WITH([qt-prefix],
             AC_HELP_STRING([--with-qt-prefix=], [to specify the path to the Qt5 installation prefix.]),
             [QTPATHS="$withval"],
             [QTPATHS="/usr /usr/qt5 /opt/qt5"])

for x in $QTPATHS; do
    if test -d $x ; then
       QTDIR="$x"
    fi
done
if test $QTDIR = xxx ; then
   AC_MSG_ERROR(Could not locate Qt5)
fi
AC_MSG_RESULT($QTDIR)

dnl
dnl Qt includes directory
dnl
AC_MSG_CHECKING(Qt includes directory)

AC_ARG_WITH([qt-includes],
             AC_HELP_STRING([--with-qt-includes], [to specify the path to directory containing the the Qt5 includes.]),
             [QTINCLUDEDIR="$withval"],
             [QTINCLUDEDIR="$QTDIR/include"])
AC_MSG_RESULT($QTINCLUDEDIR)

dnl
dnl Qt libraries directory
dnl             
AC_MSG_CHECKING(Qt libraries directory)
AC_ARG_WITH([qt-libraries],
             AC_HELP_STRING([--with-qt-libraries=], [to specify the path to directory containing the the Qt5 libraries.]),
             [QTLIBDIR="$withval"],
             [QTLIBDIR="$QTDIR/lib"])
AC_MSG_RESULT($QTLIBDIR)


dnl
dnl Qt moc
dnl             
AC_MSG_CHECKING(Qt moc)
AC_ARG_WITH([qt-moc],
             AC_HELP_STRING([--with-qt-moc=], [Full path of the moc prepreocessor.]),
             [QTMOC="$withval"],
             [QTMOC="$QTDIR/bin/moc"])
AC_MSG_RESULT($QTMOC)

AC_SUBST(QTMOC)

host=`uname -a` # AC_CANONICAL_HOST is broken at the time of this writing.
case $host in
  MINGW32*)
    AC_MSG_NOTICE(win32)
    QTLIBS="-L$QTLIBDIR -lgdi32 -luser32 -lmingw32 -lqtmain -lQt5Widgets -lQt5Gui -lQt5Core -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-s -Wl,-subsystem,windows"
    QTINC="-I$QTINCLUDEDIR -I$QTINCLUDEDIR/QtCore -I$QTINCLUDEDIR/QtGui -I$QTINCLUDEDIR/QtWidgets  -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -frtti -fexceptions"
    QTBIN="$QTDIR/bin"
    ;;
  *)
    AC_MSG_NOTICE(generic UNIX)
    AC_PATH_XTRA
    QTINC="-I$QTINCLUDEDIR -I$QTINCLUDEDIR/QtCore -I$QTINCLUDEDIR/QtGui -I$QTINCLUDEDIR/QtWidgets $X_CFLAGS -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED"
    QTLIBS="-Wl,-rpath,QTLIBDIR -L$QTLIBDIR -lQt5Widgets -lQt5Gui -lQt5Core -lpthread"
    QTBIN="$QTDIR/bin"
    ;;
esac

LIBS="$LIBS $QTLIBS"
INCLUDES="$INCLUDES $QTINC"
PATH="$PATH:$QTBIN"
CXXFLAGS="$CXXFLAGS $QTINC"

# Now we check whether we can actually build a Qt app.
cat > myqt.h << EOF
#include <QObject>
class Test : public QObject
{
Q_OBJECT
public:
  Test() {}
  ~Test() {}
public slots:
  void receive() {}
signals:
  void send();
};
EOF

cat > myqt.cpp << EOF
#include "myqt.h"
#include <QApplication>
int main( int argc, char **argv )
{
  QApplication app( argc, argv );
  Test t;
  QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) );
}
EOF

AC_MSG_CHECKING(does $QTMOC work)
bnv_try_1="$QTMOC myqt.h -o moc_myqt.cpp"
AC_TRY_EVAL(bnv_try_1)
if test x"$ac_status" != x0; then
   AC_MSG_ERROR($QTMOC doesn't work)
fi
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(can I compile moc_myqt.cpp)
bnv_try_2="$CXX -c $CXXFLAGS -o moc_myqt.o moc_myqt.cpp"
AC_TRY_EVAL(bnv_try_2)
if test x"$ac_status" != x0; then
   AC_MSG_ERROR(couldn't compile moc_myqt.cpp)
fi
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(can I compile myqt.cpp)
bnv_try_3="$CXX $QTINC -c $CXXFLAGS -o myqt.o myqt.cpp"
AC_TRY_EVAL(bnv_try_3)
if test x"$ac_status" != x0; then
   AC_MSG_ERROR(couldn't compile myqt.cpp)
fi
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(can I link against QT)
nv_try_4="$CXX $LIBS -o myqt myqt.o moc_myqt.o"
AC_TRY_EVAL(bnv_try_4)
if test x"$ac_status" != x0; then
   AC_MSG_ERROR(couldn't link)
fi
AC_MSG_RESULT(yes)

AC_MSG_CHECKING(for mkoctfile)
AC_TRY_EVAL(mkoctfile)
if test x"$ac_status" != x0; then
   AC_MSG_ERROR(mkoctfile is not in the path)
fi
AC_MSG_RESULT(yes)
rm -f moc_myqt.cpp myqt.h myqt.cpp myqt.o myqt moc_myqt.o

AC_CONFIG_FILES(Makefile src/Makefile)
AC_OUTPUT