summaryrefslogtreecommitdiff
path: root/configure.in
blob: ad7d9c861393c00ad63eabb02574de1b2047de5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
dnl Process this file with autoconf to produce a configure script.

dnl old autoconf
AC_INIT(src/)

dnl new autoconf
dnl AC_INIT
dnl AC_CONFIG_SRCDIR([src/])

AC_ARG_ENABLE(checkmem,
[  --enable-checkmem       turn on ccmalloc debugging], CHECKMEM=true)
AC_ARG_ENABLE(debug,
[  --enable-debug          turn on debugging], DEBUG=true)
AC_ARG_ENABLE(profiling,
[  --enable-profiling      turn on profiling], PROFILING=true)
AC_ARG_ENABLE(warnings,
[  --enable-warnings	   turn on compiler warnings], ENABLE_WARNINGS=true)
AC_ARG_ENABLE(optimizations,
[  --enable-optimizations  turn on compiler optimizations (recommended for avi2swf)], OPTIMIZE=true)
AC_ARG_ENABLE(lame,
[  --disable-lame          don't compile any L.A.M.E. mp3 encoding code in], DISABLE_LAME=true)
AC_ARG_WITH([external-libart],
[  --with-external-libart  use external libart library (currently broken)], [EXTERNAL_LIBART=true])
AC_ARG_WITH([poppler],
[  --with-poppler          use poppler instead of internal xpdf (currently broken)], [USE_POPPLER=true])

PACKAGE=swftools
VERSION=2008-09-22-1956


# ------------------------------------------------------------------

if test "x${srcdir}" != "x."; then
    echo "--srcdir is not supported"
    exit 1
fi

WARNINGS="-Wparentheses -Wimplicit -Wreturn-type"
if test "x$ENABLE_WARNINGS" '!=' "x";then
    WARNINGS="-Wall -Wno-unused -Wno-format -Wno-redundant-decls -D_FORTIFY_SOURCE=2 "
fi

if test "x$CHECKMEM" '!=' "x";then
    DEBUG=yes
fi
if test "x$PROFILING" '!=' "x";then
    DEBUG=yes
fi
if test "x$DEBUG" '!=' "x";then
    if test "x$PROFILING" = "x";then
        CFLAGS="$WARNINGS -O2 -g $CFLAGS"
        CXXFLAGS="$WARNINGS -O2 -g $CXXFLAGS"
        LDFLAGS="-g $LIBS"
    else
        CFLAGS="$WARNINGS -O2 -g -pg $CFLAGS"
        CXXFLAGS="$WARNINGS -O2 -g -pg $CXXFLAGS"
        LDFLAGS="-g -pg $LIBS"
    fi
else if test "x$OPTIMIZE" '!=' "x"; then
    CFLAGS="$WARNINGS -O3 -fomit-frame-pointer -Winline $CFLAGS"
    CXXFLAGS="$WARNINGS -O3 -fomit-frame-pointer -Winline $CXXFLAGS"
else
    CFLAGS="$WARNINGS -O -fomit-frame-pointer $CFLAGS"
    CXXFLAGS="$WARNINGS -O -fomit-frame-pointer $CXXFLAGS"
fi
fi

CFLAGS="-fPIC $CFLAGS"
CXXFLAGS="-fPIC $CFLAGS"

#OLDGCC=1
#if test "x$OLDGCC" '!=' "x";then
#     #CFLAGS="$CFLAGS --std=c89 -ansi -pendantic"
#     #CXXFLAGS="$CXXFLAGS --std=c89 -ansi -pendantic"
#     CFLAGS="$CFLAGS -ansi -pendantic"
#     CXXFLAGS="$CXXFLAGS -ansi -pendantic"
#fi

export PACKAGE VERSION CFLAGS CXXFLAGS

dnl Checks for programs.

AC_CANONICAL_HOST

SHARED="-shared"
MACOSX=
case $host_os in
    *darwin* ) 
	MACOSX=yes
	CFLAGS="$CFLAGS"
	CXXFLAGS="$CXXFLAGS -fno-rtti"
	SHARED="-bundle"
	# Use fink packages if available.
	#if test -d /sw/include && test -d /sw/lib; then
	#    CPPFLAGS="${CPPFLAGS} -I/sw/include"
	#    LDFLAGS="${LDFLAGS} -L/sw/lib"
	#fi
	;;
esac

AC_SUBST(SHARED)

dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_CXX


RFX_CHECK_OLDGCC

if test "x$GCC_IS_OK" '=' "x";then
    echo "***************************************************"
    echo "* Your gcc is too old to compile this!"
    echo "* "
    echo "* The last version compilable by this compiler is "
    echo "* swftools 0.7.0, which you can download from "
    echo "* http://www.swftools.org/swftools-0.7.0.tar.gz "
    echo "* ."
    echo "* Newer versions require at least gcc 3.0.0 "
    echo "***************************************************"
    exit 1
fi
    
if test "x$CHECKMEM" '!=' "x";then
    CC="ccmalloc $CC"
    CXX="ccmalloc $CXX"
    #echo running again
    #unset ac_cv_prog_CC
    #unset ac_cv_prog_CXX
    #AC_PROG_CC
    #AC_PROG_CXX
fi
 AC_PROG_CPP

 AC_PROG_RANLIB
 AC_PROG_MAKE_SET
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_CHECK_PROGS(UNCOMPRESS, gzip uncompress compress, )

PKG_PROG_PKG_CONFIG

dnl Checks for system services
OBJEXT="o"
AREXT=".a"
CXXLIBS="-lstdc++"

AC_EXEEXT

if test "x$EXEEXT" = "x.exe";then
    OBJEXT="obj"
    AREXT=".lib"
    CXXLIBS=""
fi
AC_SUBST(OBJEXT)
AC_SUBST(AREXT)

RFX_CHECK_MING

SLEXT="so"
if test "x${MINGW}" != "xyes"; then
    # no mingW
    AC_DEFINE([O_BINARY], [0], [Not defined on mingw])
else
    # mingW
    SLEXT="dll"
    CXXLIBS=""
fi
export SLEXT
AC_SUBST(SLEXT)
AC_SUBST(CXXLIBS)

# The following tries to make use of includes and libraries in
# /usr/local, too. Notice: A -I/usr/local/include might break
# things (MingW, cross-compiling etc.) in the same way as -I/usr/include, 
# especially on systems which link /usr/local to /usr, so it has yet
# to be seen how useful this is.
if test -d /usr/local/lib; then
    LDFLAGS="$LDFLAGS -L/usr/local/lib"
fi
if test -d /usr/local/include; then
# Leave that alone. It's causing trouble e.g. with gcc 3.2 on gentoo.
#   CPPFLAGS="$CPPFLAGS -I/usr/local/include"
    echo > /dev/null
fi
if test "$prefix" != "NONE" -a "$prefix" != "/usr/local" -a "$prefix" != "/usr/local/"; then
    # if the user has a special prefix (like /opt), there might also be $prefix/lib
    # and $prefix/include, which should be included in our search paths for libraries
    # and includes.
    LDFLAGS="$LDFLAGS -L${libdir}"
    CPPFLAGS="$CPPFLAGS -I${includedir}"
    # TODO- test whether gcc still works after this
fi

#Mac OS:
#LDFLAGS "-L/sw/lib" ; CPPFLAGS "-I/sw/include -I/sw/include/lame"


# this must be done after (I believe) AC_PROG_MAKE_SET
if test "x$DEBUG" '!=' "x" -o "x$STRIP" = "x";then
    STRIP="@echo debug enabled, not stripping "
    export STRIP
    AC_SUBST(STRIP)
fi

dnl Checks for libraries.
 AC_CHECK_LIB(m, sin,, 
 echo "Error: Math library not found.";
 exit;
 )
 AC_CHECK_LIB(z, deflate,, ZLIBMISSING=true)

if test "x$ZLIBMISSING" = "xtrue";then
    echo 
    echo "ERROR:"
    echo "You need zlib to compile swftools"
    echo
    exit
fi
 
AC_CHECK_LIB(jpeg, jpeg_write_raw_data,, JPEGLIBMISSING=true)
AC_CHECK_LIB(ungif, DGifOpen,, UNGIFMISSING=true)
if test "$UNGIFMISSING";then
    UNGIFMISSING=
    AC_CHECK_LIB(gif, DGifOpen,, UNGIFMISSING=true)
fi

RFX_CHECK_BYTEORDER
AC_SUBST(WORDS_BIGENDIAN)
RFX_CHECK_SYSTEM_BACKTICKS
AC_SUBST(SYSTEM_BACKTICKS)

AC_ARG_PROGRAM

dnl Checks for header files.
 AC_CONFIG_HEADER(config.h)
 AC_HEADER_DIRENT
 AC_HEADER_STDC

 AC_CHECK_HEADERS(zlib.h gif_lib.h io.h wchar.h jpeglib.h assert.h signal.h pthread.h sys/stat.h sys/mman.h sys/types.h dirent.h sys/bsdtypes.h sys/ndir.h sys/dir.h ndir.h time.h sys/time.h sys/resource.h)

AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)

