Subversion Repositories Scribus

Rev

Rev 4200 | Rev 4369 | Go to most recent revision | 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)
3485 fschmid 64
AM_INIT_AUTOMAKE(scribus,1.3.2cvs)
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
 
108
	missing_libs="${libname} ${missing_libs}"
109
	if test "${liboptional}" = "required"; then
110
		reqword="required"
111
		endmsg="This library is required for Scribus to build. Configure will now terminate."
112
	elif test "${liboptional}" = "optional"; then
113
		reqword="optional"
114
		endmsg="This library is optional, and Scribus will build without it. Continuing."
115
	else
116
		endmsg=""
117
	fi
118
 
2400 craig 119
	AC_MSG_WARN([
120
-------------------------------------------------------------------------------
2405 craig 121
The ${reqword} library ${libname} could not be found. See the BUILDING file.
122
 
123
${libmissing_text}
124
${endmsg}
2400 craig 125
-------------------------------------------------------------------------------
126
])
2405 craig 127
 
2399 craig 128
}
2405 craig 129
# end libmissing()
2399 craig 130
 
4181 craig 131
dnl Use gcc symbol visibility?
132
dnl This should probably default to "yes" in future.
133
AC_ARG_ENABLE(gcc_symbol_visibility,
4200 craig 134
			  [  --enable-gcc-symbol-visibility  Use -fvisiblity with gcc for smaller binaries.],
135
			  [use_gcc_symbol_visibility="yes"])
4181 craig 136
KDE_CHECK_COMPILER_FLAG(fvisibility=hidden, [have_visibility=yes])
137
AC_MSG_CHECKING([whether to use gcc symbol visibility controls])
4200 craig 138
if test "$use_gcc_symbol_visibility" = "yes" -a "$have_visibility" = "yes"; then
4181 craig 139
	# see http://people.redhat.com/drepper/dsohowto.pdf , http://gcc.gnu.org/wiki/Visibility
140
	gcc_visibility_flags="$CXXFLAGS -fvisibility=hidden -DHAVE_GCC_SYMBOL_VISIBILITY=1"
141
	GCC_C_VISIBILITY_FLAGS="$gcc_visibility_flags"
142
	GCC_CXX_VISIBILITY_FLAGS="$gcc_visibility_flags -fvisibility-inlines-hidden "
143
	AC_MSG_RESULT([yes])
144
else
145
	GCC_C_VISIBILITY_FLAGS=""
146
	GCC_CXX_VISIBILITY_FLAGS=""
147
	AC_MSG_RESULT([no - disabled or no compiler support])
148
fi
149
AC_SUBST(GCC_C_VISIBILITY_FLAGS)
150
AC_SUBST(GCC_CXX_VISIBILITY_FLAGS)
2399 craig 151
 
779 fschmid 152
LIBART_LIBS=""
153
LIBART_CFLAGS=""
154
LIBART_CONFIG=""
2399 craig 155
 
156
AC_PATH_PROG(LIBART_CONFIG,
2401 craig 157
			 libart2-config,
2400 craig 158
			 [],
2399 craig 159
			 [$PATH ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /usr/nekoware/bin /opt/local/bin])
160
 
