Subversion Repositories Scribus

Rev

Rev 6552 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2398 craig 1
dnl Process this file with autoconf to produce a configure script.
2
 
779 fschmid 3
# Original Author was Kalle@kde.org
4
# I lifted it in some mater. (Stephan Kulow)
5
# I used much code from Janos Farkas
2398 craig 6
# Heavily tweaked and modified for Scribus by Craig Ringer
779 fschmid 7
 
2398 craig 8
dnl Quick `configure.in.in' survival guide:
9
dnl
10
dnl AC_MSG_WARN([warning message])
11
dnl     prints the warning and continues
12
dnl AC_MSG_ERROR([error message])
13
dnl     prints the error and stops configure
2400 craig 14
dnl AC_PATH_PROG([VARNAME],[programname],[notfoundvalue],[search path])
15
dnl     Searches for programname along search path or default path and sets
16
dnl     VARNAME to the path to the program, if found. If not found and
17
dnl     notfoundvalue provided, sets VARNAME to notfoundvalue, otherwise "".
2398 craig 18
dnl AC_CHECK_LIB(lib_basename, lib_symbol, [command_if_success], [command_if_fail])
19
dnl     Looks for a library with basename lib_basename, ie libfreetype.so.3.0.0
20
dnl     might be found for lib_basename=libfreetype, and checks for the lib_symbol
21
dnl     symbol inside. The symbol is usually an important function, a version symbol,
22
dnl     etc. Runs the specified commands on failure (lib not found OR symbol not found)
23
dnl     or success, as appropriate.
24
dnl AC_CHECK_HEADER(headerfilename.h, [successcommand], [failcommand])
25
dnl     Search for headerfilename.h. If found, run successcommand, otherwise
26
dnl     run failcommand.
27
dnl AC_SUBST(VARNAME)
28
dnl     "export" VARNAME so that it's defined in the Makefile.in with the value
29
dnl     it was set to in this script. Thus:
30
dnl         LIBFRED=" -lfred "
31
dnl         AC_SUBST(LIBFRED)
32
dnl     will let you use $(LIBFRED) in the Makefile.am .
33
dnl AC_DEFINE_UNQUOTED(VARNAME, VALUE, [comment in config.h])
34
dnl     Sets VARNAME to VALUE in config.h, so it can be tested for in preprocessor
35
dnl     macros in the source. The supplied comment is included in config.h .
36
dnl
37
dnl configure.in.in is written in shell script, plus M4 macros that expand into
38
dnl yet more shell script. Some M4 macros are provided by autoconf and automake,
39
dnl some by libtool, and some are provided by KDE. In general, if its
40
dnl UPPER_CASE(WITH_BRACKETS) it'll be an M4 macro, and if it looks like shell
41
dnl script it probably is. Variables are boring old shell variables unless exported
42
dnl to somewhere using AC_SUBST(...) or AC_DEFINE_UNQUOTED(...) and friends.
43
dnl
2399 craig 44
dnl `dnl' is an M4 comment, # is a shell comment. The only differences are that
45
dnl M4 macros in shell comments still get expanded so if you want to "comment out"
46
dnl code with M4 macros you must use dnl, and that dnl comments are omitted from
47
dnl configure.in .
48
dnl
49
dnl Note that you should NOT assume the user has bash. Ensure that you TEST YOUR CODE
50
dnl with ash or a similar "primitive" shell before committing.
51
dnl
2398 craig 52
dnl Blame any errors in the above entirely on Craig Ringer. Please see the
53
dnl autoconf documentation (ha!) for details on these and more.
779 fschmid 54
 
55
AC_INIT(acinclude.m4) dnl a source file from your sub dir
56
 
57
dnl This is so we can use kde-common
58
AC_CONFIG_AUX_DIR(admin)
59
 
60
AC_CANONICAL_SYSTEM
61
AC_ARG_PROGRAM
62
 
63
dnl Automake doc recommends to do this only here. (Janos)
9317 mrdocs 64
AM_INIT_AUTOMAKE(scribus,1.3.4)
779 fschmid 65
 
2962 craig 66
dnl Check for --enable-lib64
67
KDE_CHECK_LIB64
68
 
2839 craig 69
dnl Add the libs and includes from --with-extra-libs and --with-extra-includes
70
KDE_CHECK_EXTRA_LIBS
71
 
779 fschmid 72
dnl KDE_SET_PREFIX
73
 
74
AC_PREFIX_DEFAULT(/usr/local)
75
if test "x$prefix" = "xNONE"; then
76
  prefix=$ac_default_prefix
77
  ac_configure_args="$ac_configure_args --prefix $prefix"
78
fi
79
 
1592 craig 80
dnl Look for pkg-config, which we use to find fontconfig and
81
dnl will probably need for other things in future.
82
PKG_CONFIG=""
83
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
779 fschmid 84
 
