summaryrefslogtreecommitdiffstats
blob: 80e69c08080020846f1ef999635d348af861c0fa (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
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
AC_PREREQ(2.57)
AC_INIT(Swift,[],swift@swift.im)
AC_CONFIG_SRCDIR([Swiften/Base/String.h])
AC_CONFIG_AUX_DIR([autoconf])
AC_CONFIG_HEADERS([Swiften/config.h])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST

################################################################################
# Config.h templates
################################################################################

AH_TEMPLATE(HAVE_OPENSSL, [OpenSSL library available])
AH_TEMPLATE(HAVE_LIBXML, [LibXML library available])
AH_TEMPLATE(HAVE_EXPAT, [Expat library available])
AH_TEMPLATE(HAVE_BONJOUR, [Apple Bonjour SDK available])
AH_TEMPLATE(HAVE_AVAHI, [Avahi library available])

################################################################################
# Default flags
################################################################################

# Following flags generate too much warnings (in boost etc.). Make
# a configure option for these, and add a filter script
# -Weff-c++ -Wshadow -Winline -Wunreachable-code 
# -ansi: Gets us into problems on MingW
CONFIG_CXXFLAGS="$CPPFLAGS -DHAVE_SWIFTEN_CONFIG_H $CXXFLAGS"
CONFIG_CFLAGS="$CPPFLAGS -DHAVE_SWIFTEN_CONFIG_H $CFLAGS"
CONFIG_LDFLAGS="$LDFLAGS"
CONFIG_LIBS=""

case $host in
	*-*-cygwin*)
		CONFIG_CFLAGS="$CONFIG_CFLAGS -mno-cygwin"
		CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS -mno-cygwin"
		CONFIG_LIBS="$CONFIG_LIBS -ldnsapi -lws2_32 -lwsock32"
		CONFIG_WIN32=1
		;;
	*-mingw32*)
		CONFIG_LIBS="$CONFIG_LIBS -ldnsapi -lws2_32 -lwsock32"
		CONFIG_WIN32=1
		;;
	*-*-darwin*)
    CONFIG_LIBS="$CONFIG_LIBS -lstdc++ -framework AppKit"
		CONFIG_MACOSX=1
		;;
	*)
    CONFIG_LIBS="$CONFIG_LIBS -lstdc++"
esac

case $host in
	x86_64-*)
		ARCH="amd64"
		;;
	i686-*)
		ARCH="i686"
		;;
	*)
		ARCH="i386"
esac

AC_CHECK_FILE([Swift/Makefile.inc], [BUILD_SWIFT="yes"], [BUILD_SWIFT="no"])
AC_CHECK_FILE([Limber/Makefile.inc], [BUILD_LIMBER="yes"], [BUILD_LIMBER="no"])
AC_CHECK_FILE([Slimber/Makefile.inc], [BUILD_SLIMBER="yes"], [BUILD_SLIMBER="no"])

################################################################################
# Configure options
################################################################################

AC_ARG_ENABLE(debug,
	AC_HELP_STRING(--enable-debug, [Build with debugging information (default: no)]),
		[if test "$enableval" = yes; then
			CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS -g"
			CONFIG_CFLAGS="$CONFIG_CFLAGS -g"
		 fi],
		[])

AC_ARG_ENABLE(optimize,
	AC_HELP_STRING(--enable-optimize, [Optimize build (default: no)]),
		[if test "$enableval" = yes; then
			CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS -O2"
			CONFIG_CFLAGS="$CONFIG_CFLAGS -O2"
		 fi],
		[])

AC_ARG_ENABLE(coverage,
	AC_HELP_STRING(--enable-coverage, [Enable coverage (default: no)]),
		[if test "$enableval" = yes; then
			CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS -fprofile-arcs -ftest-coverage"
			CONFIG_LDFLAGS="$CONFIG_LDFLAGS -fprofile-arcs -ftest-coverage"
		 fi],
		[])

AC_ARG_ENABLE(universal,
	AC_HELP_STRING(--enable-universal, [Enable universal builds (default: no)]),
		[if test "$enableval" = yes; then
			CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
			CONFIG_CFLAGS="$CONFIG_CFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
			CONFIG_LDFLAGS="$CONFIG_LDFLAGS -mmacosx-version-min=10.4 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
			CXXFLAGS="$CXXFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
			CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
			LDFLAGS="$LDFLAGS -mmacosx-version-min=10.4 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
		 fi],
		[])

AC_ARG_ENABLE(gcc-warnings,
	AC_HELP_STRING(--disable-gcc-warnings, [Disable GCC compiler warnings (default: no)]),
	[enable_gcc_warnings="$enableval"],
	[enable_gcc_warnings="yes"])

if test "$enable_gcc_warnings" != "no"; then
	#CONFIG_CFLAGS="$CONFIG_CFLAGS -W -Wall -Wredundant-decls -pedantic -Wno-long-long -Wundef -Wfloat-equal"
	CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS -W -Wall -Wredundant-decls -pedantic -Wno-long-long -Woverloaded-virtual -Wundef -Wfloat-equal -Wold-style-cast"
	CONFIG_LDFLAGS="$CONFIG_LDFLAGS -W -Wall"
fi

################################################################################
# Checks for programs and sets default compiler options.
################################################################################

# On windows, use some smart defaults for the compiler
case $host in
	*-*-cygwin* | *-mingw32*)
		if test -z "$CC"; then
			CC="autoconf/cccl"
		fi
		if test -z "$CXX"; then
			CXX="autoconf/cccl"
		fi
		if test -z "$MM"; then
			MM="gcc"
		fi
		;;
	*)