AC_SUBST(HAVE_UNISTD_H)
AC_SUBST(EXEEXT)

dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_INLINE
 AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_STRUCT_TM
 AC_CHECK_TYPE(boolean,int) #needed for jpeglib
 AC_CHECK_FUNCS(popen wcschr wcsdup mkstemp stat mmap lrand48 rand srand48 srand bcopy bzero time getrusage mallinfo)

AC_CHECK_SIZEOF([signed char])
AC_CHECK_SIZEOF([signed short])
AC_CHECK_SIZEOF([signed])
AC_CHECK_SIZEOF([signed long long])
AC_CHECK_SIZEOF([void*])

RFX_CHECK_FREETYPE

RFX_CHECK_FONTCONFIG

RFX_CHECK_OPENGL
if test "$HAVE_OPENGL";then
    DEVICE_OPENGL='devices/opengl.$(O)'
    AC_SUBST(DEVICE_OPENGL)
fi

lame_in_source= 
lame_makefile=
if test "x${DISABLE_LAME}" = "xtrue"; then
    echo "*" Disabling lame support...
else
    # old lame code at lib/lame
    if test -f lib/lame/Makefile.in; then
	lame_in_source='$(lame_objects)'
	lame_makefile="lib/lame/Makefile"
	CPPFLAGS="$CPPFLAGS -Ilame -Ilib/lame"
	AC_DEFINE([HAVE_LAME], [1], [have/use internal l.a.m.e. mp3 library])
    else
	if test -d /usr/include/lame; then
	    CPPFLAGS="$CPPFLAGS -I /usr/include/lame"
	else
	    if test -d /usr/local/include/lame; then
		CPPFLAGS="$CPPFLAGS -I /usr/local/include/lame"
	    fi
	fi
	AC_CHECK_LIB(mp3lame, lame_init,, NO_LIBMP3LAME=1)
        HASLAMEHEADER=
	AC_CHECK_HEADERS(lame.h,HASLAMEHEADER=1)
	if test "x$NO_LIBMP3LAME" "!=" "x1" -a "x$HASLAMEHEADER" '!=' "x";then
	    AC_DEFINE([HAVE_LAME], [1])
	fi
    fi
