Subversion Repositories Scribus

Rev

Rev 2398 | Rev 2400 | 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
14
dnl AC_PATH_PROG([VARNAME],[programname],[failure message],[search path])
15
dnl     search path, failure message optional. Searches for programname
16
dnl     along search path or default path and sets VARNAME to the path
17
dnl     to the program, if found.
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)
64
AM_INIT_AUTOMAKE(scribus,1.3.0cvs)
65
 
66
dnl KDE_SET_PREFIX
67
 
68
AC_PREFIX_DEFAULT(/usr/local)
69
if test "x$prefix" = "xNONE"; then
70
  prefix=$ac_default_prefix
71
  ac_configure_args="$ac_configure_args --prefix $prefix"
72
fi
73
 
1592 craig 74
dnl Look for pkg-config, which we use to find fontconfig and
75
dnl will probably need for other things in future.
76
PKG_CONFIG=""
77
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
779 fschmid 78
 
2399 craig 79
dnl Define a handy function to print a message for when libraries
80
dnl can't be found. This can be called from configure.in.in, and from
81
dnl configure.in.bot (which is, after all, just tacked on the bottom
82
dnl during the generation of configure).
83
 
84
missing_libs=""
85
 
86
function libmissing() {
87
dnl 	AC_MSG_WARN([
88
One or more libraries were not found. You may need to install some additional
89
libraries or packages.  If you think you have the library installed already, on
90
Linux check to make sure there is a -dev or -devel package for it installed as
91
well. Without the -dev or -devel package Scribus will not be able to find and
92
use the library. Once you have installed the library or the -dev or -devel
93
package, you must re-run this configure script.
94
Note that some libraries are OPTIONAL and Scribus will work fine without them
95
though with reduced functionality. See the BUILDING file for more info.
96
dnl ])
97
	if test -n "${1}"; then
98
		missing_libs="${missing_libs} ${1}"
99
	fi
100
}
101
 
102
 
779 fschmid 103
LIBART_LIBS=""
104
LIBART_CFLAGS=""
105
LIBART_CONFIG=""
2399 craig 106
 