2399 craig 85
dnl Define a handy function to print a message for when libraries
86
dnl can't be found. This can be called from configure.in.in, and from
87
dnl configure.in.bot (which is, after all, just tacked on the bottom
88
dnl during the generation of configure).
89
 
2405 craig 90
libmissing_text="\
91
You may need to install some additional libraries or packages (on Linux,
92
that may mean -dev or -devel packages too). Also check your environment
4202 craig 93
variables. If you're on a 64 bit machine, maybe you need to add
94
--enable-libsuffix=64 to the configure arguments.
95
See the BUILDING file for further details and troubleshooting information. "
2405 craig 96
 
2399 craig 97
missing_libs=""
98
 
2405 craig 99
# Usage: libmissing libfreetype required
100
#        libmissing libfontconfig optional
101
# to report a missing library
2838 craig 102
libmissing() {
2405 craig 103
	# name of library
104
	libname="${1}"
105
	# one of "optional" or "required"
106
	liboptional="${2}"
107
 
6552 craig 108
	terminate=no
2405 craig 109
	missing_libs="${libname} ${missing_libs}"
110
	if test "${liboptional}" = "required"; then
6552 craig 111
		terminate=yes
2405 craig 112
		reqword="required"
113
		endmsg="This library is required for Scribus to build. Configure will now terminate."
114
	elif test "${liboptional}" = "optional"; then
115
		reqword="optional"
116
		endmsg="This library is optional, and Scribus will build without it. Continuing."
117
	else
118
		endmsg=""
119
	fi
120
 
2400 craig 121
	AC_MSG_WARN([
122
-------------------------------------------------------------------------------
2405 craig 123
The ${reqword} library ${libname} could not be found. See the BUILDING file.
124
 
125
${libmissing_text}
126
${endmsg}
2400 craig 127
-------------------------------------------------------------------------------
128
])
2405 craig 129
 
6552 craig 130
	if test "$terminate" = "yes"; then
131
		AC_MSG_ERROR([Required library ${libname} not found])
132
	fi
133
 
2399 craig 134
}
2405 craig 135
# end libmissing()
2399 craig 136
 
4181 craig 137
dnl Use gcc symbol visibility?
138
dnl This should probably default to "yes" in future.
139
AC_ARG_ENABLE(gcc_symbol_visibility,
4200 craig 140
			  [  --enable-gcc-symbol-visibility  Use -fvisiblity with gcc for smaller binaries.],
141
			  [use_gcc_symbol_visibility="yes"])
4181 craig 142
KDE_CHECK_COMPILER_FLAG(fvisibility=hidden, [have_visibility=yes])
143
AC_MSG_CHECKING([whether to use gcc symbol visibility controls])
4200 craig 144
if test "$use_gcc_symbol_visibility" = "yes" -a "$have_visibility" = "yes"; then
4181 craig 145
	# see http://people.redhat.com/drepper/dsohowto.pdf , http://gcc.gnu.org/wiki/Visibility
146
	gcc_visibility_flags="$CXXFLAGS -fvisibility=hidden -DHAVE_GCC_SYMBOL_VISIBILITY=1"
147
	GCC_C_VISIBILITY_FLAGS="$gcc_visibility_flags"
148
	GCC_CXX_VISIBILITY_FLAGS="$gcc_visibility_flags -fvisibility-inlines-hidden "
149
	AC_MSG_RESULT([yes])
150
else
151
	GCC_C_VISIBILITY_FLAGS=""
152
	GCC_CXX_VISIBILITY_FLAGS=""
153
	AC_MSG_RESULT([no - disabled or no compiler support])
154
fi
155
AC_SUBST(GCC_C_VISIBILITY_FLAGS)
156
AC_SUBST(GCC_CXX_VISIBILITY_FLAGS)
2399 craig 157
 
779 fschmid 158
LIBART_LIBS=""
159
LIBART_CFLAGS=""
160
LIBART_CONFIG=""
2399 craig 161
 
162
AC_PATH_PROG(LIBART_CONFIG,
2401 craig 163
			 libart2-config,
2400 craig 164
			 [],
2399 craig 165
			 [$PATH ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /usr/nekoware/bin /opt/local/bin])
166
 
