# use AROS_LIB/INCLUDES
[AROS-Contrib.git] / arospdf / configure.in
blob81e70154405b088384a9038fbbb93c2f43cc3cf9
1 dnl Process this file with autoconf to produce a configure script.
2 dnl Copyright 1998-2005 Glyph & Cog, LLC
4 AC_PREREQ(2.57)
6 AC_INIT(xpdf/xpdf.cc)
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
12                           PostScript output],
13 AC_DEFINE(A4_PAPER))
14 AC_ARG_ENABLE(no-text-select,
15 [  --enable-no-text-select do not allow text selection],
16 AC_DEFINE(NO_TEXT_SELECT))
17 AC_ARG_ENABLE(opi,
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))
32 AC_ARG_ENABLE(cmyk,
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"
45   else
46     system_xpdfrc="$prefix/etc/xpdfrc"
47   fi
48 else
49   system_xpdfrc="$sysconfdir/xpdfrc"
51 AC_DEFINE_UNQUOTED(SYSTEM_XPDFRC, "$system_xpdfrc")
53 dnl ##### Checks for programs.
54 AC_PROG_CC
55 AC_ISC_POSIX
56 AC_PROG_CC_STDC
57 #if test -z "$CXX" -a "$CC" = "gcc"; then
58 #  CXX="gcc"
59 #fi
60 AC_PROG_CXX
61 AC_PROG_INSTALL
62 AC_PROG_RANLIB
64 dnl ##### Default values for Unix.
65 EXE=""
66 LIBPREFIX="lib"
67 AR="ar rc"
68 UP_DIR=""
70 dnl ##### Check for OS/2.
71 AC_CACHE_CHECK([for OS/2 (with EMX)],
72 xpdf_cv_sys_os2,
73 [AC_TRY_COMPILE([],
74 [__EMX__],
75 xpdf_cv_sys_os2=yes, xpdf_cv_sys_os2=no)])
76 if test "$xpdf_cv_sys_os2" = yes; then
77   EXE=".exe"
78   LIBPREFIX=""
79   AR="ar -rc"
82 dnl ##### Check for DOS (with DJGPP).
83 AC_CACHE_CHECK([for DOS (with DJGPP)],
84 xpdf_cv_sys_dos,
85 [AC_TRY_COMPILE([],
86 [__DJGPP__],
87 xpdf_cv_sys_dos=yes, xpdf_cv_sys_dos=no)])
88 if test "$xpdf_cv_sys_dos" = yes; then
89   EXE=".exe"
90   LIBPREFIX="lib"
91   AR="ar -rc"
92   UP_DIR="../"
95 dnl ##### Do substitutions.
96 AC_SUBST(EXE)
97 AC_SUBST(LIBPREFIX)
98 AC_SUBST(AR)
99 AC_SUBST(UP_DIR)
101 dnl ##### Checks for header files.
102 AC_PATH_XTRA
103 AC_HEADER_DIRENT
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++.)
108 AC_LANG_CPLUSPLUS
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>
119 #include <stddef.h>
120 #include <unistd.h>
121 #include <sys/types.h>],
122   [fd_set fds;
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])
126 else
127   AC_TRY_COMPILE([#include <stdlib.h>
128 #include <stddef.h>
129 #include <unistd.h>
130 #include <sys/types.h>
131 #include <sys/select.h>],
132     [fd_set fds;
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])
137   else
138     AC_TRY_COMPILE([#include <stdlib.h>
139 #include <stddef.h>
140 #include <unistd.h>
141 #include <sys/types.h>
142 #include <sys/bsdtypes.h>],
143       [fd_set fds;
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])
148     else
149       AC_MSG_RESULT([problem])
150     fi
151   fi
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>
160 #endif],
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])
164 else
165   AC_TRY_COMPILE([#include <stdlib.h>
166 #include <sys/types.h>
167 #include <strings.h>
168 #ifdef HAVE_SYS_SELECT_H
169 #include <sys/select.h>
170 #endif],
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])
175   else
176     AC_TRY_COMPILE([#include <stdlib.h>
177 #include <sys/types.h>
178 #include <bstring.h>
179 #ifdef HAVE_SYS_SELECT_H
180 #include <sys/select.h>
181 #endif],
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])
186     else
187       AC_MSG_RESULT([problem])
188     fi
189   fi
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>],
207 [mkstemp("foo");],
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>
229 #include <unistd.h>
230 #ifdef HAVE_SYS_SELECT_H
231 #include <sys/select.h>
232 #endif],
233 [fd_set fds;
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.
241 AC_LANG_C
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.
245 AC_SYS_LARGEFILE
246 AC_FUNC_FSEEKO
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)
258   AC_SUBST(Xpm_LIBS)
259   AC_SUBST(Xpm_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();])
271   AC_SUBST(Xext_LIBS)
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)
276   AC_SUBST(Xp_LIBS)
277   AC_SUBST(Xp_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)
281   AC_SUBST(Xt_LIBS)
282   AC_SUBST(Xt_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)
286   AC_SUBST(Xm_LIBS)
287   AC_SUBST(Xm_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)
291   AC_SUBST(Sgm_LIBS)
292   AC_SUBST(Sgm_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])
299   fi
302 dnl ##### Check for t1lib.
303 smr_CHECK_LIB(t1, t1, [Type 1 font rasterizer], 
304               T1_InitLib, t1lib.h,
305               -lm, $X_CFLAGS)
306 AC_SUBST(t1_LIBS)
307 AC_SUBST(t1_CFLAGS)
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
328   X="#"
329   XPDF_TARGET="all-no-x"
330 else
331   X=""
332   XPDF_TARGET="all"
334 AC_SUBST(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]);
344   fi
345   if test "x$smr_have_Xm_library" != xyes; then
346     AC_MSG_WARN([Couldn't find Motif]);
347   fi
348   if test "x$smr_have_freetype2_library" != xyes; then
349     AC_MSG_WARN([Couldn't find FreeType]);
350   fi
351   AC_MSG_WARN([-- You will be able to compile pdftops, pdftotext,
352         pdfinfo, pdffonts, and pdfimages, but not xpdf or pdftoppm])