107
AC_PATH_PROG(LIBART_CONFIG,
108
			 libart2-config,
109
			 [AC_MSG_ERROR([Could not find libart anywhere, check http://www.levien.com/libart/])],
110
			 [$PATH ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /usr/nekoware/bin /opt/local/bin])
111
 
779 fschmid 112
if test -n "$LIBART_CONFIG"; then
113
  vers=`$LIBART_CONFIG --version 2>/dev/null | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
114
  if test -n "$vers" && test "$vers" -ge 2003008
115
  then
116
     LIBART_LIBS="`$LIBART_CONFIG --libs`"
117
     LIBART_CFLAGS="`$LIBART_CONFIG --cflags`"
118
     AC_DEFINE_UNQUOTED(HAVE_LIBART, 1, [Defines if your system has the libart library])
119
  else
120
     AC_MSG_ERROR([You need at least libart 2.3.8])
121
  fi
122
fi
123
AC_SUBST(LIBART_LIBS)
124
AC_SUBST(LIBART_CFLAGS)
125
AC_C_BIGENDIAN
126
 
1599 craig 127
dnl Check for freetype, which Scribus *requires* to build
779 fschmid 128
LIBFREETYPE_LIBS=""
129
LIBFREETYPE_CFLAGS=""
130
 
131
FREETYPE_CONFIG=""
2399 craig 132
AC_PATH_PROG(FREETYPE_CONFIG,
133
			 freetype-config,
134
			 [AC_MSG_ERROR([Could not find libfreetype anywhere, check http://www.freetype.org/])],
135
			 [$PATH ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin /usr/nekoware/bin /usr/X11/bin])
779 fschmid 136
 
137
hafree=no
2312 craig 138
hafree_post219=
779 fschmid 139
if test -n "$FREETYPE_CONFIG"; then
140
	LIBFREETYPE_LIBS="`$FREETYPE_CONFIG --libs`"
1599 craig 141
	LIBFREETYPE_CFLAGS="`$FREETYPE_CONFIG --cflags`"
779 fschmid 142
	AC_CHECK_LIB(freetype, FT_Get_First_Char, [hafree=yes],[hafree=no], "$LIBFREETYPE_LIBS")
143
	AC_CHECK_LIB(freetype, FT_Get_Next_Char, [hafree=yes],[hafree=no], "$LIBFREETYPE_LIBS")
144
	if test $hafree = yes; then
145
		AC_DEFINE_UNQUOTED(HAVE_FREETYPE, 1, [Defines if your system has the libfreetype library])
146
	else
1599 craig 147
		AC_MSG_ERROR([You need at least freetype 2.1.0])
779 fschmid 148
	fi
1599 craig 149
 
2312 craig 150
	dnl Warn the user if they have less than freetype 2.1.9
151
	dnl Changed to fatal error
152
	AC_MSG_CHECKING(freetype version > 2.1.9)
1599 craig 153
	SAVE_CFLAGS="${CFLAGS}"
154
	CFLAGS=" ${LIBFREETYPE_CFLAGS} "
155
	AC_TRY_COMPILE([
156
	#include <ft2build.h>
157
	#include FT_FREETYPE_H
158
	],[
2312 craig 159
	#if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 1 && FREETYPE_PATCH < 9
160
	#error freetype 2.1 older than 2.1.9
1599 craig 161
	#endif
2312 craig 162
	], [hafree_post219=yes], [hafree_post219=no])
1599 craig 163
	CFLAGS="${SAVE_CFLAGS}"
2312 craig 164
	AC_MSG_RESULT($hafree_post219)
165
	if test hafree_post219 = no; then
166
		AC_MSG_WARN([Your libfreetype is too old - version 2.1.9 or newer strongly recommended])
1599 craig 167
	fi
168
 
169
	dnl Export the includes and lib path settings required to build with freetype.
779 fschmid 170
	AC_SUBST(LIBFREETYPE_LIBS)
171
	AC_SUBST(LIBFREETYPE_CFLAGS)
172
else
173
  AC_MSG_ERROR([You need at least freetype 2.1.0])
174
fi
175
 
1592 craig 176
dnl Try to find fontconfig using fontconfig-config or pkg-config.
1920 craig 177
hafontconfig=no
779 fschmid 178
LIBFONTCONFIG_LIBS=""
179
LIBFONTCONFIG_CFLAGS=""
180
FONTCONFIG_CONFIG=""
181
 
1920 craig 182
dnl Try to find fontconfig with pkg-config if we have pkg-config
183
AC_MSG_CHECKING([Checking for fontconfig with pkg-config])
184
if test -n "$PKG_CONFIG"; then
1592 craig 185
	LIBFONTCONFIG_LIBS="`$PKG_CONFIG fontconfig --libs`"
186
	LIBFONTCONFIG_CFLAGS="`$PKG_CONFIG fontconfig --cflags`"
1920 craig 187
	if test -n "$LIBFONTCONFIG_LIBS" || test -n "$LIBFONTCONFIG_CFLAGS"; then
188
		AC_MSG_RESULT([found])
189
	else
190
		AC_MSG_RESULT([not found])
191
	fi
779 fschmid 192
else
1920 craig 193
	AC_MSG_RESULT([failed: pkg-config not found])
779 fschmid 194
fi
1635 craig 195
 
1920 craig 196
dnl If fontconfig not found with pkg-config, try to find fontconfig-config
197
dnl and use that to look for fontconfig.
198
if test -z "$LIBFONTCONFIG_LIBS" && test -z "$LIBFONTCONFIG_CFLAGS"; then
2399 craig 199
	dnl Seems we didn't find fontconfig with pkg-config, so search for the old
200
	dnl fontconfig-config program instead.
201
	AC_PATH_PROG(FONTCONFIG_CONFIG,
202
				 fontconfig-config,
203
				 [],
204
				 [$PATH ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin /usr/nekoware/bin /usr/X11/bin])
1920 craig 205
	if test -n "$FONTCONFIG_CONFIG"; then
206
		dnl found fontconfig-config, use it's results
207
		LIBFONTCONFIG_LIBS="`$FONTCONFIG_CONFIG --libs`"
208
		LIBFONTCONFIG_CFLAGS="`$FONTCONFIG_CONFIG --cflags`"
209
	else
210
		AC_MSG_WARN([Couldn't find fontconfig-config or find fontconfig with pkg-config])
211
	fi
212
fi
213
 
1635 craig 214
dnl Check to see if we can compile fontconfig
215
SAVE_CFLAGS="${CFLAGS}"
216
SAVE_LDFLAGS="${LDFLAGS}"
217
CFLAGS="${CFLAGS} ${LIBFONTCONFIG_CFLAGS}"
218
LDFLAGS="${LDFLAGS} ${LIBFONTCONFIG_LIBS}"
1592 craig 219
AC_CHECK_LIB(fontconfig, FcPatternBuild, [hafontconfig=yes],[hafontconfig=no])
1635 craig 220
CFLAGS="${SAVE_CFLAGS}"
221
LDFLAGS="${SAVE_LDFLAGS}"
1592 craig 222
if test $hafontconfig = yes; then
223
	AC_DEFINE_UNQUOTED(HAVE_FONTCONFIG, 1, [Defines if your system has the libfontconfig library])
224
else
225
	AC_MSG_WARN([Couldn't find a usable libfontconfig])
226
fi
227
AC_SUBST(LIBFONTCONFIG_LIBS)
228
AC_SUBST(LIBFONTCONFIG_CFLAGS)
779 fschmid 229
 
1592 craig 230
 
779 fschmid 231
XML_LIBS=""
232
XML_CFLAGS=""
233
 
234
XML_CONFIG=""
2399 craig 235
AC_PATH_PROG(XML_CONFIG,
236
			 xml2-config,
237
			 [AC_MSG_ERROR([Could not find libxml2 anywhere, check http://www.xmlsoft.org/])],
238
			 [${PATH} ${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin /usr/bin /usr/nekoware/bin /usr/X11/bin])
779 fschmid 239
 
1599 craig 240
dnl check for LibXML2
779 fschmid 241
haxml=no
2314 craig 242
haxml26=no
243
AC_ARG_ENABLE(xml, [  --disable-xml       Don't use libxml2 and turn off some Scribus features.], [disable_xml2="yes"])
244
if test "$disable_xml2" != "yes"; then
245
	if test -n "$XML_CONFIG"; then
246
		XML_LIBS="`$XML_CONFIG --libs`"
247
		XML_CFLAGS="`$XML_CONFIG --cflags`"
248
		AC_CHECK_LIB(xml2, attribute, [haxml=yes],[haxml=no])
249
		if test $haxml = yes; then
250
			AC_DEFINE_UNQUOTED(HAVE_XML, 1, [Defines if your system has the libxml2 library])
251
			AC_SUBST(XML_LIBS)
252
			AC_SUBST(XML_CFLAGS)
253
		fi
254
		vers=`$XML_CONFIG --version 2>/dev/null | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
255
		if test -n "$vers" && test "$vers" -ge 2006000
256
		then
257
			AC_DEFINE_UNQUOTED(HAVE_XML26, 1, [Defines if your system has the libxml2 library6])
258
			haxml26=yes
259
		fi
779 fschmid 260
	fi
261
fi
262
 
1599 craig 263
dnl check for -lsocket
779 fschmid 264
AC_CHECK_LIB(socket,socket,
265
if test "$uname" != "IRIX"; then
266
	LIBS="-lsocket $LIBS"
267
else
268
	echo "Not using -lsocket since you are running IRIX."
269
fi)
270
AC_CHECK_LIB(nsl,gethostbyaddr,
271
if test "$uname" != "IRIX"; then
272
	LIBS="-lnsl $LIBS"
273
else
274
	echo "Not using -lnsl since you are running IRIX."
275
fi)
276
 
1595 craig 277
dnl Check for lcms
278
dnl TODO look for lcms using pkg-config too
2310 craig 279
dnl TODO: convert to use --with-lcms= and AC_ARG_WITH(...)
779 fschmid 280
LIBLCMS=""
281
hacms=
2310 craig 282
AC_ARG_ENABLE(lcms, [  --disable-lcms     Don't use colour management (default=no)], [disable_lcms="yes"])
283
 
284
# If lcms hasn't been explicitly disabled, look for it and see
285
# if we can use it.
286
if test "$disable_lcms" != "yes"; then
287
	# See if liblcms.so is on our search path and looks vaguely valid
288
	AC_CHECK_LIB(lcms, _cmsChannelsOf, [LIBLCMS="-llcms";hacms=yes],[LIBLCMS="";hacms=no],[-lm])
289
	hacmsh=
290
	lcms_h=
291
	# and search for lcms.h, which may or may not be in an lcms/ subdir
292
	AC_CHECK_HEADER(lcms.h, [hacmsh=yes],[hacmsh=no])
293
	if test $hacmsh = no; then
294
		AC_CHECK_HEADER(lcms/lcms.h, [hacmsh=yes],[hacmsh=no])
295
		if test $hacmsh = yes; then
296
			AC_DEFINE_UNQUOTED(CMS_INC, "lcms/lcms.h", [ColorManagementInclude])
297
			lcms_h="lcms/lcms.h"
298
		fi
299
	else
300
		AC_DEFINE_UNQUOTED(CMS_INC, "lcms.h", [ColorManagementInclude])
301
		lcms_h="lcms.h"
779 fschmid 302
	fi
2310 craig 303
	if test $hacmsh = no; then
304
		# There's not much point finding -llcms if we can't find the header file...
305
		hacms=no
306
	fi
779 fschmid 307
fi
1595 craig 308
dnl Attempt to check that lcms is new enough
309
if test $hacms = yes; then
310
	AC_MSG_CHECKING(liblcms version > 1.1.2)
311
	AC_TRY_COMPILE([
312
	#include "$lcms_h"
1599 craig 313
	],[
1595 craig 314
	#if LCMS_VERSION < 112
315
	#error liblcms is too old, need LittleCMS 1.1.2 or newer
316
	#endif
1599 craig 317
	], [], [hacms=pre112])
1595 craig 318
	AC_MSG_RESULT($hacms)
319
fi
320
 
779 fschmid 321
AC_SUBST(LIBLCMS)
322
if test $hacms = yes && test $hacmsh = yes; then
323
 AC_DEFINE_UNQUOTED(HAVE_CMS, 1, [ColorManagement])
324
fi
1580 craig 325
 
326
dnl Checks for libtiff - library exists, tiffvers.h can be found, and new enough.
779 fschmid 327
LIBTIFF=""
328
hastif=
1580 craig 329
dnl Check if we have libtiff
779 fschmid 330
AC_CHECK_LIB(tiff, TIFFOpen, [LIBTIFF="-ltiff";hastif=yes],[LIBTIFF="";hastif=no],[-lm])
1585 craig 331
if test $hastif = yes; then
332
	dnl Check for tiffvers.h
333
	AC_CHECK_HEADER(tiffvers.h, [], [LIBTIFF="";hastif=no])
334
	if test $hastif = yes; then
335
		dnl Now attempt to check if libtiff is new enough
336
		AC_MSG_CHECKING(libtiff version > 3.6.0)
337
		AC_TRY_COMPILE([
338
		#include "tiffvers.h"
1599 craig 339
		],[
1585 craig 340
		#if TIFFLIB_VERSION < 20031007
341
		#error libtiff is too old, need libtiff 3.6.0 or newer.
342
		#endif
1599 craig 343
		], [], [LIBTIFF="";hastif=pre36])
1585 craig 344
		AC_MSG_RESULT($hastif)
345
	fi
346
fi
779 fschmid 347
AC_SUBST(LIBTIFF)
348
if test $hastif = yes; then
349
 AC_DEFINE_UNQUOTED(HAVE_TIFF, 1, [Tifflib])
350
fi
1580 craig 351
 
779 fschmid 352
LIBDL2=""
353
AC_CHECK_LIB(c, dlopen, [LIBDL2="-lc"],[LIBDL2=""])
354
AC_SUBST(LIBDL2)
355
 
356
dnl generate the config header
357
AM_CONFIG_HEADER(config.h) dnl at the distribution this done
358
 
359
dnl Checks for programs.
360
AC_CHECK_COMPILERS
361
AC_ENABLE_SHARED(yes)
362
AC_ENABLE_STATIC(no)
363
KDE_PROG_LIBTOOL
364
 
365
hapython=yes
366
kde_python_link_found=no
367
KDE_CHECK_PYTHON(1.5)
368
COMPILE_PYTHON=no
369
AC_ARG_WITH(python, [  --without-python     Do not compile the Scripter Plugin],[ COMPILE_PYTHON=no ],[ COMPILE_PYTHON=yes ])
370
if test $kde_python_link_found = no; then
371
	COMPILE_PYTHON=no
372
fi
373
if test $kde_python_link_found = yes; then
374
  AC_CHECK_HEADER(python2.3/Python.h, [foo=""],[hapython=no])
375
   if test $hapython = yes; then
376
    AC_DEFINE_UNQUOTED(HAVE_PYTHON_23, 1, [Python])
377
   fi
378
fi
379
AM_CONDITIONAL(COMPILE_PYTHON, test x$COMPILE_PYTHON = xyes)
380
 
2311 craig 381
AC_ARG_ENABLE(cups, [  --disable-cups        Do not compile support for CUPS printing],[disable_cups=yes])
382
LIBCUPS=""
383
hacups=no
384
if test "$disable_cups" != "yes" ; then
385
	# Look for cups.h
386
	AC_CHECK_HEADER(cups/cups.h, [hacups_h=yes],[hacups_h=no])
387
	AC_CHECK_PROG(hacups_cfg, cups-config, yes, no)
388
	echo "'$hacups_cfg' '$hacups_h'" >/tmp/cfg
389
	if test "x$hacups_h" = "xyes" && test "x$hacups_cfg" = "xyes"; then
390
		# We have the CUPS libs and headers, so enable
391
		# the use of CUPS and tell the build where to
392
		# find it.
393
		LIBCUPS="`cups-config --libs`"
394
		AC_DEFINE_UNQUOTED(HAVE_CUPS, 1, [Cups])
395
		AC_SUBST(LIBCUPS)
396
		hacups=yes
397
	else
398
		AC_MSG_WARN([libcups could not be found. Printing functionality will be limited.])
399
		hacups=no
400
	fi
401
else
402
	hacups=no
779 fschmid 403
fi
404
 
405
COMPILE_DEBUG=no
2311 craig 406
AC_ARG_ENABLE(debug, [  --enable-debug     Enables debugging information (recommended for snapshots)],
1634 craig 407
[if test "x$enable_debug" = "xyes" || test "x$enable_debug" = "xfull"; then
779 fschmid 408
	COMPILE_DEBUG=yes
409
    CXXFLAGS="$CXXFLAGS -g3 -fno-inline -O0 "
410
    CFLAGS="$CFLAGS -g3 -fno-inline -O0 "
411
fi])
412
AM_CONDITIONAL(COMPILE_DEBUG, test x$COMPILE_DEBUG = xyes)
413
 
1689 craig 414
dnl Compile and link the gdk-pixbuf sources unless building
415
dnl a Mac-native build.
416
AM_CONDITIONAL(LINK_PIXBUF, test "$enable_mac" != "yes" )
417
 
1699 craig 418
build_mac_bundle=no
2311 craig 419
AC_ARG_ENABLE(bundle, [  --enable-bundle     Make an executable suitable for use in a .app bundle (INCOMPLETE)],
1699 craig 420
[if test "$enable_bundle" = "yes"; then
421
	build_mac_bundle=yes
422
	AC_DEFINE_UNQUOTED(BUILD_MAC_BUNDLE, 1, [Are we building an executable to be included in MacOS/X .app bundle?])
423
fi])
424
AM_CONDITIONAL(BUILD_MAC_BUNDLE, test "$build_mac_bundle" = "yes")
425
 
1732 craig 426
dnl Some platforms require special libtool flags to build dynamically loadable
427
dnl modules or plugins correctly. While libtool should take care of this with
428
dnl a fixed set of arguments, in case we need to change it later this is being
429
dnl made a configure-time substitution.
430
MODULE_LINK_FLAGS=" -module "
431
AC_SUBST(MODULE_LINK_FLAGS)
432
 
779 fschmid 433
all_libraries="$all_libraries $USER_LDFLAGS"
434
all_includes="$all_includes $USER_INCLUDES"
435
AC_SUBST(all_includes)
436
AC_SUBST(all_libraries)
437
 
438
AC_PATH_QT
439