779 fschmid 167
if test -n "$LIBART_CONFIG"; then
168
  vers=`$LIBART_CONFIG --version 2>/dev/null | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
169
  if test -n "$vers" && test "$vers" -ge 2003008
170
  then
171
     LIBART_LIBS="`$LIBART_CONFIG --libs`"
172
     LIBART_CFLAGS="`$LIBART_CONFIG --cflags`"
173
     AC_DEFINE_UNQUOTED(HAVE_LIBART, 1, [Defines if your system has the libart library])
174
  else
2405 craig 175
     libmissing libart required
2401 craig 176
	 AC_MSG_ERROR([You need at least libart 2.3.8 . See the BUILDING file.])
779 fschmid 177
  fi
2400 craig 178
else
2405 craig 179
  libmissing libart required
2401 craig 180
  AC_MSG_ERROR([You need at least libart 2.3.8 . See the BUILDING file.])
779 fschmid 181
fi
3113 fschmid 182
 
183
hacairo=no
184
LIBCAIRO_LIBS=""
185
LIBCAIRO_CFLAGS=""
186
COMPILE_CAIRO=no
187
AC_ARG_ENABLE(cairo, [  --enable-cairo     Enables building with cairo support],
188
[if test "x$enable_cairo" = "xyes" || test "x$enable_cairo" = "xfull"; then
189
	COMPILE_CAIRO=yes
190
	AC_MSG_CHECKING([Checking for cairo with pkg-config])
191
	if test -n "$PKG_CONFIG"; then
192
		LIBCAIRO_LIBS="`$PKG_CONFIG cairo --libs`"
193
		LIBCAIRO_CFLAGS="`$PKG_CONFIG cairo --cflags`"
194
		if test -n "$LIBCAIRO_LIBS" || test -n "$LIBCAIRO_CFLAGS"; then
195
			AC_MSG_RESULT([found])
196
			hacairo=yes
197
		else
198
			AC_MSG_RESULT([not found])
199
		fi
200
	else
201
		AC_MSG_RESULT([failed: pkg-config not found])
202
	fi
203
	if test $hacairo = yes; then
3320 fschmid 204
		LIBART_LIBS=""
205
		LIBART_CFLAGS=""
3113 fschmid 206
		AC_DEFINE_UNQUOTED(HAVE_CAIRO, 1, [Defines if your system has the cairo library])
207
	else
208
		libmissing cairo optional
209
		AC_MSG_WARN([Couldn't find a usable cairo])
210
	fi
211
fi])
212
AM_CONDITIONAL(COMPILE_CAIRO, test x$COMPILE_CAIRO = xyes)
213
AC_SUBST(LIBCAIRO_LIBS)
214
AC_SUBST(LIBCAIRO_CFLAGS)
215
 
779 fschmid 216
AC_SUBST(LIBART_LIBS)
217
AC_SUBST(LIBART_CFLAGS)
218
AC_C_BIGENDIAN
219
 
1599 craig 220
dnl Check for freetype, which Scribus *requires* to build
779 fschmid 221
LIBFREETYPE_LIBS=""
222
LIBFREETYPE_CFLAGS=""
223
 
224
FREETYPE_CONFIG=""
2399 craig 225
AC_PATH_PROG(FREETYPE_CONFIG,
2403 craig 226
			 freetype-config,
2402 craig 227
			 [],
2399 craig 228
			 [$PATH ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin /usr/nekoware/bin /usr/X11/bin])
779 fschmid 229
 
230
hafree=no
2312 craig 231
hafree_post219=
779 fschmid 232
if test -n "$FREETYPE_CONFIG"; then
233
	LIBFREETYPE_LIBS="`$FREETYPE_CONFIG --libs`"
1599 craig 234
	LIBFREETYPE_CFLAGS="`$FREETYPE_CONFIG --cflags`"
779 fschmid 235
	AC_CHECK_LIB(freetype, FT_Get_First_Char, [hafree=yes],[hafree=no], "$LIBFREETYPE_LIBS")
236
	AC_CHECK_LIB(freetype, FT_Get_Next_Char, [hafree=yes],[hafree=no], "$LIBFREETYPE_LIBS")
237
	if test $hafree = yes; then
238
		AC_DEFINE_UNQUOTED(HAVE_FREETYPE, 1, [Defines if your system has the libfreetype library])
239
	else
2405 craig 240
		libmissing libfreetype required
1599 craig 241
		AC_MSG_ERROR([You need at least freetype 2.1.0])
779 fschmid 242
	fi
1599 craig 243
 
2312 craig 244
	dnl Warn the user if they have less than freetype 2.1.9
245
	dnl Changed to fatal error
246
	AC_MSG_CHECKING(freetype version > 2.1.9)
1599 craig 247
	SAVE_CFLAGS="${CFLAGS}"
248
	CFLAGS=" ${LIBFREETYPE_CFLAGS} "
249
	AC_TRY_COMPILE([
250
	#include <ft2build.h>
251
	#include FT_FREETYPE_H
252
	],[
2312 craig 253
	#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 1 && FREETYPE_PATCH < 9
254
	#error freetype 2.1 older than 2.1.9
1599 craig 255
	#endif
2312 craig 256
	], [hafree_post219=yes], [hafree_post219=no])
1599 craig 257
	CFLAGS="${SAVE_CFLAGS}"
2312 craig 258
	AC_MSG_RESULT($hafree_post219)
259
	if test hafree_post219 = no; then
260
		AC_MSG_WARN([Your libfreetype is too old - version 2.1.9 or newer strongly recommended])
1599 craig 261
	fi
262
 
263
	dnl Export the includes and lib path settings required to build with freetype.
779 fschmid 264
	AC_SUBST(LIBFREETYPE_LIBS)
265
	AC_SUBST(LIBFREETYPE_CFLAGS)
266
else
2405 craig 267
	libmissing libfreetype required
2401 craig 268
	AC_MSG_ERROR([You need at least freetype 2.1.0])
779 fschmid 269
fi
270
 
1592 craig 271
dnl Try to find fontconfig using fontconfig-config or pkg-config.
1920 craig 272
hafontconfig=no
779 fschmid 273
LIBFONTCONFIG_LIBS=""
274
LIBFONTCONFIG_CFLAGS=""
275
FONTCONFIG_CONFIG=""
276
 
1920 craig 277
dnl Try to find fontconfig with pkg-config if we have pkg-config
278
AC_MSG_CHECKING([Checking for fontconfig with pkg-config])
279
if test -n "$PKG_CONFIG"; then
1592 craig 280
	LIBFONTCONFIG_LIBS="`$PKG_CONFIG fontconfig --libs`"
281
	LIBFONTCONFIG_CFLAGS="`$PKG_CONFIG fontconfig --cflags`"
1920 craig 282
	if test -n "$LIBFONTCONFIG_LIBS" || test -n "$LIBFONTCONFIG_CFLAGS"; then
283
		AC_MSG_RESULT([found])
284
	else
285
		AC_MSG_RESULT([not found])
286
	fi
779 fschmid 287
else
1920 craig 288
	AC_MSG_RESULT([failed: pkg-config not found])
779 fschmid 289
fi
1635 craig 290
 
1920 craig 291
dnl If fontconfig not found with pkg-config, try to find fontconfig-config
292
dnl and use that to look for fontconfig.
293
if test -z "$LIBFONTCONFIG_LIBS" && test -z "$LIBFONTCONFIG_CFLAGS"; then
2399 craig 294
	dnl Seems we didn't find fontconfig with pkg-config, so search for the old
295
	dnl fontconfig-config program instead.
296
	AC_PATH_PROG(FONTCONFIG_CONFIG,
297
				 fontconfig-config,
298
				 [],
299
				 [$PATH ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin /usr/nekoware/bin /usr/X11/bin])
1920 craig 300
	if test -n "$FONTCONFIG_CONFIG"; then
301
		dnl found fontconfig-config, use it's results
302
		LIBFONTCONFIG_LIBS="`$FONTCONFIG_CONFIG --libs`"
303
		LIBFONTCONFIG_CFLAGS="`$FONTCONFIG_CONFIG --cflags`"
304
	else
305
		AC_MSG_WARN([Couldn't find fontconfig-config or find fontconfig with pkg-config])
306
	fi
307
fi
308
 
1635 craig 309
dnl Check to see if we can compile fontconfig
310
SAVE_CFLAGS="${CFLAGS}"
311
SAVE_LDFLAGS="${LDFLAGS}"
312
CFLAGS="${CFLAGS} ${LIBFONTCONFIG_CFLAGS}"
313
LDFLAGS="${LDFLAGS} ${LIBFONTCONFIG_LIBS}"
1592 craig 314
AC_CHECK_LIB(fontconfig, FcPatternBuild, [hafontconfig=yes],[hafontconfig=no])
1635 craig 315
CFLAGS="${SAVE_CFLAGS}"
316
LDFLAGS="${SAVE_LDFLAGS}"
1592 craig 317
if test $hafontconfig = yes; then
318
	AC_DEFINE_UNQUOTED(HAVE_FONTCONFIG, 1, [Defines if your system has the libfontconfig library])
319
else
2405 craig 320
	libmissing libfontconfig optional
1592 craig 321
	AC_MSG_WARN([Couldn't find a usable libfontconfig])
322
fi
323
AC_SUBST(LIBFONTCONFIG_LIBS)
324
AC_SUBST(LIBFONTCONFIG_CFLAGS)
779 fschmid 325
 
1592 craig 326
 
779 fschmid 327
XML_LIBS=""
328
XML_CFLAGS=""
329
 
330
XML_CONFIG=""
2399 craig 331
AC_PATH_PROG(XML_CONFIG,
332
			 xml2-config,
2403 craig 333
			 [],
2399 craig 334
			 [${PATH} ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin /usr/nekoware/bin /usr/X11/bin])
779 fschmid 335
 
1599 craig 336
dnl check for LibXML2
779 fschmid 337
haxml=no
2314 craig 338
haxml26=no
339
AC_ARG_ENABLE(xml, [  --disable-xml       Don't use libxml2 and turn off some Scribus features.], [disable_xml2="yes"])
340
if test "$disable_xml2" != "yes"; then
341
	if test -n "$XML_CONFIG"; then
342
		XML_LIBS="`$XML_CONFIG --libs`"
343
		XML_CFLAGS="`$XML_CONFIG --cflags`"
4381 craig 344
		SAVE_LDFLAGS="$LDFLAGS"
345
		LDFLAGS="$all_libraries $XML_LDFLAGS $LDFLAGS"
2314 craig 346
		AC_CHECK_LIB(xml2, attribute, [haxml=yes],[haxml=no])
4381 craig 347
		LDFLAGS="$SAVE_LDFLAGS"
2314 craig 348
		if test $haxml = yes; then
349
			AC_DEFINE_UNQUOTED(HAVE_XML, 1, [Defines if your system has the libxml2 library])
350
			AC_SUBST(XML_LIBS)
351
			AC_SUBST(XML_CFLAGS)
2403 craig 352
		else
4369 craig 353
			libmissing libxml2
2403 craig 354
			AC_MSG_WARN([Couldn't find a usable libxml2])
2314 craig 355
		fi
356
		vers=`$XML_CONFIG --version 2>/dev/null | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
