configure.ac 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. dnl Copyright (C) 2002-2004 artofcode LLC. All rights reserved.
  2. dnl This software is provided AS-IS with no warranty, either express or
  3. dnl implied.
  4. dnl This software is distributed under license and may not be copied,
  5. dnl modified or distributed except as expressly authorized under the terms
  6. dnl of the license contained in the file LICENSE in this distribution.
  7. dnl For more information about licensing, please refer to
  8. dnl http://www.ghostscript.com/licensing/. For information on
  9. dnl commercial licensing, go to http://www.artifex.com/licensing/ or
  10. dnl contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. dnl San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  12. dnl $Id: configure.ac,v 1.51 2005/07/15 05:23:42 giles Exp $
  13. dnl Process this file with autoconf to produce a configure script
  14. dnl ------------------------------------------------
  15. dnl Initialization and Versioning
  16. dnl ------------------------------------------------
  17. AC_INIT
  18. AC_PREREQ(2.52)
  19. AC_CONFIG_SRCDIR(src/gs.c)
  20. dnl --------------------------------------------------
  21. dnl Check for programs
  22. dnl --------------------------------------------------
  23. dnl AC_PROG_CC likes to add '-g -O2' to CFLAGS. however,
  24. dnl we ignore those flags and construct our own.
  25. save_cflags=$CFLAGS
  26. AC_PROG_CC
  27. AC_PROG_CPP
  28. CFLAGS=$save_cflags
  29. AC_PROG_RANLIB
  30. #AC_PROG_INSTALL
  31. dnl --------------------------------------------------
  32. dnl Set build flags based on environment
  33. dnl --------------------------------------------------
  34. #AC_CANONICAL_HOST
  35. if test $ac_cv_prog_gcc = yes; then
  36. cflags_to_try="-Wall -Wstrict-prototypes \
  37. -Wmissing-declarations -Wmissing-prototypes \
  38. -Wcast-qual -Wwrite-strings \
  39. -fno-builtin -fno-common"
  40. optflags_to_try="-O2"
  41. else
  42. cflags_to_try=
  43. optflags_to_try="-O"
  44. fi
  45. AC_MSG_CHECKING([supported compiler flags])
  46. old_cflags=$CFLAGS
  47. echo
  48. for flag in $optflags_to_try; do
  49. CFLAGS="$CFLAGS $flag"
  50. AC_TRY_COMPILE(, [return 0;], [
  51. echo " $flag"
  52. OPT_CFLAGS="$OPT_CFLAGS $flag"
  53. ])
  54. CFLAGS=$old_cflags
  55. done
  56. for flag in $cflags_to_try; do
  57. CFLAGS="$CFLAGS $flag"
  58. AC_TRY_COMPILE(, [return 0;], [
  59. echo " $flag"
  60. GCFLAGS="$GCFLAGS $flag"
  61. ])
  62. CFLAGS=$old_cflags
  63. done
  64. AC_MSG_RESULT([ ...done.])
  65. dnl --------------------------------------------------
  66. dnl Check for headers
  67. dnl --------------------------------------------------
  68. AC_HEADER_DIRENT
  69. AC_HEADER_STDC
  70. AC_CHECK_HEADERS([errno.h fcntl.h limits.h malloc.h memory.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/time.h syslog.h unistd.h])
  71. # for gdev3b1.c (AT&T terminal interface)
  72. AC_CHECK_HEADER([sys/window.h])
  73. dnl --------------------------------------------------
  74. dnl Check for typedefs, structures, etc
  75. dnl --------------------------------------------------
  76. AC_C_CONST
  77. AC_C_INLINE
  78. AC_TYPE_MODE_T
  79. AC_TYPE_OFF_T
  80. AC_TYPE_SIZE_T
  81. AC_STRUCT_ST_BLOCKS
  82. AC_HEADER_TIME
  83. AC_STRUCT_TM
  84. dnl see if we're on a system that puts the *int*_t types
  85. dnl from stdint.h in sys/types.h
  86. if test "x$ac_cv_header_stdint_h" != xyes; then
  87. AC_CHECK_TYPES([int8_t, int16_t, int32_t, uint8_t, uint16_t, uint32_t],,,[#include <sys/types.h>])
  88. if test "$ac_cv_type_uint8_t" = yes; then
  89. AC_DEFINE([SYS_TYPES_HAS_STDINT_TYPES])
  90. GCFLAGS="$GCFLAGS -DSYS_TYPES_HAS_STDINT_TYPES"
  91. fi
  92. fi
  93. dnl we aren't interested in all of DEFS, so manually insert
  94. dnl the flags we care about
  95. if test "$ac_cv_c_const" != yes; then
  96. GCFLAGS="$GCFLAGS -Dconst="
  97. fi
  98. if test "x$ac_cv_header_stdint_h" = xyes; then
  99. GCFLAGS="$GCFLAGS -DHAVE_STDINT_H"
  100. fi
  101. dnl try to find a 64 bit type for devicen color index
  102. uint64_type="none"
  103. AC_CHECK_SIZEOF(unsigned long int)
  104. if test $ac_cv_sizeof_unsigned_long_int = 8; then
  105. uint64_type="unsigned long int"
  106. else
  107. AC_CHECK_SIZEOF(unsigned long long)
  108. if test $ac_cv_sizeof_unsigned_long_long = 8; then
  109. uint64_type="unsigned long long"
  110. else
  111. AC_CHECK_SIZEOF(unsigned __int64)
  112. if test $ac_cv_sizeof_unsigned___int64 = 8; then
  113. uint64_type="unsigned __int64"
  114. else
  115. AC_CHECK_SIZEOF(u_int64_t)
  116. if test $ac_cv_sizeof_u_int64_t = 8; then
  117. uint64_type="u_int64_t"
  118. fi
  119. fi
  120. fi
  121. fi
  122. dnl we don't need to do anything if a 64-bit type wasn't found
  123. dnl the code falls back to a (probably 32-bit) default
  124. if test "$uint64_type" != "none"; then
  125. GCFLAGS="$GCFLAGS -DGX_COLOR_INDEX_TYPE=\"$uint64_type\""
  126. fi
  127. dnl --------------------------------------------------
  128. dnl Check for libraries
  129. dnl --------------------------------------------------
  130. AC_CHECK_LIB(m, cos)
  131. dnl AC_CHECK_LIB(pthread, pthread_create)
  132. AC_MSG_CHECKING([for local jpeg library source])
  133. dnl At present, we give the local source priority over the shared
  134. dnl build, so that the D_MAX_BLOCKS_IN_MCU patch will be applied.
  135. dnl A more sophisticated approach would be to test the shared lib
  136. dnl to see whether it has already been patched.
  137. LIBJPEGDIR=src
  138. if test -f jpeg/jpeglib.h; then
  139. AC_MSG_RESULT([jpeg])
  140. SHARE_LIBJPEG=0
  141. LIBJPEGDIR=jpeg
  142. elif test -f jpeg-6b/jpeglib.h; then
  143. AC_MSG_RESULT([jpeg-6b])
  144. SHARE_LIBJPEG=0
  145. LIBJPEGDIR=jpeg-6b
  146. else
  147. AC_MSG_RESULT([no])
  148. AC_CHECK_LIB(jpeg, jpeg_set_defaults, [
  149. AC_CHECK_HEADERS([jpeglib.h], [SHARE_LIBJPEG=1])
  150. ])
  151. fi
  152. if test -z "$SHARE_LIBJPEG"; then
  153. AC_MSG_ERROR([I wasn't able to find a copy
  154. of the jpeg library. This is required for compiling
  155. ghostscript. Please download a copy of the source,
  156. e.g. from http://www.ijg.org/, unpack it at the
  157. top level of the gs source tree, and rename
  158. the directory to 'jpeg'.
  159. ])
  160. fi
  161. AC_SUBST(SHARE_LIBJPEG)
  162. AC_SUBST(LIBJPEGDIR)
  163. dnl check for the internal jpeg memory header
  164. AC_MSG_CHECKING([for jmemsys.h])
  165. if test -r $LIBJPEGDIR/jmemsys.h; then
  166. AC_MSG_RESULT([yes])
  167. else
  168. AC_MSG_RESULT([no])
  169. AC_DEFINE([DONT_HAVE_JMEMSYS_H], 1,
  170. [define if the libjpeg memory system prototypes aren't available])
  171. fi
  172. dnl these are technically optional
  173. AC_MSG_CHECKING([for local zlib source])
  174. dnl zlib is needed for language level 3, and libpng
  175. # we must define ZLIBDIR regardless because libpng.mak does a -I$(ZLIBDIR)
  176. # this seems a harmless default
  177. ZLIBDIR=src
  178. if test -d zlib; then
  179. AC_MSG_RESULT([yes])
  180. SHARE_ZLIB=0
  181. ZLIBDIR=zlib
  182. else
  183. AC_MSG_RESULT([no])
  184. AC_CHECK_LIB(z, deflate, [
  185. AC_CHECK_HEADERS(zlib.h, [SHARE_ZLIB=1])
  186. ])
  187. fi
  188. if test -z "$SHARE_ZLIB"; then
  189. AC_MSG_ERROR([I did not find a copy of zlib on your system.
  190. Please either install it, or unpack a copy of the source in a
  191. local directory named 'zlib'. See http://www.gzip.org/zlib/
  192. for more information.
  193. ])
  194. fi
  195. AC_SUBST(SHARE_ZLIB)
  196. AC_SUBST(ZLIBDIR)
  197. dnl png for the png output device; it also requires zlib
  198. LIBPNGDIR=src
  199. PNGDEVS=''
  200. PNGDEVS_ALL='$(DD)png48.dev $(DD)png16m.dev $(DD)pnggray.dev $(DD)pngmono.dev $(DD)png256.dev $(DD)png16.dev $(DD)pngalpha.dev'
  201. AC_MSG_CHECKING([for local png library source])
  202. if test -f libpng/pngread.c; then
  203. AC_MSG_RESULT([yes])
  204. SHARE_LIBPNG=0
  205. LIBPNGDIR=libpng
  206. PNGDEVS="$PNGDEVS_ALL"
  207. else
  208. AC_MSG_RESULT([no])
  209. AC_CHECK_LIB(png, png_check_sig, [
  210. AC_CHECK_HEADERS(png.h, [
  211. SHARE_LIBPNG=1
  212. PNGDEVS="$PNGDEVS_ALL"
  213. ], [SHARE_LIBPNG=0])
  214. ], [SHARE_LIBPNG=0], [-lz])
  215. fi
  216. if test -z "$PNGDEVS"; then
  217. AC_MSG_NOTICE([disabling png output devices])
  218. fi
  219. AC_SUBST(SHARE_LIBPNG)
  220. AC_SUBST(LIBPNGDIR)
  221. AC_SUBST(PNGDEVS)
  222. dnl look for IJS implementation
  223. AC_ARG_WITH(ijs, AC_HELP_STRING([--with-ijs],[include IJS driver support]))
  224. dnl set safe defaults
  225. IJSDIR=src
  226. IJSDEVS=''
  227. if test x$with_ijs != xno; then
  228. AC_MSG_CHECKING([for local ijs library source])
  229. if test -d ijs; then
  230. AC_MSG_RESULT([yes])
  231. IJSDIR=ijs
  232. IJSDEVS='$(DD)ijs.dev'
  233. else
  234. AC_MSG_RESULT([no])
  235. fi
  236. fi
  237. AC_SUBST(IJSDIR)
  238. AC_SUBST(IJSDEVS)
  239. dnl look for jbig2dec
  240. AC_ARG_WITH(jbig2dec, AC_HELP_STRING([--with-jbig2dec],[include JBIG2 decode support]))
  241. JBIG2DIR=src
  242. SHARE_JBIG2=0
  243. JBIG2DEVS=''
  244. if test x$with_jbig2dec != xno; then
  245. AC_MSG_CHECKING([for local jbig2dec library source])
  246. for d in jbig2dec jbig2dec-0.2 jbig2dec-0.3; do
  247. test -d "$d" && JBIG2DIR=$d && break
  248. done
  249. if test "x$JBIG2DIR" != xsrc; then
  250. AC_MSG_RESULT([$JBIG2DIR])
  251. else
  252. AC_MSG_RESULT([no])
  253. AC_CHECK_LIB([jbig2dec], [jbig2_page_out], [
  254. SHARE_JBIG2=1
  255. ], [
  256. AC_MSG_WARN([disabling support for JBIG2 files])
  257. with_jbig2dec=no
  258. ])
  259. fi
  260. fi
  261. if test x$with_jbig2dec != xno; then
  262. if test x$ac_cv_header_stdint_h != xyes; then
  263. AC_MSG_WARN([JBIG2 support requires stdint types which do not seem to be available.])
  264. else
  265. JBIG2DEVS='$(PSD)jbig2.dev'
  266. fi
  267. fi
  268. AC_SUBST(JBIG2DIR)
  269. AC_SUBST(SHARE_JBIG2)
  270. AC_SUBST(JBIG2DEVS)
  271. dnl look for the jasper JPEG 2000 library
  272. AC_ARG_WITH(jasper, AC_HELP_STRING([--with-jasper],[link to the JasPer library for JPEG 2000]))
  273. JASPERDIR=src
  274. SHARE_JASPER=0
  275. JPXDEVS=''
  276. if test x$with_jasper != xno; then
  277. AC_MSG_CHECKING([for local jasper library source])
  278. for d in jasper jasper-1.7*; do
  279. test -d "$d" && JASPERDIR=$d && break
  280. done
  281. if test "x$JASPERDIR" != xsrc; then
  282. AC_MSG_RESULT([$JASPERDIR])
  283. AC_MSG_CHECKING([for local jasper configure script])
  284. if test -x $JASPERDIR/configure; then
  285. AC_MSG_RESULT([yes])
  286. echo
  287. echo "Running jasper configure script..."
  288. olddir=`pwd`
  289. cd $JASPERDIR && ./configure
  290. cd $olddir
  291. echo
  292. echo "Continuing with Ghostscript configuration..."
  293. else
  294. AC_MSG_RESULT([no])
  295. AC_MSG_CHECKING([for local jasper autogen.sh script])
  296. if test -x $JASPERDIR/autogen.sh; then
  297. AC_MSG_RESULT([yes])
  298. echo
  299. echo "Running jasper autogen script..."
  300. olddir=`pwd`
  301. cd $JASPERDIR && ./autogen.sh
  302. cd $olddir
  303. echo
  304. echo "Continuing with Ghostscript configuration..."
  305. else
  306. AC_MSG_ERROR([
  307. Unable to find $JASPERDIR/src/libjasper/include/jas_config.h,
  308. or generate generate such a file for this system. You will
  309. have to build one by hand, or configure, build and install
  310. the jasper library separately.
  311. You can also pass --without-jasper to configure to disable
  312. JPEG 2000 PDF image support entirely.
  313. ])
  314. fi
  315. fi
  316. else
  317. AC_MSG_RESULT([no])
  318. AC_CHECK_LIB([jasper], [jas_image_create], [
  319. SHARE_JASPER=1
  320. ], [
  321. AC_MSG_WARN([disabling support for JPEG 2000 images])
  322. with_jasper=no
  323. ])
  324. fi
  325. fi
  326. if test x$with_jasper != xno; then
  327. JPXDEVS='$(PSD)jpx.dev'
  328. fi
  329. AC_SUBST(JASPERDIR)
  330. AC_SUBST(SHARE_JASPER)
  331. AC_SUBST(JPXDEVS)
  332. dnl optional X11 for display devices
  333. AC_PATH_XTRA
  334. XLIBS=''
  335. if test x"$no_x" = x"yes"; then
  336. AC_MSG_NOTICE([disabling X11 output devices])
  337. X11DEVS=''
  338. else
  339. # enable X11 output devices
  340. X11DEVS='$(DD)x11.dev $(DD)x11alpha.dev $(DD)x11cmyk.dev $(DD)x11gray2.dev $(DD)x11gray4.dev $(DD)x11mono.dev'
  341. # the makefile wants a list of just the library names in XLIBS
  342. for item in -lXt $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS; do
  343. stripped=`echo "$item" | sed -e 's/-l//'`
  344. if test "x$stripped" != "x$item"; then
  345. XLIBS="$XLIBS $stripped"
  346. fi
  347. done
  348. fi
  349. AC_SUBST(X11DEVS)
  350. AC_SUBST(XLIBS)
  351. dnl executible name
  352. AC_ARG_WITH(gs, AC_HELP_STRING([--with-gs=NAME],
  353. [name of the ghostscript executible [[gs]]]),
  354. [GS="$with_gs"],[GS='gs'])
  355. AC_SUBST(GS)
  356. dnl do we compile the postscript initialization files into Ghostscript?
  357. COMPILE_INITS="0"
  358. AC_ARG_ENABLE(compile-inits, AC_HELP_STRING([--enable-compile-inits],
  359. [compile initialization files into Ghostscript]),[
  360. if test x$enable_compile_inits = xyes; then
  361. COMPILE_INITS="1"
  362. fi])
  363. AC_SUBST(COMPILE_INITS)
  364. dnl --------------------------------------------------
  365. dnl Check for library functions
  366. dnl --------------------------------------------------
  367. AC_CHECK_FUNCS([mkstemp], [HAVE_MKSTEMP=-DHAVE_MKSTEMP])
  368. AC_SUBST(HAVE_MKSTEMP)
  369. AC_CHECK_FUNCS([hypot], [HAVE_HYPOT=-DHAVE_HYPOT])
  370. AC_SUBST(HAVE_HYPOT)
  371. AC_FUNC_FORK
  372. AC_PROG_GCC_TRADITIONAL
  373. AC_FUNC_MALLOC
  374. AC_FUNC_MEMCMP
  375. AC_TYPE_SIGNAL
  376. AC_FUNC_STAT
  377. AC_FUNC_VPRINTF
  378. AC_CHECK_FUNCS([bzero dup2 floor gettimeofday memchr memmove memset mkdir mkfifo modf pow putenv rint setenv sqrt strchr strerror strrchr strspn strstr])
  379. dnl --------------------------------------------------
  380. dnl Do substitutions
  381. dnl --------------------------------------------------
  382. AC_SUBST(OPT_CFLAGS)
  383. AC_SUBST(GCFLAGS)
  384. AC_OUTPUT(Makefile)