779 fschmid 161
if test -n "$LIBART_CONFIG"; then
162
  vers=`$LIBART_CONFIG --version 2>/dev/null | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
163
  if test -n "$vers" && test "$vers" -ge 2003008
164
  then
165
     LIBART_LIBS="`$LIBART_CONFIG --libs`"
166
     LIBART_CFLAGS="`$LIBART_CONFIG --cflags`"
167
     AC_DEFINE_UNQUOTED(HAVE_LIBART, 1, [Defines if your system has the libart library])
168
  else
2405 craig 169
     libmissing libart required
2401 craig 170
	 AC_MSG_ERROR([You need at least libart 2.3.8 . See the BUILDING file.])
779 fschmid 171
  fi
2400 craig 172
else
2405 craig 173
  libmissing libart required
2401 craig 174
  AC_MSG_ERROR([You need at least libart 2.3.8 . See the BUILDING file.])
779 fschmid 175
fi
3113 fschmid 176
 
177
hacairo=no
178
LIBCAIRO_LIBS=""
179
LIBCAIRO_CFLAGS=""
180
COMPILE_CAIRO=no
181
AC_ARG_ENABLE(cairo, [  --enable-cairo     Enables building with cairo support],
182
[if test "x$enable_cairo" = "xyes" || test "x$enable_cairo" = "xfull"; then
183
	COMPILE_CAIRO=yes
184
	AC_MSG_CHECKING([Checking for cairo with pkg-config])
185
	if test -n "$PKG_CONFIG"; then
186
		LIBCAIRO_LIBS="`$PKG_CONFIG cairo --libs`"
187
		LIBCAIRO_CFLAGS="`$PKG_CONFIG cairo --cflags`"
188
		if test -n "$LIBCAIRO_LIBS" || test -n "$LIBCAIRO_CFLAGS"; then
189
			AC_MSG_RESULT([found])
190
			hacairo=yes
191
		else
192
			AC_MSG_RESULT([not found])
193
		fi
194
	else
195
		AC_MSG_RESULT([failed: pkg-config not found])
196
	fi
197
	if test $hacairo = yes; then
3320 fschmid 198
		LIBART_LIBS=""
199
		LIBART_CFLAGS=""
3113 fschmid 200
		AC_DEFINE_UNQUOTED(HAVE_CAIRO, 1, [Defines if your system has the cairo library])
201
	else
202
		libmissing cairo optional
203
		AC_MSG_WARN([Couldn't find a usable cairo])
204
	fi
205
fi])
206
AM_CONDITIONAL(COMPILE_CAIRO, test x$COMPILE_CAIRO = xyes)
207
AC_SUBST(LIBCAIRO_LIBS)
208
AC_SUBST(LIBCAIRO_CFLAGS)
209
 
779 fschmid 210
AC_SUBST(LIBART_LIBS)
211
AC_SUBST(LIBART_CFLAGS)
212
AC_C_BIGENDIAN
213
 
1599 craig 214
dnl Check for freetype, which Scribus *requires* to build
779 fschmid 215
LIBFREETYPE_LIBS=""
216
LIBFREETYPE_CFLAGS=""
217
 
218
FREETYPE_CONFIG=""
2399 craig 219
AC_PATH_PROG(FREETYPE_CONFIG,
2403 craig 220
			 freetype-config,
2402 craig 221
			 [],
2399 craig 222
			 [$PATH ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin /usr/nekoware/bin /usr/X11/bin])
779 fschmid 223
 
224
hafree=no
2312 craig 225
hafree_post219=
779 fschmid 226
if test -n "$FREETYPE_CONFIG"; then
227
	LIBFREETYPE_LIBS="`$FREETYPE_CONFIG --libs`"
1599 craig 228
	LIBFREETYPE_CFLAGS="`$FREETYPE_CONFIG --cflags`"
779 fschmid 229
	AC_CHECK_LIB(freetype, FT_Get_First_Char, [hafree=yes],[hafree=no], "$LIBFREETYPE_LIBS")
230
	AC_CHECK_LIB(freetype, FT_Get_Next_Char, [hafree=yes],[hafree=no], "$LIBFREETYPE_LIBS")
231
	if test $hafree = yes; then
232
		AC_DEFINE_UNQUOTED(HAVE_FREETYPE, 1, [Defines if your system has the libfreetype library])
233
	else
2405 craig 234
		libmissing libfreetype required
1599 craig 235
		AC_MSG_ERROR([You need at least freetype 2.1.0])
779 fschmid 236
	fi
1599 craig 237
 
2312 craig 238
	dnl Warn the user if they have less than freetype 2.1.9
239
	dnl Changed to fatal error
240
	AC_MSG_CHECKING(freetype version > 2.1.9)
1599 craig 241
	SAVE_CFLAGS="${CFLAGS}"
242
	CFLAGS=" ${LIBFREETYPE_CFLAGS} "
243
	AC_TRY_COMPILE([
244
	#include <ft2build.h>
245
	#include FT_FREETYPE_H
246
	],[
2312 craig 247
	#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 1 && FREETYPE_PATCH < 9
248
	#error freetype 2.1 older than 2.1.9
1599 craig 249
	#endif
2312 craig 250
	], [hafree_post219=yes], [hafree_post219=no])
1599 craig 251
	CFLAGS="${SAVE_CFLAGS}"
2312 craig 252
	AC_MSG_RESULT($hafree_post219)
253
	if test hafree_post219 = no; then
254
		AC_MSG_WARN([Your libfreetype is too old - version 2.1.9 or newer strongly recommended])
1599 craig 255
	fi
256
 
257
	dnl Export the includes and lib path settings required to build with freetype.
779 fschmid 258
	AC_SUBST(LIBFREETYPE_LIBS)
259
	AC_SUBST(LIBFREETYPE_CFLAGS)
260
else
2405 craig 261
	libmissing libfreetype required
2401 craig 262
	AC_MSG_ERROR([You need at least freetype 2.1.0])
779 fschmid 263
fi
264
 
1592 craig 265
dnl Try to find fontconfig using fontconfig-config or pkg-config.
1920 craig 266
hafontconfig=no
779 fschmid 267
LIBFONTCONFIG_LIBS=""
268
LIBFONTCONFIG_CFLAGS=""
269
FONTCONFIG_CONFIG=""
270
 
1920 craig 271
dnl Try to find fontconfig with pkg-config if we have pkg-config
272
AC_MSG_CHECKING([Checking for fontconfig with pkg-config])
273
if test -n "$PKG_CONFIG"; then
1592 craig 274
	LIBFONTCONFIG_LIBS="`$PKG_CONFIG fontconfig --libs`"
275
	LIBFONTCONFIG_CFLAGS="`$PKG_CONFIG fontconfig --cflags`"
1920 craig 276
	if test -n "$LIBFONTCONFIG_LIBS" || test -n "$LIBFONTCONFIG_CFLAGS"; then
277
		AC_MSG_RESULT([found])
278
	else
279
		AC_MSG_RESULT([not found])
280
	fi
779 fschmid 281
else
1920 craig 282
	AC_MSG_RESULT([failed: pkg-config not found])
779 fschmid 283
fi
1635 craig 284
 
1920 craig 285
dnl If fontconfig not found with pkg-config, try to find fontconfig-config
286
dnl and use that to look for fontconfig.
287
if test -z "$LIBFONTCONFIG_LIBS" && test -z "$LIBFONTCONFIG_CFLAGS"; then
2399 craig 288
	dnl Seems we didn't find fontconfig with pkg-config, so search for the old
289
	dnl fontconfig-config program instead.
290
	AC_PATH_PROG(FONTCONFIG_CONFIG,
291
				 fontconfig-config,
292
				 [],
293
				 [$PATH ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin /usr/nekoware/bin /usr/X11/bin])
1920 craig 294
	if test -n "$FONTCONFIG_CONFIG"; then
295
		dnl found fontconfig-config, use it's results
296
		LIBFONTCONFIG_LIBS="`$FONTCONFIG_CONFIG --libs`"
297
		LIBFONTCONFIG_CFLAGS="`$FONTCONFIG_CONFIG --cflags`"
298
	else
299
		AC_MSG_WARN([Couldn't find fontconfig-config or find fontconfig with pkg-config])
300
	fi
301
fi
302
 
1635 craig 303
dnl Check to see if we can compile fontconfig
304
SAVE_CFLAGS="${CFLAGS}"
305
SAVE_LDFLAGS="${LDFLAGS}"
306
CFLAGS="${CFLAGS} ${LIBFONTCONFIG_CFLAGS}"
307
LDFLAGS="${LDFLAGS} ${LIBFONTCONFIG_LIBS}"
1592 craig 308
AC_CHECK_LIB(fontconfig, FcPatternBuild, [hafontconfig=yes],[hafontconfig=no])
1635 craig 309
CFLAGS="${SAVE_CFLAGS}"
310
LDFLAGS="${SAVE_LDFLAGS}"
1592 craig 311
if test $hafontconfig = yes; then
312
	AC_DEFINE_UNQUOTED(HAVE_FONTCONFIG, 1, [Defines if your system has the libfontconfig library])
313
else
2405 craig 314
	libmissing libfontconfig optional
1592 craig 315
	AC_MSG_WARN([Couldn't find a usable libfontconfig])
316
fi
317
AC_SUBST(LIBFONTCONFIG_LIBS)
318
AC_SUBST(LIBFONTCONFIG_CFLAGS)
779 fschmid 319
 
1592 craig 320
 
779 fschmid 321
XML_LIBS=""
322
XML_CFLAGS=""
323
 
324
XML_CONFIG=""
2399 craig 325
AC_PATH_PROG(XML_CONFIG,
326
			 xml2-config,
2403 craig 327
			 [],
2399 craig 328
			 [${PATH} ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin /usr/nekoware/bin /usr/X11/bin])
779 fschmid 329
 
1599 craig 330
dnl check for LibXML2
779 fschmid 331
haxml=no
2314 craig 332
haxml26=no
333
AC_ARG_ENABLE(xml, [  --disable-xml       Don't use libxml2 and turn off some Scribus features.], [disable_xml2="yes"])
334
if test "$disable_xml2" != "yes"; then
335
	if test -n "$XML_CONFIG"; then
336
		XML_LIBS="`$XML_CONFIG --libs`"
337
		XML_CFLAGS="`$XML_CONFIG --cflags`"
338
		AC_CHECK_LIB(xml2, attribute, [haxml=yes],[haxml=no])
339
		if test $haxml = yes; then
340
			AC_DEFINE_UNQUOTED(HAVE_XML, 1, [Defines if your system has the libxml2 library])
341
			AC_SUBST(XML_LIBS)
342
			AC_SUBST(XML_CFLAGS)
2403 craig 343
		else
344
			libmising libxml2
345
			AC_MSG_WARN([Couldn't find a usable libxml2])
2314 craig 346
		fi
347
		vers=`$XML_CONFIG --version 2>/dev/null | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
