Subversion Repositories Scribus

Rev

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