357
		if test -n "$vers" && test "$vers" -ge 2006000
358
		then
359
			AC_DEFINE_UNQUOTED(HAVE_XML26, 1, [Defines if your system has the libxml2 library6])
360
			haxml26=yes
361
		fi
2403 craig 362
	else
2405 craig 363
		libmissing libxml2 optional
2403 craig 364
		AC_MSG_WARN([Couldn't find a usable libxml2])
779 fschmid 365
	fi
366
fi
367
 
1599 craig 368
dnl check for -lsocket
779 fschmid 369
AC_CHECK_LIB(socket,socket,
370
if test "$uname" != "IRIX"; then
371
	LIBS="-lsocket $LIBS"
372
else
373
	echo "Not using -lsocket since you are running IRIX."
374
fi)
375
AC_CHECK_LIB(nsl,gethostbyaddr,
376
if test "$uname" != "IRIX"; then
377
	LIBS="-lnsl $LIBS"
378
else
379
	echo "Not using -lnsl since you are running IRIX."
380
fi)
381
 
1595 craig 382
dnl Check for lcms
383
dnl TODO look for lcms using pkg-config too
2310 craig 384
dnl TODO: convert to use --with-lcms= and AC_ARG_WITH(...)
779 fschmid 385
LIBLCMS=""
386
hacms=
6552 craig 387
# CR - we now require lcms
388
# AC_ARG_ENABLE(lcms, [  --disable-lcms     Don't use colour management (default=no)], [disable_lcms="yes"])
2310 craig 389
 
390
# If lcms hasn't been explicitly disabled, look for it and see
391
# if we can use it.
392
if test "$disable_lcms" != "yes"; then
393
	# See if liblcms.so is on our search path and looks vaguely valid
2962 craig 394
	SAVE_LDFLAGS="$LDFLAGS"
395
	LDFLAGS="$all_ldflags $LDFLAGS"
396
	export LDFLAGS
2310 craig 397
	AC_CHECK_LIB(lcms, _cmsChannelsOf, [LIBLCMS="-llcms";hacms=yes],[LIBLCMS="";hacms=no],[-lm])
398
	hacmsh=
399
	lcms_h=
400
	# and search for lcms.h, which may or may not be in an lcms/ subdir
401
	AC_CHECK_HEADER(lcms.h, [hacmsh=yes],[hacmsh=no])
402
	if test $hacmsh = no; then
403
		AC_CHECK_HEADER(lcms/lcms.h, [hacmsh=yes],[hacmsh=no])
404
		if test $hacmsh = yes; then
405
			AC_DEFINE_UNQUOTED(CMS_INC, "lcms/lcms.h", [ColorManagementInclude])
406
			lcms_h="lcms/lcms.h"
407
		fi
408
	else
409
		AC_DEFINE_UNQUOTED(CMS_INC, "lcms.h", [ColorManagementInclude])
410
		lcms_h="lcms.h"
779 fschmid 411
	fi
2310 craig 412
	if test $hacmsh = no; then
413
		# There's not much point finding -llcms if we can't find the header file...
414
		hacms=no
415
	fi
2962 craig 416
	LDFLAGS="$SAVE_LDFLAGS"
779 fschmid 417
fi
1595 craig 418
dnl Attempt to check that lcms is new enough
419
if test $hacms = yes; then
420
	AC_MSG_CHECKING(liblcms version > 1.1.2)
421
	AC_TRY_COMPILE([
422
	#include "$lcms_h"
1599 craig 423
	],[
1595 craig 424
	#if LCMS_VERSION < 112
425
	#error liblcms is too old, need LittleCMS 1.1.2 or newer
426
	#endif
1599 craig 427
	], [], [hacms=pre112])
1595 craig 428
	AC_MSG_RESULT($hacms)
429
fi
430
 
779 fschmid 431
AC_SUBST(LIBLCMS)
432
if test $hacms = yes && test $hacmsh = yes; then
2406 craig 433
	AC_DEFINE_UNQUOTED(HAVE_CMS, 1, [ColorManagement])
434
else
6552 craig 435
	libmissing liblcms required
779 fschmid 436
fi
1580 craig 437
 
438
dnl Checks for libtiff - library exists, tiffvers.h can be found, and new enough.
779 fschmid 439
LIBTIFF=""
440
hastif=
1580 craig 441
dnl Check if we have libtiff
4381 craig 442
SAVE_LDFLAGS="$LDFLAGS"
443
LDFLAGS="$all_libraries $LDFLAGS"
779 fschmid 444
AC_CHECK_LIB(tiff, TIFFOpen, [LIBTIFF="-ltiff";hastif=yes],[LIBTIFF="";hastif=no],[-lm])
4381 craig 445
LDFLAGS="$SAVE_LDFLAGS"
1585 craig 446
if test $hastif = yes; then
447
	dnl Check for tiffvers.h
4381 craig 448
	SAVE_CFLAGS="$CFLAGS"
449
	CFLAGS="$all_includes $CFLAGS"
1585 craig 450
	AC_CHECK_HEADER(tiffvers.h, [], [LIBTIFF="";hastif=no])
451
	if test $hastif = yes; then
452
		dnl Now attempt to check if libtiff is new enough
453
		AC_MSG_CHECKING(libtiff version > 3.6.0)
454
		AC_TRY_COMPILE([
455
		#include "tiffvers.h"
1599 craig 456
		],[
1585 craig 457
		#if TIFFLIB_VERSION < 20031007
458
		#error libtiff is too old, need libtiff 3.6.0 or newer.
459
		#endif
1599 craig 460
		], [], [LIBTIFF="";hastif=pre36])
1585 craig 461
		AC_MSG_RESULT($hastif)
462
	fi
4381 craig 463
	CFLAGS="$SAVE_CFLAGS"
1585 craig 464
fi
2406 craig 465
if test "${hastif}" != "yes"; then
6552 craig 466
	libmissing libtiff required
2406 craig 467
fi
779 fschmid 468
AC_SUBST(LIBTIFF)
469
if test $hastif = yes; then
2406 craig 470
	AC_DEFINE_UNQUOTED(HAVE_TIFF, 1, [Tifflib])
779 fschmid 471
fi
1580 craig 472
 
779 fschmid 473
LIBDL2=""
474
AC_CHECK_LIB(c, dlopen, [LIBDL2="-lc"],[LIBDL2=""])
475
AC_SUBST(LIBDL2)
476
 
477
dnl generate the config header
478
AM_CONFIG_HEADER(config.h) dnl at the distribution this done
479
 
480
dnl Checks for programs.
481
AC_CHECK_COMPILERS
482
AC_ENABLE_SHARED(yes)
483
AC_ENABLE_STATIC(no)
484
KDE_PROG_LIBTOOL
485
 
486
kde_python_link_found=no
2512 craig 487
KDE_CHECK_PYTHON(2.3)
2511 craig 488
COMPILE_PYTHON=
779 fschmid 489
AC_ARG_WITH(python, [  --without-python     Do not compile the Scripter Plugin],[ COMPILE_PYTHON=no ],[ COMPILE_PYTHON=yes ])
2511 craig 490
if test "$COMPILE_PYTHON" != "no"; then
491
	if test "$enable_mac" = yes ; then
492
		dnl Mac OS X always has Python, but the KDE config scripts don't know
493
		dnl how to find it. We just hardcode the values here.
494
		AC_DEFINE_UNQUOTED(HAVE_PYTHON_23, 1, [Python])
495
		PYTHONINC='-I/System/Library/Frameworks/Python.framework/Headers'
2527 craig 496
		PYTHONLIB='-L/System/Library/Frameworks/Python.framework -framework Python'
2511 craig 497
		PYTHONMODDIR='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3'
498
		COMPILE_PYTHON=yes
499
	elif test "$kde_python_link_found" = yes; then
500
		dnl Configure found the Python libs
501
		COMPILE_PYTHON=yes
502
	else
503
		dnl Configure didn't find python libs
504
		COMPILE_PYTHON=no
505
	fi
779 fschmid 506
fi
507
AM_CONDITIONAL(COMPILE_PYTHON, test x$COMPILE_PYTHON = xyes)
508
 
2311 craig 509
AC_ARG_ENABLE(cups, [  --disable-cups        Do not compile support for CUPS printing],[disable_cups=yes])
510
LIBCUPS=""
511
hacups=no
512
if test "$disable_cups" != "yes" ; then
513
	# Look for cups.h
4381 craig 514
	SAVE_CFLAGS="$CFLAGS"
515
	CFLAGS="$all_includes $CFLAGS"
2311 craig 516
	AC_CHECK_HEADER(cups/cups.h, [hacups_h=yes],[hacups_h=no])
4381 craig 517
	CFLAGS="$SAVE_CFLAGS"
2311 craig 518
	AC_CHECK_PROG(hacups_cfg, cups-config, yes, no)
519
	echo "'$hacups_cfg' '$hacups_h'" >/tmp/cfg
520
	if test "x$hacups_h" = "xyes" && test "x$hacups_cfg" = "xyes"; then
521
		# We have the CUPS libs and headers, so enable
522
		# the use of CUPS and tell the build where to
523
		# find it.
524
		LIBCUPS="`cups-config --libs`"
525
		AC_DEFINE_UNQUOTED(HAVE_CUPS, 1, [Cups])
526
		AC_SUBST(LIBCUPS)
527
		hacups=yes
528
	else
2406 craig 529
		libmissing libcups optional
2311 craig 530
		AC_MSG_WARN([libcups could not be found. Printing functionality will be limited.])
531
		hacups=no
532
	fi
533
else
534
	hacups=no
779 fschmid 535
fi
536
 
2409 craig 537
dnl While we don't use GhostScript during compilation - at least not
538
dnl currently - and can run without it, we check for it in configure
539
dnl to give users an early warning if it's missing.
540
AC_PATH_PROG(GS_PATH, gs)
2410 craig 541
AC_MSG_CHECKING([GhostScript version])
2409 craig 542
if test -z "${GS_PATH}" ; then
2410 craig 543
	AC_MSG_RESULT([gs not found])
2409 craig 544
	AC_MSG_WARN("GhostScript not found - gs 8.x is required for full features.")
2410 craig 545
else
546
	GS_VER_MAJOR=`gs --version | cut -d . -f 1`
547
	GS_VER_MINOR=`gs --version | cut -d . -f 2`
548
	AC_MSG_RESULT([${GS_VER_MAJOR}.${GS_VER_MINOR}])
549
	if (( "${GS_VER_MAJOR}" < 7 )) ; then
550
		AC_MSG_WARN("GhostScript found, but older than v7. v8 recommended.")
551
	elif (( "${GS_VER_MAJOR}" < 8 )) ; then
552
		AC_MSG_WARN("GhostScript v7 found. v8 recommended.")
553
	fi
2409 craig 554
fi
555
 
779 fschmid 556
COMPILE_DEBUG=no
2311 craig 557
AC_ARG_ENABLE(debug, [  --enable-debug     Enables debugging information (recommended for snapshots)],
1634 craig 558
[if test "x$enable_debug" = "xyes" || test "x$enable_debug" = "xfull"; then
779 fschmid 559
	COMPILE_DEBUG=yes
3592 avox 560
    if test "$enable_mac" = "yes"; then
561
        CXXFLAGS="$CXXFLAGS -g3 "
562
        CFLAGS="$CFLAGS -g3 "
563
    else
564
        CXXFLAGS="$CXXFLAGS -g3 -fno-inline -O0 "
565
        CFLAGS="$CFLAGS -g3 -fno-inline -O0 "
566
    fi
779 fschmid 567
fi])
568
AM_CONDITIONAL(COMPILE_DEBUG, test x$COMPILE_DEBUG = xyes)
569
 
1689 craig 570
dnl Compile and link the gdk-pixbuf sources unless building
571
dnl a Mac-native build.
572
AM_CONDITIONAL(LINK_PIXBUF, test "$enable_mac" != "yes" )
573
 
1699 craig 574
build_mac_bundle=no
2509 craig 575
AC_ARG_ENABLE(bundle, [  --enable-bundle     Make an executable suitable for use in a .app bundle (INCOMPLETE)], [build_mac_bundle=yes])
576
if test "$build_mac_bundle" = "yes"; then
1699 craig 577
	AC_DEFINE_UNQUOTED(BUILD_MAC_BUNDLE, 1, [Are we building an executable to be included in MacOS/X .app bundle?])
2509 craig 578
fi
579
if test "$enable_mac" != "yes" && test "$build_mac_bundle" = "yes"; then
580
	AC_MSG_ERROR([--enable-bundle only makes sense with --enable-mac])
581
fi
1699 craig 582
AM_CONDITIONAL(BUILD_MAC_BUNDLE, test "$build_mac_bundle" = "yes")
583
 
2509 craig 584
dnl On Mac OS X and Darwin we need to link the final binary to CoreFoundation.
585
if test "$enable_mac" = "yes"; then
586
	COREFOUNDATION_LIBS="-framework CoreFoundation"
587
else
588
	COREFOUNDATION_LIBS=
589
fi
590
AC_SUBST(COREFOUNDATION_LIBS)
591
 
1732 craig 592
dnl Some platforms require special libtool flags to build dynamically loadable
593
dnl modules or plugins correctly. While libtool should take care of this with
594
dnl a fixed set of arguments, in case we need to change it later this is being
595
dnl made a configure-time substitution.
596
MODULE_LINK_FLAGS=" -module "
597
AC_SUBST(MODULE_LINK_FLAGS)
598
 
779 fschmid 599
all_libraries="$all_libraries $USER_LDFLAGS"
600
all_includes="$all_includes $USER_INCLUDES"
601
AC_SUBST(all_includes)
602
AC_SUBST(all_libraries)
603
 
2689 craig 604
AH_TOP([
605
/*
606
 * Prevent code from including config.h directly. You should include
607
 * scconfig.h instead. This lets us handle win-config.h correctly, and
608
 * may do more later.
609
 */
610
#ifndef _SCCONFIG_H
611
#error "Include <scconfig.h> rather than using <config.h> directly"
612
#endif
613
])
614
 
779 fschmid 615
AC_PATH_QT
616
 
4119 craig 617
dnl Should we compile the new Boost::Python-based Python plugin?
618
AC_ARG_ENABLE(scripter2,
619
			  [  --enable-scripter2   Enable compilation of extended Python scripting],
620
			  [use_scripter2="yes"])
621
AC_MSG_CHECKING([If we should build Boost::Python-based Python scripting])
622
BOOST_PYTHON_CXXFLAGS=""
623
BOOST_PYTHON_LDFLAGS=""
624
if test "$use_scripter2" = "yes"; then
625
	dnl TODO : check for Boost::Python
626
	have_boost_python=yes
627
	if test "$have_boost_python" = "yes" ; then
628
		AC_DEFINE_UNQUOTED(HAVE_BOOST_PYTHON, 1, "Boost::Python is available")
629
		AC_DEFINE_UNQUOTED(HAVE_SCRIPTER2, 1, "We'll build and use the extended scripter")
630
		BOOST_PYTHON_CXXFLAGS=" -fexceptions -Wno-extra -Wno-unused "
631
		BOOST_PYTHON_LDFLAGS=" -lboost_python "
632
		AC_MSG_RESULT([yes])
633
	else
634
		AC_MSG_RESULT([no])
635
	fi
636
else
637
	AC_MSG_RESULT([no])
638
fi
639
AM_CONDITIONAL(HAVE_SCRIPTER2, test "$use_scripter2" = "yes")
640
AC_SUBST(BOOST_PYTHON_CXXFLAGS)
641
AC_SUBST(BOOST_PYTHON_LDFLAGS)
642
 
4381 craig 643
 
644
AC_ARG_ENABLE(qt4-test,
645
			  [  --disable-qt4-test   Skip a sanity check with Qt4 detection. Don't report bugs if you use this.],
646
			  [notestqt4="yes"])
647
if ! test "$notestqt4" = "yes" ; then
648
	dnl We have to do our Qt version check only after KDE's magic has found Qt
649
	dnl Note that configure does this test with gcc, not g++, so we need to use
650
	dnl CFLAGS not CXXFLAGS. Also, if QT_INCLUDES is the same as X_INCLUDES,
651
	dnl only X_INCLUDES must be set, so we must include both. Just use $all_includes
652
	dnl to work around the mess.
653
	SAVE_CFLAGS="${CFLAGS}"
654
	CFLAGS="$all_includes ${CFLAGS}"
655
	AC_MSG_CHECKING([if we're trying to compile against Qt 4])
656
	dnl If this snippet compiles correctly, we're using an older Qt and are fine.
657
	dnl If it fails, we know we're using Qt 4. We don't need to test for Qt 3.3
658
	dnl here, AC_PATH_QT has done that for us.
659
	AC_TRY_COMPILE([
660
	#include <qglobal.h>
661
	],[
662
	#if QT_VERSION >= 0x040000
663
	#error Scribus does not support Qt 4
664
	#endif
665
	], [using_qt4=no], [using_qt4=yes])
666
	if test "${using_qt4}" = "yes"; then
667
		AC_MSG_RESULT([Qt 4 found])
668
		AC_MSG_ERROR([Scribus does not yet support Qt 4])
669
	else
670
		AC_MSG_RESULT([Usable Qt 3.x found])
671
	fi
672
	CFLAGS="${SAVE_CFLAGS}"
2787 craig 673
fi
4181 craig 674
 
675
dnl Check to see if we're using gcc4, and if so disable a couple of warning flags that
676
dnl produce spurious warnings with qt3. Do not rely on the using_gcc4 flag elsewhere, instead
677
dnl check specific compiler capabilities with KDE_CHECK_COMPILER_FLAG(...) etc. We test this
678
dnl flag because gcc3 also supports it, but it only ends up being enabled under gcc4 due to changes
679
dnl in the behaviour of -Wall -W .
680
AC_TRY_COMPILE([
681
], [
682
#if __GNUC__ < 4
683
#error __GNUC__ < 4, not using gcc4
684
#endif
685
],
686
[ using_gcc4="yes" ], [ using_gcc4="no" ])
687
if test "$using_gcc4" = "yes"; then
9317 mrdocs 688
dnl	CXXFLAGS="$CXXFLAGS -Wno-non-virtual-dtor -Wstring-literal-comparison"
689
CXXFLAGS="$CXXFLAGS -Wno-non-virtual-dtor"
4181 craig 690
fi
691
dnl unset the flag to prevent abuse (DO NOT rely on this flag)
692
unset using_gcc4