1 dnl Process this file with autoconf to produce a configure script.
2 dnl Copyright 1998-2005 Glyph & Cog, LLC
7 AC_CONFIG_HEADER(aconf.h)
9 dnl ##### Optional features.
10 AC_ARG_ENABLE(a4-paper,
11 [ --enable-a4-paper use A4 paper size instead of Letter for
14 AC_ARG_ENABLE(no-text-select,
15 [ --enable-no-text-select do not allow text selection],
16 AC_DEFINE(NO_TEXT_SELECT))
18 [ --enable-opi include support for OPI comments],
19 AC_DEFINE(OPI_SUPPORT))
20 AC_ARG_ENABLE(multithreaded,
21 [ --enable-multithreaded include support for multithreading],
22 AC_DEFINE(MULTITHREADED))
23 AC_ARG_ENABLE(exceptions,
24 [ --enable-exceptions use C++ exceptions],
25 AC_DEFINE(USE_EXCEPTIONS))
26 AC_ARG_ENABLE(wordlist,
27 [ --enable-wordlist include support for building word lists],
28 AC_DEFINE(TEXTOUT_WORD_LIST))
29 AC_ARG_ENABLE(fixedpoint,
30 [ --enable-fixedpoint use fixed point (instead of floating point) arithmetic],
31 AC_DEFINE(USE_FIXEDPOINT))
33 [ --enable-cmyk include support for CMYK rasterization],
34 AC_DEFINE(SPLASH_CMYK))
35 AC_ARG_WITH(appdef-dir,
36 [ --with-appdef-dir set app-defaults directory],
37 AC_DEFINE_UNQUOTED(APPDEFDIR, "$with_appdef_dir"))
39 dnl ##### Path to xpdfrc.
40 dnl This ugly kludge to get the sysconfdir path is needed because
41 dnl autoconf doesn't actually set the prefix variable until later.
42 if test "$sysconfdir" = '${prefix}/etc'; then
43 if test "x$prefix" = xNONE; then
44 system_xpdfrc="$ac_default_prefix/etc/xpdfrc"
46 system_xpdfrc="$prefix/etc/xpdfrc"
49 system_xpdfrc="$sysconfdir/xpdfrc"
51 AC_DEFINE_UNQUOTED(SYSTEM_XPDFRC, "$system_xpdfrc")
53 dnl ##### Checks for programs.
57 #if test -z "$CXX" -a "$CC" = "gcc"; then
64 dnl ##### Default values for Unix.
70 dnl ##### Check for OS/2.
71 AC_CACHE_CHECK([for OS/2 (with EMX)],
75 xpdf_cv_sys_os2=yes, xpdf_cv_sys_os2=no)])
76 if test "$xpdf_cv_sys_os2" = yes; then
82 dnl ##### Check for DOS (with DJGPP).
83 AC_CACHE_CHECK([for DOS (with DJGPP)],
87 xpdf_cv_sys_dos=yes, xpdf_cv_sys_dos=no)])
88 if test "$xpdf_cv_sys_dos" = yes; then
95 dnl ##### Do substitutions.
101 dnl ##### Checks for header files.
105 dnl ##### Switch over to C++. This will make the checks below a little
106 dnl ##### bit stricter (requiring function prototypes in include files).
107 dnl ##### (99% of xpdf is written in C++.)
110 dnl ##### Check for extra libraries needed by X. (LynxOS needs this.)
111 AC_CHECK_FUNC(gethostbyname)
112 if test $ac_cv_func_gethostbyname = no; then
113 AC_CHECK_LIB(bsd, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd")
116 dnl ##### Look for header that defines select() and fd_set.
117 AC_MSG_CHECKING([select() and fd_set in sys/select.h and sys/bsdtypes.h])
118 AC_TRY_COMPILE([#include <stdlib.h>
121 #include <sys/types.h>],
123 select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no)
124 if test $xpdf_ok = yes; then
125 AC_MSG_RESULT([not needed])
127 AC_TRY_COMPILE([#include <stdlib.h>
130 #include <sys/types.h>
131 #include <sys/select.h>],
133 select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no)
134 if test $xpdf_ok = yes; then
135 AC_DEFINE(HAVE_SYS_SELECT_H)
136 AC_MSG_RESULT([need sys/select.h])
138 AC_TRY_COMPILE([#include <stdlib.h>
141 #include <sys/types.h>
142 #include <sys/bsdtypes.h>],
144 select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no)
145 if test $xpdf_ok = yes; then
146 AC_DEFINE(HAVE_SYS_BSDTYPES_H)
147 AC_MSG_RESULT([need sys/bsdtypes.h])
149 AC_MSG_RESULT([problem])
154 dnl ##### Look for header that defines FD_ZERO.
155 AC_MSG_CHECKING([FD_ZERO and strings.h or bstring.h])
156 AC_TRY_COMPILE([#include <stdlib.h>
157 #include <sys/types.h>
158 #ifdef HAVE_SYS_SELECT_H
159 #include <sys/select.h>
161 [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no)
162 if test $xpdf_ok = yes; then
163 AC_MSG_RESULT([not needed])
165 AC_TRY_COMPILE([#include <stdlib.h>
166 #include <sys/types.h>
168 #ifdef HAVE_SYS_SELECT_H
169 #include <sys/select.h>
171 [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no)
172 if test $xpdf_ok = yes; then
173 AC_DEFINE(HAVE_STRINGS_H)
174 AC_MSG_RESULT([need strings.h])
176 AC_TRY_COMPILE([#include <stdlib.h>
177 #include <sys/types.h>
179 #ifdef HAVE_SYS_SELECT_H
180 #include <sys/select.h>
182 [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no)
183 if test $xpdf_ok = yes; then
184 AC_DEFINE(HAVE_BSTRING_H)
185 AC_MSG_RESULT([need bstring.h])
187 AC_MSG_RESULT([problem])
192 dnl ##### Look for rewinddir.
193 AC_CHECK_FUNCS(rewinddir)
194 if test $ac_cv_func_rewinddir = no; then
195 AC_CHECK_LIB(cposix, rewinddir)
198 dnl ##### Checks for library functions.
199 AC_CHECK_FUNCS(popen)
200 dnl # This should use 'AC_CHECK_FUNCS(mkstemp)' but that fails if
201 dnl # the mkstemp exists in the library but isn't declared in the
202 dnl # include file (e.g., in cygwin 1.1.2).
203 AC_CACHE_CHECK([for mkstemp],
204 xpdf_cv_func_mkstemp,
205 [AC_TRY_LINK([#include <stdlib.h>
206 #include <unistd.h>],
208 xpdf_cv_func_mkstemp=yes, xpdf_cv_func_mkstemp=no)])
209 if test "$xpdf_cv_func_mkstemp" = yes; then
210 AC_DEFINE(HAVE_MKSTEMP)
212 dnl # Check for mkstemps, just like mkstemp.
213 AC_CACHE_CHECK([for mkstemps],
214 xpdf_cv_func_mkstemps,
215 [AC_TRY_LINK([#include <stdlib.h>
216 #include <unistd.h>],
217 [mkstemps("foo", 0);],
218 xpdf_cv_func_mkstemps=yes, xpdf_cv_func_mkstemps=no)])
219 if test "$xpdf_cv_func_mkstemps" = yes; then
220 AC_DEFINE(HAVE_MKSTEMPS)
223 dnl ##### Check select argument type: on HP-UX before version 10, select
224 dnl ##### takes (int *) instead of (fd_set *).
225 AC_CACHE_CHECK([whether select takes fd_set arguments],
226 xpdf_cv_func_select_arg,
227 [AC_TRY_COMPILE([#include <sys/types.h>
228 #include <sys/time.h>
230 #ifdef HAVE_SYS_SELECT_H
231 #include <sys/select.h>
234 select(1, &fds, &fds, &fds, 0);],
235 xpdf_cv_func_select_arg=yes, xpdf_cv_func_select_arg=no)])
236 if test "$xpdf_cv_func_select_arg" != yes; then
237 AC_DEFINE(SELECT_TAKES_INT)
240 dnl ##### Back to C for the library tests.
243 dnl ##### Check for fseeko/ftello or fseek64/ftell64
244 dnl The LARGEFILE and FSEEKO macros have to be called in C, not C++, mode.
247 AC_CHECK_FUNCS(fseek64, xpdf_cv_func_fseek64=yes, xpdf_cv_func_fseek64=no)
248 AC_CHECK_FUNCS(ftell64, xpdf_cv_func_ftell64=yes, xpdf_cv_func_ftell64=no)
249 if test "$xpdf_cv_func_fseek64" = yes -a "$xpdf_cv_func_ftell64" = yes; then
250 AC_DEFINE(HAVE_FSEEK64)
253 dnl ##### Check for libXpm.
254 if test -z "$no_x"; then
255 smr_CHECK_LIB(Xpm, Xpm, [pixmap library - used only for icon],
256 XpmCreatePixmapFromData, X11/xpm.h,
257 $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS)
262 dnl ##### Check for Motif (libXm).
263 if test -z "$no_x"; then
264 dnl # XextAddDisplay isn't defined in any header file, so we provide a
265 dnl # bogus prototype (so the compiler doesn't complain) and a bogus
266 dnl # header file (so the smr macro doesn't break).
267 smr_CHECK_LIB(Xext, Xext, [Motif library],
268 XextAddDisplay, X11/Xlib.h,
269 $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS,
270 [int XextAddDisplay();])
272 AC_SUBST(Xext_CFLAGS)
273 smr_CHECK_LIB(Xp, Xp, [Motif library],
274 XpStartPage, X11/extensions/Print.h,
275 $X_LIBS $X_PRE_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS)
278 smr_CHECK_LIB(Xt, Xt, [Motif library],
279 XtAppInitialize, X11/Intrinsic.h,
280 $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS)
283 smr_CHECK_LIB(Xm, Xm, [Motif library],
284 XmCreateForm, Xm/XmAll.h,
285 $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS)
288 smr_CHECK_LIB(Sgm, Sgm, [SGI Motif library],
289 SgCreateHorzPanedWindow, Sgm/HPanedW.h,
290 $Xm_LIBS $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS)
294 dnl # check for XtAppSetExitFlag, which didn't exist prior to X11R6 (?)
295 if test "x$smr_have_Xt_library" = xyes; then
296 AC_CHECK_LIB(Xt, XtAppSetExitFlag,
297 AC_DEFINE(HAVE_XTAPPSETEXITFLAG), ,
298 [$Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11])
302 dnl ##### Check for t1lib.
303 smr_CHECK_LIB(t1, t1, [Type 1 font rasterizer],
309 dnl ##### Check for FreeType 2.x.
310 dnl ##### (Note: FT_Get_Name_Index was added in FT 2.0.5, and is
311 dnl ##### the reason that Xpdf requires 2.0.5+.)
312 smr_CHECK_LIB(freetype2, freetype, [FreeType2 font rasterizer - version 2.0.5+],
313 FT_Get_Name_Index, ft2build.h, -lm)
314 AC_SUBST(freetype2_LIBS)
315 AC_SUBST(freetype2_CFLAGS)
316 if test "x$smr_have_freetype2_library" = xyes; then
317 AC_DEFINE(HAVE_FREETYPE_FREETYPE_H)
318 AC_DEFINE(HAVE_SPLASH)
321 dnl ##### Check for libpaper (Debian).
322 smr_CHECK_LIB(libpaper, paper, [Debian libpaper], paperinit, paper.h)
323 AC_SUBST(libpaper_LIBS)
324 AC_SUBST(libpaper_CFLAGS)
326 dnl ##### Disable X-specific stuff in top-level Makefile.
327 if test -n "$no_x" -o "x$smr_have_Xm_library" != xyes -o "x$smr_have_freetype2_library" != xyes; then
329 XPDF_TARGET="all-no-x"
335 AC_SUBST(XPDF_TARGET)
337 dnl ##### Write the makefiles.
338 AC_OUTPUT(Makefile goo/Makefile fofi/Makefile splash/Makefile xpdf/Makefile)
340 dnl ##### Warn user if X is missing.
341 if test -n "$no_x" -o "x$smr_have_Xm_library" != xyes -o "x$smr_have_freetype2_library" != xyes; then
342 if test -n "$no_x"; then
343 AC_MSG_WARN([Couldn't find X]);
345 if test "x$smr_have_Xm_library" != xyes; then
346 AC_MSG_WARN([Couldn't find Motif]);
348 if test "x$smr_have_freetype2_library" != xyes; then
349 AC_MSG_WARN([Couldn't find FreeType]);
351 AC_MSG_WARN([-- You will be able to compile pdftops, pdftotext,
352 pdfinfo, pdffonts, and pdfimages, but not xpdf or pdftoppm])