dnl Process this file with autoconf to produce a configure script. dnl Copyright 1998-2013 Glyph & Cog, LLC AC_PREREQ(2.57) AC_INIT(xpdf/Gfx.cc) AC_CONFIG_HEADER(aconf.h) dnl ##### Optional features. AC_ARG_ENABLE([a4-paper], AS_HELP_STRING([--enable-a4-paper], [use A4 paper size instead of Letter for PostScript output])) AS_IF([test "x$enable_a4_paper" = "xyes"], [AC_DEFINE(A4_PAPER)]) AC_ARG_ENABLE([no-text-select], AS_HELP_STRING([--enable-no-text-select], [do not allow text selection])) AS_IF([test "x$enable_no_text_select" = "xyes"], [AC_DEFINE(NO_TEXT_SELECT)]) AC_ARG_ENABLE([opi], AS_HELP_STRING([--enable-opi], [include support for OPI comments])) AS_IF([test "x$enable_opi" = "xyes"], [AC_DEFINE(OPI_SUPPORT)]) AC_ARG_ENABLE([multithreaded], AS_HELP_STRING([--enable-multithreaded], [include support for multithreading])) AS_IF([test "x$enable_multithreaded" = "xyes"], [AC_DEFINE(MULTITHREADED)]) AC_ARG_ENABLE([exceptions], AS_HELP_STRING([--enable-exceptions], [use C++ exceptions])) AS_IF([test "x$enable_exceptions" = "xyes"], [AC_DEFINE(USE_EXCEPTIONS)]) AC_ARG_ENABLE([fixedpoint], AS_HELP_STRING([--enable-fixedpoint], [use fixed point (instead of floating point) arithmetic])) AS_IF([test "x$enable_fixedpoint" = "xyes"], [AC_DEFINE(USE_FIXEDPOINT)]) AC_ARG_ENABLE([cmyk], AS_HELP_STRING([--enable-cmyk], [include support for CMYK rasterization])) AS_IF([test "x$enable_cmyk" = "xyes"], [AC_DEFINE(SPLASH_CMYK)]) AC_ARG_WITH([appdef-dir], AS_HELP_STRING([--with-appdef-dir], [set app-defaults directory])) AS_IF([test "x$with_appdef_dir" != "xno"], [AC_DEFINE_UNQUOTED(APPDEFDIR, "$with_appdef_dir")]) dnl ##### Path to xpdfrc. dnl This ugly kludge to get the sysconfdir path is needed because dnl autoconf doesn't actually set the prefix variable until later. if test "$sysconfdir" = '${prefix}/etc'; then if test "x$prefix" = xNONE; then system_xpdfrc="$ac_default_prefix/etc/xpdfrc" else system_xpdfrc="$prefix/etc/xpdfrc" fi else system_xpdfrc="$sysconfdir/xpdfrc" fi AC_DEFINE_UNQUOTED(SYSTEM_XPDFRC, "$system_xpdfrc") dnl ##### Checks for programs. AC_PROG_CC AC_ISC_POSIX AC_PROG_CC_STDC #if test -z "$CXX" -a "$CC" = "gcc"; then # CXX="gcc" #fi AC_PROG_CXX AC_PROG_INSTALL AC_PROG_RANLIB dnl ##### Default values for Unix. EXE="" LIBPREFIX="lib" AR="ar rc" UP_DIR="" dnl ##### Check for OS/2. AC_CACHE_CHECK([for OS/2 (with EMX)], xpdf_cv_sys_os2, [AC_TRY_COMPILE([], [__EMX__], xpdf_cv_sys_os2=yes, xpdf_cv_sys_os2=no)]) if test "$xpdf_cv_sys_os2" = yes; then EXE=".exe" LIBPREFIX="" AR="ar -rc" fi dnl ##### Check for DOS (with DJGPP). AC_CACHE_CHECK([for DOS (with DJGPP)], xpdf_cv_sys_dos, [AC_TRY_COMPILE([], [__DJGPP__], xpdf_cv_sys_dos=yes, xpdf_cv_sys_dos=no)]) if test "$xpdf_cv_sys_dos" = yes; then EXE=".exe" LIBPREFIX="lib" AR="ar -rc" UP_DIR="../" fi dnl ##### Do substitutions. AC_SUBST(EXE) AC_SUBST(LIBPREFIX) AC_SUBST(AR) AC_SUBST(UP_DIR) dnl ##### Checks for header files. AC_PATH_XTRA AC_HEADER_DIRENT dnl ##### Switch over to C++. This will make the checks below a little dnl ##### bit stricter (requiring function prototypes in include files). dnl ##### (99% of xpdf is written in C++.) AC_LANG_CPLUSPLUS dnl ##### Check for extra libraries needed by X. (LynxOS needs this.) AC_CHECK_FUNC(gethostbyname) if test $ac_cv_func_gethostbyname = no; then AC_CHECK_LIB(bsd, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd") fi dnl ##### Look for header that defines select() and fd_set. AC_MSG_CHECKING([select() and fd_set in sys/select.h and sys/bsdtypes.h]) AC_TRY_COMPILE([#include #include #include #include ], [fd_set fds; select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no) if test $xpdf_ok = yes; then AC_MSG_RESULT([not needed]) else AC_TRY_COMPILE([#include #include #include #include #include ], [fd_set fds; select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no) if test $xpdf_ok = yes; then AC_DEFINE(HAVE_SYS_SELECT_H) AC_MSG_RESULT([need sys/select.h]) else AC_TRY_COMPILE([#include #include #include #include #include ], [fd_set fds; select(0, NULL, NULL, NULL, NULL);], xpdf_ok=yes, xpdf_ok=no) if test $xpdf_ok = yes; then AC_DEFINE(HAVE_SYS_BSDTYPES_H) AC_MSG_RESULT([need sys/bsdtypes.h]) else AC_MSG_RESULT([problem]) fi fi fi dnl ##### Look for header that defines FD_ZERO. AC_MSG_CHECKING([FD_ZERO and strings.h or bstring.h]) AC_TRY_COMPILE([#include #include #ifdef HAVE_SYS_SELECT_H #include #endif], [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no) if test $xpdf_ok = yes; then AC_MSG_RESULT([not needed]) else AC_TRY_COMPILE([#include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif], [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no) if test $xpdf_ok = yes; then AC_DEFINE(HAVE_STRINGS_H) AC_MSG_RESULT([need strings.h]) else AC_TRY_COMPILE([#include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif], [fd_set fds; FD_ZERO(&fds);], xpdf_ok=yes, xpdf_ok=no) if test $xpdf_ok = yes; then AC_DEFINE(HAVE_BSTRING_H) AC_MSG_RESULT([need bstring.h]) else AC_MSG_RESULT([problem]) fi fi fi dnl ##### Look for rewinddir. AC_CHECK_FUNCS(rewinddir) if test $ac_cv_func_rewinddir = no; then AC_CHECK_LIB(cposix, rewinddir) fi dnl ##### Checks for library functions. AC_CHECK_FUNCS(popen) dnl # This should use 'AC_CHECK_FUNCS(mkstemp)' but that fails if dnl # the mkstemp exists in the library but isn't declared in the dnl # include file (e.g., in cygwin 1.1.2). AC_CACHE_CHECK([for mkstemp], xpdf_cv_func_mkstemp, [AC_TRY_LINK([#include #include ], [mkstemp("foo");], xpdf_cv_func_mkstemp=yes, xpdf_cv_func_mkstemp=no)]) if test "$xpdf_cv_func_mkstemp" = yes; then AC_DEFINE(HAVE_MKSTEMP) fi dnl # Check for mkstemps, just like mkstemp. AC_CACHE_CHECK([for mkstemps], xpdf_cv_func_mkstemps, [AC_TRY_LINK([#include #include ], [mkstemps("foo", 0);], xpdf_cv_func_mkstemps=yes, xpdf_cv_func_mkstemps=no)]) if test "$xpdf_cv_func_mkstemps" = yes; then AC_DEFINE(HAVE_MKSTEMPS) fi dnl ##### Check select argument type: on HP-UX before version 10, select dnl ##### takes (int *) instead of (fd_set *). AC_CACHE_CHECK([whether select takes fd_set arguments], xpdf_cv_func_select_arg, [AC_TRY_COMPILE([#include #include #include #ifdef HAVE_SYS_SELECT_H #include #endif], [fd_set fds; select(1, &fds, &fds, &fds, 0);], xpdf_cv_func_select_arg=yes, xpdf_cv_func_select_arg=no)]) if test "$xpdf_cv_func_select_arg" != yes; then AC_DEFINE(SELECT_TAKES_INT) fi dnl ##### Check for std::sort. AC_CACHE_CHECK([for std::sort], xpdf_cv_func_std_sort, [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include struct functor { bool operator()(const int &i0, const int &i1) { return i0 < i1; } };]], [[int a[100]; std::sort(a, a+100, functor());]])], xpdf_cv_func_std_sort=yes, xpdf_cv_func_std_sort=no)]) if test "$xpdf_cv_func_std_sort" = yes; then AC_DEFINE(HAVE_STD_SORT) fi dnl ##### Back to C for the library tests. AC_LANG_C dnl ##### Check for fseeko/ftello or fseek64/ftell64 dnl The LARGEFILE and FSEEKO macros have to be called in C, not C++, mode. AC_SYS_LARGEFILE AC_FUNC_FSEEKO AC_CHECK_FUNCS(fseek64, xpdf_cv_func_fseek64=yes, xpdf_cv_func_fseek64=no) AC_CHECK_FUNCS(ftell64, xpdf_cv_func_ftell64=yes, xpdf_cv_func_ftell64=no) if test "$xpdf_cv_func_fseek64" = yes -a "$xpdf_cv_func_ftell64" = yes; then AC_DEFINE(HAVE_FSEEK64) fi dnl ##### Check for libXpm. if test -z "$no_x"; then smr_CHECK_LIB(Xpm, Xpm, [pixmap library - used only for icon], XpmCreatePixmapFromData, X11/xpm.h, $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS) AC_SUBST(Xpm_LIBS) AC_SUBST(Xpm_CFLAGS) fi dnl ##### Check for Motif (libXm). if test -z "$no_x"; then dnl # XextAddDisplay isn't defined in any header file, so we provide a dnl # bogus prototype (so the compiler doesn't complain) and a bogus dnl # header file (so the smr macro doesn't break). smr_CHECK_LIB(Xext, Xext, [Motif library], XextAddDisplay, X11/Xlib.h, $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS, [int XextAddDisplay();]) AC_SUBST(Xext_LIBS) AC_SUBST(Xext_CFLAGS) smr_CHECK_LIB(Xp, Xp, [Motif library], XpStartPage, X11/extensions/Print.h, $X_LIBS $X_PRE_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS) AC_SUBST(Xp_LIBS) AC_SUBST(Xp_CFLAGS) smr_CHECK_LIB(Xt, Xt, [Motif library], XtAppInitialize, X11/Intrinsic.h, $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS) AC_SUBST(Xt_LIBS) AC_SUBST(Xt_CFLAGS) smr_CHECK_LIB(Xm, Xm, [Motif library], XmCreateForm, Xm/XmAll.h, $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS) AC_SUBST(Xm_LIBS) AC_SUBST(Xm_CFLAGS) smr_CHECK_LIB(Sgm, Sgm, [SGI Motif library], SgCreateHorzPanedWindow, Sgm/HPanedW.h, $Xm_LIBS $Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11, $X_CFLAGS) AC_SUBST(Sgm_LIBS) AC_SUBST(Sgm_CFLAGS) dnl # check for XtAppSetExitFlag, which didn't exist prior to X11R6 (?) if test "x$smr_have_Xt_library" = xyes; then AC_CHECK_LIB(Xt, XtAppSetExitFlag, AC_DEFINE(HAVE_XTAPPSETEXITFLAG), , [$Xt_LIBS $X_LIBS $X_PRE_LIBS $Xp_LIBS $Xext_LIBS $X_EXTRA_LIBS -lX11]) fi fi dnl ##### Check for FreeType 2.x. dnl ##### (Note: FT_Get_Name_Index was added in FT 2.0.5, and is dnl ##### the reason that Xpdf requires 2.0.5+.) smr_CHECK_LIB(freetype2, freetype, [FreeType2 font rasterizer - version 2.0.5+], FT_Get_Name_Index, ft2build.h, -lm) AC_SUBST(freetype2_LIBS) AC_SUBST(freetype2_CFLAGS) if test "x$smr_have_freetype2_library" = xyes; then AC_DEFINE(HAVE_FREETYPE_FREETYPE_H) AC_DEFINE(HAVE_SPLASH) fi dnl ##### Check for libpng. smr_CHECK_LIB(libpng, png, [PNG library], png_write_row, png.h, -lz) AC_SUBST(libpng_LIBS) AC_SUBST(libpng_CFLAGS) dnl ##### Check for libpaper (Debian). smr_CHECK_LIB(libpaper, paper, [Debian libpaper], paperinit, paper.h) AC_SUBST(libpaper_LIBS) AC_SUBST(libpaper_CFLAGS) dnl ##### Disable X-specific stuff in top-level Makefile. if test -n "$no_x" -o "x$smr_have_Xm_library" != xyes -o "x$smr_have_freetype2_library" != xyes; then X="#" XPDF_TARGET="all-no-x" else X="" XPDF_TARGET="all" fi AC_SUBST(X) AC_SUBST(XPDF_TARGET) dnl ##### Extra libraries. EXTRA_LIBS= EXTRA_CFLAGS= AC_SUBST(EXTRA_LIBS) AC_SUBST(EXTRA_CFLAGS) dnl ##### Write the makefiles. AC_OUTPUT(Makefile goo/Makefile fofi/Makefile splash/Makefile xpdf/Makefile) dnl ##### Warn user if X is missing. if test -n "$no_x" -o "x$smr_have_Xm_library" != xyes -o "x$smr_have_freetype2_library" != xyes; then if test -n "$no_x"; then AC_MSG_WARN([Couldn't find X]); fi if test "x$smr_have_Xm_library" != xyes; then AC_MSG_WARN([Couldn't find Motif]); fi if test "x$smr_have_freetype2_library" != xyes; then AC_MSG_WARN([Couldn't find FreeType]); fi AC_MSG_WARN([-- You will be able to compile pdftops, pdftotext, pdfinfo, pdffonts, pdfdetach, and pdfimages, but not xpdf or pdftoppm]) fi dnl ##### Warn user if libpng is missing. if test "x$smr_have_libpng_library" != xyes; then AC_MSG_WARN([Couldn't find libpng -- you will not be able to build pdftohtml or pdftopng]) fi