fi
AC_SUBST(lame_in_source)

art_in_source='$(art_objects)'
AC_DEFINE([INTERNAL_LIBART], [1], [use internal libart library])

if test "x$EXTERNAL_LIBART" = "xtrue"; then
    art_in_source=
    PKG_CHECK_MODULES([LIBART],[libart-2.0],,[libart_pkgconfig_libart=no])
    if test "x$libart_pkgconfig_libart" = "xno"; then
        AC_CHECK_HEADERS([libart_lgpl/libart.h],[
           AC_CHECK_LIB([art_lgpl_2],[art_new],,[])
        ],[AC_MSG_ERROR([No libart library found. This library is required.])])
    else
	CPPFLAGS="$CPPFLAGS $LIBART_CFLAGS"
        AC_DEFINE([INTERNAL_LIBART], [0])
        LIBS="$LIBS $LIBART_LIBS"
    fi
fi
AC_SUBST([art_in_source])

xpdf_in_source='$(xpdf_objects)'
splash_in_source='$(splash_objects)'

if test "x$USE_POPPLER" = "xtrue"; then
    xpdf_in_source=
    splash_in_source=
    AC_DEFINE([HAVE_POPPLER],[1],[use poppler])
    PKG_CHECK_MODULES([POPPLER],[poppler poppler-splash],,[poppler_pkgconfig=no])
    if test "x$poppler_pkgconfig" = "xno"; then
        AC_LANG_PUSH([C++])
        AC_CHECK_HEADERS([OutputDev.h],[
           AC_CHECK_LIB([poppler],[main],,[])
        ],[AC_MSG_ERROR([No poppler library found. This library is required.])])
        AC_LANG_POP
    else
	CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
        AC_DEFINE([HAVE_POPPLER], [1])
        LIBS="$LIBS $POPPLER_LIBS"
    fi
