1dnl Process this file with autoconf to produce a configure script. 2dnl Copyright 1998-2013 Glyph & Cog, LLC 3 4AC_PREREQ(2.57) 5 6AC_INIT(xpdf/Gfx.cc) 7AC_CONFIG_HEADER(aconf.h) 8 9dnl ##### Optional features. 10 11AC_ARG_ENABLE([a4-paper], 12 AS_HELP_STRING([--enable-a4-paper], 13 [use A4 paper size instead of Letter for PostScript output])) 14AS_IF([test "x$enable_a4_paper" = "xyes"], 15 [AC_DEFINE(A4_PAPER)]) 16 17AC_ARG_ENABLE([no-text-select], 18 AS_HELP_STRING([--enable-no-text-select], 19 [do not allow text selection])) 20AS_IF([test "x$enable_no_text_select" = "xyes"], 21 [AC_DEFINE(NO_TEXT_SELECT)]) 22 23AC_ARG_ENABLE([opi], 24 AS_HELP_STRING([--enable-opi], 25 [include support for OPI comments])) 26AS_IF([test "x$enable_opi" = "xyes"], 27 [AC_DEFINE(OPI_SUPPORT)]) 28 29AC_ARG_ENABLE([multithreaded], 30 AS_HELP_STRING([--enable-multithreaded], 31 [include support for multithreading])) 32AS_IF([test "x$enable_multithreaded" = "xyes"], 33 [AC_DEFINE(MULTITHREADED)]) 34 35AC_ARG_ENABLE([exceptions], 36 AS_HELP_STRING([--enable-exceptions], 37 [use C++ exceptions])) 38AS_IF([test "x$enable_exceptions" = "xyes"], 39 [AC_DEFINE(USE_EXCEPTIONS)]) 40 41AC_ARG_ENABLE([fixedpoint], 42 AS_HELP_STRING([--enable-fixedpoint], 43 [use fixed point (instead of floating point) arithmetic])) 44AS_IF([test "x$enable_fixedpoint" = "xyes"], 45 [AC_DEFINE(USE_FIXEDPOINT)]) 46 47AC_ARG_ENABLE([cmyk], 48 AS_HELP_STRING([--enable-cmyk], 49 [include support for CMYK rasterization])) 50AS_IF([test "x$enable_cmyk" = "xyes"], 51 [AC_DEFINE(SPLASH_CMYK)]) 52 53AC_ARG_WITH([appdef-dir], 54 AS_HELP_STRING([--with-appdef-dir], 55 [set app-defaults directory])) 56AS_IF([test "x$with_appdef_dir" != "xno"], 57 [AC_DEFINE_UNQUOTED(APPDEFDIR, "$with_appdef_dir")]) 58 59dnl ##### Path to xpdfrc. 60dnl This ugly kludge to get the sysconfdir path is needed because 61dnl autoconf doesn't actually set the prefix variable until later. 62if test "$sysconfdir" = '${prefix}/etc'; then 63 if test "x$prefix" = xNONE; then 64 system_xpdfrc="$ac_default_prefix/etc/xpdfrc" 65 else 66 system_xpdfrc="$prefix/etc/xpdfrc" 67 fi 68else 69 system_xpdfrc="$sysconfdir/xpdfrc" 70fi 71AC_DEFINE_UNQUOTED(SYSTEM_XPDFRC, "$system_xpdfrc") 72 73dnl ##### Checks for programs. 74AC_PROG_CC 75AC_ISC_POSIX 76AC_PROG_CC_STDC 77#if test -z "$CXX" -a "$CC" = "gcc"; then 78# CXX="gcc" 79#fi 80AC_PROG_CXX 81AC_PROG_INSTALL 82AC_PROG_RANLIB 83 84dnl ##### Default values for Unix. 85EXE="" 86LIBPREFIX="lib" 87AR="ar rc" 88UP_DIR="" 89 90dnl ##### Check for OS/2. 91AC_CACHE_CHECK([for OS/2 (with EMX)], 92xpdf_cv_sys_os2, 93[AC_TRY_COMPILE([], 94[__EMX__], 95xpdf_cv_sys_os2=yes, xpdf_cv_sys_os2=no)]) 96if test "$xpdf_cv_sys_os2" = yes; then 97 EXE=".exe" 98 LIBPREFIX="" 99 AR="ar -rc" 100fi 101 102dnl ##### Check for DOS (with DJGPP). 103AC_CACHE_CHECK([for DOS (with DJGPP)], 104xpdf_cv_sys_dos, 105[AC_TRY_COMPILE([], 106[__DJGPP__], 107xpdf_cv_sys_dos=yes, xpdf_cv_sys_dos=no)]) 108if test "$xpdf_cv_sys_dos" = yes; then 109 EXE=".exe" 110 LIBPREFIX="lib" 111 AR="ar -rc" 112 UP_DIR="../" 113fi 114 115dnl ##### Do substitutions. 116AC_SUBST(EXE) 117AC_SUBST(LIBPREFIX) 118AC_SUBST(AR) 119AC_SUBST(UP_DIR) 120 121dnl ##### Checks for header files. 122AC_PATH_XTRA 123AC_HEADER_DIRENT 124 125dnl ##### Switch over to C++. This will make the checks below a little 126dnl ##### bit stricter (requiring function prototypes in include files). 127dnl ##### (99% of xpdf is written in C++.) 128AC_LANG_CPLUSPLUS 129 130dnl ##### Check for extra libraries needed by X. (LynxOS needs this.) 131AC_CHECK_FUNC(gethostbyname) 132if test $ac_cv_func_gethostbyname = no; then 133 AC_CHECK_LIB(bsd, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd") 134fi 135 136dnl ##### Look for header that defines select() and fd_set. 137AC_MSG_CHECKING([select() and fd_set in sys/select.h and sys/bsdtypes.h]) 138AC_TRY_COMPILE([#include <stdlib.h> 139#include <stddef.h> 140#include <unistd.h> 141#include <sys/types.h>], 142 [fd_set fds; 143select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no) 144if test $xpdf_ok = yes; then 145 AC_MSG_RESULT([not needed]) 146else 147 AC_TRY_COMPILE([#include <stdlib.h> 148#include <stddef.h> 149#include <unistd.h> 150#include <sys/types.h> 151#include <sys/select.h>], 152 [fd_set fds; 153select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no) 154 if test $xpdf_ok = yes; then 155 AC_DEFINE(HAVE_SYS_SELECT_H) 156 AC_MSG_RESULT([need sys/select.h]) 157 else 158 AC_TRY_COMPILE([#include <stdlib.h> 159#include <stddef.h> 160#include <unistd.h> 161#include <sys/types.h> 162#include <sys/bsdtypes.h>], 163 [fd_set fds; 164select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no) 165 if test $xpdf_ok = yes; then 166 AC_DEFINE(HAVE_SYS_BSDTYPES_H) 167 AC_MSG_RESULT([need sys/bsdtypes.h]) 168 else 169 AC_MSG_RESULT([problem]) 170 fi 171 fi 172fi 173 174dnl ##### Look for header that defines FD_ZERO. 175AC_MSG_CHECKING([FD_ZERO and strings.h or bstring.h]) 176AC_TRY_COMPILE([#include <stdlib.h> 177#include <sys/types.h> 178#ifdef HAVE_SYS_SELECT_H 179#include <sys/select.h> 180#endif], 181[fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no) 182if test $xpdf_ok = yes; then 183 AC_MSG_RESULT([not needed]) 184else 185 AC_TRY_COMPILE([#include <stdlib.h> 186#include <sys/types.h> 187#include <strings.h> 188#ifdef HAVE_SYS_SELECT_H 189#include <sys/select.h> 190#endif], 191 [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no) 192 if test $xpdf_ok = yes; then 193 AC_DEFINE(HAVE_STRINGS_H) 194 AC_MSG_RESULT([need strings.h]) 195 else 196 AC_TRY_COMPILE([#include <stdlib.h> 197#include <sys/types.h> 198#include <bstring.h> 199#ifdef HAVE_SYS_SELECT_H 200#include <sys/select.h> 201#endif], 202 [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no) 203 if test $xpdf_ok = yes; then 204 AC_DEFINE(HAVE_BSTRING_H) 205 AC_MSG_RESULT([need bstring.h]) 206 else 207 AC_MSG_RESULT([problem]) 208 fi 209 fi 210fi 211 212dnl ##### Look for rewinddir. 213AC_CHECK_FUNCS(rewinddir) 214if test $ac_cv_func_rewinddir = no; then 215 AC_CHECK_LIB(cposix, rewinddir) 216fi 217 218dnl ##### Checks for library functions. 219AC_CHECK_FUNCS(popen) 220dnl # This should use 'AC_CHECK_FUNCS(mkstemp)' but that fails if 221dnl # the mkstemp exists in the library but isn't declared in the 222dnl # include file (e.g., in cygwin 1.1.2). 223AC_CACHE_CHECK([for mkstemp], 224xpdf_cv_func_mkstemp, 225[AC_TRY_LINK([#include <stdlib.h> 226#include <unistd.h>], 227[mkstemp("foo");], 228xpdf_cv_func_mkstemp=yes, xpdf_cv_func_mkstemp=no)]) 229if test "$xpdf_cv_func_mkstemp" = yes; then 230 AC_DEFINE(HAVE_MKSTEMP) 231fi 232dnl # Check for mkstemps, just like mkstemp. 233AC_CACHE_CHECK([for mkstemps], 234xpdf_cv_func_mkstemps, 235[AC_TRY_LINK([#include <stdlib.h> 236#include <unistd.h>], 237[mkstemps("foo", 0);], 238xpdf_cv_func_mkstemps=yes, xpdf_cv_func_mkstemps=no)]) 239if test "$xpdf_cv_func_mkstemps" = yes; then 240 AC_DEFINE(HAVE_MKSTEMPS) 241fi 242 243dnl ##### Check select argument type: on HP-UX before version 10, select 244dnl ##### takes (int *) instead of (fd_set *). 245AC_CACHE_CHECK([whether select takes fd_set arguments], 246xpdf_cv_func_select_arg, 247[AC_TRY_COMPILE([#include <sys/types.h> 248#include <sys/time.h> 249#include <unistd.h> 250#ifdef HAVE_SYS_SELECT_H 251#include <sys/select.h> 252#endif], 253[fd_set fds; 254select(1, &fds, &fds, &fds, 0);], 255xpdf_cv_func_select_arg=yes, xpdf_cv_func_select_arg=no)]) 256if test "$xpdf_cv_func_select_arg" != yes; then 257 AC_DEFINE(SELECT_TAKES_INT) 258fi 259 260dnl ##### Check for std::sort. 261AC_CACHE_CHECK([for std::sort], 262xpdf_cv_func_std_sort, 263[AC_COMPILE_IFELSE( 264 [AC_LANG_PROGRAM([[#include <algorithm> 265struct functor { 266 bool operator()(const int &i0, const int &i1) { return i0 < i1; } 267};]], 268 [[int a[100]; 269std::sort(a, a+100, functor());]])], 270xpdf_cv_func_std_sort=yes, xpdf_cv_func_std_sort=no)]) 271if test "$xpdf_cv_func_std_sort" = yes; then 272 AC_DEFINE(HAVE_STD_SORT) 273fi 274 275dnl ##### Back to C for the library tests. 276AC_LANG_C 277 278dnl ##### Check for fseeko/ftello or fseek64/ftell64 279dnl The LARGEFILE and FSEEKO macros have to be called in C, not C++, mode. 280AC_SYS_LARGEFILE 281AC_FUNC_FSEEKO 282AC_CHECK_FUNCS(fseek64, xpdf_cv_func_fseek64=yes, xpdf_cv_func_fseek64=no) 283AC_CHECK_FUNCS(ftell64, xpdf_cv_func_ftell64=yes, xpdf_cv_func_ftell64=no) 284if test "$xpdf_cv_func_fseek64" = yes -a "$xpdf_cv_func_ftell64" = yes; then 285 AC_DEFINE(HAVE_FSEEK64) 286fi 287 288dnl ##### Check for libXpm. 289if test -z "$no_x"; then 290 smr_CHECK_LIB(Xpm, Xpm, [pixmap library - used only for icon], 291 XpmCreatePixmapFromData, X11/xpm.h, 292 $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS) 293 AC_SUBST(Xpm_LIBS) 294 AC_SUBST(Xpm_CFLAGS) 295fi 296 297dnl ##### Check for Motif (libXm). 298if test -z "$no_x"; then 299 dnl # XextAddDisplay isn't defined in any header file, so we provide a 300 dnl # bogus prototype (so the compiler doesn't complain) and a bogus 301 dnl # header file (so the smr macro doesn't break). 302 smr_CHECK_LIB(Xext, Xext, [Motif library], 303 XextAddDisplay, X11/Xlib.h, 304 $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS, 305 [int XextAddDisplay();]) 306 AC_SUBST(Xext_LIBS) 307 AC_SUBST(Xext_CFLAGS) 308 smr_CHECK_LIB(Xp, Xp, [Motif library], 309 XpStartPage, X11/extensions/Print.h, 310 $X_LIBS $X_PRE_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS) 311 AC_SUBST(Xp_LIBS) 312 AC_SUBST(Xp_CFLAGS) 313 smr_CHECK_LIB(Xt, Xt, [Motif library], 314 XtAppInitialize, X11/Intrinsic.h, 315 $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS) 316 AC_SUBST(Xt_LIBS) 317 AC_SUBST(Xt_CFLAGS) 318 smr_CHECK_LIB(Xm, Xm, [Motif library], 319 XmCreateForm, Xm/XmAll.h, 320 $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS) 321 AC_SUBST(Xm_LIBS) 322 AC_SUBST(Xm_CFLAGS) 323 smr_CHECK_LIB(Sgm, Sgm, [SGI Motif library], 324 SgCreateHorzPanedWindow, Sgm/HPanedW.h, 325 $Xm_LIBS $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS) 326 AC_SUBST(Sgm_LIBS) 327 AC_SUBST(Sgm_CFLAGS) 328 329 dnl # check for XtAppSetExitFlag, which didn't exist prior to X11R6 (?) 330 if test "x$smr_have_Xt_library" = xyes; then 331 AC_CHECK_LIB(Xt, XtAppSetExitFlag, 332 AC_DEFINE(HAVE_XTAPPSETEXITFLAG), , 333 [$Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11]) 334 fi 335fi 336 337dnl ##### Check for FreeType 2.x. 338dnl ##### (Note: FT_Get_Name_Index was added in FT 2.0.5, and is 339dnl ##### the reason that Xpdf requires 2.0.5+.) 340smr_CHECK_LIB(freetype2, freetype, [FreeType2 font rasterizer - version 2.0.5+], 341 FT_Get_Name_Index, ft2build.h, -lm) 342AC_SUBST(freetype2_LIBS) 343AC_SUBST(freetype2_CFLAGS) 344if test "x$smr_have_freetype2_library" = xyes; then 345 AC_DEFINE(HAVE_FREETYPE_FREETYPE_H) 346 AC_DEFINE(HAVE_SPLASH) 347fi 348 349dnl ##### Check for libpng. 350smr_CHECK_LIB(libpng, png, [PNG library], png_write_row, png.h, -lz) 351AC_SUBST(libpng_LIBS) 352AC_SUBST(libpng_CFLAGS) 353 354dnl ##### Check for libpaper (Debian). 355smr_CHECK_LIB(libpaper, paper, [Debian libpaper], paperinit, paper.h) 356AC_SUBST(libpaper_LIBS) 357AC_SUBST(libpaper_CFLAGS) 358 359dnl ##### Disable X-specific stuff in top-level Makefile. 360if test -n "$no_x" -o "x$smr_have_Xm_library" != xyes -o "x$smr_have_freetype2_library" != xyes; then 361 X="#" 362 XPDF_TARGET="all-no-x" 363else 364 X="" 365 XPDF_TARGET="all" 366fi 367AC_SUBST(X) 368AC_SUBST(XPDF_TARGET) 369 370dnl ##### Extra libraries. 371EXTRA_LIBS= 372EXTRA_CFLAGS= 373AC_SUBST(EXTRA_LIBS) 374AC_SUBST(EXTRA_CFLAGS) 375 376dnl ##### Write the makefiles. 377AC_OUTPUT(Makefile goo/Makefile fofi/Makefile splash/Makefile xpdf/Makefile) 378 379dnl ##### Warn user if X is missing. 380if test -n "$no_x" -o "x$smr_have_Xm_library" != xyes -o "x$smr_have_freetype2_library" != xyes; then 381 if test -n "$no_x"; then 382 AC_MSG_WARN([Couldn't find X]); 383 fi 384 if test "x$smr_have_Xm_library" != xyes; then 385 AC_MSG_WARN([Couldn't find Motif]); 386 fi 387 if test "x$smr_have_freetype2_library" != xyes; then 388 AC_MSG_WARN([Couldn't find FreeType]); 389 fi 390 AC_MSG_WARN([-- You will be able to compile pdftops, pdftotext, 391 pdfinfo, pdffonts, pdfdetach, and pdfimages, but not xpdf 392 or pdftoppm]) 393fi 394 395dnl ##### Warn user if libpng is missing. 396if test "x$smr_have_libpng_library" != xyes; then 397 AC_MSG_WARN([Couldn't find libpng -- you will not be able to build pdftohtml or pdftopng]) 398fi 399