348
		if test -n "$vers" && test "$vers" -ge 2006000
349
		then
350
			AC_DEFINE_UNQUOTED(HAVE_XML26, 1, [Defines if your system has the libxml2 library6])
351
			haxml26=yes
352
		fi
2403 craig 353
	else
2405 craig 354
		libmissing libxml2 optional
2403 craig 355
		AC_MSG_WARN([Couldn't find a usable libxml2])
779 fschmid 356
	fi
357
fi
358
 
1599 craig 359
dnl check for -lsocket
779 fschmid 360
AC_CHECK_LIB(socket,socket,
361
if test "$uname" != "IRIX"; then
362
	LIBS="-lsocket $LIBS"
363
else
364
	echo "Not using -lsocket since you are running IRIX."
365
fi)
366
AC_CHECK_LIB(nsl,gethostbyaddr,
367
if test "$uname" != "IRIX"; then
368
	LIBS="-lnsl $LIBS"
369
else
370
	echo "Not using -lnsl since you are running IRIX."
371
fi)
372
 
1595 craig 373
dnl Check for lcms
374
dnl TODO look for lcms using pkg-config too
2310 craig 375
dnl TODO: convert to use --with-lcms= and AC_ARG_WITH(...)
779 fschmid 376
LIBLCMS=""
377
hacms=
2310 craig 378
AC_ARG_ENABLE(lcms, [  --disable-lcms     Don't use colour management (default=no)], [disable_lcms="yes"])
379
 
380
# If lcms hasn't been explicitly disabled, look for it and see
381
# if we can use it.
382
if test "$disable_lcms" != "yes"; then
383
	# See if liblcms.so is on our search path and looks vaguely valid
2962 craig 384
	SAVE_LDFLAGS="$LDFLAGS"
385
	LDFLAGS="$all_ldflags $LDFLAGS"
386
	export LDFLAGS
2310 craig 387
	AC_CHECK_LIB(lcms, _cmsChannelsOf, [LIBLCMS="-llcms";hacms=yes],[LIBLCMS="";hacms=no],[-lm])
388
	hacmsh=
389
	lcms_h=
390
	# and search for lcms.h, which may or may not be in an lcms/ subdir
391
	AC_CHECK_HEADER(lcms.h, [hacmsh=yes],[hacmsh=no])
392
	if test $hacmsh = no; then
393
		AC_CHECK_HEADER(lcms/lcms.h, [hacmsh=yes],[hacmsh=no])
394
		if test $hacmsh = yes; then
395
			AC_DEFINE_UNQUOTED(CMS_INC, "lcms/lcms.h", [ColorManagementInclude])
396
			lcms_h="lcms/lcms.h"
397
		fi
398
	else
399
		AC_DEFINE_UNQUOTED(CMS_INC, "lcms.h", [ColorManagementInclude])
400
		lcms_h="lcms.h"
779 fschmid 401
	fi
2310 craig 402
	if test $hacmsh = no; then
403
		# There's not much point finding -llcms if we can't find the header file...
404
		hacms=no
405
	fi
2962 craig 406
	LDFLAGS="$SAVE_LDFLAGS"
779 fschmid 407
fi
1595 craig 408
dnl Attempt to check that lcms is new enough
409
if test $hacms = yes; then
410
	AC_MSG_CHECKING(liblcms version > 1.1.2)
411
	AC_TRY_COMPILE([
412
	#include "$lcms_h"
1599 craig 413
	],[
1595 craig 414
	#if LCMS_VERSION < 112
415
	#error liblcms is too old, need LittleCMS 1.1.2 or newer
416
	#endif
1599 craig 417
	], [], [hacms=pre112])
1595 craig 418
	AC_MSG_RESULT($hacms)
419
fi
420
 
779 fschmid 421
AC_SUBST(LIBLCMS)
422
if test $hacms = yes && test $hacmsh = yes; then
2406 craig 423
	AC_DEFINE_UNQUOTED(HAVE_CMS, 1, [ColorManagement])
424
else
425
	libmissing liblcms optional
779 fschmid 426
fi
1580 craig 427
 
428
dnl Checks for libtiff - library exists, tiffvers.h can be found, and new enough.
779 fschmid 429
LIBTIFF=""
430
hastif=
1580 craig 431
dnl Check if we have libtiff
779 fschmid 432
AC_CHECK_LIB(tiff, TIFFOpen, [LIBTIFF="-ltiff";hastif=yes],[LIBTIFF="";hastif=no],[-lm])
1585 craig 433
if test $hastif = yes; then
434
	dnl Check for tiffvers.h
435
	AC_CHECK_HEADER(tiffvers.h, [], [LIBTIFF="";hastif=no])
436
	if test $hastif = yes; then
437
		dnl Now attempt to check if libtiff is new enough
438
		AC_MSG_CHECKING(libtiff version > 3.6.0)
439
		AC_TRY_COMPILE([
440
		#include "tiffvers.h"
1599 craig 441
		],[
1585 craig 442
		#if TIFFLIB_VERSION < 20031007
443
		#error libtiff is too old, need libtiff 3.6.0 or newer.
444
		#endif
1599 craig 445
		], [], [LIBTIFF="";hastif=pre36])
1585 craig 446
		AC_MSG_RESULT($hastif)
447
	fi
448
fi
2406 craig 449
if test "${hastif}" != "yes"; then
450
	libmissing libtiff optional
451
fi
779 fschmid 452
AC_SUBST(LIBTIFF)
453
if test $hastif = yes; then
2406 craig 454
	AC_DEFINE_UNQUOTED(HAVE_TIFF, 1, [Tifflib])
779 fschmid 455
fi
1580 craig 456
 
779 fschmid 457
LIBDL2=""
458
AC_CHECK_LIB(c, dlopen, [LIBDL2="-lc"],[LIBDL2=""])
459
AC_SUBST(LIBDL2)
460
 
461
dnl generate the config header
462
AM_CONFIG_HEADER(config.h) dnl at the distribution this done
463
 
464
dnl Checks for programs.
465
AC_CHECK_COMPILERS
466
AC_ENABLE_SHARED(yes)
467
AC_ENABLE_STATIC(no)
468
KDE_PROG_LIBTOOL
469
 
470
kde_python_link_found=no
2512 craig 471
KDE_CHECK_PYTHON(2.3)
2511 craig 472
COMPILE_PYTHON=
779 fschmid 473
AC_ARG_WITH(python, [  --without-python     Do not compile the Scripter Plugin],[ COMPILE_PYTHON=no ],[ COMPILE_PYTHON=yes ])
2511 craig 474
if test "$COMPILE_PYTHON" != "no"; then
475
	if test "$enable_mac" = yes ; then
476
		dnl Mac OS X always has Python, but the KDE config scripts don't know
477
		dnl how to find it. We just hardcode the values here.
478
		AC_DEFINE_UNQUOTED(HAVE_PYTHON_23, 1, [Python])
479
		PYTHONINC='-I/System/Library/Frameworks/Python.framework/Headers'
2527 craig 480
		PYTHONLIB='-L/System/Library/Frameworks/Python.framework -framework Python'
2511 craig 481
		PYTHONMODDIR='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3'
482
		COMPILE_PYTHON=yes
483
	elif test "$kde_python_link_found" = yes; then
484
		dnl Configure found the Python libs
485
		COMPILE_PYTHON=yes
486
	else
487
		dnl Configure didn't find python libs
488
		COMPILE_PYTHON=no
489
	fi
779 fschmid 490
fi
491
AM_CONDITIONAL(COMPILE_PYTHON, test x$COMPILE_PYTHON = xyes)
492
 
2311 craig 493
AC_ARG_ENABLE(cups, [  --disable-cups        Do not compile support for CUPS printing],[disable_cups=yes])
494
LIBCUPS=""
495
hacups=no
496
if test "$disable_cups" != "yes" ; then
497
	# Look for cups.h
498
	AC_CHECK_HEADER(cups/cups.h, [hacups_h=yes],[hacups_h=no])
499
	AC_CHECK_PROG(hacups_cfg, cups-config, yes, no)
500
	echo "'$hacups_cfg' '$hacups_h'" >/tmp/cfg
501
	if test "x$hacups_h" = "xyes" && test "x$hacups_cfg" = "xyes"; then
502
		# We have the CUPS libs and headers, so enable
503
		# the use of CUPS and tell the build where to
504
		# find it.
505
		LIBCUPS="`cups-config --libs`"
506
		AC_DEFINE_UNQUOTED(HAVE_CUPS, 1, [Cups])
507
		AC_SUBST(LIBCUPS)
508
		hacups=yes
509
	else
2406 craig 510
		libmissing libcups optional
2311 craig 511
		AC_MSG_WARN([libcups could not be found. Printing functionality will be limited.])
512
		hacups=no
513
	fi
514
else
515
	hacups=no
779 fschmid 516
fi
517
 
2409 craig 518
dnl While we don't use GhostScript during compilation - at least not
519
dnl currently - and can run without it, we check for it in configure
520
dnl to give users an early warning if it's missing.
521
AC_PATH_PROG(GS_PATH, gs)
2410 craig 522
AC_MSG_CHECKING([GhostScript version])
2409 craig 523
if test -z "${GS_PATH}" ; then
2410 craig 524
	AC_MSG_RESULT([gs not found])
2409 craig 525
	AC_MSG_WARN("GhostScript not found - gs 8.x is required for full features.")
2410 craig 526
else
527
	GS_VER_MAJOR=`gs --version | cut -d . -f 1`
528
	GS_VER_MINOR=`gs --version | cut -d . -f 2`
529
	AC_MSG_RESULT([${GS_VER_MAJOR}.${GS_VER_MINOR}])
530
	if (( "${GS_VER_MAJOR}" < 7 )) ; then
531
		AC_MSG_WARN("GhostScript found, but older than v7. v8 recommended.")
532
	elif (( "${GS_VER_MAJOR}" < 8 )) ; then
533
		AC_MSG_WARN("GhostScript v7 found. v8 recommended.")
534
	fi
2409 craig 535
fi
536
 
779 fschmid 537
COMPILE_DEBUG=no
2311 craig 538
AC_ARG_ENABLE(debug, [  --enable-debug     Enables debugging information (recommended for snapshots)],
1634 craig 539
[if test "x$enable_debug" = "xyes" || test "x$enable_debug" = "xfull"; then
779 fschmid 540
	COMPILE_DEBUG=yes
3592 avox 541
    if test "$enable_mac" = "yes"; then
542
        CXXFLAGS="$CXXFLAGS -g3 "
543
        CFLAGS="$CFLAGS -g3 "
544
    else
545
        CXXFLAGS="$CXXFLAGS -g3 -fno-inline -O0 "
546
        CFLAGS="$CFLAGS -g3 -fno-inline -O0 "
547
    fi
779 fschmid 548
fi])
549
AM_CONDITIONAL(COMPILE_DEBUG, test x$COMPILE_DEBUG = xyes)
550
 
1689 craig 551
dnl Compile and link the gdk-pixbuf sources unless building
552
dnl a Mac-native build.
553
AM_CONDITIONAL(LINK_PIXBUF, test "$enable_mac" != "yes" )
554
 
1699 craig 555
build_mac_bundle=no
2509 craig 556
AC_ARG_ENABLE(bundle, [  --enable-bundle     Make an executable suitable for use in a .app bundle (INCOMPLETE)], [build_mac_bundle=yes])
557
if test "$build_mac_bundle" = "yes"; then
1699 craig 558
	AC_DEFINE_UNQUOTED(BUILD_MAC_BUNDLE, 1, [Are we building an executable to be included in MacOS/X .app bundle?])
2509 craig 559
fi
560
if test "$enable_mac" != "yes" && test "$build_mac_bundle" = "yes"; then
561
	AC_MSG_ERROR([--enable-bundle only makes sense with --enable-mac])
562
fi
1699 craig 563
AM_CONDITIONAL(BUILD_MAC_BUNDLE, test "$build_mac_bundle" = "yes")
564
 
2509 craig 565
dnl On Mac OS X and Darwin we need to link the final binary to CoreFoundation.
566
if test "$enable_mac" = "yes"; then
567
	COREFOUNDATION_LIBS="-framework CoreFoundation"
568
else
569
	COREFOUNDATION_LIBS=
570
fi
571
AC_SUBST(COREFOUNDATION_LIBS)
572
 
1732 craig 573
dnl Some platforms require special libtool flags to build dynamically loadable
574
dnl modules or plugins correctly. While libtool should take care of this with
575
dnl a fixed set of arguments, in case we need to change it later this is being
576
dnl made a configure-time substitution.
577
MODULE_LINK_FLAGS=" -module "
578
AC_SUBST(MODULE_LINK_FLAGS)
579
 
779 fschmid 580
all_libraries="$all_libraries $USER_LDFLAGS"
581
all_includes="$all_includes $USER_INCLUDES"
582
AC_SUBST(all_includes)
583
AC_SUBST(all_libraries)
584
 
2689 craig 585
AH_TOP([
586
/*
587
 * Prevent code from including config.h directly. You should include
588
 * scconfig.h instead. This lets us handle win-config.h correctly, and
589
 * may do more later.
590
 */
591
#ifndef _SCCONFIG_H
592
#error "Include <scconfig.h> rather than using <config.h> directly"
593
#endif
594
])
595
 
779 fschmid 596
AC_PATH_QT
597
 
4119 craig 598
dnl Should we compile the new Boost::Python-based Python plugin?
599
AC_ARG_ENABLE(scripter2,
600
			  [  --enable-scripter2   Enable compilation of extended Python scripting],
601
			  [use_scripter2="yes"])
602
AC_MSG_CHECKING([If we should build Boost::Python-based Python scripting])
603
BOOST_PYTHON_CXXFLAGS=""
604
BOOST_PYTHON_LDFLAGS=""
605
if test "$use_scripter2" = "yes"; then
606
	dnl TODO : check for Boost::Python
607
	have_boost_python=yes
608
	if test "$have_boost_python" = "yes" ; then
609
		AC_DEFINE_UNQUOTED(HAVE_BOOST_PYTHON, 1, "Boost::Python is available")
610
		AC_DEFINE_UNQUOTED(HAVE_SCRIPTER2, 1, "We'll build and use the extended scripter")
611
		BOOST_PYTHON_CXXFLAGS=" -fexceptions -Wno-extra -Wno-unused "
612
		BOOST_PYTHON_LDFLAGS=" -lboost_python "
613
		AC_MSG_RESULT([yes])
614
	else
615
		AC_MSG_RESULT([no])
616
	fi
617
else
618
	AC_MSG_RESULT([no])
619
fi
620
AM_CONDITIONAL(HAVE_SCRIPTER2, test "$use_scripter2" = "yes")
621
AC_SUBST(BOOST_PYTHON_CXXFLAGS)
622
AC_SUBST(BOOST_PYTHON_LDFLAGS)
623
 
2787 craig 624
dnl We have to do our Qt version check only after KDE's magic has found Qt
2788 craig 625
AC_MSG_CHECKING([if we're trying to compile against Qt 4])
2787 craig 626
SAVE_CFLAGS="${CFLAGS}"
627
CFLAGS="${QT_INCLUDES} ${CFLAGS}"
628
dnl If this snippet compiles correctly, we're using an older Qt and are fine.
629
dnl If it fails, we know we're using Qt 4. We don't need to test for Qt 3.3
630
dnl here, AC_PATH_QT has done that for us.
631
AC_TRY_COMPILE([
632
#include <qglobal.h>
633
],[
634
#if QT_VERSION >= 0x040000
635
#error Scribus does not support Qt 4
636
#endif
637
], [using_qt4=no], [using_qt4=yes])
638
CFLAGS="${SAVE_CFLAGS}"
639
if test "${using_qt4}" = "yes"; then
640
	AC_MSG_RESULT([Qt 4 found])
641
	AC_MSG_ERROR([Scribus does not yet support Qt 4])
642
else
2788 craig 643
	AC_MSG_RESULT([Usable Qt 3.x found])
2787 craig 644
fi
4181 craig 645
 
646
dnl Check to see if we're using gcc4, and if so disable a couple of warning flags that
647
dnl produce spurious warnings with qt3. Do not rely on the using_gcc4 flag elsewhere, instead
648
dnl check specific compiler capabilities with KDE_CHECK_COMPILER_FLAG(...) etc. We test this
649
dnl flag because gcc3 also supports it, but it only ends up being enabled under gcc4 due to changes
650
dnl in the behaviour of -Wall -W .
651
AC_TRY_COMPILE([
652
], [
653
#if __GNUC__ < 4
654
#error __GNUC__ < 4, not using gcc4
655
#endif
656
],
657
[ using_gcc4="yes" ], [ using_gcc4="no" ])
658
if test "$using_gcc4" = "yes"; then
659
	CXXFLAGS="$CXXFLAGS -Wno-non-virtual-dtor"
660
fi
661
dnl unset the flag to prevent abuse (DO NOT rely on this flag)
662
unset using_gcc4