fi
AC_SUBST([xpdf_in_source])
AC_SUBST([splash_in_source])

# ------------------------------------------------------------------
 
RFX_CHECK_AVI2SWF
if test "x${AVIFILE}" = "xtrue"; then
    VIDEO_LIBS="$VIDEO_LIBS $AVIFILE_LIBS"
    VIDEO_CFLAGS="$VIDEO_CFLAGS $AVIFILE_CFLAGS"
    AC_DEFINE([HAVE_AVIFILE], [1], [Define if avifile is present])
fi

if test "x${WIN32}" != "x"; then
    #AC_CHECK_LIB(avifil32, AVIFileInit,AVIFIL32=true)
    #if test "x${AVIFIL32}" != "x"; then
    #  VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
    #fi
    VIDEO_LIBS="$VIDEO_LIBS -lavifil32"
    AVIFIL32=true
fi

AC_SUBST(VIDEO_LIBS)
AC_SUBST(VIDEO_CFLAGS)
# ------------------------------------------------------------------

if test "x${UNCOMPRESS}" = "xgzip"; then
    AC_DEFINE([USE_GZIP], [1], [Define if gzip is present])
fi
AC_SUBST(USE_GZIP)

# ------------------------------------------------------------------

RFX_CHECK_PYTHON

if test "x$PYTHON_OK" '!=' "xyes";then
    echo all install uninstall clean: > lib/python/Makefile
    # fail silently- the most users won't have any need for the
    # python interface anyway
else
    pythonrfxswf="lib/python/Makefile"
fi

# ------------------------------------------------------------------

AC_MSG_CHECKING([for missing libraries])

if test "x$ZLIBMISSING" = "xtrue";then
    MISSINGLIBS="${MISSINGLIBS} zlib"
    DISABLEPNG2SWF=true
    PARTIAL=true
fi
if test "x$JPEGLIBMISSING" = "xtrue";then
    MISSINGLIBS="${MISSINGLIBS} jpeglib"
    DISABLEPDF2SWF=true
    DISABLEJPEG2SWF=true
    PARTIAL=true
fi
#if test "x$T1LIBMISSING" = "xtrue";then
#    MISSINGLIBS="${MISSINGLIBS} t1lib"
#fi
if test "x$UNGIFMISSING" = "xtrue";then
    DISABLEGIF2SWF=true
    MISSINGLIBS="${MISSINGLIBS} ungif"
    PARTIAL=true
fi

if test "x${ac_cv_header_jpeglib_h}" '!=' "xyes"; then
    DISABLEPDF2SWF=true;
    DISABLEJPEG2SWF=true;
    MISSINGLIBS="${MISSINGLIBS} jpeglib.h"
    PARTIAL=true
fi
if test "x$HAVE_FREETYPE" '!=' "x1"; then
    DISABLEPDF2SWF=true;
    MISSINGLIBS="${MISSINGLIBS} freetype"
    PARTIAL=true
fi
#if test "x${ac_cv_header_t1lib_h}" '!=' "xyes"; then
#    MISSINGLIBS="${MISSINGLIBS} t1lib.h"
#fi
if test "x${ac_cv_header_gif_lib_h}" '!=' "xyes"; then
    DISABLEGIF2SWF=true
    MISSINGLIBS="${MISSINGLIBS} gif_lib.h"
    PARTIAL=true
fi
if test "x${ac_cv_header_zlib_h}" '!=' "xyes"; then
    DISABLEPNG2SWF=true;
    MISSINGLIBS="${MISSINGLIBS} zlib.h"
    PARTIAL=true
fi
#if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
#    MISSINGLIBS="${MISSINGLIBS} avifile"
#fi

AC_MSG_RESULT(${MISSINGLIBS})

# ------------------------------------------------------------------

if test "x${MISSINGLIBS}" '!=' "x"; then
  echo "***************************************************"
  echo "* The following headers/libraries are missing: " ${MISSINGLIBS}
fi