esac

AC_PROG_CC
AC_PROG_CXX
AC_GNU_SOURCE
AC_PROG_MAKE_SET
AC_PROG_INSTALL
#AC_SYS_LARGEFILE
CONFIG_CC="$CC"
CONFIG_CXX="$CXX"
if test -z "$MM"; then
	MM="$CC"
fi

# Qt
if test "$BUILD_SWIFT" == "yes"; then
	NEED_QT=yes
fi
if test "$NEED_QT" == "yes"; then
  AX_QT()
  if test "$HAVE_QT" != yes; then
    AC_MSG_ERROR([Could not find Qt])
  fi
fi

# Expat
AX_LIB_EXPAT()
if test "$HAVE_EXPAT" = yes; then
	CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS $EXPAT_CFLAGS"
	CONFIG_LDFLAGS="$CONFIG_LDFLAGS $EXPAT_LDFLAGS"
	AC_DEFINE(HAVE_EXPAT)
fi

# LibXML
AX_LIBXML()
CONFIG_HAVE_LIBXML="$HAVE_LIBXML"
if test "$HAVE_LIBXML" = yes; then
	CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS $LIBXML_CPPFLAGS"
	CONFIG_LDFLAGS="$CONFIG_LDFLAGS $LIBXML_LDFLAGS"
	CONFIG_LIBS="$LIBXML_LIBS $CONFIG_LIBS"
	AC_DEFINE(HAVE_LIBXML)
fi

# Test whether we have *a* parser, and use bundled Expat if necessary
if test "$HAVE_EXPAT" != yes -a "$HAVE_LIBXML" != yes; then
  AC_MSG_NOTICE([No installed XML parser found. Using bundled Expat])
  HAVE_EXPAT=yes
  USE_BUNDLED_EXPAT=yes
fi

# OpenSSL
AX_OPENSSL()
CONFIG_HAVE_OPENSSL="$HAVE_OPENSSL"
if test "$HAVE_OPENSSL" = yes; then
	CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS $OPENSSL_CPPFLAGS"
	CONFIG_CFLAGS="$CONFIG_CFLAGS $OPENSSL_CPPFLAGS"
	CONFIG_LIBS="$CONFIG_LIBS $OPENSSL_LIBS"
	AC_DEFINE(HAVE_OPENSSL)
fi

# Resolv
AC_CHECK_LIB(resolv, inet_aton)

# DNSSD Service
case $host in
	*-*-cygwin*)
		;;
	*-mingw32*)
		;;
	*-*-darwin*)
		HAVE_BONJOUR=yes
    AC_DEFINE(HAVE_BONJOUR)
		;;
	*)
    AX_AVAHI()
    if test "$HAVE_AVAHI" = yes; then
      CONFIG_CXXFLAGS="$CONFIG_CXXFLAGS $AVAHI_CPPFLAGS"
      CONFIG_LDFLAGS="$CONFIG_LDFLAGS $AVAHI_LDFLAGS"
      CONFIG_LIBS="$AVAHI_LIBS $CONFIG_LIBS"
      AC_DEFINE(HAVE_AVAHI)
    fi
esac


################################################################################
# Build configuration summary
################################################################################

echo
echo "    Build Configuration"
echo "    -------------------"

TEXT_XML_PARSERS=
if test "$HAVE_LIBXML" == "yes"; then TEXT_XML_PARSERS="LibXML"; fi
if test "$USE_BUNDLED_EXPAT" == "yes"; then TEXT_XML_PARSERS="(Bundled)"; fi
if test "$HAVE_EXPAT" == "yes"; then TEXT_XML_PARSERS="Expat $TEXT_XML_PARSERS"; fi
echo "    XML Parser(s): $TEXT_XML_PARSERS"

if test "$HAVE_OPENSSL" = yes; then TEXT_TLS_SUPPORT="OpenSSL"; fi
if test "$HAVE_OPENSSL" != yes; then TEXT_TLS_SUPPORT="Disabled"; fi
echo "    TLS support: $TEXT_TLS_SUPPORT"
echo

################################################################################
# Generate files
################################################################################

AC_SUBST(SET_MAKE)
AC_SUBST(HAVE_EXPAT)
AC_SUBST(HAVE_AVAHI)
AC_SUBST(HAVE_BONJOUR)
AC_SUBST(CONFIG_CXX)
AC_SUBST(CONFIG_CXXFLAGS)
AC_SUBST(CONFIG_CC)
AC_SUBST(MM)
AC_SUBST(CONFIG_CFLAGS)
AC_SUBST(CONFIG_LDFLAGS)
AC_SUBST(CONFIG_LIBS)
AC_SUBST(LIBS)
AC_SUBST(CONFIG_WIN32)
AC_SUBST(CONFIG_MACOSX)
AC_SUBST(CONFIG_HAVE_OPENSSL)
AC_SUBST(USE_BUNDLED_EXPAT)
AC_SUBST(CONFIG_HAVE_LIBXML)
AC_SUBST(QMAKE)
AC_SUBST(BUILD_SWIFT)
AC_SUBST(BUILD_LIMBER)
AC_SUBST(BUILD_SLIMBER)
AC_SUBST(ARCH)

AC_CONFIG_FILES([Makefile.config])
if test "$BUILD_SWIFT" == "yes"; then
	AC_CONFIG_FILES([Swift/QtUI/config.pri])
fi
AC_OUTPUT