avi2swf="avi2swf/Makefile"
if test "x${AVIFILE}" '!=' "xtrue" -a "x${AVIFIL32}" '!=' "xtrue"; then
 #don't whine, avi2swf is outdated anyway
 #echo "* Disabling avi2swf tool..."
 echo all install uninstall clean: > avi2swf/Makefile
 avi2swf=
fi

pdf2swf_makefile="lib/pdf/Makefile"
PDF2SWF='pdf2swf$(E)'
LIBPDF='libpdf$(A)'

if test "x${DISABLEPDF2SWF}" = "xtrue"; then
  echo "* Disabling pdf2swf tool..."
  rm -f lib/pdf/Makefile
  echo all install uninstall clean libpdf: > lib/pdf/Makefile
  pdf2swf_makefile=""
  PDF2SWF=
  LIBPDF=
fi
AC_SUBST(PDF2SWF)
AC_SUBST(LIBPDF)

if test "x${ZLIBMISSING}" = "xtrue"; then
  echo
  echo "* Warning! Without zlib, you will not be able to read"
  echo "* or write compressed Flash MX files!"
fi

JPEG2SWF='jpeg2swf$(E)'
if test "x${DISABLEJPEG2SWF}" = "xtrue"; then
  echo "* Disabling jpeg2swf tool..."
  JPEG2SWF=
fi
export JPEG2SWF
AC_SUBST(JPEG2SWF)

GIF2SWF='gif2swf$(E)'
if test "x${DISABLEGIF2SWF}" = "xtrue"; then
  echo "* Disabling gif2swf tool..."
  GIF2SWF=
fi
export GIF2SWF
AC_SUBST(GIF2SWF)

PNG2SWF='png2swf$(E)'
if test "x${DISABLEPNG2SWF}" = "xtrue"; then
  echo "* Disabling png2swf tool..."
  PNG2SWF=
fi
export PNG2SWF
AC_SUBST(PNG2SWF)

if test "x${MISSINGLIBS}" '!=' "x"; then
  if test "x${PARTIAL}" '=' "x"; then
    echo "* (never mind)"
  fi
  echo "***************************************************"
fi

# ------------------------------------------------------------------

AH_TOP([
#ifndef __config_h__
#define __config_h__
])

AH_BOTTOM([
#ifdef HAVE_ZLIB_H
#ifdef HAVE_LIBZ
#define HAVE_ZLIB
#endif
#endif

#ifdef HAVE_JPEGLIB_H
#ifdef HAVE_LIBJPEG
#define HAVE_JPEGLIB
#endif
#endif

#ifdef HAVE_FT2BUILD_H
#define HAVE_FREETYPE_H 1
#endif

#ifdef HAVE_GL_GL_H
#ifdef HAVE_GL_GLUT_H
#ifdef HAVE_OPENGL
#define USE_OPENGL
#endif
#endif
#endif

#ifdef HAVE_POPPLER
#define GString GooString
#define GHash GooHash
#endif

#endif // __config_h__
])

if test -f "release.in"; then release_in="./release"; fi
if test -f "Makefile.new.in"; then mk_in="./Makefile.new"; fi
FILES="$release_in $mk_in Makefile.common ${avi2swf} Makefile lib/Makefile lib/action/Makefile src/Makefile ${pdf2swf_makefile} swfs/Makefile ${pythonrfxswf} ${lame_makefile} lib/art/Makefile lib/readers/Makefile"
AC_OUTPUT(${FILES})

dnl new autoconf
dnl AC_CONFIG_FILES([${FILES}])
dnl AC_OUTPUT

#
# On development trees, create snapshots of config.status
#
if test -f snapshot -a "x$CHECKMEM" = "x" -a "x$PROFILING" = "x";then
    if test "x${MINGW}" = "xyes"; then
	echo cp config.status config.status.win32
	cp config.status config.status.win32
    else
	if test "x$DEBUG" '=' "x" -a "x$OPTIMIZE"  '=' "x";then
	    echo cp config.status config.status.linux
	    cp config.status config.status.linux
	fi
	if test "x$DEBUG" '!=' "x" -a "x$OPTIMIZE"  '=' "x";then
	    echo cp config.status config.status.debug
	    cp config.status config.status.debug
	fi
	if test "x$DEBUG"    = "x" -a "x$OPTIMIZE" '!=' "x"; then
	    echo cp config.status config.status.optimize
	    cp config.status config.status.optimize
	fi
    fi
fi