Cairo/0000755000175100001440000000000014531324150011323 5ustar hornikusersCairo/NAMESPACE0000644000175100001440000000013114531200444012534 0ustar hornikusersexportPattern("^Cairo") importFrom("grDevices", "dev.cur") importFrom("graphics", "par") Cairo/man/0000755000175100001440000000000014531200444012075 5ustar hornikusersCairo/man/Cairo.serial.Rd0000644000175100001440000000152214531200444014677 0ustar hornikusers\name{Cairo.serial} \alias{Cairo.serial} \title{ Check for changes in the graphics state of Cairo devices. } \description{ \code{Cairo.serial} returns an integer that is increased with every plotting operation on the device. This allows user code to determine whether any new content has been added to the device since it was last checked. } \usage{ Cairo.serial(device = dev.cur()) } \arguments{ \item{device}{device number or an object of the class \code{Cairo} (as obtained from the \code{\link{Cairo}} function).} } %\details{ %} \value{ Integer value. } \author{ Simon Urbanek } \note{ The integer value overflows to 0 at 2^31. Typically only equality should be checked and for such it is extremely unlikely that the state has changed yet the serial value is the same due to overflow. } %\examples{ %} \keyword{device} Cairo/man/CairoFonts.Rd0000644000175100001440000000430614531200444014436 0ustar hornikusers\name{CairoFonts} \alias{CairoFonts} \title{ Set the fonts used for all Cairo graphics devices. } \description{ \code{CairoFonts} initializes the fonts used for Cairo graphics devices. } \usage{ CairoFonts( regular="Helvetica:style=Regular", bold="Helvetica:style=Bold", italic="Helvetica:style=Italic", bolditalic="Helvetica:style=Bold Italic,BoldItalic", symbol="Symbol", usePUA=TRUE ) } \arguments{ \item{regular}{character; fontconfig pattern for the 'plain text' font.} \item{bold}{character; fontconfig pattern for the 'bold face' font.} \item{italic}{character; fontconfig pattern for the 'italic' font.} \item{bolditalic}{character; fontconfig pattern for the 'bold italic' font.} \item{symbol}{character; fontconfig pattern for the 'symbol' font.} \item{usePUA}{logical; if \code{FALSE} then symbols are using regular Unicode code points (supported by regular fonts), otherwise Private Unicode Area (PUA) of symbols is used (typically better propulated by specialized symbol fonts). R 4.0.0 or higher is required for \code{usePUA=FALSE}.} } \details{ This function sets the fonts for Cairo graphics devices globally; previously opened Cairo graphics devices will also use these fonts. The argument names correspond to the five values of the graphical parameter 'font', i.e. regular is 1, bold is 2, italic is 3, etc. For an explanation of fontconfig patterns, see \code{\link{CairoFontMatch}}. } \section{Known issues}{ \itemize{ \item This function is only available when the cairo graphics library is configured with FreeType and Fontcofig support. \item R math symbols are supported, but require a "Symbol" font with the Adobe Symbol Encoding unless \code{usePUA=FALSE} is used (available in R 4.0.0 or higher only). } } \seealso{ \code{\link{CairoFontMatch}}, \code{\link{Cairo}}, \code{\link{par}}, } \examples{ \dontrun{ # # The following fontconfig patterns define the free truetype fonts # available in the debian package 'ttf-freefont'. # # Freesans is very similar to Helvetica CairoFonts( regular="FreeSans:style=Medium", bold="FreeSans:style=Bold", italic="FreeSans:style=Oblique", bolditalic="FreeSans:style=BoldOblique" ) }} \keyword{device} Cairo/man/Cairo.Rd0000644000175100001440000002460614531200444013431 0ustar hornikusers\name{Cairo} \alias{Cairo} \alias{CairoX11} \alias{CairoPNG} \alias{CairoPDF} \alias{CairoSVG} \alias{CairoPS} \alias{CairoWin} \alias{CairoJPEG} \alias{CairoTIFF} \title{ Create a new Cairo-based graphics device } \description{ \code{Cairo} initializes a new graphics device that uses the cairo graphics library for rendering. The current implementation produces high-quality PNG, JPEG, TIFF bitmap files, high resolution PDF files with embedded fonts, SVG graphics and PostScript files. It also provides X11 and Windows interactive graphics devices. Unlike other devices it supports all graphics features including alpha blending, anti-aliasing etc. \code{CairoX11}, \code{CairoPNG}, \code{CairoPDF}, \code{CairoPS} and \code{CairoSVG} are convenience wrappers of \code{Cairo} that take the same arguments as the corresponding device it replaces such as \code{X11}, \code{png}, \code{pdf}, etc. Use of the \code{Cairo} function is encouraged as it is more flexible than the wrappers. } \usage{ Cairo(width = 640, height = 480, file="", type="png", pointsize=12, bg = "transparent", canvas = "white", units = "px", dpi = "auto", ...) CairoX11(display=Sys.getenv("DISPLAY"), width = 7, height = 7, pointsize = 12, gamma = getOption("gamma"), bg = "transparent", canvas = "white", xpos = NA, ypos = NA, ...) CairoPNG(filename = "Rplot\%03d.png", width = 480, height = 480, pointsize = 12, bg = "white", res = NA, ...) CairoJPEG(filename = "Rplot\%03d.jpeg", width = 480, height = 480, pointsize = 12, quality = 75, bg = "white", res = NA, ...) CairoTIFF(filename = "Rplot\%03d.tiff", width = 480, height = 480, pointsize = 12, bg = "white", res = NA, ...) CairoPDF(file = ifelse(onefile, "Rplots.pdf","Rplot\%03d.pdf"), width = 6, height = 6, onefile = TRUE, family = "Helvetica", title = "R Graphics Output", fonts = NULL, paper = "special", encoding, bg, fg, pointsize, pagecentre, ...) CairoSVG(file = ifelse(onefile, "Rplots.svg", "Rplot\%03d.svg"), width = 6, height = 6, onefile = TRUE, bg = "transparent", pointsize = 12, ...) CairoWin(width = 7, height = 7, pointsize = 12, record = getOption("graphics.record"), rescale = c("R", "fit", "fixed"), xpinch, ypinch, bg = "transparent", canvas = "white", gamma = getOption("gamma"), xpos = NA, ypos = NA, buffered = getOption("windowsBuffered"), restoreConsole = FALSE, ...) CairoPS(file = ifelse(onefile, "Rplots.ps", "Rplot\%03d.ps"), onefile = TRUE, family, title = "R Graphics Output", fonts = NULL, encoding, bg, fg, width, height, horizontal, pointsize, paper, pagecentre, print.it, command, colormodel) } \arguments{ \item{width}{width of the plot area (also see \code{units}).} \item{height}{height of the plot area (also see \code{units}).} \item{file}{name of the file to be created or connection to write to. Only PDF, PS and PNG types support connections. For X11 type \code{file} specifies the display name. If \code{NULL} or \code{""} a reasonable default will be chosen which is \code{"plot.type"} for file-oriented types and value of the \code{DISPLAY} environment variable for X11. For image types the file name can contain printf-style formatting expecting one integer parameter which is the page number, such as \code{"Rplot\%03d.png"}. The page numbers start at one. The filename is expanded using \code{\link{path.expand}}. } \item{type}{output type. This version of Cario supports "png", "jpeg" and "tiff" bitmaps (png/tiff with transparent background), "pdf" PDF-file with embedded fonts, "svg" SVG-file, "ps" PostScript-file, "x11" X11 interactive window and "win" Windows graphics. A special type "raster" creates an image back-end that produces no actual output file but can be used in conjunction with any of \code{dev.capture()}, \code{grid.cap()} or \code{Cairo:::.image()} to create in-memory images. Depending on the support of various backends in cairo graphics some of the options may not be available for your system. See \code{\link{Cairo.capabilities}} function.} \item{pointsize}{initial text size (in points).} \item{canvas}{canvas color (must be opaque). The canvas is only used by devices that display graphics on a screen and the canvas is only visible only if bg is transparent.} \item{bg}{plot background color (can include alpha-component or be transparent alltogether).} \item{units}{units for of the \code{width} and \code{height} specifications. It can be any of \code{"px"} (pixels), \code{"in"} (inches), \code{"pt"} (points), \code{"cm"} (centimeters) or \code{"mm"} (millimeters).} \item{dpi}{DPI used for the conversion of units to pixels. If set to \code{"auto"} the DPI resolution will be determined by the back-end.} \item{...}{additional backend specific parameters (e.g. \code{quality} setting for JPEG (0..100), \code{compression} for TIFF (0,1=none, 5=LZW (default), 7=JPEG, 8=Adobe Deflate), \code{locator} for a custom locator function in image back-ends) The PDF back-end supports following additional arguments: \code{author}, \code{subject}, \code{creator}, \code{keywords}, \code{create.date} and \code{modify.date}. If specified, all of the above must be single strings. The dates must be in PDF-defined format, you can use something like \code{paste0("D:",gsub("[- :]","",.POSIXct(Sys.time(),"GMT"))),"Z")} to convert from \code{POSIXct} to PDF format. In addition, the \code{version} argument (as documented in \code{\link{pdf}}) can be either a string or a scalar real number. However, the cairographics library only supports values 1.4 and 1.5. All parameters listed below are defined by the other devices are are used by the wrappers to make it easier replace other devices by \code{Cairo}. They are described in detail in the documentation corresponding to the device that is being replaced.} \item{display}{X11 display, see \code{\link{X11}}} \item{gamma}{gamma correction} \item{xpos}{see \code{\link{X11}}} \item{ypos}{see \code{\link{X11}}} \item{filename}{same as \code{file} in \code{Cairo}} \item{res}{resolution in ppi, see \code{\link{png}}, will override \code{dpi} in \code{Cairo} if set to anything other than \code{NA} or \code{NULL}. Note that cairographics does not support tagging PNG output files with DPI so the raster image will be produced with the dpi setting, but readers may render it at some default dpi setting.} \item{quality}{quality of the jpeg, see \code{\link{jpeg}}} \item{onefile}{logical: if true (the default) allow multiple figures in one file (see \code{\link{pdf}}). false is currently not supported by vector devices} \item{family}{font family, see \code{\link{pdf}}} \item{title}{see \code{\link{pdf}}} \item{fonts}{see \code{\link{pdf}}, ignored, \code{Cairo} automatically detects and embeds fonts} \item{paper}{see \code{\link{pdf}} (ignored, \code{Cairo} uses device dimensions)} \item{encoding}{see \code{\link{pdf}} (ignored, \code{Cairo} uses native enconding except for symbols)} \item{fg}{see \code{\link{pdf}} (ignored)} \item{pagecentre}{see \code{\link{pdf}} (ignored, \code{Cairo} uses device dimensions and thus it is irrelevant)} #ifdef windows \item{record}{see \code{\link{windows}} (ignored)} \item{rescale}{see \code{\link{windows}} (ignored)} \item{xpinch}{see \code{\link{windows}} (ignored)} \item{ypinch}{see \code{\link{windows}} (ignored)} \item{buffered}{see \code{\link{windows}} (ignored, \code{Cairo} always uses cache buffer)} \item{restoreConsole}{see \code{\link{windows}} (ignored)} #endif #ifndef windows \item{record}{Windows-specific, ignored on unix} \item{rescale}{Windows-specific, ignored on unix} \item{xpinch}{Windows-specific, ignored on unix} \item{ypinch}{Windows-specific, ignored on unix} \item{buffered}{Windows-specific, ignored on unix} \item{restoreConsole}{Windows-specific, ignored on unix} #endif \item{horizontal}{see \code{\link{postscript}} (ignored)} \item{print.it}{see \code{\link{postscript}} (ignored)} \item{command}{see \code{\link{postscript}} (ignored)} \item{colormodel}{see \code{\link{postscript}} (ignored, \code{Cairo} always uses \code{RGB} or \code{ARGB})} } \value{ The (invisible) return value is NULL if the device couldn't be created or a \code{Cairo} object if successful. The vaule of the object is the device number. } \section{Known issues}{ \itemize{ \item The X11 backend is quite slow. The reason is the cairographics implementation of the backend, so we can't do much about it. It should be possible to drop cairographics' Xlib backend entirely and use image backend copied into an X11 window instead. We may try that in future releases. \item TrueType (and OpenType) fonts are supported when this package is compiled against a cairo graphics library configured with FreeType and Fontconfig support. Therefore make sure have a cairo graphics library with all bells and whistles to get a good result. \item R math symbols are supported, but require a TrueType "Symbol" font accessible to Cairo under that name. } } \seealso{ \code{\link{CairoFonts}} } \examples{ # very simple KDE Cairo(600, 600, file="plot.png", type="png", bg="white") plot(rnorm(4000),rnorm(4000),col="#ff000018",pch=19,cex=2) # semi-transparent red dev.off() # creates a file "plot.png" with the above plot # you can use any Cairo backend and get the same result # vector, bitmap or on-screen CairoPDF("plot.pdf", 6, 6, bg="transparent") data(iris) attach(iris) plot(Petal.Length, rep(-0.03,length(Species)), xlim=c(1,7), ylim=c(0,1.7), xlab="Petal.Length", ylab="Density", pch=21, cex=1.5, col="#00000001", main = "Iris (yet again)", bg=c("#ff000020","#00ff0020","#0000ff20")[unclass(Species)]) for (i in 1:3) polygon(density(Petal.Length[unclass(Species)==i],bw=0.2), col=c("#ff000040","#00ff0040","#0000ff40")[i]) dev.off() ## remove the example files if not in an interactive session if (!interactive()) unlink(c("plot.png","plot.pdf")) } \keyword{device} Cairo/man/Cairo.onSave.Rd0000644000175100001440000000265014531200444014656 0ustar hornikusers\name{Cairo.onSave} \alias{Cairo.onSave} \title{ Cairo callbacks } \description{ \code{Cairo.onSave} set the \code{onSave} callback which allows R code to be run when Cairo finalizes a page (either due to a new page being created or by the device being closed). The callback expects \code{function(device, page)} where \code{device} will be the device number and \code{page} is the currently finished page number (starting at 1). } \usage{ Cairo.onSave(device = dev.cur(), onSave) } %- maybe also 'usage' for other objects documented here. \arguments{ \item{device}{device number or \code{Cairo} object (as returned by the \code{\link{Cairo}} function)} \item{onSave}{function that will replace the current callback or \code{NULL} to remove the current callback} } %\details{ %} \value{ The old callback being replaced or \code{NULL} if there was none. } %\references{ %} \author{ Simon Urbanek } \note{ The function \code{onSave} will be evaluated in the global environment and no error checking is done, so you must make sure to catch errors, otherwise the behavior is undefined (and may included crashing R or other bad things). } \seealso{ \code{\link{Cairo}} } \examples{ if (require(png, quietly=TRUE)) { dev <- Cairo(800, 600, type='raster') Cairo.onSave(dev, function(dev, page) .GlobalEnv$png <- writePNG(Cairo.capture(dev)) ) plot(1:10, col=2) dev.off() str(png) } } \keyword{device} Cairo/man/CairoFontMatch.Rd0000644000175100001440000001003614531200444015225 0ustar hornikusers\name{CairoFonMatch} \alias{CairoFontMatch} \title{ Find installed fonts with a fontconfig pattern } \description{ \code{CairoFontMatch} searches for fonts based on a fontconfig pattern. } \usage{ CairoFontMatch(fontpattern="Helvetica",sort=FALSE,verbose=FALSE) } \arguments{ \item{fontpattern}{character; a fontconfig pattern.} \item{sort}{logical; if 'FALSE', display only the best matching font for the pattern. If 'TRUE', display a sorted list of best matching fonts.} \item{verbose}{logical; if 'FALSE', display the family, style, and file property for the pattern. if 'TRUE', display the canonical font pattern for each match.} } \details{ This function displays a list of one or more fonts matching the supplied fontconfig pattern. sort='FALSE' displays the font that Cairo will use for the supplied pattern, while sort='TRUE' displays a sorted list of best matching fonts. The simplest fontconfig pattern matching all installed fonts is ":". Here's what CairoFontMatch(":") displays on this system: \preformatted{ 1. family: "Bitstream Vera Sans", style: "Roman", file: "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf" } verbose='FALSE' displays the font properties 'family', 'style', and 'file', while verbose='TRUE' will display the canonical font pattern, displaying all properties known for the font (output of CairoFontMatch(":",verbose=TRUE)): \preformatted{ 1. family: "Bitstream Vera Sans", style: "Roman", file: "/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf" "Bitstream Vera Sans-12:familylang=en:style=Roman:stylelang=en:slant=0:weight=80:width=100:pixelsize=12.5:foundry=bitstream:hintstyle=3:hinting=True:verticallayout=False:autohint=False:globaladvance=True:index=0:outline=True:scalable=True:dpi=75:rgba=1:scale=1:fontversion=131072:fontformat=TrueType:embeddedbitmap=True:decorative=False" } A simple approach to selecting a font starts with calling CairoFontMatch(":",sort=TRUE) to list all available fonts. Next, the user will choose a font from the list and call CairoFontMatch("FamilyName:style=PreferredStyle",sort=TRUE) substituting "FamilyName" and "PreferredStyle" with the desired values. If only one font is found, then the user has found the fontconfig pattern that will select the desired font. Otherwise, the user will call CairoFontMatch with verbose=TRUE to determine other properties to add to the pattern to attain the desired font, for instance the fontformat. The following excerpt is from the fontconfig user's manual (http://fontconfig.org/) and better describes the fontconfig pattern definition: "Fontconfig provides a textual representation for patterns that the library can both accept and generate. The representation is in three parts, first a list of family names, second a list of point sizes and finally a list of additional properties: -:=:=... Values in a list are separated with commas. The name needn't include either families or point sizes; they can be elided. In addition, there are symbolic constants that simultaneously indicate both a name and a value. Here are some examples: \preformatted{ Font Pattern Meaning ---------------------------------------------------------- Times-12 12 point Times Roman Times-12:bold 12 point Times Bold Courier:italic Courier Italic in the default size Monospace:matrix=1 .1 0 1 The users preferred monospace font with artificial obliquing } The '\', '-', ':' and ',' characters in family names must be preceeded by a '\' character to avoid having them misinterpreted. Similarly, values containing '\', '=', '_', ':' and ',' must also have them preceeded by a '\' character. The '\' characters are stripped out of the family name and values as the font name is read." } \section{Known issues}{ \itemize{ \item This function is only available when the Cairo graphics library is configured with FreeType and FontConfig support. } } \seealso{ \code{\link{CairoFonts}}, \code{\link{Cairo}} } \keyword{device} Cairo/man/Cairo.capabilities.Rd0000644000175100001440000000151014531200444016046 0ustar hornikusers\name{Cairo.capabilities} \alias{Cairo.capabilities} \title{ Reports which output types are supported by this Cairo build } \description{ \code{Cairo.capabilities} returns a logical vector describing the capabilities of this particular Cairo build. } \usage{ Cairo.capabilities() } \details{ The \code{Cairo} package provides multiple back-ends, such as images (PNG, JPEG, TIFF), vector graphics (PDF, PostScript, SVG) or displays (X11, Windows). However, not all systems support all back-ends. The \code{Cairo.capabilities} function returns a logical vector showing which capabilities are supported in this particular Cairo build. Note that the capabilities depend both on the libraries available in the system as well as the compiled-in modules in cairo graphics. } \seealso{ \code{\link{Cairo}} } \keyword{device} Cairo/man/Cairo.capture.Rd0000644000175100001440000000225614531200444015070 0ustar hornikusers\name{Cairo.capture} \alias{Cairo.capture} \alias{Cairo.snapshot} \title{ Capture contents of an image backend or a display list snapshot. } \description{ \code{Cairo.capture} is essentially the same as \code{dev.capture(native=TRUE)} with the exception that it works where \code{dev.capture} doesn't such as \code{onSave} callbacks. \code{Cairo.snapshot} is very similar to \code{recordPlot} except it also allows to retrieve the last snapshot. } \usage{ Cairo.capture(device = dev.cur()) Cairo.snapshot(device = dev.cur(), last=FALSE) } \arguments{ \item{device}{device number or an object of the class \code{Cairo} (as obtained from the \code{\link{Cairo}} function).} \item{last}{logical, if \code{FALSE} then a new snapshot is created (exactly the same as \code{recordPlot()}), if \code{TRUE} then the last known snapshot is retrieved, if \code{NA} then a snapshot is created first, but if the display list is empty last snapshot is retrieved instead.} } \value{ \code{Cairo.capture}: object of the class \code{nativeRaster}. \code{Cairo.snapshot}: object of the class \code{recordedplot}. } \author{ Simon Urbanek } %\examples{ %} \keyword{device} Cairo/DESCRIPTION0000644000175100001440000000266314531324150013040 0ustar hornikusersPackage: Cairo Version: 1.6-2 Title: R Graphics Device using Cairo Graphics Library for Creating High-Quality Bitmap (PNG, JPEG, TIFF), Vector (PDF, SVG, PostScript) and Display (X11 and Win32) Output Author: Simon Urbanek , Jeffrey Horner Maintainer: Simon Urbanek Depends: R (>= 2.4.0) Imports: grDevices, graphics Suggests: png Enhances: FastRWeb Description: R graphics device using cairographics library that can be used to create high-quality vector (PDF, PostScript and SVG) and bitmap output (PNG,JPEG,TIFF), and high-quality rendering in displays (X11 and Win32). Since it uses the same back-end for all output, copying across formats is WYSIWYG. Files are created without the dependence on X11 or other external programs. This device supports alpha channel (semi-transparent drawing) and resulting images can contain transparent and semi-transparent regions. It is ideal for use in server environments (file output) and as a replacement for other devices that don't have Cairo's capabilities such as alpha support or anti-aliasing. Backends are modular such that any subset of backends is supported. License: GPL-2 | GPL-3 SystemRequirements: cairo (>= 1.2 http://www.cairographics.org/) URL: http://www.rforge.net/Cairo/ NeedsCompilation: yes Packaged: 2023-11-27 20:50:44 UTC; rforge Repository: CRAN Date/Publication: 2023-11-28 08:44:24 UTC Cairo/configure.ac0000644000175100001440000002571014531200444013615 0ustar hornikusers# Process this file with autoconf to produce a configure script. AC_INIT([Cairo],[1.3],[Simon.Urbanek@r-project.org]) AC_CONFIG_SRCDIR([src/cairogd.c]) AC_CONFIG_HEADERS([src/cconfig.h]) # find R home and set CC/CFLAGS : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi RBIN="${R_HOME}/bin/R" CC=`"${RBIN}" CMD config CC`; CFLAGS=`"${RBIN}" CMD config CFLAGS` CPPFLAGS=`"${RBIN}" CMD config CPPFLAGS` LDFLAGS=`"${RBIN}" CMD config LDFLAGS` CPP="${CC} -E" AC_SUBST(R_HOME) # Checks for programs. AC_LANG(C) AC_PROG_CC # Checks for libraries. # Checks for header files. AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([string.h sys/time.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_PATH_PROG([PKGCONF],[pkg-config],[],[$PATH:/usr/local/bin:ext/bin:ext:/sw/bin:/opt/bin]) have_cairo=no if test "xx$CAIRO_LIBS" == "xx"; then if test "xx$PKGCONF" != "xx"; then AC_MSG_CHECKING([whether pkg-config knows about cairo]) if "${PKGCONF}" --exists cairo; then AC_MSG_RESULT([yes]) AC_MSG_CHECKING([for configurable backends]) modlist="cairo" for module in cairo-ft cairo-pdf cairo-png cairo-ps cairo-svn cairo-xlib cairo-xlib-xrender cairo-win32; do if "${PKGCONF}" --exists ${module}; then modlist="${modlist} ${module}" fi done AC_MSG_RESULT(${modlist}) CAIRO_CFLAGS=`"${PKGCONF}" --cflags ${modlist}` CAIRO_LIBS=`"${PKGCONF}" --libs ${modlist}` AC_MSG_CHECKING([whether --static is needed]) saveLIBS="$LIBS" LIBS="$saveLIBS ${CAIRO_LIBS}" AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY(cairo_reset_clip)], [AC_MSG_RESULT([no])], [CAIRO_LIBS=`"${PKGCONF}" --libs --static ${modlist}` LIBS="$saveLIBS ${CAIRO_LIBS}" AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY(cairo_reset_clip)], [AC_MSG_RESULT([yes]) PKGCONF_LIB_ADD=--static ], [AC_MSG_RESULT([neither works, abandoning pkg-config]) CAIRO_LIBS='' ]) ]) LIBS="$saveLIBS" else AC_MSG_RESULT([no]) fi fi fi if test -z "${CAIRO_LIBS}"; then AC_MSG_NOTICE([CAIRO_LIBS is unset, attempting to guess it.]) cpre='' for pre in /usr /usr/local /usr/X11 /usr/X11R6 /opt /sw; do if test -e "${pre}/include/cairo/cairo.h"; then cpre=${pre}; break fi done if test -n "${cpre}"; then CAIRO_CFLAGS="-I${cpre}/include/cairo" if test "${cpre}" = /usr; then CAIRO_LIBS="-lcairo" else CAIRO_LIBS="-L${cpre}/lib -lcairo" fi fi fi AC_MSG_NOTICE([CAIRO_CFLAGS=${CAIRO_CFLAGS}]) # Check for Rconn patch AC_MSG_CHECKING([if R was compiled with the RConn patch]) if test -f "${R_HOME}/include/R_ext/RConn.h"; then AC_MSG_RESULT([yes]) HAVE_RCONN_H="-DHAVE_RCONN_H" else AC_MSG_RESULT([no]) HAVE_RCONN_H="" fi CPPFLAGS="$CPPFLAGS ${CAIRO_CFLAGS} ${HAVE_RCONN_H}" AC_CHECK_HEADER(cairo.h,,AC_MSG_ERROR([Cannot find cairo.h! Please install cairo (http://www.cairographics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly.])) AC_MSG_CHECKING([for PNG support in Cairo]) AC_LINK_IFELSE([AC_LANG_SOURCE([ #include "cairo.h" int main(void) { #ifndef CAIRO_HAS_PNG_FUNCTIONS #error no PNG support #endif return 0; }])],[AC_MSG_RESULT([yes])] ,[AC_MSG_RESULT([no]) AC_MSG_ERROR([Cairo library has no PNG support.])]) uses_ats=no AC_MSG_CHECKING([for ATS font support in Cairo]) AC_LINK_IFELSE([AC_LANG_SOURCE([ #include "cairo.h" int main(void) { #ifndef CAIRO_HAS_ATSUI_FONT #error no PNG support #endif return 0; }])],[AC_MSG_RESULT([yes]) uses_ats=yes],[AC_MSG_RESULT([no])]) if test "xx${CAIRO_LIBS}" == "xx"; then if test $uses_ats == "yes"; then CAIRO_LIBS="-lcairo -lpng -lz -framework ApplicationServices" else CAIRO_LIBs="-lcairo -lpng -lz" fi fi AC_MSG_NOTICE([CAIRO_LIBS=${CAIRO_LIBS}]) LIBS="$LIBS ${CAIRO_LIBS}" AC_SEARCH_LIBS(deflate, z) AC_MSG_CHECKING([whether Cairo programs can be compiled]) AC_LINK_IFELSE([AC_LANG_SOURCE([ #include int main(void) { cairo_surface_t *cs = 0; cairo_t *cr; cr = cairo_create(cs); return 0; } ])],[AC_MSG_RESULT(yes)], [AC_MSG_ERROR([Cannot compile a simple Cairo program. See config.log for details.])]) dnl AC_CHECK_LIB(cairo, cairo_image_surface_get_format) dnl if test "$ac_cv_lib_cairo_cairo_image_surface_get_format" != "yes"; then dnl AC_MSG_ERROR([Cairo is too old: >= 1.2 is needed.]) dnl fi AC_CHECK_DECLS([cairo_image_surface_get_format], [#include ]) has_cairo_ft=no AC_ARG_WITH([freetype], AS_HELP_STRING(--with-freetype,[compile support for better font handling using FreeType and Fontconfig if present and supported by cairo. (default is @<:@auto@:>@).]), [with_freetype=$withval], [with_freetype=auto]) AC_MSG_CHECKING([whether FreeType support is desired]) AC_MSG_RESULT(${with_freetype}) if test x${with_freetype} != xno; then ## with_freetype AC_MSG_CHECKING([for FreeType support in cairo]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include #ifndef CAIRO_HAS_FT_FONT #error nope, no ft #endif ])],[has_cairo_ft=yes]) AC_MSG_RESULT(${has_cairo_ft}) need_xtra_ft_flags=no if test "${has_cairo_ft}" = yes; then AC_MSG_CHECKING([whether FreeType needs additional flags]) AC_LINK_IFELSE([AC_LANG_SOURCE([ #include #include int main(void) { cairo_ft_font_face_create_for_pattern(0); return 0; } ])],[],[need_xtra_ft_flags=yes]) AC_MSG_RESULT(${need_xtra_ft_flags}) fi if test "${need_xtra_ft_flags}" = yes; then if test -n "${PKGCONF}"; then AC_MSG_CHECKING([whether pkg-config knows about fontconfig or freetype2]) ftmod='' for module in fontconfig freetype2; do if "${PKGCONF}" --exists ${module}; then ftmod="${ftmod} ${module}"; fi done if test -n "${ftmod}"; then AC_MSG_RESULT(yes) FT_CPPFLAGS=`"${PKGCONF}" --cflags ${ftmod}` FT_LIBS=`"${PKGCONF}" --libs ${PKGCONF_LIB_ADD} ${ftmod}` else AC_MSG_RESULT(no) fi fi if test -z "${FT_LIBS}"; then AC_MSG_CHECKING([whether fontconfig/freetype2 location can be guessed]) FCI=''; FTI=''; FCL=''; FTL='' for pre in /usr /usr/X11 /usr/X11R6 /usr/local /opt /sw; do if test -z "${FCI}" -a -e "${pre}/include/fontconfig/fontconfig.h"; then FCI="-I${pre}/include" FCL="-L${pre}/lib" fi if test -z "${FTI}" -a -e "${pre}/include/freetype2/freetype/freetype.h"; then FTI="-I${pre}/include/freetype2" FTL="-L${pre}/lib" fi done if test "${FCI}" = -I/usr/include; then FCI=''; fi if test "${FCL}" = "-L/usr/lib"; then FCL=''; fi if test "${FTL}" = "-L/usr/lib"; then FTL=''; fi if test "${FTL}" = "${FCL}"; then FTL=''; fi if test -z "${FCI}" -a -z "${FTI}"; then AC_MSG_RESULT(no) AC_MSG_ERROR([Cannot find fontconfig/freetype2 although cairo claims to support it. Please check your cairo installation and/or update cairo if necessary or set CAIRO_CFLAGS/CAIRO_LIBS accordingly.]) fi FT_CPPFLAGS="${FCI} ${FTI}" FT_LIBS="${FCL} ${FTL} -lfontconfig -lfreetype -lz" AC_MSG_RESULT([possibly]) fi zLIBS="${LIBS}" LIBS="${LIBS} ${FT_LIBS}" zCPPFLAGS="${CPPFLAGS}" CPPFLAGS="${CPPFLAGS} ${FT_CPPFLAGS}" AC_MSG_CHECKING([whether additional flags work]) AC_LINK_IFELSE([AC_LANG_SOURCE([ #include #include int main(void) { cairo_ft_font_face_create_for_pattern(0); return 0; } ])],[AC_MSG_RESULT(yes) CAIRO_LIBS="${CAIRO_LIBS} ${FT_LIBS}" CAIRO_CFLAGS="${CAIRO_CFLAGS} ${FT_CPPFLAGS}" ],[ AC_MSG_RESULT(no) AC_MSG_ERROR([Cannot use cairo-ft backend, although cairo claims it is working. Please check your caito installation and/or update cairo if necessary or set CAIRO_CFLAGS/CAIRO_LIBS accordingly.]) ]) fi fi ## with_freetype # --- check for JPEG support --- AC_MSG_CHECKING([whether libjpeg works]) zLIBS="${LIBS}" LIBS="${LIBS} -ljpeg" AC_LINK_IFELSE([AC_LANG_SOURCE([ #include #include int main(void) { struct jpeg_compress_struct cinfo; jpeg_create_compress(&cinfo); return 0; } ])],[ AC_MSG_RESULT([yes]) AC_DEFINE(SUPPORTS_JPEG, 1, [Define to 1 if libjpeg is present and working])], [ AC_MSG_RESULT(no) LIBS="${zLIBS}"]) # --- check for Harfbuzz/ICU support --- AC_ARG_WITH([harfbuzz], AS_HELP_STRING(--with-harfbuzz,[compile support for bi-directional Unicode and advanced text layout (like ligature support) using Harfbuzz and ICU libraries. (default is @<:@auto@:>@).]), [with_harfbuzz=$withval], [with_harfbuzz=auto]) AC_MSG_CHECKING([whether Harfbuzz layout is desired]) AC_MSG_RESULT(${with_harfbuzz}) if test x${with_harfbuzz} != xno; then if test x${has_cairo_ft} != xyes; then if test x${with_harfbuzz} = xyes; then AC_MSG_ERROR([ERROR: Harfbuzz support is requested, but FreeType is not available. Harfbuzz requires cairo with FreeType support to be present.]) else AC_MSG_NOTICE([NOTE: Harfbuzz requires cairo with FreeType support which is not available.]) fi with_harfbuzz=no fi fi if test x${with_harfbuzz} != xno; then AC_MSG_CHECKING([whether Harfbuzz + ICU works]) zLIBS="${LIBS}" zCPPFLAGS="${CPPFLAGS}" if test -n "$PKGCONF"; then : ${HB_CPPFLAGS=`"${PKGCONF}" --cflags harfbuzz-icu icu-uc`} : ${HB_LIBS=`"${PKGCONF}" --libs ${PKGCONF_LIB_ADD} harfbuzz-icu icu-uc`} fi if test -z "${HB_LIBS}"; then HB_LIBS='-lharfbuzz-icu -licuuc -licudata -lharfbuzz' fi ## ICU uses C++ (sadly) so requires stdc++ - this may not be very portable ... LIBS="${LIBS} ${HB_LIBS} -lstdc++" CPPFLAGS="${CPPFLAGS} ${HB_CPPFLAGS}" AC_LINK_IFELSE([AC_LANG_SOURCE([ #include #include #include #include #include int main(void) { UBiDi *bidi = 0; UChar *text = 0; bidi = ubidi_open(); hb_buffer_t *buf = hb_buffer_create(); hb_buffer_set_unicode_funcs(buf, hb_icu_get_unicode_funcs()); return 0; } ])],[ AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_HARFBUZZ, 1, [Define to 1 if Harfbuzz and ICU are present and working])], [ AC_MSG_RESULT(no) LIBS="${zLIBS}" CPPFLAGS="${zCPPFLAGS}" HB_CPPFLAGS='' ]) fi # --- check for TIFF support AC_MSG_CHECKING([whether libtiff works]) zLIBS="${LIBS}" if test -n "$PKGCONF"; then ## FIXME: --cflags? TIFF_LIBS=`"${PKGCONF}" --libs ${PKGCONF_LIB_ADD} libtiff-4` fi if test -z "${TIFF_LIBS}"; then TIFF_LIBS=-ltiff fi LIBS="${LIBS} ${TIFF_LIBS}" AC_LINK_IFELSE([AC_LANG_SOURCE([ #include int main(void) { TIFF *out = TIFFOpen("new.tif", "w"); TIFFSetField (out, TIFFTAG_IMAGEWIDTH, 100); return 0; } ])],[ AC_MSG_RESULT([yes]) AC_DEFINE(SUPPORTS_TIFF, 1, [Define to 1 if libtiff is present and working])], [ AC_MSG_RESULT(no) LIBS="${zLIBS}"]) ## our CPPFLAGS included R's CPPFLAGS which we don't need to ## set so only include those we detected in addition to the ## R CMD config CPPFLAGS CPPFLAGS="${CAIRO_CFLAGS} ${HB_CPPFLAGS} ${HAVE_RCONN_H}" AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],[enable debug flags and output. @<:@no@:>@])], [want_debug="${enableval}"], [want_debug=no]) if test ${want_debug} = yes; then CPPFLAGS="-DJGD_DEBUG=1 ${CPPFLAGS}" fi AC_CONFIG_FILES([src/Makevars]) AC_OUTPUT Cairo/src/0000755000175100001440000000000014531200444012111 5ustar hornikusersCairo/src/xlib-backend.c0000644000175100001440000003147514531200444014612 0ustar hornikusers/* -*- mode: C; tab-width: 4; c-basic-offset: 4 -*- Created 4/6/2007 by Simon Urbanek Copyright (C) 2007 Simon Urbanek X11 window handling is based on src/modules/devX11.c from the R sources: Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka Copyright (C) 1997--2005 Robert Gentleman, Ross Ihaka and the R Development Core Team License: GPL v2 or GPL v3 */ #include #include #include "xlib-backend.h" #if CAIRO_HAS_XLIB_SURFACE static const char *types_list[] = { "x11", 0 }; static Rcairo_backend_def RcairoBackendDef_ = { BET_XLIB, types_list, "X11", CBDF_VISUAL, 0 }; Rcairo_backend_def *RcairoBackendDef_xlib = &RcairoBackendDef_; #include #include #include #include #include #include #include typedef struct { Rcairo_backend *be; /* back-link */ Display *display; Visual *visual; Window rootwin; Window window; Cursor gcursor; int screen; int width; int height; } Rcairo_xlib_data; static int inclose = 0; static XContext devPtrContext; static void ProcessX11Events(void *); static void handleDisplayEvent(Display *display, XEvent event); #define X_BELL_VOLUME 0 /* integer between -100 and 100 for the volume of the bell in locator. */ /*---- save page ----*/ static void xlib_save_page(Rcairo_backend* be, int pageno){ cairo_show_page(be->cc); cairo_set_source_rgba(be->cc,1,1,1,1); cairo_reset_clip(be->cc); cairo_new_path(be->cc); cairo_paint(be->cc); } /*---- resize ----*/ static void xlib_resize(Rcairo_backend* be, double width, double height){ Rcairo_xlib_data *xd = (Rcairo_xlib_data *) be->backendSpecific; if (xd) { xd->width=width; xd->height=height; } be->width=width; be->height=height; if (be->cs) cairo_xlib_surface_set_size(be->cs, width, height); Rcairo_backend_repaint(be); if (xd->display) XSync(xd->display, 0); } /*---- mode ---- (0=done, 1=busy, 2=locator) */ static void xlib_mode(Rcairo_backend* be, int which){ if (be->in_replay) return; if (which < 1) { Rcairo_xlib_data *xd = (Rcairo_xlib_data *) be->backendSpecific; if (xd->display) XSync(xd->display, 0); } } /*---- locator ----*/ int xlib_locator(struct st_Rcairo_backend *be, double *x, double *y) { XEvent event; Rcairo_xlib_data *cd = (Rcairo_xlib_data *) be->backendSpecific; Rcairo_xlib_data *cdEvent = NULL; XPointer temp; int done = 0; Display *display = cd->display; ProcessX11Events((void*)NULL); /* discard pending events */ XSync(display, 1); /* handle X events as normal until get a button click in the desired device */ while (!done /* && displayOpen FIXME! */) { XNextEvent(display, &event); /* possibly later R_CheckUserInterrupt(); */ if (event.type == ButtonPress) { XFindContext(display, event.xbutton.window, devPtrContext, &temp); cdEvent = (Rcairo_xlib_data *) temp; if (cdEvent == cd) { if (event.xbutton.button == Button1) { int useBeep = asLogical(GetOption(install("locatorBell"), R_BaseEnv)); *x = event.xbutton.x; *y = event.xbutton.y; /* Make a beep! Was print "\07", but that messes up some terminals. */ if(useBeep) XBell(display, X_BELL_VOLUME); XSync(display, 0); done = 1; } else done = 2; } } else handleDisplayEvent(display, event); } /* if it was a Button1 succeed, otherwise fail */ return (done == 1); } /*---- destroy ----*/ static void xlib_backend_destroy(Rcairo_backend* be) { Rcairo_xlib_data *xd = (Rcairo_xlib_data *) be->backendSpecific; cairo_surface_destroy(be->cs); cairo_destroy(be->cc); inclose = 1; ProcessX11Events((void*) NULL); if (xd) { XFreeCursor(xd->display, xd->gcursor); XDestroyWindow(xd->display, xd->window); XSync(xd->display, 0); } free(be); } /*-----------------*/ static int firstInit = 1; static void Rcairo_init_xlib(void) { if (!firstInit) return; devPtrContext = XUniqueContext(); } typedef struct Rcairo_display_list_s { Display *display; InputHandler *handler; struct Rcairo_display_list_s *next; } Rcairo_display_list; static Rcairo_display_list display_list = { 0, 0, 0 }; /* FIXME: this is bad - we need to associate it with a display */ static Atom _XA_WM_PROTOCOLS, protocol; #include /* Xlib provides no way to detect I/O error, it just exists the process, so we use a handler to detect such conditions and prevent it from exiting */ typedef int (x11_io_handler_t)(Display*); static jmp_buf x11_io_error_jmp; static Display *x11_io_error_display; static int x11_safety_handler(Display *display) { x11_io_error_display = display; longjmp(x11_io_error_jmp, 1); return 0; } static int ProcessX11DisplayEvents(Display *display) { XEvent event; int ok = 0; /* setup IOErrorHandler while we process events such that errors don't kill R */ x11_io_handler_t *last_handler = XSetIOErrorHandler(x11_safety_handler); if (setjmp(x11_io_error_jmp) == 0) { while (display && XPending(display)) { XNextEvent(display, &event); handleDisplayEvent(display, event); } ok = 1; } XSetIOErrorHandler(last_handler); return ok; } static void handleDisplayEvent(Display *display, XEvent event) { XPointer temp; Rcairo_xlib_data *xd = NULL; /* fprintf(stderr, "handleDisplayEvent, type=%d, inclose=%d\n", (int) event.type, inclose); */ if (event.xany.type == Expose) { /* fprintf(stderr, "Expose (inclose=%d)\n", inclose); */ while(XCheckTypedEvent(display, Expose, &event)) ; XFindContext(display, event.xexpose.window, devPtrContext, &temp); xd = (Rcairo_xlib_data *) temp; if (event.xexpose.count == 0) /* sync - some X11 implementations seem to need this */ XSync(xd->display, 0); } else if (event.type == ConfigureNotify) { /* fprintf(stderr,"ConfigureNotify (inclose=%d)\n", inclose); */ while(XCheckTypedEvent(display, ConfigureNotify, &event)) ; XFindContext(display, event.xconfigure.window, devPtrContext, &temp); xd = (Rcairo_xlib_data *) temp; if (xd->width != event.xconfigure.width || xd->height != event.xconfigure.height) { /* printf(" - configure %d x %d (vs %d x %d)\n", event.xconfigure.width, event.xconfigure.height, xd->width, xd->height); */ Rcairo_backend_resize(xd->be, event.xconfigure.width, event.xconfigure.height); /* Gobble Expose events; we'll redraw anyway */ while(XCheckTypedEvent(display, Expose, &event)) ; } } else if (event.type == DestroyNotify) { /* fprintf(stderr,"DestroyNotify (inclose=%d)\n", inclose); */ XFindContext(display, event.xclient.window, devPtrContext, &temp); xd = (Rcairo_xlib_data *) temp; Rcairo_backend_kill(xd->be); } else if ((event.type == ClientMessage) && (event.xclient.message_type == _XA_WM_PROTOCOLS)) /* fprintf(stderr,"ClientMessage (inclose=%d)\n", inclose); */ if (!inclose && event.xclient.data.l[0] == protocol) { XFindContext(display, event.xclient.window, devPtrContext, &temp); xd = (Rcairo_xlib_data *) temp; Rcairo_backend_kill(xd->be); } } static void ProcessX11Events(void *foo) { Rcairo_display_list *l = &display_list, *last = 0; /* fprintf(stderr, "ProcessX11Events:\n"); */ while (l && l->display) { /* fprintf(stderr, " display=%p (inclose=%d)\n", l->display, inclose); */ if (ProcessX11DisplayEvents(l->display)) { /* error -> need to remove */ removeInputHandler(&R_InputHandlers, l->handler); l->display = 0; l->handler = 0; if (last) last->next = l->next; Rf_error("X11 fatal IO error: please save work and shut down R"); } else last = l; l = l->next; } /* fprintf(stderr, "--done ProcessX11Events--\n"); */ } Rcairo_backend *Rcairo_new_xlib_backend(Rcairo_backend *be, const char *display, double width, double height, double umpl) { Rcairo_xlib_data *xd; if ( ! (xd = (Rcairo_xlib_data*) calloc(1,sizeof(Rcairo_xlib_data)))) { free(be); return NULL; } be->backend_type = BET_XLIB; be->backendSpecific = xd; xd->be = be; be->destroy_backend = xlib_backend_destroy; be->save_page = xlib_save_page; be->resize = xlib_resize; be->mode = xlib_mode; be->locator = xlib_locator; be->truncate_rect = 1; { int depth; int blackpixel = 0; int whitepixel = 0; static XSetWindowAttributes attributes; /* Window attributes */ XSizeHints *hint; XEvent event; char *title = "Cairo display"; if (!display) { display=getenv("DISPLAY"); if (!display) display=":0.0"; } xd->display = XOpenDisplay(display); if (!xd->display) error("Update to open X11 display %s", display); { /* we maintain a list of displays we used so far. let's see if we encountered this display already. if not, setup the event handler etc. */ Rcairo_display_list *l = &display_list; while (l->display != xd->display && l->next) l=l->next; if (l->display) l = l->next = (Rcairo_display_list *)calloc(1, sizeof(Rcairo_display_list)); if (l->display != xd->display) { /* new display */ l->display = xd->display; l->handler = addInputHandler(R_InputHandlers, ConnectionNumber(xd->display), ProcessX11Events, 71); Rcairo_init_xlib(); } } xd->screen = DefaultScreen(xd->display); { /* adjust width and height to be in pixels */ if (be->dpix<=0) { /* is DPI set to auto? then find it out */ int dwp = DisplayWidth(xd->display,xd->screen); int dwr = DisplayWidthMM(xd->display,xd->screen); int dhp = DisplayHeight(xd->display,xd->screen); int dhr = DisplayHeightMM(xd->display,xd->screen); if (dwp && dwr && dhp && dhr) { be->dpix = ((double)dwp)/((double)dwr)*25.4; be->dpiy = ((double)dhp)/((double)dhr)*25.4; } } if (umpl>0 && be->dpix<=0) { warning("cannot determine DPI from the screen, assuming 90dpi"); be->dpix = 90; be->dpiy = 90; } if (be->dpiy==0 && be->dpix>0) be->dpiy=be->dpix; if (umpl>0) { width = width * umpl * be->dpix; height = height * umpl * be->dpiy; umpl=-1; } if (umpl!=-1) { width *= (-umpl); height *= (-umpl); } } xd->rootwin = DefaultRootWindow(xd->display); depth = DefaultDepth(xd->display, xd->screen); xd->visual = DefaultVisual(xd->display, xd->screen); if (!xd->visual) error("Unable to get visual from X11 display %s", display); if (xd->visual->class != TrueColor) error("Sorry, Cairo Xlib back-end supports true-color displays only."); { int d=depth; for (;d;d--) whitepixel=(whitepixel << 1)|1; } devPtrContext = XUniqueContext(); memset(&attributes, 0, sizeof(attributes)); attributes.background_pixel = whitepixel; attributes.border_pixel = blackpixel; attributes.backing_store = Always; attributes.event_mask = ButtonPressMask | ExposureMask | StructureNotifyMask; hint = XAllocSizeHints(); hint->x = 10; hint->y = 10; xd->width = hint->width = be->width = width; xd->height = hint->height = be->height = height; hint->flags = PPosition | PSize; xd->window = XCreateSimpleWindow(xd->display, xd->rootwin, hint->x,hint->y, hint->width, hint->height, 1, blackpixel, whitepixel); if (!xd->window) { XFree(hint); error("Unable to create X11 window on display %s", display); } XSetWMNormalHints(xd->display, xd->window, hint); XFree(hint); XChangeWindowAttributes(xd->display, xd->window, CWEventMask | CWBackPixel | CWBorderPixel | CWBackingStore, &attributes); XStoreName(xd->display, xd->window, title); xd->gcursor = XCreateFontCursor(xd->display, XC_crosshair); XDefineCursor(xd->display, xd->window, xd->gcursor); { /* FIXME: this is really display-dependent */ _XA_WM_PROTOCOLS = XInternAtom(xd->display, "WM_PROTOCOLS", 0); protocol = XInternAtom(xd->display, "WM_DELETE_WINDOW", 0); XSetWMProtocols(xd->display, xd->window, &protocol, 1); } XSaveContext(xd->display, xd->window, devPtrContext, (XPointer) xd); XSelectInput(xd->display, xd->window, ExposureMask | ButtonPressMask | StructureNotifyMask); XMapWindow(xd->display, xd->window); XSync(xd->display, 0); while ( XPeekEvent(xd->display, &event), !XCheckTypedEvent(xd->display, Expose, &event)) ; } be->cs = cairo_xlib_surface_create(xd->display, xd->window, xd->visual, (double)width,(double)height); if (cairo_surface_status(be->cs) != CAIRO_STATUS_SUCCESS){ free(be); return NULL; } be->cc = cairo_create(be->cs); if (cairo_status(be->cc) != CAIRO_STATUS_SUCCESS){ free(be); return NULL; } cairo_set_operator(be->cc,CAIRO_OPERATOR_ATOP); return be; } #else Rcairo_backend_def *RcairoBackendDef_xlib = 0; Rcairo_backend *Rcairo_new_xlib_backend(Rcairo_backend *be, const char *display, double width, double height, double umpl) { error("cairo library was compiled without XLIB back-end."); return NULL; } #endif Cairo/src/img-backend.c0000644000175100001440000001671414531200444014427 0ustar hornikusers/* -*- mode: C; tab-width: 4; c-basic-offset: 4 -*- Copyright (C) 2004-2007 Simon Urbanek Copyright (C) 2006 Jeffrey Horner License: GPL v2 or GPL v3 */ #ifdef HAVE_RCONN_H #include #include #include #define R_INTERFACE_PTRS #include #include #include #include #endif #include #include #include #include #include "img-backend.h" #include "img-jpeg.h" #include "img-tiff.h" #define default_jpeg_quality 75 static const char* img_types[] = { "png", #ifdef SUPPORTS_JPEG "jpeg", #endif #ifdef SUPPORTS_TIFF "tiff", #endif "raster", 0 }; static Rcairo_backend_def RcairoBackendDef_image_ = { BET_IMAGE, img_types, "image", CBDF_FILE|CBDF_CONN, 0 }; Rcairo_backend_def *RcairoBackendDef_image = &RcairoBackendDef_image_; static int cairo_op = -1; SEXP Rcso(SEXP v) { cairo_op = asInteger(v); return v; } static void image_backend_destroy(Rcairo_backend* be) { if (be->backendSpecific){ Rcairo_image_backend *image = (Rcairo_image_backend *)be->backendSpecific; if (image->buf) free(image->buf); if (image->filename) free(image->filename); if (image->locator_call && image->locator_call != R_NilValue) R_ReleaseObject(image->locator_call); free(be->backendSpecific); } cairo_surface_destroy(be->cs); cairo_destroy(be->cc); free(be); } /* utility function: create a filename based on the original specification and the pageno result must be freed by the caller */ static char *image_filename(Rcairo_backend* be, int pageno) { Rcairo_image_backend *image = (Rcairo_image_backend *)be->backendSpecific; char *fn; int l = strlen(image->filename)+16; fn=(char*) malloc(l); fn[l-1] = 0; snprintf(fn, l-1, image->filename, pageno); return fn; } static void image_save_page_jpg(Rcairo_backend* be, int pageno){ Rcairo_image_backend *image = (Rcairo_image_backend *)be->backendSpecific; char *fn = image_filename(be, pageno); int width = cairo_image_surface_get_width(be->cs); int height = cairo_image_surface_get_height(be->cs); /* although we don't use alpha, cairo still aligns on 4 so we have to set channels=4 */ int res = save_jpeg_file(image->buf, width, height, fn, image->quality?image->quality:default_jpeg_quality, 4); free(fn); if (res == -2) error("Sorry, this Cairo was compiled without jpeg support."); if (res) error("Unable to write jpeg file."); } static void image_save_page_tiff(Rcairo_backend* be, int pageno){ Rcairo_image_backend *image = (Rcairo_image_backend *)be->backendSpecific; char *fn = image_filename(be, pageno); int width = cairo_image_surface_get_width(be->cs); int height = cairo_image_surface_get_height(be->cs); cairo_format_t cf = image->format; int res = save_tiff_file(image->buf, width, height, fn, (cf==CAIRO_FORMAT_RGB24)?3:4, image->quality); free(fn); if (res == -2) error("Sorry, this Cairo was compiled without tiff support."); if (res) error("Unable to write tiff file."); } static void image_save_page_png(Rcairo_backend* be, int pageno){ /* Rcairo_image_backend *image = (Rcairo_image_backend *)be->backendSpecific; */ char *fn; fn=image_filename(be, pageno); cairo_surface_write_to_png(be->cs, fn); free(fn); } static void image_save_page_null(Rcairo_backend* be, int pageno) { } #ifdef HAVE_RCONN_H static cairo_status_t send_image_data(void *closure, const unsigned char *data, unsigned int length) { Rcairo_backend *be = (Rcairo_backend *)closure; Rcairo_image_backend *image; image = (Rcairo_image_backend *)be->backendSpecific; if (R_WriteConnection(image->conn, data, length, 1)) return CAIRO_STATUS_SUCCESS; else return CAIRO_STATUS_WRITE_ERROR; } static void image_send_page(Rcairo_backend* be, int pageno){ cairo_surface_write_to_png_stream (be->cs, send_image_data , (void *)be); } #endif int image_locator(struct st_Rcairo_backend *be, double *x, double *y) { Rcairo_image_backend *image; image = (Rcairo_image_backend *)be->backendSpecific; if (image->locator_call && image->locator_call != R_NilValue) { SEXP res; INTEGER(image->locator_dev)[0] = ndevNumber(be->dd) + 1; res = eval(image->locator_call, R_GlobalEnv); if (TYPEOF(res) == INTSXP && LENGTH(res) == 2) { *x = INTEGER(res)[0]; *y = INTEGER(res)[1]; return 1; } if (TYPEOF(res) == REALSXP && LENGTH(res) == 2) { *x = REAL(res)[0]; *y = REAL(res)[1]; return 1; } } return 0; } Rcairo_backend *Rcairo_new_image_backend(Rcairo_backend *be, int conn, const char *filename, const char *type, int width, int height, int quality, int alpha_plane, SEXP locator_cb) { Rcairo_image_backend *image; int stride = 4 * width; if ( ! (image = (Rcairo_image_backend *)calloc(1,sizeof(Rcairo_image_backend)))){ free(be); return NULL; } /* filename will be irrelevan for raster output */ if (type && !strcmp(type, "raster")) filename = 0; if (filename){ if ( !(image->filename = malloc(strlen(filename)+1))){ free(be); free(image); return NULL; } strcpy(image->filename,filename); } else { #ifdef HAVE_RCONN_H image->conn = conn; be->save_page = image_send_page; #else be->save_page = image_save_page_null; #endif } be->backend_type = BET_IMAGE; be->destroy_backend = image_backend_destroy; be->locator = image_locator; be->backendSpecific = (void *)image; be->truncate_rect = 1; be->width = width; be->height = height; if (!strcmp(type,"jpg")) alpha_plane=0; /* forge jpeg to never have alpha */ if ( ! (image->buf = calloc (stride * height, 1))){ free(be); free(image->filename); free(image); return NULL; } image->format = alpha_plane ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24; be->cs = cairo_image_surface_create_for_data (image->buf, image->format, width, height, stride); if (cairo_surface_status(be->cs) != CAIRO_STATUS_SUCCESS){ if (image->buf) free(image->buf); free(be); free(image->filename); free(image); return NULL; } if (locator_cb != R_NilValue) R_PreserveObject((image->locator_call = lang2(locator_cb, (image->locator_dev = allocVector(INTSXP, 1)) ))); else image->locator_call = R_NilValue; if (!strcmp(type,"png") ||!strcmp(type,"png24") ||!strcmp(type,"png32")) { if (!alpha_plane) be->flags|=CDF_FAKE_BG; if (!be->save_page) be->save_page = image_save_page_png; } else if (!strcmp(type,"jpg") || !strcmp(type,"jpeg")) { #ifdef SUPPORTS_JPEG image->quality = quality; if (!be->save_page) be->save_page = image_save_page_jpg; be->flags|=CDF_OPAQUE; /* no transparency at all */ #else cairo_surface_destroy(be->cs); free(image->buf); error("Sorry, this Cairo was compiled without jpeg support."); #endif } else if (!strcmp(type,"tif") || !strcmp(type,"tiff")) { #ifdef SUPPORTS_TIFF image->quality = quality; if (!alpha_plane) be->flags|=CDF_OPAQUE; if (!be->save_page) be->save_page = image_save_page_tiff; #else cairo_surface_destroy(be->cs); free(image->buf); error("Sorry, this Cairo was compiled without tiff support."); #endif } /* etc. */ be->cc = cairo_create(be->cs); if (cairo_status(be->cc) != CAIRO_STATUS_SUCCESS){ if (image->buf) free(image->buf); free(be); free(image->filename); free(image); return NULL; } /* Note: back-ends with alpha-plane don't work with ATOP, because cairo doesn't increase the opacity and thus the resulting picture will be fully transparent. */ cairo_set_operator(be->cc,alpha_plane?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_ATOP); /* debug */ if (cairo_op != -1) cairo_set_operator(be->cc,cairo_op); return be; } Cairo/src/pdf-backend.c0000644000175100001440000001134314531200444014415 0ustar hornikusers#include #include #include "pdf-backend.h" #ifdef HAVE_RCONN_H #include #include #include #define R_INTERFACE_PTRS #include #include #include #include #endif #if CAIRO_HAS_PDF_SURFACE static const char *types_list[] = { "pdf", 0 }; static Rcairo_backend_def RcairoBackendDef_ = { BET_PDF, types_list, "PDF", CBDF_FILE|CBDF_CONN|CBDF_MULTIPAGE, 0 }; Rcairo_backend_def *RcairoBackendDef_pdf = &RcairoBackendDef_; static void pdf_save_page(Rcairo_backend* be, int pageno){ cairo_show_page(be->cc); } #ifdef HAVE_RCONN_H static cairo_status_t send_image_data(void *closure, const unsigned char *data, unsigned int length) { Rcairo_backend *be = (Rcairo_backend *)closure; int conn; conn = *(int *)be->backendSpecific; if (R_WriteConnection(conn, data, length, 1)) return CAIRO_STATUS_SUCCESS; else return CAIRO_STATUS_WRITE_ERROR; } #endif static void pdf_backend_destroy(Rcairo_backend* be) { cairo_surface_destroy(be->cs); cairo_destroy(be->cc); free(be); } Rcairo_backend *Rcairo_new_pdf_backend(Rcairo_backend *be, int conn, const char *filename, double width, double height, SEXP aux) { be->backend_type = BET_PDF; be->destroy_backend = pdf_backend_destroy; be->save_page = pdf_save_page; if (filename){ char *fn = NULL; int len = strlen(filename); /* Add .pdf extension if necessary */ if (len>3 && strcmp(filename+len-4,".pdf")){ fn = malloc(len + 5); if (!fn) { free(be); return NULL; } strcpy(fn,filename); strcat(fn,".pdf"); filename = fn; } be->cs = cairo_pdf_surface_create(filename,(double)width,(double)height); if (fn) free(fn); } else { #ifdef HAVE_RCONN_H if ( ! (be->backendSpecific = calloc(1,sizeof(int)))){ free(be); return NULL; } *(int *)be->backendSpecific = conn; be->cs = cairo_pdf_surface_create_for_stream(send_image_data,(void *)be,(double)width,(double)height); #else free(be); return NULL; #endif } if (cairo_surface_status(be->cs) != CAIRO_STATUS_SUCCESS){ free(be); return NULL; } be->cc = cairo_create(be->cs); if (cairo_status(be->cc) != CAIRO_STATUS_SUCCESS){ free(be); return NULL; } cairo_set_operator(be->cc,CAIRO_OPERATOR_OVER); /* metadata is only available since cairo 1.16 */ #if (((CAIRO_VERSION_MAJOR << 8) | CAIRO_VERSION_MINOR) >= 0x110) while (aux && aux != R_NilValue) { SEXP arg = CAR(aux); SEXP name = TAG(aux); aux = CDR(aux); if (Rf_install("title") == name && TYPEOF(arg) == STRSXP && LENGTH(arg) == 1) cairo_pdf_surface_set_metadata(be->cs, CAIRO_PDF_METADATA_TITLE, Rf_translateCharUTF8(STRING_ELT(arg, 0))); else if (Rf_install("author") == name && TYPEOF(arg) == STRSXP && LENGTH(arg) == 1) cairo_pdf_surface_set_metadata(be->cs, CAIRO_PDF_METADATA_AUTHOR, Rf_translateCharUTF8(STRING_ELT(arg, 0))); else if (Rf_install("subject") == name && TYPEOF(arg) == STRSXP && LENGTH(arg) == 1) cairo_pdf_surface_set_metadata(be->cs, CAIRO_PDF_METADATA_SUBJECT, Rf_translateCharUTF8(STRING_ELT(arg, 0))); else if (Rf_install("creator") == name && TYPEOF(arg) == STRSXP && LENGTH(arg) == 1) cairo_pdf_surface_set_metadata(be->cs, CAIRO_PDF_METADATA_CREATOR, Rf_translateCharUTF8(STRING_ELT(arg, 0))); else if (Rf_install("keywords") == name && TYPEOF(arg) == STRSXP && LENGTH(arg) == 1) cairo_pdf_surface_set_metadata(be->cs, CAIRO_PDF_METADATA_KEYWORDS, Rf_translateCharUTF8(STRING_ELT(arg, 0))); else if (Rf_install("create.date") == name && TYPEOF(arg) == STRSXP && LENGTH(arg) == 1) cairo_pdf_surface_set_metadata(be->cs, CAIRO_PDF_METADATA_CREATE_DATE, Rf_translateCharUTF8(STRING_ELT(arg, 0))); else if (Rf_install("modify.date") == name && TYPEOF(arg) == STRSXP && LENGTH(arg) == 1) cairo_pdf_surface_set_metadata(be->cs, CAIRO_PDF_METADATA_MOD_DATE, Rf_translateCharUTF8(STRING_ELT(arg, 0))); else if (Rf_install("version") == name && (TYPEOF(arg) == REALSXP || TYPEOF(arg) == STRSXP) && LENGTH(arg) == 1) { double ver = asReal(arg); if (ver != 1.4 && ver != 1.5) Rf_warning("Unsupported PDF version requested, ignoring, only 1.4 or 1.5 is supported by cairographics"); else cairo_pdf_surface_restrict_to_version(be->cs, (ver == 1.4) ? CAIRO_PDF_VERSION_1_4 : CAIRO_PDF_VERSION_1_5); } else if (name != R_NilValue) Rf_warning("Unused or invalid argument `%s', ingoring", CHAR(PRINTNAME(name))); } #endif return be; } #else Rcairo_backend_def *RcairoBackendDef_pdf = 0; Rcairo_backend *Rcairo_new_pdf_backend(Rcairo_backend *be, int conn, const char *filename, double width, double height) { error("cairo library was compiled without PDF back-end."); return NULL; } #endif Cairo/src/img-backend.h0000644000175100001440000000121214531200444014417 0ustar hornikusers#ifndef __IMAGE_BACKEND_H__ #define __IMAGE_BACKEND_H__ #include "backend.h" /* usually we don't expose this, but the experimental image backplane API needs this so that we don't have to use cairo 1.2 API */ typedef struct st_Rcairo_image_backend { void *buf; char *filename; int conn; int quality; cairo_format_t format; SEXP locator_call, locator_dev; } Rcairo_image_backend; extern Rcairo_backend_def *RcairoBackendDef_image; Rcairo_backend *Rcairo_new_image_backend(Rcairo_backend *be, int conn, const char *filename, const char *type, int width, int height, int quality, int alpha_plane, SEXP locator_cb); #endif Cairo/src/cairogd.h0000644000175100001440000000565614531200444013706 0ustar hornikusers#ifndef _DEV_GD_H #define _DEV_GD_H #define CAIROGD_VER 0x010602 /* Cairo v1.6-2 */ /* cairo R package config */ #include "cconfig.h" #include /* Windows cannot statically use FontConfig, so so we ignore CAIRO_FT there (as does R). If the user wishes to override (e.g. for non-static builds), use: -DUSE_CAIRO_FT=1 */ #if CAIRO_HAS_FT_FONT && !defined(_WIN32) && !defined(USE_CAIRO_FT) #define USE_CAIRO_FT 1 #endif /* ignore USE_CAIRO_FT=1 if cairo-ft is not available */ #if USE_CAIRO_FT && defined(CAIRO_HAS_FT_FONT) && ! CAIRO_HAS_FT_FONT #undef USE_CAIRO_FT #endif #ifndef USE_CAIRO_FT #define USE_CAIRO_FT 0 #endif #if USE_CAIRO_FT #include #include FT_TRUETYPE_IDS_H #include #endif /* work around bug #45376 in freetype 2.6.0 */ #ifdef TYPEOF #undef TYPEOF #endif #include "backend.h" #include #if R_GE_version < 4 #include #include #define BEGIN_SUSPEND_INTERRUPTS #define END_SUSPEND_INTERRUPTS #endif /* the internal representation of a color in this (R) API is RGBa with a=0 meaning transparent and a=255 meaning opaque (hence a means 'opacity'). previous implementation was different (inverse meaning and 0x80 as NA), so watch out. */ #if R_VERSION < 0x20000 #define CONVERT_COLOR(C) ((((C)==0x80000000) || ((C)==-1))?0:(((C)&0xFFFFFF)|((0xFF000000-((C)&0xFF000000))))) #else #define CONVERT_COLOR(C) (C) #endif #define CAIROGD_MAGIC (0x43614744) /* for compatibility with older R versions */ #if R_GE_version < 4 #define GEaddDevice(X) addDevice((DevDesc*)(X)) #define GEdeviceNumber(X) devNumber((DevDesc*)(X)) #define GEgetDevice(X) ((GEDevDesc*) GetDevice(X)) #define ndevNumber(X) devNumber((DevDesc*)(X)) #define GEkillDevice(X) KillDevice(X) #define desc2GEDesc(X) ((DevDesc*) GetDevice(devNumber((DevDesc*) (X)))) #endif typedef struct { #ifdef USE_MAGIC int magic; /* magic number such that we recognize Cairo */ #endif double cex; /* Character expansion */ int lty; /* Line type */ double lwd; int col; /* Color */ int fill; int canvas; /* Canvas */ int fontface; /* Typeface */ int fontsize; /* Size in points */ int basefontface; /* Typeface */ int basefontsize; /* Size in points */ /* --- custom fields --- */ Rcairo_backend *cb; /* cairo backend */ /* those are set before Open is invoked such that we can pass any number of initial parameters without modifying the code */ int bg; /* bg */ double gamma; /* gamma */ double dpix, dpiy, asp; double fontscale; /* scaling of fonts due to DPI change */ int gd_fill, gd_draw; /* current GD colors */ double gd_ftsize, gd_ftm_ascent, gd_ftm_descent, gd_ftm_width; int gd_ftm_char; /*gd_ftm_xxx are font-metric cached values - char specifying the last query */ int npages; /* sequence # in case multiple pages are requested */ int holdlevel; } CairoGDDesc; #endif Cairo/src/cairotalk.c0000644000175100001440000014401214531200444014230 0ustar hornikusers/* -*- mode: C; tab-width: 4; c-basic-offset: 4 -*- */ #include "backend.h" #include "cairogd.h" #include "cairotalk.h" #include "cairobem.h" #include "img-backend.h" #include "pdf-backend.h" #include "svg-backend.h" #include "ps-backend.h" #include "xlib-backend.h" #include "w32-backend.h" #include "img-tiff.h" /* for TIFF_COMPR_LZW */ #include #define USE_RINTERNALS 1 #include #include #include /* attribute_visible */ #include "Rapi.h" #ifdef HAVE_HARFBUZZ #include #include #include #include #include #include #include #include #include #endif /* Device Driver Actions */ #if R_VERSION < 0x10900 #error This device needs at least R version 1.9.0 #endif #define CREDC(C) (((unsigned int)(C))&0xff) #define CGREENC(C) ((((unsigned int)(C))&0xff00)>>8) #define CBLUEC(C) ((((unsigned int)(C))&0xff0000)>>16) #define CALPHA(C) ((((unsigned int)(C))&0xff000000)>>24) #if R_VERSION < R_Version(2,7,0) #define constxt #else #define constxt const #endif static void CairoGD_Activate(NewDevDesc *dd); static void CairoGD_Circle(double x, double y, double r, R_GE_gcontext *gc, NewDevDesc *dd); static void CairoGD_Clip(double x0, double x1, double y0, double y1, NewDevDesc *dd); static void CairoGD_Close(NewDevDesc *dd); static void CairoGD_Deactivate(NewDevDesc *dd); static Rboolean CairoGD_Locator(double *x, double *y, NewDevDesc *dd); static void CairoGD_Line(double x1, double y1, double x2, double y2, R_GE_gcontext *gc, NewDevDesc *dd); static void CairoGD_MetricInfo(int c, R_GE_gcontext *gc, double* ascent, double* descent, double* width, NewDevDesc *dd); static void CairoGD_Mode(int mode, NewDevDesc *dd); static void CairoGD_NewPage(R_GE_gcontext *gc, NewDevDesc *dd); static void CairoGD_Path(double *x, double *y, int npoly, int *nper, Rboolean winding, R_GE_gcontext *gc, NewDevDesc *dd); static void CairoGD_Polygon(int n, double *x, double *y, R_GE_gcontext *gc, NewDevDesc *dd); static void CairoGD_Polyline(int n, double *x, double *y, R_GE_gcontext *gc, NewDevDesc *dd); static void CairoGD_Rect(double x0, double y0, double x1, double y1, R_GE_gcontext *gc, NewDevDesc *dd); static void CairoGD_Size(double *left, double *right, double *bottom, double *top, NewDevDesc *dd); static double CairoGD_StrWidthNative(constxt char *str, R_GE_gcontext *gc, NewDevDesc *dd); static double CairoGD_StrWidthUTF8(constxt char *str, R_GE_gcontext *gc, NewDevDesc *dd); static void CairoGD_TextNative(double x, double y, constxt char *str, double rot, double hadj, R_GE_gcontext *gc, NewDevDesc *dd); static void CairoGD_TextUTF8(double x, double y, constxt char *str, double rot, double hadj, R_GE_gcontext *gc, NewDevDesc *dd); static void CairoGD_Raster(unsigned int *raster, int w, int h, double x, double y, double width, double height, double rot, Rboolean interpolate, R_GE_gcontext *gc, NewDevDesc *dd); static SEXP CairoGD_Cap(NewDevDesc *dd); static int CairoGD_HoldFlush(NewDevDesc *dd, int level); /* additional GE 13 API */ static SEXP CairoGD_setPattern(SEXP pattern, pDevDesc dd); static void CairoGD_releasePattern(SEXP ref, pDevDesc dd); static SEXP CairoGD_setClipPath(SEXP path, SEXP ref, pDevDesc dd); static void CairoGD_releaseClipPath(SEXP ref, pDevDesc dd); static SEXP CairoGD_setMask(SEXP path, SEXP ref, pDevDesc dd); static void CairoGD_releaseMask(SEXP ref, pDevDesc dd); /* fake mbcs support for old R versions */ #if R_GE_version < 4 #define mbcslocale 0 #define Rf_ucstoutf8(X,Y) #define AdobeSymbol2utf8(A,B,W) { A[0]=s[0]; A[1]=0; } #endif #ifdef JGD_DEBUG #define Rcairo_set_source_rgb(C,R,G,B) { Rprintf("S:RGB> %f %f %f\n", R, G, B); cairo_set_source_rgb(C,R,G,B); } #define Rcairo_set_source_rgba(C,R,G,B,A) { Rprintf("S:RGBA> %f %f %f (%f)\n", R, G, B, A); cairo_set_source_rgba(C,R,G,B,A); } #define Rcairo_set_color(cc, col) { if (CALPHA(col)==255) { Rcairo_set_source_rgb (cc, ((double)CREDC(col))/255., ((double)CGREENC(col))/255., ((double)CBLUEC(col))/255.); } else { Rcairo_set_source_rgba (cc, ((double)CREDC(col))/255., ((double)CGREENC(col))/255., ((double)CBLUEC(col))/255., ((double)CALPHA(col))/255.); }; } #else #define Rcairo_set_color(cc, col) { if (CALPHA(col)==255) { cairo_set_source_rgb (cc, ((double)CREDC(col))/255., ((double)CGREENC(col))/255., ((double)CBLUEC(col))/255.); } else { cairo_set_source_rgba (cc, ((double)CREDC(col))/255., ((double)CGREENC(col))/255., ((double)CBLUEC(col))/255., ((double)CALPHA(col))/255.); }; } #endif int Rcairo_symbol_font_use_pua = 1; #if USE_CAIRO_FT FT_Library Rcairo_ft_library = NULL; typedef struct { cairo_font_face_t *face; FT_Face ft_face; #ifdef HAVE_HARFBUZZ hb_font_t *hb_font; hb_face_t *hb_face; long font_size; #endif char *family; int updated; } Rcairo_font_face; /* 0..3 regular, 4 symbol, 5..8 custom family */ Rcairo_font_face Rcairo_fonts[10]; static const cairo_user_data_key_t key; void Rcairo_font_destroy(Rcairo_font_face *rf) { if (rf->face) { cairo_font_face_destroy(rf->face); rf->face = NULL; } /* NOTE: the ownership of ft_face went to cairo so we don't get to release it. */ rf->ft_face = NULL; #ifdef HAVE_HARFBUZZ if (rf->hb_font) hb_font_destroy(rf->hb_font); rf->hb_font = NULL; if (rf->hb_face) hb_face_destroy(rf->hb_face); rf->hb_face = NULL; #endif } cairo_font_face_t *Rcairo_set_font_face(Rcairo_font_face *rf, int setCharmap, const char *file){ cairo_font_face_t *c_face; cairo_status_t status; FT_Face face; FT_Error er; FT_CharMap found = 0; FT_CharMap charmap; int n; /* Ensure that freetype library is ready */ if (!Rcairo_ft_library){ if (FT_Init_FreeType(&Rcairo_ft_library)){ error("Failed to initialize freetype library in Rcairo_set_font_face!\n"); return 0; /* unreachable code */ } } er = FT_New_Face(Rcairo_ft_library, file, 0, &face); if ( er == FT_Err_Unknown_File_Format ) { error("Unsupported font file format\n"); return NULL; } else if ( er ) { error("Unknown font problem\n"); return NULL; } for ( n = 0; n < face->num_charmaps; n++ ) { charmap = face->charmaps[n]; if ( charmap->platform_id == TT_PLATFORM_MACINTOSH) { found = charmap; break; } } /* Only do this for symbol font */ if (found && setCharmap){ er = FT_Set_Charmap( face, found ); } /* NOTE: cairo may keep fonts around beyond our use (e.g. the PDF device keeps it until it generated the PDF later by re-playing the commands). Hence we have to let cairo manage the lifespan of the FT face. By keeping the cairo face we control our side of the bargain. */ c_face = cairo_ft_font_face_create_for_ft_face(face,FT_LOAD_DEFAULT); status = cairo_font_face_set_user_data (c_face, &key, face, (cairo_destroy_func_t) FT_Done_Face); if (status) { cairo_font_face_destroy (c_face); FT_Done_Face (face); return NULL; } #ifdef HAVE_HARFBUZZ /* both HB objects increase the ref count on FT face so it doesn't get released while they need it */ rf->hb_face = hb_ft_face_create_referenced(face); /* font needs size ... */ rf->font_size = 800; /* default is 12pt = 12.5 * 64 = 800 */ FT_Set_Char_Size(face, 0, rf->font_size, 0, 0); rf->hb_font = hb_ft_font_create_referenced(face); hb_ft_font_set_funcs(rf->hb_font); #endif rf->ft_face = face; rf->face = c_face; return c_face; } void Rcairo_set_font(int i, const char *fcname){ FcFontSet *fs; FcPattern *pat, *match; FcResult result; FcChar8 *file; int j; pat = FcNameParse((FcChar8 *)fcname); if (!pat){ error("Fontconfig cannot parse font specification \"%s\" in CairoFonts()", fcname); return; } FcConfigSubstitute (0, pat, FcMatchPattern); FcDefaultSubstitute (pat); fs = FcFontSetCreate (); match = FcFontMatch (0, pat, &result); FcPatternDestroy (pat); if (match) { FcFontSetAdd (fs, match); } else { error("No font found in CairoFonts() for \"%s\"", fcname); FcFontSetDestroy (fs); return; } /* should be at least one font face in fontset */ if (fs) { for (j = 0; j < fs->nfont; j++) { /* Need to make sure a real font file exists */ if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) { Rcairo_font_face rc_face; /* set in a copy first so we only destroy existing on error */ memset(&rc_face, 0, sizeof(rc_face)); /* returns cairo face on success or NULL on error */ if (Rcairo_set_font_face(&rc_face, i == 4, (const char *)file)) { /* success */ if (Rcairo_fonts[i].face) Rcairo_font_destroy(&Rcairo_fonts[i]); memcpy(&Rcairo_fonts[i], &rc_face, sizeof(rc_face)); #ifdef JGD_DEBUG Rprintf("INFO: setting font index %d to font %p from file %s (spec %s)\n", i, rc_face.face, file, fcname); #endif } else Rf_warning("Unable to get face for font type %d from %s (for %s)", i + 1, (const char*) file, fcname); break; } } FcFontSetDestroy (fs); Rcairo_fonts[i].updated = 1; } else { error("No font found for \"%s\" in CairoFonts()", fcname); } } #endif static void set_cf_antialias(cairo_t *cc) { cairo_font_options_t *fo = cairo_font_options_create(); cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_SUBPIXEL); cairo_set_font_options(cc, fo); cairo_font_options_destroy(fo); } static void Rcairo_setup_font(CairoGDDesc* xd, R_GE_gcontext *gc) { cairo_t *cc = xd->cb->cc; #if USE_CAIRO_FT int i = gc->fontface - 1; if (i < 0 || i >= 5) i = 0; if (i < 4 && *gc->fontfamily) { i += 5; /* fetch custom family into corresponding custom slot */ if (!Rcairo_fonts[i].family || strcmp(Rcairo_fonts[i].family, gc->fontfamily)) { char spec[128]; #ifdef JGD_DEBUG Rprintf("INFO: new custom family '%s' in slot %d\n", gc->fontfamily, i); #endif if (strlen(gc->fontfamily) < sizeof(spec) - 32) { const char *specs[4] = { ":style=Regular", ":style=Bold", ":style=Italic", ":style=BoldItalic, BoldItalic" }; strcpy(spec, gc->fontfamily); strcat(spec, specs[i - 5]); Rcairo_set_font(i, spec); } else Rcairo_set_font(i, gc->fontfamily); if (Rcairo_fonts[i].family) free(Rcairo_fonts[i].family); Rcairo_fonts[i].family = strdup(gc->fontfamily); } } if (Rcairo_fonts[i].updated || (xd->fontface != i + 1)){ cairo_set_font_face(cc, Rcairo_fonts[i].face); set_cf_antialias(cc); Rcairo_fonts[i].updated = 0; #ifdef JGD_DEBUG Rprintf(" font face %d changed to \"%s\" %fpt\n", i, gc->fontfamily, gc->cex*gc->ps + 0.5); #endif } xd->fontface = i + 1; #else /* no FreeType */ char *Cfontface="Helvetica"; int slant = CAIRO_FONT_SLANT_NORMAL; int wght = CAIRO_FONT_WEIGHT_NORMAL; #ifdef WIN32 if (gc->fontface==5) Cfontface="Times"; #else if (gc->fontface==5) Cfontface="Symbol"; #endif if (gc->fontfamily[0]) Cfontface=gc->fontfamily; if (gc->fontface==3 || gc->fontface==4) slant=CAIRO_FONT_SLANT_ITALIC; if (gc->fontface==2 || gc->fontface==4) wght=CAIRO_FONT_WEIGHT_BOLD; cairo_select_font_face (cc, Cfontface, slant, wght); set_cf_antialias(cc); #ifdef JGD_DEBUG Rprintf(" font \"%s\" %fpt (slant:%d, weight:%d)\n", Cfontface, gc->cex*gc->ps + 0.5, slant, wght); #endif #endif /* Add 0.5 per devX11.c in R src. We want to match its png output as close * as possible. */ cairo_set_font_size (cc, gc->cex * gc->ps * xd->fontscale + 0.5); #ifdef HAVE_HARFBUZZ #ifdef JGD_DEBUG Rprintf("INFO: set font[%d] size to %.f (cex=%.f, ps=%.f, fontscale=%.f)\n", i, (gc->cex * gc->ps * xd->fontscale + 0.5) * 64, gc->cex, gc->ps, xd->fontscale); #endif long new_size = (gc->cex * gc->ps * xd->fontscale + 0.5) * 64; if (Rcairo_fonts[i].font_size != new_size || !Rcairo_fonts[i].hb_font) { #ifdef JGD_DEBUG Rprintf("INFO: allocating new instance of font %d for size %ld\n", i, new_size); #endif FT_Set_Char_Size(Rcairo_fonts[i].ft_face, 0, new_size, 0, 0); Rcairo_fonts[i].font_size = new_size; if (Rcairo_fonts[i].hb_font) hb_font_destroy(Rcairo_fonts[i].hb_font); Rcairo_fonts[i].hb_font = hb_ft_font_create_referenced(Rcairo_fonts[i].ft_face); hb_ft_font_set_funcs(Rcairo_fonts[i].hb_font); } #endif } static void Rcairo_set_line(CairoGDDesc* xd, R_GE_gcontext *gc) { cairo_t *cc = xd->cb->cc; cairo_line_cap_t lend = CAIRO_LINE_CAP_SQUARE; cairo_line_join_t ljoin = CAIRO_LINE_JOIN_ROUND; /* Line width: par lwd */ cairo_set_line_width(cc, gc->lwd * xd->fontscale); /* use fontscale to match the DPI setting */ /* Line end: par lend */ switch(gc->lend){ case GE_ROUND_CAP: lend = CAIRO_LINE_CAP_ROUND; break; case GE_BUTT_CAP: lend = CAIRO_LINE_CAP_BUTT; break; case GE_SQUARE_CAP: lend = CAIRO_LINE_CAP_SQUARE; break; } cairo_set_line_cap(cc,lend); /* Line join: par ljoin */ switch(gc->ljoin){ case GE_ROUND_JOIN: ljoin = CAIRO_LINE_JOIN_ROUND; break; case GE_MITRE_JOIN: ljoin = CAIRO_LINE_JOIN_MITER; break; case GE_BEVEL_JOIN: ljoin = CAIRO_LINE_JOIN_BEVEL; break; } cairo_set_line_join(cc,ljoin); if (gc->lty==0 || gc->lty==-1) cairo_set_dash(cc,0,0,0); else { double ls[16]; /* max 16x4=64 bit */ int l=0, dt=gc->lty; while (dt>0) { ls[l]=(double)(dt&15); dt>>=4; l++; } cairo_set_dash(cc, ls, l, 0); } } /*------- the R callbacks begin here ... ------------------------*/ #define c_trunc(X) ((double)((int)(X))) /* some Suns don't have trunc(), so we use the cast-way to truncate */ static void CairoGD_Activate(NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb) return; if (xd->cb->activation) xd->cb->activation(xd->cb, 1); } static SEXP CairoGD_Cap(NewDevDesc *dd) { SEXP raster = R_NilValue, dim; CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; cairo_surface_t *s; if(!xd || !xd->cb || !(s = xd->cb->cs)) return raster; cairo_surface_flush(s); /* we have defined way of getting the contents only from image back-ends */ if (cairo_surface_get_type(s) == CAIRO_SURFACE_TYPE_IMAGE) { int w = cairo_image_surface_get_width(s); int h = cairo_image_surface_get_height(s); unsigned int *dst, size = w * h, i; unsigned int *img = (unsigned int*) cairo_image_surface_get_data(s); cairo_format_t fmt = cairo_image_surface_get_format(s); /* we only support RGB or ARGB */ if (fmt != CAIRO_FORMAT_RGB24 && fmt != CAIRO_FORMAT_ARGB32) return raster; raster = PROTECT(allocVector(INTSXP, size)); dst = (unsigned int*) INTEGER(raster); #ifdef JGD_DEBUG Rprintf("format = %s (%d x %d)\n", (fmt == CAIRO_FORMAT_ARGB32) ? "ARGB" : "RGB", w, h); #endif if (fmt == CAIRO_FORMAT_ARGB32) /* ARGB is the default we use in most cases */ /* annoyingly Cairo uses pre-multiplied storage so we have to reverse that */ for (i = 0; i < size; i++) { unsigned int v = *(img++), a = v >> 24; dst[i] = (a == 0) ? 0 : /* special cases for alpha = 0.0 and 1.0 */ ((a == 255) ? R_RGB((v >> 16) & 255, (v >> 8) & 255, v & 255) : R_RGBA(((v >> 16) & 255) * 255 / a, ((v >> 8) & 255) * 255 / a, (v & 255) * 255 / a, a)); } else for (i = 0; i < size; i++) dst[i] = R_RGB((img[i] >> 16) & 255, (img[i] >> 8) & 255, img[i] & 255); dim = allocVector(INTSXP, 2); INTEGER(dim)[0] = h; INTEGER(dim)[1] = w; setAttrib(raster, R_DimSymbol, dim); UNPROTECT(1); } return raster; } static void CairoGD_Circle(double x, double y, double r, R_GE_gcontext *gc, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb) return; { cairo_t *cc = xd->cb->cc; #ifdef JGD_DEBUG Rprintf("circle %x %f/%f %f [%08x/%08x]\n",cc, x, y, r, gc->col, gc->fill); #endif cairo_new_path(cc); cairo_arc(cc, x, y, r + 0.5 , 0., 2 * M_PI); /* Add 0.5 like devX11 */ if (CALPHA(gc->fill)) { Rcairo_set_color(cc, gc->fill); cairo_fill_preserve(cc); } if (CALPHA(gc->col) && gc->lty!=-1) { Rcairo_set_color(cc, gc->col); Rcairo_set_line(xd, gc); cairo_stroke(cc); } else cairo_new_path(cc); xd->cb->serial++; } } static void CairoGD_Clip(double x0, double x1, double y0, double y1, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; cairo_t *cc; if(!xd || !xd->cb) return; cc = xd->cb->cc; if (x1deviceSpecific; if(!xd || !xd->cb) return; xd->npages++; xd->cb->save_page(xd->cb,xd->npages); if (xd->cb->onSave && xd->cb->onSave != R_NilValue) { SEXP devNr = PROTECT(ScalarInteger(ndevNumber(dd) + 1)); SEXP pageNr = PROTECT(ScalarInteger(xd->npages)); eval(PROTECT(lang3(xd->cb->onSave, devNr, pageNr)), R_GlobalEnv); UNPROTECT(3); R_ReleaseObject(xd->cb->onSave); xd->cb->onSave = 0; } xd->cb->destroy_backend(xd->cb); free(xd); dd->deviceSpecific=NULL; } static void CairoGD_Deactivate(NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb) return; if (xd->cb->activation) xd->cb->activation(xd->cb, 0); } static int CairoGD_HoldFlush(NewDevDesc *dd, int level) { int ol; CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if (!xd) return 0; ol = xd->holdlevel; xd->holdlevel += level; if (xd->holdlevel < 0) xd->holdlevel = 0; if (xd->holdlevel == 0) { /* flush */ if (xd->cb && xd->cb->sync) /* if a back-end provides sync, we just pass on */ xd->cb->sync(xd->cb); else /* otherwise just do cairo-side flush */ if (xd->cb && xd->cb->cs) cairo_surface_flush(xd->cb->cs); } else if (ol == 0) { /* first hold */ /* could display a wait cursor or something ... */ } return xd->holdlevel; } static Rboolean CairoGD_Locator(double *x, double *y, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb) return FALSE; if (xd->cb && xd->cb->locator) return xd->cb->locator(xd->cb, x, y); return FALSE; } static void CairoGD_Line(double x1, double y1, double x2, double y2, R_GE_gcontext *gc, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb) return; #ifdef JGD_DEBUG Rprintf("line %f/%f %f/%f [%08x/%08x]\n", x1, y1, x2, y2, gc->col, gc->fill); #endif if (CALPHA(gc->col) && gc->lty!=-1) { cairo_t *cc = xd->cb->cc; cairo_new_path(cc); if ((x1==x2 || y1==y2) &&xd->cb->truncate_rect) { /* if we are snapping rectangles to grid, we also need to snap straight lines to make sure they match - e.g. tickmarks, baselines etc. */ x1=c_trunc(x1)+0.5; x2=c_trunc(x2)+0.5; y1=c_trunc(y1)+0.5; y2=c_trunc(y2)+0.5; } cairo_move_to(cc, x1, y1); cairo_line_to(cc, x2, y2); Rcairo_set_color(cc, gc->col); Rcairo_set_line(xd, gc); cairo_stroke(cc); xd->cb->serial++; } } #ifdef HAVE_HARFBUZZ static UChar js_buf[128]; static int str2utf16(const char *c, int len, UChar **buf, const char *ifrom) { void *ih; const char *ce = (len < 0) ? strchr(c, 0) : (c + len); if (ce == c) { buf[0] = 0; return 0; } size_t osize = sizeof(UChar) * (ce - c + 1), isize = ce - c; UChar *js = buf[0] = (osize < sizeof(js_buf)) ? js_buf : (UChar*) R_alloc(sizeof(UChar), ce - c + 1); char *dst = (char*) js; int end_test = 1, is_le = (((char*)&end_test)[0] == 1) ? 1 : 0; if (!ifrom) ifrom = ""; ih = Riconv_open(is_le ? "UTF-16LE" : "UTF-16BE", ifrom); if (ih == (void *)(-1)) Rf_error("Unable to start conversion to UTF-16"); while (c < ce) { size_t res = Riconv(ih, &c, &isize, &dst, &osize); /* this should never happen since we allocated far more than needed */ if (res == -1 && errno == E2BIG) Rf_error("Conversion to UTF-16 failed due to unexpectedly large buffer requirements."); else if(res == -1 && (errno == EILSEQ || errno == EINVAL)) { /* invalid char */ if (is_le) { *(dst++) = '?'; *(dst++) = 0; } else { *(dst++) = 0; *(dst++) = '?'; } osize -= 2; c++; isize--; } } Riconv_close(ih); /* FIXME: not 64-bit safe ... */ return (int) (dst - (char*) js); } typedef struct { unsigned int glyphs, g_alloc; cairo_glyph_t *glyph; double x, y; } rc_text_shape; static rc_text_shape shared_text_shape; /* FIXME: this is not thread safe. Threads are not supported in R anyway, but just saying... This will be used across Cairo devices, but keeping one buffer reduces allocations. */ static rc_text_shape *init_text_shape(void) { shared_text_shape.x = 0.0; shared_text_shape.y = 0.0; shared_text_shape.glyphs = 0; return &shared_text_shape; } #define CHB_DIR_LTR 0 #define CHB_DIR_RTL 1 #define CHB_FIRST 4 #define CHB_LAST 8 #define CHB_UTF8 16 static void chb_add_glyphs(rc_text_shape *rc, Rcairo_font_face *fcface, const UChar *text, int32_t start, int32_t len, int flags) { hb_buffer_t *buf = hb_buffer_create(); hb_unicode_funcs_t* unicode_func = hb_icu_get_unicode_funcs(); hb_buffer_set_unicode_funcs(buf, unicode_func); hb_buffer_set_direction(buf, (flags & CHB_DIR_RTL) ? HB_DIRECTION_RTL : HB_DIRECTION_LTR); if (flags & CHB_FIRST) hb_buffer_set_flags (buf, HB_BUFFER_FLAG_BOT); if (flags & CHB_LAST) hb_buffer_set_flags (buf, HB_BUFFER_FLAG_EOT); if (len > 0) { hb_script_t script = hb_unicode_script(unicode_func, text[start]); hb_buffer_set_script(buf, script); // hb_buffer_set_language(buf, hb_language_from_string("fa", -1)); hb_tag_t tag = hb_script_to_iso15924_tag(script); char scs[8]; hb_tag_to_string(tag, scs); scs[5] = 0; #ifdef JGD_DEBUG Rprintf("INFO: script identified as %s\n", scs); #endif } /* Layout the text */ if (flags & CHB_UTF8) hb_buffer_add_utf8(buf, ((const char*) text) + start, len, 0, len); else hb_buffer_add_utf16(buf, ((const uint16_t*) text) + start, len, 0, len); hb_shape(fcface->hb_font, buf, NULL, 0); #ifdef JGD_DEBUG if (flags & CHB_UTF8) Rprintf("TEXT(UTF8): %s\n", (const char *)text); else { Rprintf("TEXT: "); for (int k = start; k < start + len; k++) Rprintf("%04x[%c] ", text[k], (text[k] < 127) ? ((char) text[k]) : '.'); Rprintf("\n"); } #endif /* Get the glyphs info */ unsigned int glyph_count; hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buf, &glyph_count); hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buf, &glyph_count); #define MIN_GLYPH_N(X) (((X) < 128) ? 128 : (X)) if (glyph_count + rc->glyphs > rc->g_alloc) { unsigned int need = (sizeof(cairo_glyph_t) * MIN_GLYPH_N(glyph_count + rc->glyphs)) * 2; void *ng = malloc(need); #ifdef JGD_DEBUG Rprintf("INFO: allocating %u bytes to fit at least %u glyphs\n", need, (glyph_count + rc->glyphs)); #endif if (!ng) Rf_error("Cannot allocate memory for %u glyphs", glyph_count); if (rc->glyph && rc->glyphs) { #ifdef JGD_DEBUG Rprintf(" (copying existing %u glyphs)\n", rc->glyphs); #endif memcpy(ng, rc->glyph, rc->glyphs * sizeof(cairo_glyph_t)); free(rc->glyph); } rc->glyph = ng; rc->g_alloc = need / sizeof(cairo_glyph_t); } #ifdef JGD_DEBUG Rprintf(" start location: %.2f, %.2f (glyphs=%d, alloc=%d)\n", rc->x, rc->y, rc->glyphs, rc->g_alloc); #endif for (unsigned int i = 0; i < glyph_count; i++) { int j = rc->glyphs++; rc->glyph[j].index = glyph_info[i].codepoint; rc->glyph[j].x = rc->x + (glyph_pos[i].x_offset / 64.0); rc->glyph[j].y = rc->y - (glyph_pos[i].y_offset / 64.0); #ifdef JGD_DEBUG Rprintf(" [%02d -> %02d] %.2f, %.2f 0x%04x\n", i, j, rc->glyph[j].x, rc->glyph[j].y, (int) rc->glyph[j].index); #endif rc->x += glyph_pos[i].x_advance / 64.0; rc->y -= glyph_pos[i].y_advance / 64.0; } #ifdef JGD_DEBUG Rprintf(" final location: %.2f, %.2f (%u glyphs)\n", rc->x, rc->y, rc->glyphs); #endif hb_buffer_destroy(buf); } /* simple processing for ASCII text: LTR, treat as UTF8 input */ static rc_text_shape *c_setup_ascii_glyphs(CairoGDDesc *xd, R_GE_gcontext *gc, const char *str) { rc_text_shape *ts = init_text_shape(); int i = xd->fontface - 1; if (i < 0 || i > 8) i = 0; Rcairo_font_face *rf = &Rcairo_fonts[i]; chb_add_glyphs(ts, rf, (const UChar*) str, 0, strlen(str), CHB_DIR_LTR | CHB_FIRST | CHB_LAST | CHB_UTF8); return ts; } /* split text into runs with the same directionality then call HB to shape each run. The result is a set of cairo glyphs with locations */ static rc_text_shape *c_setup_glyphs(CairoGDDesc *xd, R_GE_gcontext *gc, const char *str, const char *encoding) { /* check for ASCII input to avoid complicated processing */ const unsigned char *c = (const unsigned char*) str; while (*c && *c < 128) c++; if (!*c) return c_setup_ascii_glyphs(xd, gc, str); UBiDi *bidi = 0; UChar *text = 0; UErrorCode err = U_ZERO_ERROR; int32_t ulen = 0; if (!bidi) bidi = ubidi_open(); if (!bidi) Rf_error("Unable to allocate memory for UBiDi"); ulen = str2utf16(str, strlen(str), &text, encoding) / sizeof(UChar); /* str2utf16 returns bytes, need chars */ ubidi_setPara(bidi, text, ulen, UBIDI_DEFAULT_LTR, NULL, &err); if (U_FAILURE(err)) Rf_error("Unable to compute UBiDi for string '%s'", str); rc_text_shape *ts = init_text_shape(); int i = xd->fontface - 1; if (i < 0 || i > 8) i = 0; Rcairo_font_face *rf = &Rcairo_fonts[i]; UBiDiDirection direction = ubidi_getDirection(bidi); if (direction != UBIDI_MIXED) { #ifdef JGD_DEBUG Rprintf("INFO: unidirectional text with direction %s, text: %s\n", (direction & 1) ? "RTL" : "LTR", str); #endif chb_add_glyphs(ts, rf, text, 0, ulen, (direction ? CHB_DIR_RTL : CHB_DIR_LTR) | CHB_FIRST | CHB_LAST); } else { int32_t count, i, start, length; count = ubidi_countRuns(bidi, &err); if (U_FAILURE(err)) Rf_error("Unable to determine directionality runs for string '%s'", str); #ifdef JGD_DEBUG Rprintf("INFO: multidirectional text '%s' with %d runs\n", str, (int) count); #endif for (i = 0; i < count; i++) { direction = ubidi_getVisualRun(bidi, i, &start, &length); #ifdef JGD_DEBUG Rprintf(" %s: %d, %d chars\n", (direction & 1) ? "RTL" : "LTR", start, length); #endif chb_add_glyphs(ts, rf, text, start, length, (direction ? CHB_DIR_RTL : CHB_DIR_LTR) | ((i == 0) ? CHB_FIRST: 0) | ((i == count - 1) ? CHB_LAST : 0)); } } ubidi_close(bidi); return ts; } #endif /* HARFBUZZ */ static void CairoGD_MetricInfo(int c, R_GE_gcontext *gc, double* ascent, double* descent, double* width, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; cairo_t *cc; cairo_text_extents_t te = {0, 0, 0, 0, 0, 0}; char str[16]; int Unicode = mbcslocale; double x_factor = 1.0; if(!xd || !xd->cb) return; if(c < 0) {c = -c; Unicode = 1;} cc = xd->cb->cc; Rcairo_setup_font(xd, gc); /* FIXME: with FT we could use face->ascender, descender from the font or face->glyph->metrics for the particular character */ if (!c) { /* this should give us a reasonably decent (g) and almost max width (M) */ str[0]='M'; str[1]='g'; str[2]=0; x_factor = 0.5; /* halve the width since we use two chars */ } else if (c > 127 && Unicode) { Rf_ucstoutf8(str, (unsigned int) c); #if R_VERSION >= R_Version(4,0,0) if (gc->fontface == 5 && !Rcairo_symbol_font_use_pua) { /* handle conversion away form PUA */ const char *npstr = utf8Toutf8NoPUA(str); memcpy(str, npstr, 4); /* at most 3 + NUL */ } #endif } else { str[0] = c; str[1] = 0; /* Here, we assume that c < 256 */ } cairo_text_extents(cc, str, &te); #ifdef JGD_DEBUG Rprintf("metric %x [%c]: bearing %f:%f, size %f:%f, advance %f:%f\n",c, (char)c, te.x_bearing, te.y_bearing, te.width, te.height, te.x_advance, te.y_advance); #endif *ascent = -te.y_bearing; *descent = te.height + te.y_bearing; /* cairo doesn't report width of whitespace, so use x_advance */ *width = te.x_advance * x_factor; #ifdef JGD_DEBUG Rprintf("FM> ascent=%f, descent=%f, width=%f\n", *ascent, *descent, *width); #endif } static void CairoGD_Mode(int mode, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb) return; if (xd->cb->mode) xd->cb->mode(xd->cb, mode); } static void CairoGD_NewPage(R_GE_gcontext *gc, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; cairo_t *cc; if(!xd || !xd->cb) return; cc = xd->cb->cc; xd->npages++; if (xd->npages > 0) { /* first request is not saved as this is part of the init */ xd->cb->save_page(xd->cb,xd->npages); if (xd->cb->onSave) { SEXP devNr = PROTECT(ScalarInteger(ndevNumber(dd) + 1)); SEXP pageNr = PROTECT(ScalarInteger(xd->npages)); eval(PROTECT(lang3(xd->cb->onSave, devNr, pageNr)), R_GlobalEnv); UNPROTECT(3); } } cairo_reset_clip(cc); /* we don't need to fill if the back-end sets nozero and bg is transparent */ if (! (R_TRANSPARENT(xd->bg) && (xd->cb->flags & CDF_NOZERO)) ) { /* we are assuming that the operator is reasonable enough to clear the page. Setting CAIRO_OPERATOR_SOURCE seemed to trigger rasterization for PDF and SVG backends, so we leave the operator alone. Make sure the back-end sets an operator that is optimal for the back-end */ Rcairo_set_color(cc, xd->bg); if (xd->cb->flags & CDF_OPAQUE) { /* Opaque devices use canvas if bg is transparent */ if (R_TRANSPARENT(xd->bg)) Rcairo_set_color(cc, xd->canvas); } else { if (xd->cb->flags & CDF_FAKE_BG) { if (R_TRANSPARENT(xd->bg)) Rcairo_set_color(cc, fake_bg_color); } } cairo_new_path(cc); cairo_paint(cc); xd->cb->serial++; } } static SEXP findArg(const char *name, SEXP list) { SEXP ns = install(name); while (list && list!=R_NilValue) { if (TAG(list)==ns) return CAR(list); list=CDR(list); } return 0; } Rboolean CairoGD_Open(NewDevDesc *dd, CairoGDDesc *xd, const char *type, int conn, const char *file, double w, double h, double umpl, SEXP aux) { if (umpl==0) error("unit multiplier cannot be zero"); xd->fill = 0xffffffff; /* transparent, was R_RGB(255, 255, 255); */ xd->col = R_RGB(0, 0, 0); xd->npages=-1; xd->cb = (Rcairo_backend*) calloc(1,sizeof(Rcairo_backend)); if (!xd->cb) return FALSE; xd->cb->dd = dd; xd->cb->dpix = xd->dpix; xd->cb->dpiy = xd->dpiy; /* Select Cairo backend */ /* Cairo 1.2-0: jpeg and tiff are created via external libraries (libjpeg/libtiff) by our code */ if (!strcmp(type,"png") || !strcmp(type,"png24") || !strcmp(type,"jpeg") || !strcmp(type,"jpg") || !strcmp(type,"tif") || !strcmp(type,"tiff") || !strcmp(type, "raster")) { int alpha_plane = 0; int quality = 0; /* find out if we have quality setting */ SEXP loc_cb = R_NilValue; #if R_GE_version >= 9 loc_cb = findArg("locator", aux); if (loc_cb && TYPEOF(loc_cb) == CLOSXP) { dd->haveLocator = 2; /* yes, custom supplied locator callback */ } else { dd->haveLocator = 1; /* no locator on image back-ends */ loc_cb = R_NilValue; } #endif if (R_ALPHA(xd->bg) < 255) alpha_plane=1; if (!strcmp(type,"jpeg") || !strcmp(type,"jpg")) { SEXP arg = findArg("quality", aux); if (arg && arg!=R_NilValue) quality = asInteger(arg); if (quality<0) quality=0; if (quality>100) quality=100; alpha_plane=0; #if R_GE_version >= 9 /* JPEG has no tbg */ dd->haveTransparentBg = 1; #endif } if (!strcmp(type,"tif") || !strcmp(type,"tiff")) { SEXP arg = findArg("compression", aux); if (arg && arg!=R_NilValue) quality = asInteger(arg); else quality = TIFF_COMPR_LZW; /* default */ } if (umpl>=0) { if (xd->dpix <= 0) error("images cannot be created with other units than 'px' if dpi is not specified"); if (xd->dpiy <= 0) xd->dpiy=xd->dpix; w = w*umpl*xd->dpix; h = h*umpl*xd->dpiy; } else { if (umpl != -1) { w = (-umpl)*w; h = (-umpl)*h; } } xd->cb->width = w; xd->cb->height = h; xd->cb = Rcairo_new_image_backend(xd->cb, conn, file, type, (int)(w+0.5), (int)(h+0.5), quality, alpha_plane, loc_cb); } else if (!strcmp(type,"pdf") || !strcmp(type,"ps") || !strcmp(type,"postscript") || !strcmp(type,"svg")) { #if R_GE_version >= 9 /* no locator, no capture */ dd->haveLocator = 1; dd->haveCapture = 1; #endif /* devices using native units, covert those to points */ if (umpl<0) { if (xd->dpix <= 0) error("dpi must be specified when creating vector devices with units='px'"); if (xd->dpiy <= 0) xd->dpiy=xd->dpix; w = w/xd->dpix; h = h/xd->dpiy; umpl=1; } w = w * umpl * 72; /* inches * 72 = pt */ h = h * umpl * 72; xd->cb->width = w; xd->cb->height = h; xd->cb->flags|=CDF_NOZERO; if (!strcmp(type,"pdf")) xd->cb = Rcairo_new_pdf_backend(xd->cb, conn, file, w, h, aux); else if (!strcmp(type,"ps") || !strcmp(type,"postscript")) xd->cb = Rcairo_new_ps_backend(xd->cb, conn, file, w, h); else if (!strcmp(type,"svg")) xd->cb = Rcairo_new_svg_backend(xd->cb, conn, file, w, h); } else { /* following devices are pixel-based yet supporting umpl */ if (umpl>0 && xd->dpix>0) { /* convert if we can */ if (xd->dpiy <= 0) xd->dpiy=xd->dpix; w = w * umpl * xd->dpix; h = h * umpl * xd->dpiy; umpl = -1; } /* otherwise device's dpi will be used */ xd->cb->width = w; xd->cb->height = h; /* also following devices are opaque UI-devices */ xd->cb->flags |= CDF_HAS_UI|CDF_OPAQUE; if (!strcmp(type,"x11") || !strcmp(type,"X11") || !strcmp(type,"xlib")) xd->cb = Rcairo_new_xlib_backend(xd->cb, file, w, h, umpl); else if (!strncmp(type,"win",3)) xd->cb = Rcairo_new_w32_backend(xd->cb, file, w, h, umpl); else { error("Unsupported output type \"%s\" - choose from png, png24, jpeg, tiff, pdf, ps, svg, win and x11.", type); return FALSE; } } if (!xd->cb) { error("Failed to create Cairo backend!"); return FALSE; } /* get modified dpi in case the backend has set it */ xd->dpix = xd->cb->dpix; xd->dpiy = xd->cb->dpiy; if (xd->dpix>0 && xd->dpiy>0) xd->asp = xd->dpix / xd->dpiy; Rcairo_backend_init_surface(xd->cb); /* cc = xd->cb->cc; cairo_save(cc); */ #ifdef JGD_DEBUG Rprintf("open [type='%s'] %d x %d (flags %04x)\n", type, (int)w, (int)h, xd->cb->flags); #endif return TRUE; } static void CairoGD_Path(double *x, double *y, int npoly, int *nper, Rboolean winding, R_GE_gcontext *gc, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb || !nper || npoly < 1) return; { int i, j, n; cairo_t *cc = xd->cb->cc; Rcairo_set_line(xd, gc); #ifdef JGD_DEBUG Rprintf("path %d polygons [%08x/%08x]\n", npoly, gc->col, gc->fill); #endif cairo_new_path(cc); n = 0; for (i = 0; i < npoly; i++) { cairo_move_to(cc, x[n], y[n]); n++; for(j = 1; j < nper[i]; j++) { cairo_line_to(cc, x[n], y[n]); n++; } cairo_close_path(cc); } if (CALPHA(gc->fill)) { if (winding) cairo_set_fill_rule(cc, CAIRO_FILL_RULE_WINDING); else cairo_set_fill_rule(cc, CAIRO_FILL_RULE_EVEN_ODD); Rcairo_set_color(cc, gc->fill); cairo_fill_preserve(cc); } if (CALPHA(gc->col) && gc->lty != -1) { Rcairo_set_color(cc, gc->col); cairo_stroke(cc); } else cairo_new_path(cc); xd->cb->serial++; } } static void CairoGD_Polygon(int n, double *x, double *y, R_GE_gcontext *gc, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb || n<2) return; { int i=1; cairo_t *cc = xd->cb->cc; Rcairo_set_line(xd, gc); #ifdef JGD_DEBUG Rprintf("polygon %d points [%08x/%08x]\n", n, gc->col, gc->fill); #endif cairo_new_path(cc); cairo_move_to(cc, x[0], y[0]); while (ifill)) { Rcairo_set_color(cc, gc->fill); cairo_fill_preserve(cc); } if (CALPHA(gc->col) && gc->lty!=-1) { Rcairo_set_color(cc, gc->col); cairo_stroke(cc); } else cairo_new_path(cc); xd->cb->serial++; } } static void CairoGD_Polyline(int n, double *x, double *y, R_GE_gcontext *gc, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb || n<2) return; { int i=1; cairo_t *cc = xd->cb->cc; #ifdef JGD_DEBUG Rprintf("poly-line %d points [%08x]\n", n, gc->col); #endif if (CALPHA(gc->col) && gc->lty!=-1) { cairo_new_path(cc); cairo_move_to(cc, x[0], y[0]); while (icol); Rcairo_set_line(xd, gc); cairo_stroke(cc); xd->cb->serial++; } } } static void CairoGD_Rect(double x0, double y0, double x1, double y1, R_GE_gcontext *gc, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb) return; { cairo_t *cc = xd->cb->cc; double snap_add = 0.0; if (x1col, gc->fill); #endif /* Snap to grid so that image() plots and rectangles look nicer, but only if the backend wishes so */ if (xd->cb->truncate_rect) { cairo_user_to_device(cc,&x0,&y0); cairo_user_to_device(cc,&x1,&y1); x0 = trunc(x0); x1 = trunc(x1); y0 = trunc(y0); y1 = trunc(y1); cairo_device_to_user(cc,&x0,&y0); cairo_device_to_user(cc,&x1,&y1); snap_add=1; } cairo_new_path(cc); cairo_rectangle(cc, x0, y0, x1-x0+snap_add, y1-y0+snap_add); if (CALPHA(gc->fill)) { Rcairo_set_color(cc, gc->fill); cairo_fill_preserve(cc); } if (CALPHA(gc->col) && gc->lty!=-1) { /* if we are snapping, note that lines must be in 0.5 offset to fills in order hit the same pixels, because lines extend to both sides */ if (xd->cb->truncate_rect) { cairo_new_path(cc); cairo_rectangle(cc, x0+0.5, y0+0.5, x1-x0, y1-y0); } Rcairo_set_color(cc, gc->col); cairo_stroke(cc); } else cairo_new_path(cc); xd->cb->serial++; } } static void CairoGD_Raster(unsigned int *raster, int w, int h, double x, double y, double width, double height, double rot, Rboolean interpolate, R_GE_gcontext *gc, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb) return; { /* the code in this block has been adapted from R 2.12.1, src/modules/X11/cairoX11.c (c) 2010 R Development Core Team under GPL 2+ */ cairo_t *cc = xd->cb->cc; cairo_surface_t *image; unsigned char *imageData; int i; cairo_save(cc); cairo_translate(cc, x, y); if (rot != 0.0) cairo_rotate(cc, -rot * M_PI/180); if (w != width || h != height) cairo_scale(cc, width / w, height / h); /* Flip vertical first */ cairo_translate(cc, 0, h / 2.0); cairo_scale(cc, 1, -1); cairo_translate(cc, 0, -h / 2.0); /* allocate data and transform to pre-mpl alpha */ imageData = (unsigned char *) malloc(4*w*h); for (i = 0; i < w * h; i++) { int alpha = R_ALPHA(raster[i]); imageData[i*4 + 3] = alpha; if (alpha < 255) { imageData[i*4 + 2] = R_RED(raster[i]) * alpha / 255; imageData[i*4 + 1] = R_GREEN(raster[i]) * alpha / 255; imageData[i*4 + 0] = R_BLUE(raster[i]) * alpha / 255; } else { imageData[i*4 + 2] = R_RED(raster[i]); imageData[i*4 + 1] = R_GREEN(raster[i]); imageData[i*4 + 0] = R_BLUE(raster[i]); } } image = cairo_image_surface_create_for_data(imageData, CAIRO_FORMAT_ARGB32, w, h, 4 * w); cairo_set_source_surface(cc, image, 0, 0); if (interpolate) { cairo_pattern_set_filter(cairo_get_source(cc), CAIRO_FILTER_BILINEAR); cairo_pattern_set_extend(cairo_get_source(cc), CAIRO_EXTEND_PAD); } else cairo_pattern_set_filter(cairo_get_source(cc), CAIRO_FILTER_NEAREST); cairo_new_path(cc); cairo_rectangle(cc, 0, 0, w, h); cairo_clip(cc); cairo_paint(cc); cairo_restore(cc); cairo_surface_destroy(image); free(imageData); xd->cb->serial++; } } static void CairoGD_Size(double *left, double *right, double *bottom, double *top, NewDevDesc *dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; if(!xd || !xd->cb) return; *left=*top=0.0; *right=xd->cb->width; *bottom=xd->cb->height; } /* NOTE: encoding is only used for the Harfbuzz implementation which converts everything to UTF-16 before processing so in fact any input encoding will work. All other paths pass the string through as-is so rely on cairo handing UTF-8 and R using TextUTF8 and StrWidthUTF8. */ static double CairoGD_StrWidthEnc(constxt char *str, R_GE_gcontext *gc, NewDevDesc *dd, const char *encoding) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; int slen = strlen(str); if (!str) return 0; if(!xd || !xd->cb) return slen*8; Rcairo_setup_font(xd, gc); #if R_VERSION >= R_Version(4,0,0) if (gc->fontface == 5 && !Rcairo_symbol_font_use_pua) str = utf8Toutf8NoPUA(str); #endif { cairo_t *cc = xd->cb->cc; cairo_text_extents_t te = {0, 0, 0, 0, 0, 0}; #ifdef HAVE_HARFBUZZ rc_text_shape *ts = c_setup_glyphs(xd, gc, str, encoding); cairo_glyph_extents(cc, ts->glyph, ts->glyphs, &te); #else cairo_text_extents(cc, str, &te); #endif /* Cairo doesn't take into account whitespace char widths, * but the x_advance does */ return te.x_advance; } } static double CairoGD_StrWidthUTF8(constxt char *str, R_GE_gcontext *gc, NewDevDesc *dd) { return CairoGD_StrWidthEnc(str, gc, dd, "UTF-8"); } static double CairoGD_StrWidthNative(constxt char *str, R_GE_gcontext *gc, NewDevDesc *dd) { return CairoGD_StrWidthEnc(str, gc, dd, ""); } static void CairoGD_TextEnc(double x, double y, constxt char *str, double rot, double hadj, R_GE_gcontext *gc, NewDevDesc *dd, const char *encoding) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; cairo_t *cc; if(!xd || !xd->cb) return; cc = xd->cb->cc; Rcairo_setup_font(xd,gc); #ifdef JGD_DEBUG Rprintf("text (encoding '%s') \"%s\" face %d %f:%f rot=%f hadj=%f [%08x:%08x]\n", encoding, str, gc->fontface, x, y, rot, hadj, gc->col, gc->fill); #endif #if R_VERSION >= R_Version(4,0,0) if (gc->fontface == 5 && !Rcairo_symbol_font_use_pua) str = utf8Toutf8NoPUA(str); #endif #ifdef HAVE_HARFBUZZ rc_text_shape *ts = c_setup_glyphs(xd, gc, str, encoding); #endif cairo_save(cc); cairo_translate(cc, x, y); if (hadj!=0. || rot!=0.) { cairo_text_extents_t te = {0, 0, 0, 0, 0, 0}; #ifdef HAVE_HARFBUZZ cairo_glyph_extents(cc, ts->glyph, ts->glyphs, &te); #else cairo_text_extents(cc, str, &te); #endif if (rot!=0.) cairo_rotate(cc, - rot / 180. * M_PI); if (hadj!=0.) cairo_translate(cc, -te.x_advance*hadj, 0); /* Rcairo_set_color(cc, 0xff80ff); */ } Rcairo_set_color(cc, gc->col); #ifdef HAVE_HARFBUZZ cairo_show_glyphs(cc, ts->glyph, ts->glyphs); #else cairo_move_to(cc, 0, 0); cairo_show_text(cc, str); #endif xd->cb->serial++; #ifdef JGD_DEBUG { cairo_text_extents_t te = {0, 0, 0, 0, 0, 0}; #ifdef HAVE_HARFBUZZ cairo_glyph_extents(cc, ts->glyph, ts->glyphs, &te); #else cairo_text_extents(cc, str, &te); #endif if (hadj!=0.) x = x - (te.x_advance*hadj); /* debug - mark the origin of the text */ Rcairo_set_color(cc, 0x8080ff); cairo_new_path(cc); cairo_move_to(cc,x-3.,y); cairo_line_to(cc,x+3.,y); cairo_stroke(cc); cairo_new_path(cc); cairo_move_to(cc,x,y-3.); cairo_line_to(cc,x,y+3.); cairo_stroke(cc); x = x + te.x_advance; cairo_new_path(cc); cairo_move_to(cc,x-3.,y); cairo_line_to(cc,x+3.,y); cairo_stroke(cc); cairo_new_path(cc); cairo_move_to(cc,x,y-3.); cairo_line_to(cc,x,y+3.); cairo_stroke(cc); } #endif cairo_restore(cc); } static void CairoGD_TextUTF8(double x, double y, constxt char *str, double rot, double hadj, R_GE_gcontext *gc, NewDevDesc *dd) { CairoGD_TextEnc(x, y, str, rot, hadj, gc, dd, "UTF-8"); } static void CairoGD_TextNative(double x, double y, constxt char *str, double rot, double hadj, R_GE_gcontext *gc, NewDevDesc *dd) { CairoGD_TextEnc(x, y, str, rot, hadj, gc, dd, ""); } static SEXP CairoGD_setPattern(SEXP pattern, pDevDesc dd) { return R_NilValue; } static void CairoGD_releasePattern(SEXP ref, pDevDesc dd) { } static SEXP CairoGD_setClipPath(SEXP path, SEXP ref, pDevDesc dd) { return R_NilValue; } static void CairoGD_releaseClipPath(SEXP ref, pDevDesc dd) {} static SEXP CairoGD_setMask(SEXP path, SEXP ref, pDevDesc dd) { return R_NilValue; } static void CairoGD_releaseMask(SEXP ref, pDevDesc dd) {} /** fill the R device structure with callback functions */ void Rcairo_setup_gd_functions(NewDevDesc *dd) { dd->close = CairoGD_Close; dd->activate = CairoGD_Activate; dd->deactivate = CairoGD_Deactivate; dd->size = CairoGD_Size; dd->newPage = CairoGD_NewPage; dd->clip = CairoGD_Clip; dd->strWidth = CairoGD_StrWidthNative; dd->text = CairoGD_TextNative; dd->rect = CairoGD_Rect; dd->circle = CairoGD_Circle; dd->line = CairoGD_Line; dd->polyline = CairoGD_Polyline; dd->polygon = CairoGD_Polygon; dd->locator = CairoGD_Locator; dd->mode = CairoGD_Mode; dd->metricInfo = CairoGD_MetricInfo; #if R_GE_version >= 4 dd->hasTextUTF8 = TRUE; dd->strWidthUTF8 = CairoGD_StrWidthUTF8; dd->textUTF8 = CairoGD_TextUTF8; dd->wantSymbolUTF8 = TRUE; #if R_GE_version >= 6 dd->raster = CairoGD_Raster; dd->cap = CairoGD_Cap; #if R_GE_version >= 8 dd->path = CairoGD_Path; #if R_GE_version >= 9 dd->holdflush = CairoGD_HoldFlush; #if R_GE_version >= 13 dd->setPattern = CairoGD_setPattern; dd->releasePattern = CairoGD_releasePattern; dd->setClipPath = CairoGD_setClipPath; dd->releaseClipPath = CairoGD_releaseClipPath; dd->setMask = CairoGD_setMask; dd->releaseMask = CairoGD_releaseMask; #endif #endif #endif #endif #endif } void Rcairo_backend_resize(Rcairo_backend *be, double width, double height) { if (!be || !be->dd) return; if (be->resize) { CairoGDDesc *xd = (CairoGDDesc *) be->dd->deviceSpecific; if(!xd) return; /* Rprintf("cairotalk.resize(%d,%d) %d:%d %dx%d\n", width, height, be->dd->top, be->dd->left, be->dd->right, be->dd->bottom); */ be->width=width; be->height=height; be->dd->size(&(be->dd->left), &(be->dd->right), &(be->dd->bottom), &(be->dd->top), be->dd); be->resize(be, width, height); } } void Rcairo_backend_repaint(Rcairo_backend *be) { if (!be || !be->dd) return; { int devNum = ndevNumber(be->dd); if (devNum > 0) { be->in_replay = 1; GEplayDisplayList(GEgetDevice(devNum)); be->in_replay = 0; if (be->mode) be->mode(be, -1); } } } void Rcairo_backend_kill(Rcairo_backend *be) { if (!be || !be->dd) return; GEkillDevice(desc2GEDesc(be->dd)); } static int has_initd_fc = 0; void Rcairo_backend_init_surface(Rcairo_backend *be) { cairo_t *cc = be->cc; /* clearing of the surface is done directly in NewPage */ /* CairoGDDesc *cd = (CairoGDDesc *) be->dd->deviceSpecific; */ cairo_reset_clip(cc); #if USE_CAIRO_FT /* Ensure that fontconfig library is ready */ if (!has_initd_fc && !FcInit ()) error ("Can't init font config library\n"); has_initd_fc = 1; /* Ensure that freetype library is ready */ if (!Rcairo_ft_library && FT_Init_FreeType(&Rcairo_ft_library)) error("Failed to initialize freetype library in CairoGD_Open!\n"); if (Rcairo_fonts[0].face == NULL) Rcairo_set_font(0,"Helvetica:style=Regular"); if (Rcairo_fonts[1].face == NULL) Rcairo_set_font(1,"Helvetica:style=Bold"); if (Rcairo_fonts[2].face == NULL) Rcairo_set_font(2,"Helvetica:style=Italic"); if (Rcairo_fonts[3].face == NULL) Rcairo_set_font(3,"Helvetica:style=Bold Italic,BoldItalic"); if (Rcairo_fonts[4].face == NULL) Rcairo_set_font(4,"Symbol"); #else cairo_select_font_face (cc, "Helvetica", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); set_cf_antialias(cc); cairo_set_font_size (cc, 14); #endif } /* add any new back-ends to this list */ void Rcairo_register_builtin_backends(void) { if (RcairoBackendDef_image) Rcairo_register_backend(RcairoBackendDef_image); if (RcairoBackendDef_pdf) Rcairo_register_backend(RcairoBackendDef_pdf); if (RcairoBackendDef_ps) Rcairo_register_backend(RcairoBackendDef_ps); if (RcairoBackendDef_svg) Rcairo_register_backend(RcairoBackendDef_svg); if (RcairoBackendDef_xlib) Rcairo_register_backend(RcairoBackendDef_xlib); if (RcairoBackendDef_w32) Rcairo_register_backend(RcairoBackendDef_w32); } static const R_CallMethodDef callMethods[] = { {"Cairo_get_serial", (DL_FUNC) &Cairo_get_serial, 1}, {"Cairo_set_onSave", (DL_FUNC) &Cairo_set_onSave, 2}, {"Rcairo_capture", (DL_FUNC) &Rcairo_capture, 1}, {"Rcairo_initialize", (DL_FUNC) &Rcairo_initialize, 0}, {"Rcairo_snapshot", (DL_FUNC) &Rcairo_snapshot, 2}, {"Rcairo_supported_types", (DL_FUNC) &Rcairo_supported_types, 0}, {"get_img_backplane", (DL_FUNC) &get_img_backplane, 1}, {"ptr_to_raw", (DL_FUNC) &ptr_to_raw, 3}, {"raw_to_ptr", (DL_FUNC) &raw_to_ptr, 5}, {NULL, NULL, 0} }; static const R_ExternalMethodDef externalMethods[] = { {"cairo_create_new_device", (DL_FUNC) &cairo_create_new_device, -1}, {"cairo_font_match", (DL_FUNC) &cairo_font_match, -1}, {"cairo_font_set", (DL_FUNC) &cairo_font_set, -1}, {NULL, NULL, 0} }; void attribute_visible R_init_Cairo(DllInfo *dll) { R_registerRoutines(dll, 0, callMethods, 0, externalMethods); R_useDynamicSymbols(dll, FALSE); /* R_forceSymbols(dll, TRUE); */ } /* called on load */ SEXP Rcairo_initialize(void) { Rcairo_register_builtin_backends(); return R_NilValue; } /* this is a shortcut for dev.capture(native=TRUE) that also works in onSave (R disables the device before calling Close so you can't use dev.capture) */ SEXP Rcairo_capture(SEXP dev) { int devNr = asInteger(dev) - 1; GEDevDesc *gd = GEgetDevice(devNr); if (gd) { NewDevDesc *dd = gd->dev; if (dd) { SEXP res = CairoGD_Cap(dd); if (res != R_NilValue) { PROTECT(res); setAttrib(res, R_ClassSymbol, mkString("nativeRaster")); UNPROTECT(1); return res; } } } Rf_error("Unable to capture content - not a valid image backend Cairo device"); return R_NilValue; } SEXP Rcairo_snapshot(SEXP dev, SEXP sLast) { int last = asInteger(sLast); int devNr = asInteger(dev) - 1; GEDevDesc *gd = GEgetDevice(devNr); if (!gd) Rf_error("invalid device"); return last ? gd->savedSnapshot : GEcreateSnapshot(gd); } Cairo/src/ps-backend.h0000644000175100001440000000047514531200444014277 0ustar hornikusers#ifndef __CAIRO_PS_BACKEND_H__ #define __CAIRO_PS_BACKEND_H__ #include "backend.h" #if CAIRO_HAS_PS_SURFACE #include #endif extern Rcairo_backend_def *RcairoBackendDef_ps; Rcairo_backend *Rcairo_new_ps_backend(Rcairo_backend *be, int conn, const char *filename, double width, double height); #endif Cairo/src/img-tiff.h0000644000175100001440000000100614531200444013761 0ustar hornikusers#ifndef __IMG_TIFF_H__ #define __IMG_TIFF_H__ /* compression values: */ #define TIFF_COMPR_NONE 1 #define TIFF_COMPR_RLE 2 #define TIFF_COMPR_LZW 5 #define TIFF_COMPR_JPEG 7 /* the source is assumed to be 32-bit aligned pixels plane (even if channels=3) in native endianness format. really supported are only channels values 3 (RGB Tiff) and 4 (RGBA Tiff). compression value of 0 means that no flag will be set */ int save_tiff_file(void *buf, int w, int h, char *fn, int channels, int compression); #endif Cairo/src/cairogd.c0000644000175100001440000003646614531200444013704 0ustar hornikusers/* -*- mode: C; tab-width: 4; c-basic-offset: 4 -*- * Cairo-based gd (C)2004,5,7 Simon Urbanek (simon.urbanek@r-project.org) * * Parts of this code are based on the X11 device skeleton from the R project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define R_CairoGD 1 #include "cairogd.h" #include "cairotalk.h" #include "img-backend.h" double jGDdpiX = 100.0; double jGDdpiY = 100.0; double jGDasp = 1.0; #ifdef USE_GAMMA /* actually we use it in cairotalk as well - we may want to do soemthing about it ... */ static SEXP findArg(char *name, SEXP list) { SEXP ns = install(name); while (list && list!=R_NilValue) { if (TAG(list)==ns) return CAR(list); list=CDR(list); } return 0; } #endif /* type: png[24] file: file to write to width/heigth initps: initial PS bgcolor: currently only -1 (transparent) and 0xffffff (white) are really supported - gamma: 0.6 */ Rboolean Rcairo_new_device_driver(NewDevDesc *dd, const char *type, int conn, const char *file, double width, double height, double initps, int bgcolor, int canvas, double umul, double *dpi, SEXP aux) { CairoGDDesc *xd; double dpi_exX = 1.0, dpi_exY = 1.0; #ifdef JGD_DEBUG Rprintf("Rcairo_new_device_driver(\"%s\", \"%s\", %f, %f, %f)\n",type,file,width,height,initps); #endif /* allocate new device description */ if (!(xd = (CairoGDDesc*)calloc(1, sizeof(CairoGDDesc)))) return FALSE; #ifdef USE_MAGIC xd->magic = CAIROGD_MAGIC #endif xd->fontface = -1; xd->fontsize = -1; xd->basefontface = 1; xd->basefontsize = initps; xd->canvas = canvas; xd->bg = bgcolor; xd->gamma = 1.0; #ifdef USE_GAMMA { SEXP g = findArg("gamma", aux); if (g ** g!=R_NilValue) xd->gamma = asReal(g); } #endif xd->asp = 1.0; if (dpi) { xd->dpix = dpi[0]; xd->dpiy = dpi[1]; /* FIXME: Pango uses 96dpi - do we care or are we always going through FT such that 72dpi is correct? */ dpi_exX = dpi[0] / 72.0; dpi_exY = dpi[1] / 72.0; if (dpi_exX == 0.0) dpi_exX = 1.0; if (dpi_exY == 0.0) dpi_exY = 1.0; if (xd->dpix > 0.0 && xd->dpiy > 0.0) xd->asp = xd->dpix / xd->dpiy; } else xd->dpix = xd->dpiy = 0.0; /* ---- fill dd ----- */ /* Set up Data Structures. */ Rcairo_setup_gd_functions(dd); dd->left = dd->clipLeft = 0; /* left */ dd->top = dd->clipTop = 0; /* top */ /* Nominal Character Sizes in Pixels */ dd->cra[0] = 0.9 * initps * dpi_exX; /* FIXME: we should use font metric for this */ dd->cra[1] = 1.2 * initps * dpi_exY; /* adjust font size according to the DPI scalig. FIXME: we have no way of supporting non-square pixels? */ xd->fontscale = dpi_exX; /* Character Addressing Offsets */ /* These are used to plot a single plotting character */ /* so that it is exactly over the plotting point */ dd->xCharOffset = 0.4900; dd->yCharOffset = 0.3333; dd->yLineBias = 0.1; /* Device capabilities */ #if R_GE_version < 4 dd->canResizePlot = TRUE; /* opt */ dd->canChangeFont = TRUE; dd->canRotateText = TRUE; dd->canResizeText = TRUE; #endif dd->canClip = TRUE; dd->canHAdj = 2; dd->canChangeGamma = FALSE; dd->startlty = LTY_SOLID; dd->startfont = 1; /* set default behavior - backends should change it where they diverge from the default */ #if R_GE_version >= 9 dd->haveRaster = 2; /* yes */ dd->haveTransparency = 2; /* yes */ dd->haveTransparentBg = 3;/* yes, full alpha range */ dd->haveCapture = 2; /* yes */ dd->haveLocator = 2; /* yes */ #endif #if R_GE_version >= 13 dd->deviceVersion = R_GE_definitions; #endif dd->deviceSpecific = (void *) xd; #ifdef JGD_DEBUG Rprintf("Cairo-Open, dimensions: %f x %f, umul=%f, dpi=%f/%f\n", width, height, umul, xd->dpix, xd->dpiy); #endif /* open the device */ if (!CairoGD_Open(dd, xd, type, conn, file, width, height, umul, aux) || !xd->cb) { free(xd); dd->deviceSpecific = 0; return FALSE; } #if R_GE_version < 5 if (!xd->cb->resize) dd->canResizePlot = FALSE; #endif /* those were deferred, because they depend on xd and Open may have modified them */ dd->right = dd->clipRight = xd->cb->width; /* right */ dd->bottom = dd->clipBottom = xd->cb->height; /* bottom */ dd->startps = xd->basefontsize; /* = initps */ dd->startcol = xd->col; dd->startfill = xd->fill; dd->startgamma = xd->gamma; /* Inches per raster unit */ if (xd->dpix > 0 && xd->dpiy <= 0) xd->dpiy = xd->dpix; dd->ipr[0] = (xd->dpix > 0)?(1/xd->dpix):(1.0/72.0); dd->ipr[1] = (xd->dpiy > 0)?(1/xd->dpiy):(1.0/72.0); #if R_GE_version < 4 dd->asp = (xd->asp > 0)?xd->asp:1.0; #endif #ifdef JGD_DEBUG Rprintf("Cairo-Open, returned: %f x %f, dpi=%f/%f\n", xd->cb->width, xd->cb->height, xd->dpix, xd->dpiy); Rprintf(" ipr=%f/%f (1/ipr)=%f/%f\n", dd->ipr[0], dd->ipr[1], 1/dd->ipr[0], 1/dd->ipr[1]); #endif dd->displayListOn = TRUE; return(TRUE); } SEXP cairo_create_new_device(SEXP args) { NewDevDesc *dev = NULL; GEDevDesc *dd; const char *devname="Cairo"; const char *type, *file = NULL; double width, height, initps, umul, dpi[2]; int bgcolor = -1, canvas = -1; int conn = -1; SEXP v; args=CDR(args); v=CAR(args); args=CDR(args); if (!isString(v) || LENGTH(v)<1) error("output type must be a string"); PROTECT(v); type=CHAR(STRING_ELT(v,0)); UNPROTECT(1); v=CAR(args); args=CDR(args); if (isString(v)){ PROTECT(v); file=CHAR(STRING_ELT(v,0)); UNPROTECT(1); } else if (isInteger(v)){ #ifdef HAVE_RCONN_H conn = asInteger(v); #else error("file must be a filename. to support writing to a connection, recompile R and Cairo with the R Connection Patch. "); #endif } else { error("file must be a filename"); } v=CAR(args); args=CDR(args); if (!isNumeric(v)) error("`width' must be a number"); width=asReal(v); v=CAR(args); args=CDR(args); if (!isNumeric(v)) error("`height' must be a number"); height=asReal(v); v=CAR(args); args=CDR(args); if (!isNumeric(v)) error("initial point size must be a number"); initps=asReal(v); v=CAR(args); args=CDR(args); if (!isString(v) && !isInteger(v) && !isLogical(v) && !isReal(v)) error("invalid color specification for `bg'"); bgcolor = RGBpar(v, 0); v=CAR(args); args=CDR(args); if (!isString(v) && !isInteger(v) && !isLogical(v) && !isReal(v)) error("invalid color specification for `canvas'"); canvas = RGBpar(v, 0); v=CAR(args); args=CDR(args); if (!isNumeric(v)) error("unit multiplier must be a number"); umul = asReal(v); v=CAR(args); args=CDR(args); if (!isNumeric(v)) error("dpi must be a number"); dpi[0] = dpi[1] = asReal(v); #ifdef JGD_DEBUG Rprintf("type=%s, file=%s, bgcolor=0x%08x, canvas=0x%08x, umul=%f, dpi=%f\n", type, file, bgcolor, canvas, umul, dpi[0]); #endif R_GE_checkVersionOrDie(R_GE_version); R_CheckDeviceAvailable(); BEGIN_SUSPEND_INTERRUPTS { if (!(dev = (NewDevDesc*)calloc(1, sizeof(NewDevDesc)))) return R_NilValue; #if R_GE_version < 4 dev->newDevStruct = 1; #endif #if R_GE_version < 5 dev->displayList = R_NilValue; dev->savedSnapshot = R_NilValue; #endif if (!Rcairo_new_device_driver(dev, type, conn, file, width, height, initps, bgcolor, canvas, umul, dpi, args)) { free(dev); error("unable to start device %s", devname); } gsetVar(PROTECT(install(".Device")), PROTECT(mkString(devname)), R_NilValue); UNPROTECT(2); dd = GEcreateDevDesc(dev); GEaddDevice(dd); GEinitDisplayList(dd); } END_SUSPEND_INTERRUPTS; #ifdef JGD_DEBUG Rprintf("CairoGD> devNum=%d, dd=%x\n", 1 + GEdeviceNumber(dd), dd); #endif v = ScalarInteger(1 + GEdeviceNumber(dd)); return v; } void cairo_set_display_param(double *par) { jGDdpiX = par[0]; jGDdpiY = par[1]; jGDasp = par[2]; } void cairo_get_display_param(double *par) { par[0] = jGDdpiX; par[1] = jGDdpiY; par[2] = jGDasp; } void gdd_get_version(int *ver) { *ver=CAIROGD_VER; } SEXP cairo_font_match(SEXP args){ #if USE_CAIRO_FT SEXP v; const char *fcname; int sort; int verbose; args = CDR(args); /* Get fontname */ v = CAR(args); args = CDR(args); if (!isString(v) || LENGTH(v)<1){ warning("fontname must be a character vector of length 1\n"); return R_NilValue; } fcname = CHAR(STRING_ELT(v,0)); /* Get sort option */ v=CAR(args); args=CDR(args); if (!isLogical(v) || LENGTH(v)<1){ warning("sort options must be a logical\n"); return R_NilValue; } sort = LOGICAL(v)[0]; /* Get verbose option */ v=CAR(args); args=CDR(args); if (!isLogical(v) || LENGTH(v)<1){ warning("verbose options must be a logical\n"); return R_NilValue; } verbose = LOGICAL(v)[0]; /* Now search for fonts */ { FcFontSet *fs; FcPattern *pat; FcResult result; if (!FcInit ()) { warning ("Can't init font config library\n"); return R_NilValue; } pat = FcNameParse ((FcChar8 *)fcname); if (!pat){ warning ("Problem with font config library in FcNameparse\n"); return R_NilValue; } FcConfigSubstitute (0, pat, FcMatchPattern); FcDefaultSubstitute (pat); if (sort) { fs = FcFontSort (0, pat, FcTrue, 0, &result); } else { FcPattern *match; fs = FcFontSetCreate (); match = FcFontMatch (0, pat, &result); if (match) FcFontSetAdd (fs, match); } FcPatternDestroy (pat); if (fs) { int j; for (j = 0; j < fs->nfont; j++) { FcChar8 *family; FcChar8 *style; FcChar8 *file; if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &file) != FcResultMatch) file = (FcChar8 *) ""; /* else { FcChar8 *slash = (FcChar8 *) strrchr ((char *) file, '/'); if (slash) file = slash+1; } */ if (FcPatternGetString (fs->fonts[j], FC_FAMILY, 0, &family) != FcResultMatch) family = (FcChar8 *) ""; if (FcPatternGetString (fs->fonts[j], FC_STYLE, 0, &style) != FcResultMatch) file = (FcChar8 *) ""; Rprintf ("%d. family: \"%s\", style: \"%s\", file: \"%s\"\n", j+1, family, style, file); if (verbose) { FcPattern *vpat; FcChar8 *fname; fname = FcNameUnparse(fs->fonts[j]); if (fname) { if ((vpat = FcNameParse(fname))) { FcPatternDel(vpat,FC_CHARSET); FcPatternDel(vpat,FC_LANG); free(fname); fname = FcNameUnparse(vpat); } Rprintf(" \"%s\"\n",fname); free(fname); FcPatternDestroy(vpat); } } } FcFontSetDestroy (fs); } } #else warning("the R Cairo package was not installed with font matching capability. Please consider installing the cairo graphics engine (www.cairographics.org) with freetype and fontconfig support"); #endif return R_NilValue; } SEXP cairo_font_set(SEXP args){ #if USE_CAIRO_FT SEXP v; int i; const char *font; args = CDR(args); /* 0-3 = regular, 4 = symbol, 5 = PUA */ for (i = 0; i < 5; i++){ v = CAR(args); args = CDR(args); if (!isNull(v) && isString(v) && LENGTH(v)==1){ font = CHAR(STRING_ELT(v,0)); Rcairo_set_font(i, font); } } v = CAR(args); if (!isNull(v)) { int pua = asInteger(v) ? 1 : 0; #if R_VERSION >= R_Version(4,0,0) Rcairo_symbol_font_use_pua = pua; #else if (!pua) warning("You R does not support symbol font without PUA, upgrade R to at least 4.0.0"); #endif /* !PUA (R 4.0.0) */ } #else /* FT_FONT */ #ifdef WIN32 warning("CairoFonts() has no effect on Windows. Please use par(family=\"...\") to specify the desired font - see ?par."); #else warning("The R Cairo package was not installed with fontconfig. Please consider installing the cairo graphics engine (www.cairographics.org) with freetype and fontconfig support"); #endif #endif return R_NilValue; } /* experimental */ SEXP get_img_backplane(SEXP dev) { int devNr = asInteger(dev)-1; GEDevDesc *gd = GEgetDevice(devNr); if (gd) { NewDevDesc *dd=gd->dev; if (dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; #ifdef USE_MAGIC if (xd->magic != CAIROGD_MAGIC) error("Not a Cairo device"); #endif if(xd && xd->cb) { int bet = xd->cb->backend_type; switch (bet) { case BET_IMAGE: { Rcairo_image_backend *image = (Rcairo_image_backend*) xd->cb->backendSpecific; SEXP l = allocVector(VECSXP, 2); unsigned char *data = image->buf; cairo_format_t dformat = image->format; int width = cairo_image_surface_get_width(xd->cb->cs); int height = cairo_image_surface_get_height(xd->cb->cs); PROTECT(l); { SEXP info = allocVector(INTSXP, 3); int *iv = INTEGER(info); iv[0] = width; iv[1] = height; iv[2] = dformat; SET_VECTOR_ELT(l, 1, info); } { SEXP ref = R_MakeExternalPtr(data, R_NilValue, R_NilValue); SET_VECTOR_ELT(l, 0, ref); } UNPROTECT(1); return l; } } error("unsupported backend"); } } } error("invalid device number"); return R_NilValue; } SEXP ptr_to_raw(SEXP ptr, SEXP off, SEXP len) { int o = asInteger(off); int l = asInteger(len); if (TYPEOF(ptr) != EXTPTRSXP) error("ptr argument must be an external pointer"); { unsigned char *data = (unsigned char*) EXTPTR_PTR(ptr); if (data) { SEXP v = allocVector(RAWSXP, l); Rbyte *rc = RAW(v); memcpy(rc, data+o, l); return v; } } return R_NilValue; } SEXP raw_to_ptr(SEXP ptr, SEXP woff, SEXP raw, SEXP roff, SEXP len) { int o1 = asInteger(woff); int o2 = asInteger(roff); int l = asInteger(len); if (TYPEOF(ptr) != EXTPTRSXP) error("ptr argument must be an external pointer"); if (TYPEOF(raw) != RAWSXP) error("raw argument must be a raw vector"); { unsigned char *data = (unsigned char*) EXTPTR_PTR(ptr); Rbyte *rc = RAW(raw); memcpy(data+o1, rc+o2, l); return ptr; } return R_NilValue; } SEXP Cairo_get_serial(SEXP dev) { int devNr = asInteger(dev) - 1; GEDevDesc *gd = GEgetDevice(devNr); if (gd) { NewDevDesc *dd = gd->dev; if (dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; #ifdef USE_MAGIC if (xd->magic != CAIROGD_MAGIC) error("Not a Cairo device"); #endif if(xd && xd->cb) return ScalarInteger(xd->cb->serial & 0x7ffffff); /* return 31-bit so it is easier to handle in R */ } } Rf_error("Not a valid Cairo device"); return R_NilValue; } SEXP Cairo_set_onSave(SEXP dev, SEXP fn) { int devNr = asInteger(dev) - 1; GEDevDesc *gd = GEgetDevice(devNr); if (gd) { NewDevDesc *dd = gd->dev; if (dd) { CairoGDDesc *xd = (CairoGDDesc *) dd->deviceSpecific; #ifdef USE_MAGIC if (xd->magic != CAIROGD_MAGIC) error("Not a Cairo device"); #endif if (xd && xd->cb) { SEXP old = xd->cb->onSave; if (!old) old = R_NilValue; if (fn != R_NilValue) { R_PreserveObject(fn); xd->cb->onSave = fn; } else xd->cb->onSave = 0; if (old != R_NilValue) R_ReleaseObject(old); return old; } } } Rf_error("Not a valid Cairo device"); return R_NilValue; } Cairo/src/cairotalk.h0000644000175100001440000000067214531200444014240 0ustar hornikusers#ifndef __JGD_TALK_H__ #define __JGD_TALK_H__ #ifdef HAVE_CONFIG_H # include #endif #include "cairogd.h" void Rcairo_setup_gd_functions(NewDevDesc *dd); Rboolean CairoGD_Open(NewDevDesc *dd, CairoGDDesc *xd, const char *type, int conn, const char *file, double w, double h, double umpl, SEXP aux); #if USE_CAIRO_FT void Rcairo_set_font(int i, const char *fcname); #endif extern int Rcairo_symbol_font_use_pua; #endif Cairo/src/xlib-backend.h0000644000175100001440000000051314531200444014604 0ustar hornikusers#ifndef __CAIRO_XLIB_BACKEND_H__ #define __CAIRO_XLIB_BACKEND_H__ #include "backend.h" #if CAIRO_HAS_XLIB_SURFACE #include #endif extern Rcairo_backend_def *RcairoBackendDef_xlib; Rcairo_backend *Rcairo_new_xlib_backend(Rcairo_backend *be, const char *display, double width, double height, double umpl); #endif Cairo/src/img-jpeg.c0000644000175100001440000000313514531200444013756 0ustar hornikusers/* -*- mode: C; tab-width: 4; c-basic-offset: 4 -*- Copyright (C) 2007 Simon Urbanek License: GPL v2 or GPL v3 */ #include "cconfig.h" #ifdef SUPPORTS_JPEG #include #include #include int save_jpeg_file(void *buf, int w, int h, char *fn, int quality, int channels) { struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; FILE *output_file = fopen(fn, "wb"); JSAMPROW slr; if (!output_file) return -1; if (channels!=3 && channels!=4) return -1; cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); cinfo.in_color_space = JCS_RGB; cinfo.input_components = 3; cinfo.image_width=w; cinfo.image_height=h; jpeg_set_defaults(&cinfo); jpeg_set_quality(&cinfo, quality, (quality<25)?0:1); jpeg_stdio_dest(&cinfo, output_file); jpeg_start_compress(&cinfo, TRUE); if (channels == 3) { unsigned char *src = (unsigned char*) buf; int sl = 0; while (sl> 16) & 255; dp[1] = (*src >> 8) & 255; dp[2] = *src & 255; src++; dp+=3; x++; } slr=dst; jpeg_write_scanlines(&cinfo, &slr, 1); sl++; } free(dst); } jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); fclose(output_file); return 0; } #else int save_jpeg_file(void *buf, int w, int h, char *fn, int quality, int channels) { return -2; } #endif Cairo/src/w32-backend.c0000644000175100001440000003026414531200444014262 0ustar hornikusers/* -*- mode: C; tab-width: 4; c-basic-offset: 4 -*- Created 4/11/2007 by Simon Urbanek Copyright (C) 2007 Simon Urbanek GA interface is partially based on devWindows.c from R License: GPL v2 or GPL v3 Conditionals: NATIVE_UI - if set, we use plain Win32 API (works for stand-alone or SDI apps), otherwise we use GraphApp from R. The latter is the default. */ #include #include #include "w32-backend.h" #if CAIRO_HAS_WIN32_SURFACE static const char *types_list[] = { "win", 0 }; static Rcairo_backend_def RcairoBackendDef_ = { BET_W32, types_list, "Windows", CBDF_VISUAL, 0 }; Rcairo_backend_def *RcairoBackendDef_w32 = &RcairoBackendDef_; /* --- GraphApp support --- we use GA from R headers --- */ #ifndef NATIVE_UI #include #undef resize /* this is an excerpt from internal.h objinfo structure we need it to get the window handle for native GDI */ typedef struct ga_objinfo { int kind; int refcount; HANDLE handle; } ga_object; #endif typedef struct { Rcairo_backend *be; /* back-link */ HWND wh; /* window handle */ HDC cdc; /* cache device context */ HDC hdc; /* window device context */ HBITMAP cb; /* cache bitmap */ int width; int height; #ifndef NATIVE_UI window gawin; /* GA window if we use graphapp */ #endif } Rcairo_w32_data; /*---- save page ----*/ static void w32_save_page(Rcairo_backend* be, int pageno){ cairo_show_page(be->cc); cairo_set_source_rgba(be->cc,1,1,1,1); cairo_reset_clip(be->cc); cairo_new_path(be->cc); cairo_paint(be->cc); } /*---- resize ----*/ static void w32_resize(Rcairo_backend* be, double width, double height){ Rcairo_w32_data *xd = (Rcairo_w32_data *) be->backendSpecific; RECT r; HBITMAP ob; HDC hdc; if (!xd) return; if (xd->cdc) { DeleteDC(xd->cdc); DeleteObject(xd->cb); } if (be->cs) { cairo_destroy(be->cc); be->cc=0; cairo_surface_destroy(be->cs); be->cs=0; } be->width=xd->width=width; be->height=xd->height=height; /* manage HDC -- we have to re-get it after resize due to clipping issues */ if (!xd->hdc) xd->hdc = GetDC( xd->wh ); else { ReleaseDC(xd->wh, xd->hdc); xd->hdc = GetDC( xd->wh ); } hdc=xd->hdc; /* first re-paint the window */ GetClientRect( xd->wh, &r ); /* Rprintf("w32_resize(%g,%g); rect=(%d,%d)-(%d,%d)\n", width, height, r.left, r.bottom, r.right, r.top); */ be->cs = cairo_win32_surface_create( hdc ); be->cc = cairo_create( be->cs ); Rcairo_backend_repaint(be); cairo_copy_page(be->cc); cairo_surface_flush(be->cs); /* then create a cached copy */ xd->cdc = CreateCompatibleDC( hdc ); xd->cb = CreateCompatibleBitmap( hdc, r.right, r.bottom ); ob = SelectObject(xd->cdc, xd->cb); BitBlt(xd->cdc, 0, 0, r.right, r.bottom, hdc, 0, 0, SRCCOPY); } /*---- mode ---- (-1=replay finished, 0=done, 1=busy, 2=locator) */ static void w32_mode(Rcairo_backend* be, int which){ Rcairo_w32_data *xd = (Rcairo_w32_data *) be->backendSpecific; if (be->in_replay) return; if (which < 1) { cairo_copy_page(be->cc); cairo_surface_flush(be->cs); /* upate cache */ if (xd->cdc) { DeleteDC(xd->cdc); DeleteObject(xd->cb); } xd->cdc = CreateCompatibleDC( xd->hdc ); xd->cb = CreateCompatibleBitmap( xd->hdc, xd->width, xd->height ); SelectObject(xd->cdc, xd->cb); BitBlt(xd->cdc, 0, 0, xd->width, xd->height, xd->hdc, 0, 0, SRCCOPY); } } /*---- locator ----*/ int w32_locator(struct st_Rcairo_backend *be, double *x, double *y) { Rcairo_w32_data *cd = (Rcairo_w32_data *) be->backendSpecific; return 0; } /*---- destroy ----*/ static void w32_backend_destroy(Rcairo_backend* be) { Rcairo_w32_data *xd = (Rcairo_w32_data *) be->backendSpecific; if (xd->cdc) { DeleteDC(xd->cdc); xd->cdc=0; DeleteObject(xd->cb); xd->cb=0; } if (xd->gawin) { del(xd->gawin); doevent(); xd->gawin=0; } else if (xd->wh) { DestroyWindow(xd->wh); } cairo_surface_destroy(be->cs); cairo_destroy(be->cc); free(be); } /*-----------------*/ #ifdef NATIVE_UI static int inited_w32 = 0; typedef struct w32chain_s { HWND w; window gawin; Rcairo_backend *be; struct w32chain_s *next; } w32chain_t; static w32chain_t wchain; static HWND parent; /* parent of all windows - i.e. the Rgui Workspace or similar */ static HINSTANCE instance; /* instance handle for the current process */ static int isMDI; /* set to 1 if we are hooked into Rgui's MDI, 0 otherwise */ static char* appname; /* name of the application we hook into (e.g. "Rgui") */ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { Rcairo_backend *be = 0; Rcairo_w32_data *xd = 0; w32chain_t *l = &wchain; while (l && l->be) { if (l->w == hwnd) { be = l->be; break; } l = l -> next; } if (!be) be=wchain.be; /*HACK: DEBUG: FIXME! */ if (!be) { { FILE *f=fopen("c:\\debug.txt","a"); fprintf(f,"Window: %x: be is NULL!\n", hwnd); fclose(f); } return isMDI?DefMDIChildProc(hwnd, uMsg, wParam, lParam):DefWindowProc(hwnd, uMsg, wParam, lParam); } xd = (Rcairo_w32_data*) be->backendSpecific; { FILE *f=fopen("c:\\debug.txt","a"); fprintf(f,"Window: %x, msg: %x, [%x, %x]\n", (unsigned int)hwnd, (unsigned int)uMsg, (unsigned int)wParam, (unsigned int)lParam); fclose(f); } switch (uMsg) { /* case WM_DESTROY: PostQuitMessage(0); break; case WM_QUERYENDSESSION: return((long) TRUE); // we agree to end session. */ case WM_CLOSE: DestroyWindow(hwnd); break; case WM_SIZE: { RECT r; GetClientRect( hwnd, &r ); { FILE *f=fopen("c:\\debug.txt","a"); fprintf(f," - WM_SIZE: %d x %d\n", r.right, r.bottom); fclose(f); } Rcairo_backend_resize(be, r.right, r.bottom); } return 0; case WM_PAINT: { RECT r, ur; { FILE *f=fopen("c:\\debug.txt","a"); fprintf(f," - WM_PAINT: %d\n", (int)GetUpdateRect(hwnd,&ur,1)); fclose(f); } if (GetUpdateRect(hwnd,&ur,1)) { PAINTSTRUCT ps; HDC wdc=BeginPaint(hwnd,&ps); GetClientRect( hwnd, &r ); BitBlt(wdc, 0, 0, r.right, r.bottom, xd->cdc, 0, 0, SRCCOPY); ValidateRect(hwnd, NULL); EndPaint(hwnd,&ps); } return 0; } default: return isMDI?DefMDIChildProc(hwnd, uMsg, wParam, lParam):DefWindowProc(hwnd, uMsg, wParam, lParam); } return 0; } BOOL CALLBACK EnumWin( HWND hwnd, LPARAM lParam) { char buf[128]; *buf=0; GetClassName(hwnd, buf, 127); Rprintf("win> %08x (%s)\n", hwnd, buf); return 1; } /* just for fun - an easter egg - never really used in Cairo */ void list_all_windows() { EnumWindows(&EnumWin,0); } static void get_R_window() { char mname[127]; char fn[64]; char *c = mname, *d = mname; instance = GetModuleHandle(0); GetModuleFileName(instance, mname, sizeof(mname)); Rprintf(" Module name: '%s'\n", mname); /* GetFileTitle(mname, fn, sizeof(fn)); we do this manually so we don't need -lcomdlg32 */ for (;*c;c++) if (*c=='/' || *c=='\\') d=c+1; c=d; while (*c) c++; c--; while (c>d && *c!='.') c--; if (*c=='.') *c=0; appname=strdup(d); strcpy(fn, d); strcat(fn, " Workspace"); parent=FindWindow(fn, 0); if (parent) isMDI = 1; else parent = FindWindow(appname, 0); } #else static void HelpClose(window w) { Rcairo_backend *be = (Rcairo_backend *) getdata(w); Rcairo_backend_kill(be); } static void HelpExpose(window w, rect r) { Rcairo_backend *be = (Rcairo_backend *) getdata(w); Rcairo_w32_data *xd = (Rcairo_w32_data *) be->backendSpecific; HWND hwnd = (HWND) ((ga_object*)(xd->gawin))->handle; RECT cr; HDC wdc=GetDC(hwnd); GetClientRect( hwnd, &cr ); /* if (cr.right != xd->width || cr.bottom != xd->height) { ReleaseDC(hwnd, wdc); Rprintf("HelpExpose: size mismatch, calling resize\n"); Rcairo_backend_resize(be, cr.right, cr.bottom); return; }*/ BitBlt(wdc, 0, 0, cr.right, cr.bottom, xd->cdc, 0, 0, SRCCOPY); ValidateRect(hwnd, NULL); ReleaseDC(hwnd, wdc); } static void HelpResize(window w, rect r) { Rcairo_backend *be = (Rcairo_backend *) getdata(w); Rcairo_backend_resize(be, r.width, r.height); } #endif Rcairo_backend *Rcairo_new_w32_backend(Rcairo_backend *be, const char *display, double width, double height, double umpl) { Rcairo_w32_data *xd; #ifdef NATIVE_UI w32chain_t *l = &wchain; #endif if ( ! (xd = (Rcairo_w32_data*) calloc(1,sizeof(Rcairo_w32_data)))) { free(be); return NULL; } be->backend_type = BET_W32; be->backendSpecific = xd; xd->be = be; be->destroy_backend = w32_backend_destroy; be->save_page = w32_save_page; be->resize = w32_resize; be->mode = w32_mode; be->locator = w32_locator; be->truncate_rect = 1; if (be->dpix<=0) { /* try to find out the DPI setting */ HWND dw = GetDesktopWindow(); if (dw) { HDC dc = GetDC(dw); if (dc) { int dpix = GetDeviceCaps(dc, LOGPIXELSX); int dpiy = GetDeviceCaps(dc, LOGPIXELSY); ReleaseDC(dw, dc); if (dpix>0) be->dpix=(double)dpix; if (dpiy>0) be->dpiy=(double)dpiy; } } } /* adjust width and height to be in pixels */ if (umpl>0 && be->dpix<=0) { be->dpix = 96; be->dpiy = 96; } if (be->dpiy==0 && be->dpix>0) be->dpiy=be->dpix; if (umpl>0) { width = width * umpl * be->dpix; height = height * umpl * be->dpiy; umpl=-1; } if (umpl!=-1) { width *= (-umpl); height *= (-umpl); } be->width = width; be->height = height; #ifdef NATIVE_UI if (!inited_w32) { WNDCLASS wc; get_R_window(); { FILE *f=fopen("c:\\debug.txt","w"); fprintf(f,"init W32; isMDI=%d, parent=%x\n", isMDI, (unsigned int) parent); fclose(f); } wc.style=0; wc.lpfnWndProc=WindowProc; wc.cbClsExtra=0; wc.cbWndExtra=0; wc.hInstance=instance; wc.hIcon=0; wc.hCursor=LoadCursor(NULL, IDC_ARROW); wc.hbrBackground=GetSysColorBrush(COLOR_WINDOW); wc.lpszMenuName=NULL; wc.lpszClassName="RCairoWindow"; RegisterClass(&wc); wc.cbWndExtra=/* CBWNDEXTRA */ 1024; wc.lpszClassName="RCairoDoc"; RegisterClass(&wc); inited_w32 = 1; } while (l->be && l->next) l=l->next; if (l->be) { l->next = (w32chain_t*) calloc(1,sizeof(w32chain_t)); l = l->next; } l->be = be; #else { window gawin = newwindow("Cairo Graphics", rect(20,20,width,height), Document|StandardWindow); xd->gawin = gawin; xd->wh = (HWND) ((ga_object*)gawin)->handle; addto(gawin); gsetcursor(gawin, ArrowCursor); if (ismdi()) { int btsize = 24; control tb; tb = newtoolbar(btsize + 4); gsetcursor(tb, ArrowCursor); addto(tb); } addto(gawin); newmenubar(NULL); newmdimenu(); show(gawin); /* twice, for a Windows bug */ show(gawin); BringToTop(gawin, 0); setresize(gawin, HelpResize); setredraw(gawin, HelpExpose); setclose(gawin, HelpClose); setdata(gawin, (void *) be); w32_resize(be, width, height); } #endif #ifdef NATIVE_UI if (isMDI) { HWND mdiClient; CLIENTCREATESTRUCT ccs; HMENU rm = GetMenu(parent); HMENU wm = GetSubMenu(rm, 4); ccs.hWindowMenu = wm; ccs.idFirstChild = 512+0xE000; /* from graphapp/internal.h -> MinDocID */ Rprintf("Menu = %x, Windows = %x, ID = %x\n", rm, wm, ccs.idFirstChild); mdiClient = CreateWindow("MDICLIENT","Cairo",WS_CHILD|WS_VISIBLE,CW_USEDEFAULT,CW_USEDEFAULT,width,height, parent,NULL,instance,&ccs); ShowWindow(mdiClient, SW_SHOW); Rprintf("mdiClient: %x\n", mdiClient); { MDICREATESTRUCT mcs; mcs.szTitle = "Cairo device"; mcs.szClass = "RCairoDoc"; mcs.hOwner = instance; mcs.x = CW_USEDEFAULT; mcs.cx = width; mcs.y = CW_USEDEFAULT; mcs.cy = height; mcs.style = WS_MAXIMIZE|WS_MINIMIZE|WS_CHILD|WS_VISIBLE; xd->wh = l->w = (HWND) SendMessage (mdiClient, WM_MDICREATE, 0, (LONG) (LPMDICREATESTRUCT) &mcs); Rprintf("MDICREATE result: %x\n", l->w); } { FILE *f=fopen("c:\\debug.txt","a"); fprintf(f,"parent: %x\nMDIclient: %x\ndoc: %x\n", parent, mdiClient, l->w); fclose(f); } } else { l->w = xd->wh = CreateWindow("RCairoWindow","Cairo",WS_OVERLAPPEDWINDOW, 100,100,width,height, parent,NULL,instance,NULL); } ShowWindow(xd->wh, SW_SHOWNORMAL); w32_resize(be, width, height); UpdateWindow(xd->wh); #endif return be; } #else Rcairo_backend_def *RcairoBackendDef_w32 = 0; Rcairo_backend *Rcairo_new_w32_backend(Rcairo_backend *be, const char *display, double width, double height, double umpl) { error("cairo library was compiled without win32 back-end."); return NULL; } #endif Cairo/src/Makevars.win0000644000175100001440000000042614531200444014403 0ustar hornikusersifdef DEBUG XTRA_PKG_CPPFLAGS=-DJGD_DEBUG endif ifeq "$(WIN)" "64" BITS=64 else BITS=32 endif PKG_CPPFLAGS=-I. -Iwin$(BITS) $(XTRA_PKG_CPPFLAGS) PKG_LIBS=win$(BITS)/libcairo.a win$(BITS)/libpixman-1.a win$(BITS)/libpng.a win$(BITS)/libz.a -lgdi32 -lmsimg32 $(GRAPHAPP_LIB) Cairo/src/Rapi.h0000644000175100001440000000103414531200444013153 0ustar hornikusers#ifndef RAPI_H__ #define RAPI_H__ #include SEXP Cairo_get_serial(SEXP dev); SEXP Cairo_set_onSave(SEXP dev, SEXP fn); SEXP Rcairo_capture(SEXP dev); SEXP Rcairo_initialize(void); SEXP Rcairo_snapshot(SEXP dev, SEXP sLast); SEXP Rcairo_supported_types(void); SEXP get_img_backplane(SEXP dev); SEXP ptr_to_raw(SEXP ptr, SEXP off, SEXP len); SEXP raw_to_ptr(SEXP ptr, SEXP woff, SEXP raw, SEXP roff, SEXP len); SEXP cairo_create_new_device(SEXP args); SEXP cairo_font_match(SEXP args); SEXP cairo_font_set(SEXP args); #endif Cairo/src/img-jpeg.h0000644000175100001440000000021114531200444013753 0ustar hornikusers#ifndef __IMG_JPEG_H__ #define __IMG_JPEG_H__ int save_jpeg_file(void *buf, int w, int h, char *fn, int quality, int channels); #endif Cairo/src/cconfig.h.in0000644000175100001440000000414114531200444014277 0ustar hornikusers/* src/cconfig.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the declaration of `cairo_image_surface_get_format', and to 0 if you don't. */ #undef HAVE_DECL_CAIRO_IMAGE_SURFACE_GET_FORMAT /* Define to 1 if Harfbuzz and ICU are present and working */ #undef HAVE_HARFBUZZ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDIO_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if all of the C90 standard headers exist (not just the ones required in a freestanding environment). This macro is provided for backward compatibility; new code need not use it. */ #undef STDC_HEADERS /* Define to 1 if libjpeg is present and working */ #undef SUPPORTS_JPEG /* Define to 1 if libtiff is present and working */ #undef SUPPORTS_TIFF /* Define to empty if `const' does not conform to ANSI C. */ #undef const Cairo/src/cairobem.h0000644000175100001440000000020014531200444014033 0ustar hornikusers#ifndef RCAIRO_BEM_H #define RCAIRO_BEM_H #include "backend.h" void Rcairo_register_backend(Rcairo_backend_def* def); #endif Cairo/src/svg-backend.h0000644000175100001440000000050314531200444014444 0ustar hornikusers#ifndef __CAIRO_SVG_BACKEND_H__ #define __CAIRO_SVG_BACKEND_H__ #include "backend.h" #if CAIRO_HAS_SVG_SURFACE #include #endif extern Rcairo_backend_def *RcairoBackendDef_svg; Rcairo_backend *Rcairo_new_svg_backend(Rcairo_backend *be, int conn, const char *filename, double width, double height); #endif Cairo/src/Makevars.ucrt0000644000175100001440000000136514531200444014566 0ustar hornikusersifdef DEBUG XTRA_PKG_CPPFLAGS=-DJGD_DEBUG endif ifeq "$(WIN)" "64" BITS=64 else BITS=32 endif PKG_CPPFLAGS = -I. ifeq (,$(shell pkg-config --version 2>/dev/null)) PKG_CPPFLAGS += -I$(LOCAL_SOFT)/include/cairo -I$(LOCAL_SOFT)/include/freetype2 LIBSHARPYUV = $(or $(and $(wildcard $(R_TOOLS_SOFT)/lib/libsharpyuv.a),-lsharpyuv),) PKG_LIBS += -lcairo -lfontconfig -lintl -liconv -lexpat -lfreetype -lharfbuzz \ -lpixman-1 -ltiff -lwebp $(LIBSHARPYUV) -llzma -lzstd -ljpeg -lpng -lbz2 \ -lz -lgdi32 -lmsimg32 else PKG_CPPFLAGS += $(shell pkg-config --cflags cairo libtiff-4 libjpeg) PKG_LIBS += $(shell pkg-config --libs cairo libtiff-4 libjpeg) endif PKG_LIBS += $(GRAPHAPP_LIB) PKG_CPPFLAGS += $(XTRA_PKG_CPPFLAGS) Cairo/src/pdf-backend.h0000644000175100001440000000053014531200444014416 0ustar hornikusers#ifndef __CAIRO_PDF_BACKEND_H__ #define __CAIRO_PDF_BACKEND_H__ #include "backend.h" extern Rcairo_backend_def *RcairoBackendDef_pdf; #if CAIRO_HAS_PDF_SURFACE #include #endif Rcairo_backend *Rcairo_new_pdf_backend(Rcairo_backend *be, int conn, const char *filename, double width, double height, SEXP aux); #endif Cairo/src/backend.h0000644000175100001440000001013014531200444013644 0ustar hornikusers#ifndef __CAIRO_BACKEND_H__ #define __CAIRO_BACKEND_H__ /* Cario config from configure */ #include "cconfig.h" #include #include #include #include #include #include #if R_VERSION >= R_Version(2,8,0) #ifndef NewDevDesc #define NewDevDesc DevDesc #endif #endif #define CDF_HAS_UI 0x0001 /* backend has UI (e.g. window) */ #define CDF_FAKE_BG 0x0002 /* fake transparent background */ #define CDF_OPAQUE 0x0004 /* device doesn't support any kind of alpha, not even fake */ #define CDF_NOZERO 0x0008 /* if set pages don't need to be zeroed */ #define CBDF_FILE 0x0001 /* can output to file(s) */ #define CBDF_CONN 0x0002 /* can output to a connection */ #define CBDF_VISUAL 0x0004 /* can produce visual output (window/screen) */ #define CBDF_MULTIPAGE 0x0008 /* supports multiple pages in one document (relevant to file/conn only) */ #define fake_bg_color (0xfffefefe) /* known cairo back-ends (as of cairographics 1.4.2) */ #define BET_IMAGE 1 #define BET_PDF 2 #define BET_PS 3 #define BET_SVG 4 #define BET_XLIB 5 #define BET_W32 6 #define BET_QUARTZ 7 #define BET_USER 64 typedef struct st_Rcairo_backend_def { int backend_type; /* see BET_xxx constants */ const char **types; /* supported types (0-terminated list) */ const char *name; /* human-readable back-end name */ int flags; /* see CBDF_xxx constants */ /*----- creation call-back -----*/ void *create; /* not used yet, should be set to 0 */ } Rcairo_backend_def; typedef struct st_Rcairo_backend { int backend_type; /* see BET_xxx constants */ /*----- instance variables -----*/ void *backendSpecific; /* private data for backend use */ cairo_t *cc; /* cairo context */ cairo_surface_t *cs; /* cairo surface */ NewDevDesc *dd; /* device descriptor */ double width, height; /* size in native units (pixels or pts) */ int in_replay; /* set to 1 if it is known where the painting stops and thus the backend doesn't need to perform any synchronization until we're done. if mode is set, it is called ater replay with mode=-1 */ int truncate_rect; /* set to 1 to truncate rectangle coordinates to integers. Useful with bitmap back-ends. */ int serial; /* this variable is increased with each operation so it can be used to track whether the content has potentially changed since last poll */ SEXP onSave; /* optional R callback to call after the page has been saved */ /*----- back-end global variables (capabilities etc.) -----*/ int flags; /* see CDF_xxx above */ double dpix, dpiy; /*----- back-end global callbacks (=methods) -----*/ /* cairo_surface_t *(*create_surface)(struct st_Rcairo_backend *be, int width, int height); */ void (*save_page)(struct st_Rcairo_backend *be, int pageno); void (*destroy_backend)(struct st_Rcairo_backend *be); /* optional callbacks - must be set to 0 if unsupported */ int (*locator)(struct st_Rcairo_backend *be, double *x, double *y); void (*activation)(struct st_Rcairo_backend *be, int activate); /* maps both Activate/Deactivate */ void (*mode)(struct st_Rcairo_backend *be, int mode); /* in addition it is called after internal replay with mode -1 */ void (*resize)(struct st_Rcairo_backend *be, double width, double height); void (*sync)(struct st_Rcairo_backend *be); /* force sync for devices that do asynchronous drawing */ } Rcairo_backend; /* implemented in cairotalk but can be used by any back-end to talk to the GD system */ void Rcairo_backend_resize(Rcairo_backend *be, double width, double height); /* won't do anything if resize is not implemented in the back-end */ void Rcairo_backend_repaint(Rcairo_backend *be); /* re-plays the display list */ void Rcairo_backend_kill(Rcairo_backend *be); /* kills the devide */ void Rcairo_backend_init_surface(Rcairo_backend *be); /* initialize a new surface */ #endif Cairo/src/ps-backend.c0000644000175100001440000000476414531200444014277 0ustar hornikusers#include #include #include "ps-backend.h" #ifdef HAVE_RCONN_H #include #include #include #define R_INTERFACE_PTRS #include #include #include #include #endif #if CAIRO_HAS_PDF_SURFACE static const char *types_list[] = { "ps", 0 }; static Rcairo_backend_def RcairoBackendDef_ = { BET_PS, types_list, "PostScript", CBDF_FILE|CBDF_CONN|CBDF_MULTIPAGE, 0 }; Rcairo_backend_def *RcairoBackendDef_ps = &RcairoBackendDef_; static void ps_save_page(Rcairo_backend* be, int pageno){ cairo_show_page(be->cc); } #ifdef HAVE_RCONN_H static cairo_status_t send_image_data(void *closure, const unsigned char *data, unsigned int length) { Rcairo_backend *be = (Rcairo_backend *)closure; int conn; conn = *(int *)be->backendSpecific; if (R_WriteConnection(conn, data, length, 1)) return CAIRO_STATUS_SUCCESS; else return CAIRO_STATUS_WRITE_ERROR; } #endif static void ps_backend_destroy(Rcairo_backend* be) { cairo_surface_destroy(be->cs); cairo_destroy(be->cc); free(be); } Rcairo_backend *Rcairo_new_ps_backend(Rcairo_backend *be, int conn, const char *filename, double width, double height) { be->backend_type = BET_PS; be->destroy_backend = ps_backend_destroy; be->save_page = ps_save_page; if (filename){ char *fn = NULL; int len = strlen(filename); /* Add .ps extension if necessary */ if (len>3 && strcmp(filename+len-3,".ps")){ fn = malloc(len + 5); if (!fn) { free(be); return NULL; } strcpy(fn,filename); strcat(fn,".ps"); filename = fn; } be->cs = cairo_ps_surface_create(filename,(double)width,(double)height); if (fn) free(fn); } else { #ifdef HAVE_RCONN_H if ( ! (be->backendSpecific = calloc(1,sizeof(int)))){ free(be); return NULL; } *(int *)be->backendSpecific = conn; be->cs = cairo_ps_surface_create_for_stream(send_image_data,(void *)be,(double)width,(double)height); #else free(be); return NULL; #endif } if (cairo_surface_status(be->cs) != CAIRO_STATUS_SUCCESS){ free(be); return NULL; } be->cc = cairo_create(be->cs); if (cairo_status(be->cc) != CAIRO_STATUS_SUCCESS){ free(be); return NULL; } cairo_set_operator(be->cc,CAIRO_OPERATOR_OVER); return be; } #else Rcairo_backend_def *RcairoBackendDef_ps = 0; Rcairo_backend *Rcairo_new_ps_backend(Rcairo_backend *be, int conn, const char *filename, double width, double height) { error("cairo library was compiled without PostScript back-end."); return NULL; } #endif Cairo/src/svg-backend.c0000644000175100001440000000506714531200444014451 0ustar hornikusers#include #include #include "svg-backend.h" #ifdef HAVE_RCONN_H #include #include #include #define R_INTERFACE_PTRS #include #include #include #include #endif #if CAIRO_HAS_SVG_SURFACE static const char *types_list[] = { "svg", 0 }; static Rcairo_backend_def RcairoBackendDef_ = { BET_SVG, types_list, "SVG", CBDF_FILE|CBDF_CONN|CBDF_MULTIPAGE, /* we can't really do multi-page, but we can't do multifiles, either */ 0 }; Rcairo_backend_def *RcairoBackendDef_svg = &RcairoBackendDef_; static void svg_save_page(Rcairo_backend* be, int pageno){ cairo_show_page(be->cc); } #ifdef HAVE_RCONN_H static cairo_status_t send_image_data(void *closure, const unsigned char *data, unsigned int length) { Rcairo_backend *be = (Rcairo_backend *)closure; int conn; conn = *(int *)be->backendSpecific; if (R_WriteConnection(conn, data, length, 1)) return CAIRO_STATUS_SUCCESS; else return CAIRO_STATUS_WRITE_ERROR; } #endif static void svg_backend_destroy(Rcairo_backend* be) { cairo_surface_destroy(be->cs); cairo_destroy(be->cc); free(be); } Rcairo_backend *Rcairo_new_svg_backend(Rcairo_backend *be, int conn, const char *filename, double width, double height) { be->backend_type = BET_SVG; be->destroy_backend = svg_backend_destroy; be->save_page = svg_save_page; if (filename){ char *fn = NULL; int len = strlen(filename); /* Add .svg extension if necessary */ if (len>3 && strcmp(filename+len-4,".svg")){ fn = malloc(len + 5); if (!fn) { free(be); return NULL; } strcpy(fn,filename); strcat(fn,".svg"); filename = fn; } be->cs = cairo_svg_surface_create(filename,(double)width,(double)height); if (fn) free(fn); } else { #ifdef HAVE_RCONN_H if ( ! (be->backendSpecific = calloc(1,sizeof(int)))){ free(be); return NULL; } *(int *)be->backendSpecific = conn; be->cs = cairo_svg_surface_create_for_stream(send_image_data,(void *)be,(double)width,(double)height); #else free(be); return NULL; #endif } if (cairo_surface_status(be->cs) != CAIRO_STATUS_SUCCESS){ free(be); return NULL; } be->cc = cairo_create(be->cs); if (cairo_status(be->cc) != CAIRO_STATUS_SUCCESS){ free(be); return NULL; } cairo_set_operator(be->cc,CAIRO_OPERATOR_OVER); return be; } #else Rcairo_backend_def *RcairoBackendDef_svg = 0; Rcairo_backend *Rcairo_new_svg_backend(Rcairo_backend *be, int conn, const char *filename, double width, double height) { error("cairo library was compiled without SVG support."); return NULL; } #endif Cairo/src/cairobem.c0000644000175100001440000000302314531200444014034 0ustar hornikusers/* Cairo back-end management */ #include #include #include "backend.h" static const char *types[64]; static struct bed_list_st { Rcairo_backend_def* bed; struct bed_list_st* next; } root; void Rcairo_register_backend(Rcairo_backend_def* def) { struct bed_list_st *l=&root; while (l->bed && l->next) { if (l->bed == def) return; /* nothing to do if we have this be alreay */ l = l->next; } if (l->bed) { l->next = (struct bed_list_st*) malloc(sizeof(struct bed_list_st)); l = l->next; l->next = 0; } l->bed = def; { /* collect types list */ const char **c = types; const char **d = def->types; while (*c) c++; while (*d) { *c=*d; c++; d++; if (c-types > 48) break; } } } int Rcairo_type_supported(const char *type) { const char **c = types; if (!type) return 0; while (*c) { if (!strcmp(type, *c)) return 1; c++; } return 0; } /* for additional capabilities */ #include "cairogd.h" SEXP Rcairo_supported_types(void) { const char **c = types; int i = 0; SEXP res; while (*c) { c++; i++; } /* we also add general capabilities: freetype and harfbuzz */ #if USE_CAIRO_FT i++; #ifdef HAVE_HARFBUZZ i++; #endif #endif PROTECT(res=allocVector(STRSXP, i)); i = 0; c = types; while (*c) { SET_STRING_ELT(res, i, mkChar(*c)); c++; i++; } #if USE_CAIRO_FT SET_STRING_ELT(res, i++, mkChar("freetype")); #ifdef HAVE_HARFBUZZ SET_STRING_ELT(res, i++, mkChar("harfbuzz")); #endif #endif UNPROTECT(1); return res; } Cairo/src/Makevars.in0000644000175100001440000000012414531200444014207 0ustar hornikusersPKG_CFLAGS=@CFLAGS@ PKG_CPPFLAGS=@CPPFLAGS@ -I. -Iinclude PKG_LIBS=@LDFLAGS@ @LIBS@ Cairo/src/w32-backend.h0000644000175100001440000000051114531200444014257 0ustar hornikusers#ifndef __CAIRO_W32_BACKEND_H__ #define __CAIRO_W32_BACKEND_H__ #include "backend.h" #if CAIRO_HAS_WIN32_SURFACE #include #endif extern Rcairo_backend_def *RcairoBackendDef_w32; Rcairo_backend *Rcairo_new_w32_backend(Rcairo_backend *be, const char *display, double width, double height, double umpl); #endif Cairo/src/img-tiff.c0000644000175100001440000000374714531200444013772 0ustar hornikusers/* -*- mode: C; tab-width: 4; c-basic-offset: 4 -*- Copyright (C) 2007 Simon Urbanek License: GPL v2 or GPL v3 */ #include "cconfig.h" #ifdef SUPPORTS_TIFF #include #include #include #include int save_tiff_file(void *buf, int w, int h, char *fn, int channels, int compression) { tsize_t linebytes = channels * w; unsigned char *tbuf = NULL; TIFF *out= TIFFOpen(fn, "w"); unsigned int row = 0; unsigned short extra[1] = { EXTRASAMPLE_ASSOCALPHA }; if (!out) return -1; TIFFSetField (out, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(out, TIFFTAG_IMAGELENGTH, h); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, channels); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); if (channels>3) TIFFSetField(out, TIFFTAG_EXTRASAMPLES, (unsigned short) 1, extra); if (compression) TIFFSetField(out, TIFFTAG_COMPRESSION, compression); /* Rprintf(" %d x %d, %d chs, scanls=%d, strips=%d, compr=%d\n", w, h, channels, TIFFScanlineSize(out), TIFFDefaultStripSize(out, w * channels), compression); */ if (TIFFScanlineSize(out) < linebytes) tbuf = (unsigned char *)_TIFFmalloc(linebytes); else tbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out)); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, w * channels)); while (row < h) { unsigned int *src = (unsigned int*)(&((unsigned char*)buf)[row*w*4]); unsigned char *dst = tbuf; int x = 0; while (x < w) { *dst = (*src >> 16) & 255; dst++; *dst = (*src >> 8) & 255; dst++; *dst = *src & 255; dst++; if (channels>3) { *dst = *src >> 24; dst++; } src++; x++; } if (TIFFWriteScanline(out, tbuf, row, 0) < 0) break; row++; } TIFFClose(out); if (tbuf) _TIFFfree(tbuf); return 0; } #else int save_tiff_file(void *buf, int w, int h, char *fn, int channels) { return -2; } #endif Cairo/NEWS0000644000175100001440000002667714531200444012043 0ustar hornikusersNEWS/Changelog 1.6-2 (2023-11-28) o Minor bugfixes: invalid format specified in UBiDi error string, incorrect font name passed if the font family name is too long. o Update Windows build to use pkg-config (Thanks to Tomáš Kalibera!) (#43) 1.6-1 (2023-08-17) o The following additional arguments can be used to set PDF metadata: title, author, subject, creator, keywords, create.date and modify.date if cairo version 1.16 or higher is used. (#15) o The `version` argument for PDF back-end is now honored and defaults to 1.4. Note that currently cairo library only supports PDF target versions 1.4 or 1.5. o The xlib back-end no longer requires headers from Xt. (#39) 1.6-0 (2022-07-05) o Added text drawing using Harfbuzz and ICU. This significantly improves the quality of text rendeded by Cairo and enables support for right-to-left and bi-directional text. (#23) It also enables the use of ligatures. (#18) This feature is only enabled if `pkg-config` is present and knows how to use the `harfbuzz-icu` module. o The `family=` argument in text drawing is now honored also for FreeType and Harfbuzz back-ends. o configure gains two arguments: `--with-freetype` and `--with-harfbuzz`. They both default to `auto` which means FreeType and Harfbuzz will be used if present. If set to `yes` then the support is required. If set to `no` (or the `--without` form is used) then the corresponding support is explicitly disabled. Note that Harfbuzz requires FreeType. o added `--enable-debug` argument to configure which will make Cairo extremely chatty on the console. o By default `cairo-ft` will be ignored on Windows, becasue it it does not work without associated FontConfig configuration files and font cache. (#37) This behavior can be changed by using `-DUSE_CAIRO_FT=1` to force the use of `cairo-ft` unconditionally. o Cairo.capabilities() now also reports two capabilities which are not format-related: "freetype" and "harfbuzz". The former indicates whether `cairo-ft` is used and the later indicates whether the newly introduced Harfbuzz + ICU bi-directional rendering support is present. 1.5-15 (2022-03-16) o CairoX11 (xlib back-end): install an X11 I/O error handler while processing events such that broken connections are detected and don't kill R. o added the option to license under GPL v3. All original authors explicitly agreed and included code based on R is licensed under GPL-2+ allowing this. 1.5-14 (2021-12-21) o update configure/autoconf, some dependencies such as libtiff are now also detected using pkg-config. Tests are now correctly using CPPFLAGS from R. o add entry points for GE version 13 (needed for R 4.1.0) Note that this is just a port of CRAN NMU which was posted as version 1.15-12.2 on CRAN, but was not an actual Cairo version. 1.5-13 (2020-04-15) o add support for CairoFont(usePUA=FALSE) to support regular fonts without Adobe Symbol Encoding as symbol fonts in R 4.0.0 and higher. Setting usePUA=FALSE in older versions of R will issue a warning. 1.5-12 (2020-04-11) o use pkg-config --static --libs when needed o adapt to API changes in R 4.0.0, also improves symbol placement in recent R versions 1.5-11 (2020-02-26) o fixed missing PROTECT() (thanks to Tomáš Kalibera) o minor changes to remove R CMD check warnings 1.5-10 (2019-03-27) o support compilation with C++11-only compilers (#19) o add path.expand() for filenames (#12) o add C symbol registration o update configure.ac to be more compliant 1.5-9 (2015-09-25) o work around bug #45376 in freetype 2.6.0 causing compilation failure 1.5-8 (2015-07-29) o fix a premature memory release in locator handling for raster back-ends. 1.5-7 (2015-07-27) o fix a segfault in CairoFontMatch() in case FcNameParse() fails (closes #10) o image back-end can now provide custom locator if a `locator` argument is passed to `Cairo()` with the desired callback function. The callback function accepts `dev` argument and should return either a numeric vector of length 2 (x, y) or `NULL`. This is mainly useful for `type='raster'` passed to external UI where that UI can provide locator capability. o add Cairo.snapshot() which is similar to recordPlot() but also allows the retrieval of the last snapshot. 1.5-6 (2014-06-26) o scale line width by the same amount as fonts such that resolution changes are consistent even in that respect 1.5-5 (2013-12-23) o fix onSave reporting incorrect page number for the last page (introduced in 1.5-4, closes #6) o scale fonts unconditionally according to the dpi adjustment (fixes issues with grid graphics and dpi changes) 1.5-4 (2013-12-12) o fix invalid pointsize scaling if dpi auto-detection is used (closes #1) o fix failure to emit final page in some multi-page settings (closes #4) o the `res' parameter in CairoPNG(), CairoTIFF() and CairoJPEG() it now passed down to Cairo() which now accepts `res' to override the value of `dpi' if `res' is set to anyhting other than NA or NULL. (closes #3) o release onSave callback function on close (closes #2) 1.5-3 (2013-12-03) o remove compatibility layers to make R 3.x happy o adjust pointsize according to the dpi setting 1.5-2 (2012-11-05) o added Cairo.onSave() callback which allows R code to be run when Cairo finishes a page o added Cairo.serial() function which allows user code to check whether the graphics have been updated o bugfix/update in Cairo connection patch (by Karl Millar) 1.5-1 (2011-12-10) o add support for dev.hold()/dev.flush() o use new R 2.14.0 device capabilities advertizing feature o fix memory leak when setting fonts via CairoFonts() o explicitly request font anti-aliasing even if it is not the surface default - in particular Windows has disabled font anti-aliasing by default 1.5-0 (2011-09-30) o fix swapped bold vs italic traits if freetype is not available o use Times font for symbols on Windows because Symbol font doesn't seem to support Unicode o add support for poly-paths o add support for dev.capture()/grid.cap() o added new type "raster" that creates an image back-end without any output file. It can be used in conjunction with dev.capture() to create in-memory image representations, e.g.: Cairo(type='raster') plot(1:10, col=2) p = writePNG(dev.capture(native=TRUE), raw()) will create a raw vector containg a PNG image. 1.4-9 (2011-04-06) o force static built-in libraries on Windows to prevent Cairo from picking up broken system libraries 1.4-8 (2011-03-07) o spurious character in the 1.4-7 w32-backed source has made it unusable on Windows. This is a re-packaging of 1.4-7 without that spurious character. 1.4-7 (2011-03-07) o fix a bug in raster support causing raster to be usable only once o win backend: release and re-get DC on resize -- fixes resizing issues in CairoWin() for some Windows versions 1.4-6 (2011-02-10) o adds raster image support (courtesy of R core) o update Windows libcairo binary to cairo 1.10.2, use static build to avoid DLL issues and add 64-bit binary 1.4-5 (2009-07-16) o minor Windows configuration change o fix SET_VECTOR_ELT issue for R 2.9.0+ 1.4-4 (2008-10-17) o adapt to changes in R-devel (2.9.0-to-be), clean up warnings 1.4-3 (2008-07-21) o make the use of an invalid font non-fatal o allow Cairo to compile on some older systems that don't have trunc() o updated libcairo binary for Windows to 1.6.4 (from GTK+) 1.4-2 (2008-04-03) o adapt to even more changes in R 2.7 1.4-1 (2008-03-14) o adapt to R 2.7 changes 1.4-0 o fix DPI detection in X11 back-end and use 90dpi as a fallback o fix cra settings to be closer to what other devices use o CairoX11 no longer fixes DPI to 72, "auto" is now the default. In addition, CairoWin and CairoX11 allow additional arguments to ba passed to Cairo. 1.3-5 (2007-08-27) o adapt to const char* CHARs in R-devel o fix a bug in CairoSVG (wrong argument name) o fix a bug in CairoPS (units were not set to "in" and width/height had no defaults) o fix unintentional doubling of the .ps suffix 1.3-4 (2007-05-10) o more fixes in flag-guessing o some vector backends (e.g. PDF, SVG) were falling back to bitamp rasterization, we try to prevent this o address expose issues with some X11 servers o add CairoSVG wrapper o add an unified way to register back-ends and get a list of all supported types. o add Cairo.capabilities() function 1.3-3 2007-04-25 o improve detection of cairo and its dependencies o work around missing API such that cairo 1.0 can be used. However, it is strongly encouraged to use cairo 1.2 or possibly 1.4 as they contain important bugfixes. o fix page numbering to start at 1 (was 0) and update documentation correspondingly 1.3-2 2007-04-18 o added format autodetection for tiff and png. The 32-bit version of either format is used if the background is not opaque. o fixed bug in the value returned by Cairo o added type and file attributes to the Cairo object o added (hidden, experimental) functions that allow direct modification of image content in Cairo (.image, .ptr.to.raw and .raw.to.ptr) 1.3-1 o change semantics of canvas and bg to match other devices: canvas is used by devices that don't support any kind of transparency in case bg is translucent o fixed data ordering issues in TIFF and JPEG output o added "compression" parameter to TIFF back-end which now defaults to LZW compression 1.3-0 o add support for canvas and dpi specification o allow backends to detect native resolution o add support for custom parameters (e.g. quality for jpeg) 1.2-1 o improve rendering on bitmap devices by aligning straight lines to the pixel grid and adding bleed to such fills. o added wrappers that take exactly the same parameters as existing devices such as png, jpeg, pdf, postscript, X11 or windows and map them to calls to Cairo. They can be used to replace native devices by Cairo without the need to change existing code. o added namespace 1.2-0 o additional interactive back ends: X11 (XLib) and win (Win32) o enhanced back-end API to support interactive back-ends o change default backgroud color to "white", because alpha-blending doesn't work properly in cairo when painting on purely transparent background. o change the way filenames are interpreted, use multi-file printf convention as other devices do. o added support for jpeg and tiff image formats 1.1-0 o additional file/stream back-ends: svg, ps o enhanced back-end API 1.0-0 o fixed function names to not conflict with GDD 0.1-5 o added R connections patch support at config time. see http://wiki.r-project.org/rwiki/doku.php?id=developers:r_connections_api 0.1-4 (2006-12-07) o add pdf backend (Jeff Horner) o fix up backend infrastructure (Jeff Horner) 0.1-3 (2006-12-06) o add freetype and fontconfig support (Jeff Horner) o fix memory leaks (Jeff Horner) o make transparent background default with bg="transparent" 0.1-2 (2006-12-05) o add support for caps/joints (patch by Jeff Horner) o make rectangels to snap to grid (patch by Jeff Horner) o use transparent image background by default 0.1-1 (2005-12-23) o first official release, image backend works, others are waiting to be implemented by volunteers Cairo/configure.win0000644000175100001440000000323414531200444014024 0ustar hornikusers#!/bin/sh echo " checking Windows runtime" runtime=`"${R_HOME}/bin/Rscript" -e 'cat(R.version$crt)'` echo " found: '$runtime'" if [ x"$runtime" = xucrt ]; then echo " UCRT run-time, assuming toolchain has everything" echo " declaring SUPPORTS_JPEG and SUPPORTS_TIFF" echo '#define SUPPORTS_JPEG 1' > src/cconfig.h echo '#define SUPPORTS_TIFF 1' >> src/cconfig.h else echo " MSVCRT run-time" echo " checking cairo headers and libraries" allok=yes if [ ! -e src/win64/libcairo.a ]; then if [ ! -e src/cairo-current-win.tar.gz ]; then echo " cannot find current cairograhics files" echo " attempting to download them" echo 'download.file("http://www.rforge.net/Cairo/files/cairo-current-win.tar.gz","src/cairo-current-win.tar.gz",mode="wb")'|${R_HOME}/bin/R --vanilla --slave fi if [ ! -e src/cairo-current-win.tar.gz ]; then allok=no else echo " unpacking current cairo" tar fxz src/cairo-current-win.tar.gz if [ ! -e src/win64/libcairo.a ]; then allok=no fi fi fi if [ ! -e src/win64/libcairo.a ]; then allok=no fi if [ ! -e src/win64/cconfig.h ]; then echo '/* no extra features */' > src/win64/cconfig.h fi if [ ! -e src/win32/cconfig.h ]; then echo '/* no extra features */' > src/win32/cconfig.h fi if [ ${allok} != yes ]; then echo "" echo " *** ERROR: unable to find cairographics files" echo "" echo " They must be either in src/win32 and src/win64 or in a tar-ball" echo " src/cairo-current-win.tar.gz" echo "" echo " You can get the latest binary ball from" echo " http://www.rforge.net/Cairo/files/" echo "" exit 1 fi echo " seems ok, ready to go" fi exit 0 Cairo/R/0000755000175100001440000000000014531200444011523 5ustar hornikusersCairo/R/zzz.R0000644000175100001440000000062514531200444012506 0ustar hornikusers.onLoad <- function(libname, pkgname) { ## add our libs to the PATH if (.Platform$OS.type=="windows") { lp<-gsub("/","\\\\",paste(libname,pkgname,"libs",sep="/")) cp<-strsplit(Sys.getenv("PATH"),";") if (! lp %in% cp) Sys.setenv(PATH=paste(lp,Sys.getenv("PATH"),sep=";")) } library.dynam("Cairo", pkgname, libname) .Call("Rcairo_initialize", PACKAGE="Cairo") } Cairo/R/imgtools.R0000644000175100001440000000104514531200444013503 0ustar hornikusers.image <- function(device) { a <- .Call("get_img_backplane", device, PACKAGE="Cairo") names(a) <- c('ref', 'info') a$width <- a[[2]][1] a$height <- a[[2]][2] a$format <- c("ARGB","RGB","A8","A1","dep","RGB16")[a[[2]][3]+1] class(a) <- "CairoImageRef" a } .ptr.to.raw <- function(ptr, begin, length) .Call("ptr_to_raw", ptr, begin, length, PACKAGE="Cairo") .raw.to.ptr <- function(ptr, offset=0, raw, begin=0, length=length(raw)) invisible(.Call("raw_to_ptr", ptr, offset, raw, begin, length, PACKAGE="Cairo")) Cairo/R/Cairo.R0000644000175100001440000001704114531200444012706 0ustar hornikusers### Copyright (C) 2004-2007 Simon Urbanek ### License: GPL v2 ### mapping of supported type names to canonical type names ### as of 1.3-2 png/png24/png32 are the same (we don't support png8 anyway) .supported.types <- c(png="png",png24="png",png32="png",jpeg="jpeg",jpg="jpeg",tiff="tiff",tif="tiff", pdf="pdf",svg="svg",ps="ps",postscript="ps",x11="x11",xlib="x11", win="win",win32="win",window="win",windows="win",w32="win",raster="raster") Cairo <- function(width=640, height=480, file="", type="png", pointsize=12, bg="transparent", canvas="white", units="px", dpi="auto", ...) { ctype <- tolower(type) if (!ctype %in% names(.supported.types)) stop("Unknown output type `",type,"'.") ctype <- .supported.types[ctype==names(.supported.types)] if (is.null(file) || !nchar(file)) file <- if (ctype != 'x11') paste("plot.",ctype,sep='') else Sys.getenv("DISPLAY") if (is.character(file) && length(file) != 1) stop("file must be a character vector of length 1 or a connection") else if (inherits(file,"connection") && (summary(file)$opened != "opened" || summary(file)$"can write" != "yes")) stop("connection must be open and writeable") if (is.character(file)) file <- path.expand(file) if (length(units)!=1 || ! units %in% c("px","pt","in","cm","mm")) stop("invalid unit (supported are px, pt, in, cm and mm)") ## res is used in bitmap wrappers to set dpi ## the default is NA so we only honor it if it's set to a non-default value res <- list(...)$res if (!is.null(res) && all(!is.na(res))) dpi <- res if (any(dpi=="auto" || dpi=="")) dpi <- 0 if (length(dpi)!=1 || !is.numeric(dpi) || dpi<0) stop("invalid dpi specification (must be 'auto' or a positive number)") dpi <- as.double(dpi) ## unit multiplier: >0 mpl to get inches, <0 mpl to get device pixels umpl <- as.double(c(-1, 1/72, 1, 1/2.54, 1/25.4)[units==c("px","pt","in","cm","mm")]) gdn<-.External("cairo_create_new_device", as.character(ctype), file, width, height, pointsize, bg, canvas, umpl, dpi, ..., PACKAGE="Cairo") par(bg=bg) invisible(structure(gdn,class=c("Cairo",paste("Cairo",toupper(ctype),sep='')),type=as.character(ctype),file=file)) } Cairo.capabilities <- function() { ust <- c(unique(.supported.types), "freetype", "harfbuzz") cap <- !is.na(match(ust, .Call("Rcairo_supported_types", PACKAGE="Cairo"))) names(cap) <- ust cap } ###-------------- supporting functions ----------------- CairoFontMatch <- function(fontpattern="Helvetica",sort=FALSE,verbose=FALSE) { if (typeof(fontpattern) != "character") stop("fontname must be a character vector of length 1") if (typeof(sort) != "logical") stop("sort option must be a logical") if (typeof(verbose) != "logical") stop("verbose option must be a logical") invisible(.External("cairo_font_match",fontpattern,sort,verbose,PACKAGE="Cairo")) } CairoFonts <- function( regular="Helvetica:style=Regular", bold="Helvetica:style=Bold", italic="Helvetica:style=Italic", bolditalic="Helvetica:style=Bold Italic,BoldItalic", symbol="Symbol", usePUA=TRUE) { if (!is.null(regular) && typeof(regular) != "character") stop("regular option must be a character vector of length 1") if (!is.null(bold) && typeof(bold) != "character") stop("bold option must be a character vector of length 1") if (!is.null(italic) && typeof(italic) != "character") stop("italic option must be a character vector of length 1") if (!is.null(bolditalic) && typeof(bolditalic) != "character") stop("bolditalic option must be a character vector of length 1") if (!is.null(symbol) && typeof(symbol) != "character") stop("symbol option must be a character vector of length 1") invisible(.External("cairo_font_set", regular, bold, italic, bolditalic, symbol, usePUA, PACKAGE="Cairo")) } ###-------------- convenience wrapper functions ----------------- CairoX11 <- function(display=Sys.getenv("DISPLAY"), width = 7, height = 7, pointsize = 12, gamma = getOption("gamma"), bg = "transparent", canvas = "white", xpos = NA, ypos = NA, ...) { Cairo(width, height, file=display, type='x11', pointsize=pointsize, bg=bg, units="in", ...) } CairoPNG <- function(filename = "Rplot%03d.png", width = 480, height = 480, pointsize = 12, bg = "white", res = NA, ...) { Cairo(width, height, type='png', file=filename, pointsize=pointsize, bg=bg, res=res, ...) } CairoTIFF <- function(filename = "Rplot%03d.tiff", width = 480, height = 480, pointsize = 12, bg = "white", res = NA, ...) { Cairo(width, height, type='tiff', file=filename, pointsize=pointsize, bg=bg, res=res, ...) } CairoJPEG <- function(filename = "Rplot%03d.jpeg", width = 480, height = 480, pointsize = 12, quality = 75, bg = "white", res = NA, ...) { Cairo(width, height, type='jpeg', file=filename, pointsize=pointsize, bg=bg, quality=quality, res=res, ...) } CairoPDF <- function(file = ifelse(onefile, "Rplots.pdf", "Rplot%03d.pdf"), width = 6, height = 6, onefile = TRUE, family = "Helvetica", title = "R Graphics Output", fonts = NULL, paper = "special", encoding, bg, fg, pointsize, pagecentre, ...) { if (!onefile) stop("Sorry, PDF backend of Cairo supports onefile=TRUE only") if (missing(pointsize)) pointsize <- 12 if (missing(bg)) bg <- "white" Cairo(width, height, file, "pdf", pointsize=pointsize, bg=bg, units="in", title = title, ...) } CairoSVG <- function(file = ifelse(onefile, "Rplots.svg", "Rplot%03d.svg"), width = 6, height = 6, onefile = TRUE, bg = "transparent", pointsize = 12, ...) { if (!onefile) stop("Sorry, SVG backend of Cairo supports onefile=TRUE only") Cairo(width, height, type='svg', file=file, pointsize=pointsize, bg=bg, units='in', ...) } CairoPS <- function(file = ifelse(onefile, "Rplots.ps", "Rplot%03d.ps"), onefile = TRUE, family, title = "R Graphics Output", fonts = NULL, encoding, bg, fg, width, height, horizontal, pointsize, paper, pagecentre, print.it, command, colormodel) { if (!onefile) stop("Sorry, PostScript backend of Cairo supports onefile=TRUE only") if (missing(pointsize)) pointsize <- 12 if (missing(bg)) bg <- "white" # the following are different from R's postscript defaults! # the PS device uses page dimensions, we don't if (missing(width)) width <- 8 if (missing(height)) height <- 6 Cairo(width, height, file, "ps", pointsize=pointsize, bg=bg, units="in") } CairoWin <- function(width = 7, height = 7, pointsize = 12, record = getOption("graphics.record"), rescale = c("R", "fit", "fixed"), xpinch, ypinch, bg = "transparent", canvas = "white", gamma = getOption("gamma"), xpos = NA, ypos = NA, buffered = getOption("windowsBuffered"), restoreConsole = FALSE, ...) { Cairo(width, height, '', 'win', pointsize=pointsize, bg=bg, units="in", ...) } Cairo.serial <- function(device = dev.cur()) .Call("Cairo_get_serial", device, PACKAGE="Cairo") Cairo.onSave <- function(device = dev.cur(), onSave) .Call("Cairo_set_onSave", device, onSave, PACKAGE="Cairo") Cairo.capture <- function(device = dev.cur()) .Call("Rcairo_capture", device, PACKAGE="Cairo") Cairo.snapshot <- function(device = dev.cur(), last=FALSE) { res <- if (is.na(last)) { res <- .Call("Rcairo_snapshot", device, FALSE, PACKAGE="Cairo") if (is.null(res[[1]])) .Call("Rcairo_snapshot", device, TRUE, PACKAGE="Cairo") else res } else .Call("Rcairo_snapshot", device, last, PACKAGE="Cairo") attr(res, "pid") <- Sys.getpid() class(res) <- "recordedplot" res } Cairo/MD50000644000175100001440000000421614531324150011636 0ustar hornikusers81cc57d6f896ffa1319b3ada21923317 *DESCRIPTION 4349f93fca74b0151a9435bfbeec5673 *NAMESPACE 30670d03a122babf484786074af0e42e *NEWS e6ecc2f7aa4084f8727d4955935b9289 *R/Cairo.R 45f780dde83799bfd5ec2d67659fded4 *R/imgtools.R a9008f9a9abd726e834484d834008b47 *R/zzz.R caa046d1635592fd3c442eef02f03dc5 *configure fe6229e71b930841e2e3c1691c4c2884 *configure.ac 9eb8bc37132611649508d3633d0b515f *configure.win b156ddcaedf02dfdfa2c537963fa69f1 *man/Cairo.Rd 08dffecb11001a3d8d781c6834100cac *man/Cairo.capabilities.Rd 828f9d2b515a62d1e7ba8aadb582b01f *man/Cairo.capture.Rd 021c456c904c3400f5a8cebe93e9b8bb *man/Cairo.onSave.Rd f15d68f877a128ae9727519c64b21dd0 *man/Cairo.serial.Rd 051eda87864302d0a09cfb6315975ae2 *man/CairoFontMatch.Rd 37aa98197989deec1b00bba343e199f3 *man/CairoFonts.Rd 0a452df871ff02cc77b07df796e20739 *src/Makevars.in f84a32dd849d62e5890a2fdbff0f7a15 *src/Makevars.ucrt 72c5f27149e19f5b0663a9908caacdb1 *src/Makevars.win d3ee50dae8105f2fded647142c7bfc94 *src/Rapi.h 8a2c9ef2d88975f2a853fe5145d39745 *src/backend.h d48f95759226b7bcd0aa9ffe6c8cec07 *src/cairobem.c 4839a2d606ecaa9e9a000e38cb075fc7 *src/cairobem.h d62b169707dc25a0166ec6b6418d614d *src/cairogd.c 50766953c5e82903e0589bcb7a69e1ce *src/cairogd.h 6cf3f08103febf530f5897cae336194c *src/cairotalk.c 9135781b3a9af05d75deb9489d0093e1 *src/cairotalk.h 051131c99dc3c23fdd13e6061d652e55 *src/cconfig.h.in 12898653f7e2c8f4d501dd29321ef5fe *src/img-backend.c 64361f5aefcef67513607eb825a58e98 *src/img-backend.h 789266506ae5f63245134fbf0bc7a406 *src/img-jpeg.c 8d58fa8f009a29a0394d1bbdfe828807 *src/img-jpeg.h 0c010812436595d1fc9c2932b921634f *src/img-tiff.c 8c4ef00c7ecd978ce7836c6592b181ed *src/img-tiff.h 5fcdd875c15a48b8fa1492a063787f06 *src/pdf-backend.c d63880ecfee6069d27f1edac3252fb91 *src/pdf-backend.h ce5574d57233558cd7f69e5a0f4467aa *src/ps-backend.c ad3d54689163db0667e5e5b8f672dd38 *src/ps-backend.h b9c233c78f507bdf1f92ab52f49a5ead *src/svg-backend.c 2508ee0d495026cde2c59009af983f7f *src/svg-backend.h 58e34e2a1fc9f04bf7f29d07916f148d *src/w32-backend.c 68f9a9c2fdb49f778bb0638f67fb54ae *src/w32-backend.h 8dc17baea359a252ab6af0e02dcedb12 *src/xlib-backend.c f978a2861b85129a9955aa7b4677a1d4 *src/xlib-backend.h Cairo/configure0000755000175100001440000047117414531200444013247 0ustar hornikusers#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.71 for Cairo 1.3. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, # Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="as_nop=: if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else \$as_nop case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ) then : else \$as_nop exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 blah=\$(echo \$(echo blah)) test x\"\$blah\" = xblah || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" if (eval "$as_required") 2>/dev/null then : as_have_required=yes else $as_nop as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null then : else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$as_shell as_have_required=yes if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null then : break 2 fi fi done;; esac as_found=false done IFS=$as_save_IFS if $as_found then : else $as_nop if { test -f "$SHELL" || test -f "$SHELL.exe"; } && as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$SHELL as_have_required=yes fi fi if test "x$CONFIG_SHELL" != x then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno then : printf "%s\n" "$0: This script requires a shell more modern than all" printf "%s\n" "$0: the shells that I found on your system." if test ${ZSH_VERSION+y} ; then printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." else printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and $0: Simon.Urbanek@r-project.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Cairo' PACKAGE_TARNAME='cairo' PACKAGE_VERSION='1.3' PACKAGE_STRING='Cairo 1.3' PACKAGE_BUGREPORT='Simon.Urbanek@r-project.org' PACKAGE_URL='' ac_unique_file="src/cairogd.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_STDIO_H # include #endif #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_header_c_list= ac_subst_vars='LTLIBOBJS LIBOBJS PKGCONF OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC R_HOME target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking with_freetype with_harfbuzz enable_debug ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures Cairo 1.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/cairo] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of Cairo 1.3:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-debug enable debug flags and output. [no] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-freetype compile support for better font handling using FreeType and Fontconfig if present and supported by cairo. (default is [auto]). --with-harfbuzz compile support for bi-directional Unicode and advanced text layout (like ligature support) using Harfbuzz and ICU libraries. (default is [auto]). Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for configure.gnu first; this name is used for a wrapper for # Metaconfig's "Configure" on case-insensitive file systems. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF Cairo configure 1.3 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_check_decl LINENO SYMBOL VAR INCLUDES EXTRA-OPTIONS FLAG-VAR # ------------------------------------------------------------------ # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. Pass EXTRA-OPTIONS to the compiler, using FLAG-VAR. ac_fn_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 printf %s "checking whether $as_decl_name is declared... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` eval ac_save_FLAGS=\$$6 as_fn_append $6 " $5" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext eval $6=\$ac_save_FLAGS fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_check_decl ac_configure_args_raw= for ac_arg do case $ac_arg in *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append ac_configure_args_raw " '$ac_arg'" done case $ac_configure_args_raw in *$as_nl*) ac_safe_unquote= ;; *) ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. ac_unsafe_a="$ac_unsafe_z#~" ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; esac cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by Cairo $as_me 1.3, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac printf "%s\n" "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Sanitize IFS. IFS=" "" $as_nl" # Save into config.log some information that might help in debugging. { echo printf "%s\n" "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo printf "%s\n" "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then printf "%s\n" "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then printf "%s\n" "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && printf "%s\n" "$as_me: caught signal $ac_signal" printf "%s\n" "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h printf "%s\n" "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then ac_site_files="$CONFIG_SITE" elif test "x$prefix" != xNONE; then ac_site_files="$prefix/share/config.site $prefix/etc/config.site" else ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi for ac_site_file in $ac_site_files do case $ac_site_file in #( */*) : ;; #( *) : ac_site_file=./$ac_site_file ;; esac if test -f "$ac_site_file" && test -r "$ac_site_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 printf "%s\n" "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 printf "%s\n" "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Test code for whether the C compiler supports C89 (global declarations) ac_c_conftest_c89_globals=' /* Does the compiler advertise C89 conformance? Do not test the value of __STDC__, because some compilers set it to 0 while being otherwise adequately conformant. */ #if !defined __STDC__ # error "Compiler does not advertise C89 conformance" #endif #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ struct buf { int x; }; struct buf * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not \xHH hex character constants. These do not provoke an error unfortunately, instead are silently treated as an "x". The following induces an error, until -std is added to get proper ANSI mode. Curiously \x00 != x always comes out true, for an array size at least. It is necessary to write \x00 == 0 to get something that is true only with -std. */ int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) '\''x'\'' int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), int, int);' # Test code for whether the C compiler supports C89 (body of main). ac_c_conftest_c89_main=' ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); ' # Test code for whether the C compiler supports C99 (global declarations) ac_c_conftest_c99_globals=' // Does the compiler advertise C99 conformance? #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L # error "Compiler does not advertise C99 conformance" #endif #include extern int puts (const char *); extern int printf (const char *, ...); extern int dprintf (int, const char *, ...); extern void *malloc (size_t); // Check varargs macros. These examples are taken from C99 6.10.3.5. // dprintf is used instead of fprintf to avoid needing to declare // FILE and stderr. #define debug(...) dprintf (2, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK #error "your preprocessor is broken" #endif #if BIG_OK #else #error "your preprocessor is broken" #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) continue; return 0; } // Check varargs and va_copy. static bool test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str = ""; int number = 0; float fnumber = 0; while (*format) { switch (*format++) { case '\''s'\'': // string str = va_arg (args_copy, const char *); break; case '\''d'\'': // int number = va_arg (args_copy, int); break; case '\''f'\'': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); return *str && number && fnumber; } ' # Test code for whether the C compiler supports C99 (body of main). ac_c_conftest_c99_main=' // Check bool. _Bool success = false; success |= (argc != 0); // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[0] = argv[0][0]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\'' || dynamic_array[ni.number - 1] != 543); ' # Test code for whether the C compiler supports C11 (global declarations) ac_c_conftest_c11_globals=' // Does the compiler advertise C11 conformance? #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L # error "Compiler does not advertise C11 conformance" #endif // Check _Alignas. char _Alignas (double) aligned_as_double; char _Alignas (0) no_special_alignment; extern char aligned_as_int; char _Alignas (0) _Alignas (int) aligned_as_int; // Check _Alignof. enum { int_alignment = _Alignof (int), int_array_alignment = _Alignof (int[100]), char_alignment = _Alignof (char) }; _Static_assert (0 < -_Alignof (int), "_Alignof is signed"); // Check _Noreturn. int _Noreturn does_not_return (void) { for (;;) continue; } // Check _Static_assert. struct test_static_assert { int x; _Static_assert (sizeof (int) <= sizeof (long int), "_Static_assert does not work in struct"); long int y; }; // Check UTF-8 literals. #define u8 syntax error! char const utf8_literal[] = u8"happens to be ASCII" "another string"; // Check duplicate typedefs. typedef long *long_ptr; typedef long int *long_ptr; typedef long_ptr long_ptr; // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. struct anonymous { union { struct { int i; int j; }; struct { int k; long int l; } w; }; int m; } v1; ' # Test code for whether the C compiler supports C11 (body of main). ac_c_conftest_c11_main=' _Static_assert ((offsetof (struct anonymous, i) == offsetof (struct anonymous, w.k)), "Anonymous union alignment botch"); v1.i = 2; v1.w.k = 5; ok |= v1.i != 5; ' # Test code for whether the C compiler supports C11 (complete). ac_c_conftest_c11_program="${ac_c_conftest_c89_globals} ${ac_c_conftest_c99_globals} ${ac_c_conftest_c11_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} ${ac_c_conftest_c99_main} ${ac_c_conftest_c11_main} return ok; } " # Test code for whether the C compiler supports C99 (complete). ac_c_conftest_c99_program="${ac_c_conftest_c89_globals} ${ac_c_conftest_c99_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} ${ac_c_conftest_c99_main} return ok; } " # Test code for whether the C compiler supports C89 (complete). ac_c_conftest_c89_program="${ac_c_conftest_c89_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} return ok; } " as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H" as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H" as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H" as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers src/cconfig.h" # find R home and set CC/CFLAGS : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then echo "could not determine R_HOME" exit 1 fi RBIN="${R_HOME}/bin/R" CC=`"${RBIN}" CMD config CC`; CFLAGS=`"${RBIN}" CMD config CFLAGS` CPPFLAGS=`"${RBIN}" CMD config CPPFLAGS` LDFLAGS=`"${RBIN}" CMD config LDFLAGS` CPP="${CC} -E" # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. set dummy ${ac_tool_prefix}clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "clang", so it can be a program name with args. set dummy clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi fi test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion -version; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 printf %s "checking whether the C compiler works... " >&6; } ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else $as_nop ac_file='' fi if test -z "$ac_file" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 printf %s "checking for C compiler default output file name... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 printf "%s\n" "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 printf %s "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else $as_nop { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 printf "%s\n" "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 printf %s "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 printf "%s\n" "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 printf %s "checking for suffix of object files... " >&6; } if test ${ac_cv_objext+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 printf "%s\n" "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 printf %s "checking whether the compiler supports GNU C... " >&6; } if test ${ac_cv_c_compiler_gnu+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_compiler_gnu=yes else $as_nop ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } ac_compiler_gnu=$ac_cv_c_compiler_gnu if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+y} ac_save_CFLAGS=$CFLAGS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 printf %s "checking whether $CC accepts -g... " >&6; } if test ${ac_cv_prog_cc_g+y} then : printf %s "(cached) " >&6 else $as_nop ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes else $as_nop CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 printf "%s\n" "$ac_cv_prog_cc_g" >&6; } if test $ac_test_CFLAGS; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi ac_prog_cc_stdc=no if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 printf %s "checking for $CC option to enable C11 features... " >&6; } if test ${ac_cv_prog_cc_c11+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c11=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c11_program _ACEOF for ac_arg in '' -std=gnu11 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c11=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c11" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c11" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c11" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } CC="$CC $ac_cv_prog_cc_c11" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 ac_prog_cc_stdc=c11 fi fi if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 printf %s "checking for $CC option to enable C99 features... " >&6; } if test ${ac_cv_prog_cc_c99+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c99_program _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c99" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c99" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } CC="$CC $ac_cv_prog_cc_c99" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 ac_prog_cc_stdc=c99 fi fi if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 printf %s "checking for $CC option to enable C89 features... " >&6; } if test ${ac_cv_prog_cc_c89+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c89_program _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c89" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c89" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } CC="$CC $ac_cv_prog_cc_c89" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 ac_prog_cc_stdc=c89 fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Checks for libraries. # Checks for header files. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 printf %s "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if test ${ac_cv_header_sys_wait_h+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main (void) { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_header_sys_wait_h=yes else $as_nop ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 printf "%s\n" "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then printf "%s\n" "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi ac_header= ac_cache= for ac_item in $ac_header_c_list do if test $ac_cache; then ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then printf "%s\n" "#define $ac_item 1" >> confdefs.h fi ac_header= ac_cache= elif test $ac_header; then ac_cache=$ac_item else ac_header=$ac_item fi done if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes then : printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default" if test "x$ac_cv_header_string_h" = xyes then : printf "%s\n" "#define HAVE_STRING_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" if test "x$ac_cv_header_sys_time_h" = xyes then : printf "%s\n" "#define HAVE_SYS_TIME_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" if test "x$ac_cv_header_unistd_h" = xyes then : printf "%s\n" "#define HAVE_UNISTD_H 1" >>confdefs.h fi # Checks for typedefs, structures, and compiler characteristics. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 printf %s "checking for an ANSI C-conforming const... " >&6; } if test ${ac_cv_c_const+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* IBM XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* IBM XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_const=yes else $as_nop ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 printf "%s\n" "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then printf "%s\n" "#define const /**/" >>confdefs.h fi # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_PKGCONF+y} then : printf %s "(cached) " >&6 else $as_nop case $PKGCONF in [\\/]* | ?:[\\/]*) ac_cv_path_PKGCONF="$PKGCONF" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="$PATH:/usr/local/bin:ext/bin:ext:/sw/bin:/opt/bin" for as_dir in $as_dummy do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_PKGCONF="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKGCONF=$ac_cv_path_PKGCONF if test -n "$PKGCONF"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PKGCONF" >&5 printf "%s\n" "$PKGCONF" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi have_cairo=no if test "xx$CAIRO_LIBS" == "xx"; then if test "xx$PKGCONF" != "xx"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pkg-config knows about cairo" >&5 printf %s "checking whether pkg-config knows about cairo... " >&6; } if "${PKGCONF}" --exists cairo; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for configurable backends" >&5 printf %s "checking for configurable backends... " >&6; } modlist="cairo" for module in cairo-ft cairo-pdf cairo-png cairo-ps cairo-svn cairo-xlib cairo-xlib-xrender cairo-win32; do if "${PKGCONF}" --exists ${module}; then modlist="${modlist} ${module}" fi done { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${modlist}" >&5 printf "%s\n" "${modlist}" >&6; } CAIRO_CFLAGS=`"${PKGCONF}" --cflags ${modlist}` CAIRO_LIBS=`"${PKGCONF}" --libs ${modlist}` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether --static is needed" >&5 printf %s "checking whether --static is needed... " >&6; } saveLIBS="$LIBS" LIBS="$saveLIBS ${CAIRO_LIBS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define cairo_reset_clip to an innocuous variant, in case declares cairo_reset_clip. For example, HP-UX 11i declares gettimeofday. */ #define cairo_reset_clip innocuous_cairo_reset_clip /* System header to define __stub macros and hopefully few prototypes, which can conflict with char cairo_reset_clip (); below. */ #include #undef cairo_reset_clip /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char cairo_reset_clip (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_cairo_reset_clip || defined __stub___cairo_reset_clip choke me #endif int main (void) { return cairo_reset_clip (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } else $as_nop CAIRO_LIBS=`"${PKGCONF}" --libs --static ${modlist}` LIBS="$saveLIBS ${CAIRO_LIBS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define cairo_reset_clip to an innocuous variant, in case declares cairo_reset_clip. For example, HP-UX 11i declares gettimeofday. */ #define cairo_reset_clip innocuous_cairo_reset_clip /* System header to define __stub macros and hopefully few prototypes, which can conflict with char cairo_reset_clip (); below. */ #include #undef cairo_reset_clip /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char cairo_reset_clip (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_cairo_reset_clip || defined __stub___cairo_reset_clip choke me #endif int main (void) { return cairo_reset_clip (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } PKGCONF_LIB_ADD=--static else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: neither works, abandoning pkg-config" >&5 printf "%s\n" "neither works, abandoning pkg-config" >&6; } CAIRO_LIBS='' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="$saveLIBS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi fi if test -z "${CAIRO_LIBS}"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CAIRO_LIBS is unset, attempting to guess it." >&5 printf "%s\n" "$as_me: CAIRO_LIBS is unset, attempting to guess it." >&6;} cpre='' for pre in /usr /usr/local /usr/X11 /usr/X11R6 /opt /sw; do if test -e "${pre}/include/cairo/cairo.h"; then cpre=${pre}; break fi done if test -n "${cpre}"; then CAIRO_CFLAGS="-I${cpre}/include/cairo" if test "${cpre}" = /usr; then CAIRO_LIBS="-lcairo" else CAIRO_LIBS="-L${cpre}/lib -lcairo" fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CAIRO_CFLAGS=${CAIRO_CFLAGS}" >&5 printf "%s\n" "$as_me: CAIRO_CFLAGS=${CAIRO_CFLAGS}" >&6;} # Check for Rconn patch { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if R was compiled with the RConn patch" >&5 printf %s "checking if R was compiled with the RConn patch... " >&6; } if test -f "${R_HOME}/include/R_ext/RConn.h"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } HAVE_RCONN_H="-DHAVE_RCONN_H" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } HAVE_RCONN_H="" fi CPPFLAGS="$CPPFLAGS ${CAIRO_CFLAGS} ${HAVE_RCONN_H}" ac_fn_c_check_header_compile "$LINENO" "cairo.h" "ac_cv_header_cairo_h" "$ac_includes_default" if test "x$ac_cv_header_cairo_h" = xyes then : else $as_nop as_fn_error $? "Cannot find cairo.h! Please install cairo (http://www.cairographics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly." "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for PNG support in Cairo" >&5 printf %s "checking for PNG support in Cairo... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include "cairo.h" int main(void) { #ifndef CAIRO_HAS_PNG_FUNCTIONS #error no PNG support #endif return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } as_fn_error $? "Cairo library has no PNG support." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext uses_ats=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ATS font support in Cairo" >&5 printf %s "checking for ATS font support in Cairo... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include "cairo.h" int main(void) { #ifndef CAIRO_HAS_ATSUI_FONT #error no PNG support #endif return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } uses_ats=yes else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test "xx${CAIRO_LIBS}" == "xx"; then if test $uses_ats == "yes"; then CAIRO_LIBS="-lcairo -lpng -lz -framework ApplicationServices" else CAIRO_LIBs="-lcairo -lpng -lz" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: CAIRO_LIBS=${CAIRO_LIBS}" >&5 printf "%s\n" "$as_me: CAIRO_LIBS=${CAIRO_LIBS}" >&6;} LIBS="$LIBS ${CAIRO_LIBS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing deflate" >&5 printf %s "checking for library containing deflate... " >&6; } if test ${ac_cv_search_deflate+y} then : printf %s "(cached) " >&6 else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char deflate (); int main (void) { return deflate (); ; return 0; } _ACEOF for ac_lib in '' z do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO" then : ac_cv_search_deflate=$ac_res fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${ac_cv_search_deflate+y} then : break fi done if test ${ac_cv_search_deflate+y} then : else $as_nop ac_cv_search_deflate=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_deflate" >&5 printf "%s\n" "$ac_cv_search_deflate" >&6; } ac_res=$ac_cv_search_deflate if test "$ac_res" != no then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether Cairo programs can be compiled" >&5 printf %s "checking whether Cairo programs can be compiled... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { cairo_surface_t *cs = 0; cairo_t *cr; cr = cairo_create(cs); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop as_fn_error $? "Cannot compile a simple Cairo program. See config.log for details." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5 printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; } if test ${ac_cv_c_undeclared_builtin_options+y} then : printf %s "(cached) " >&6 else $as_nop ac_save_CFLAGS=$CFLAGS ac_cv_c_undeclared_builtin_options='cannot detect' for ac_arg in '' -fno-builtin; do CFLAGS="$ac_save_CFLAGS $ac_arg" # This test program should *not* compile successfully. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { (void) strchr; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop # This test program should compile successfully. # No library function is consistently available on # freestanding implementations, so test against a dummy # declaration. Include always-available headers on the # off chance that they somehow elicit warnings. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include extern void ac_decl (int, char *); int main (void) { (void) ac_decl (0, (char *) 0); (void) ac_decl; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : if test x"$ac_arg" = x then : ac_cv_c_undeclared_builtin_options='none needed' else $as_nop ac_cv_c_undeclared_builtin_options=$ac_arg fi break fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done CFLAGS=$ac_save_CFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5 printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; } case $ac_cv_c_undeclared_builtin_options in #( 'cannot detect') : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot make $CC report undeclared builtins See \`config.log' for more details" "$LINENO" 5; } ;; #( 'none needed') : ac_c_undeclared_builtin_options='' ;; #( *) : ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;; esac ac_fn_check_decl "$LINENO" "cairo_image_surface_get_format" "ac_cv_have_decl_cairo_image_surface_get_format" "$ac_includes_default" "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_cairo_image_surface_get_format" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_CAIRO_IMAGE_SURFACE_GET_FORMAT $ac_have_decl" >>confdefs.h if test $ac_have_decl = 1 then : #include fi has_cairo_ft=no # Check whether --with-freetype was given. if test ${with_freetype+y} then : withval=$with_freetype; with_freetype=$withval else $as_nop with_freetype=auto fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether FreeType support is desired" >&5 printf %s "checking whether FreeType support is desired... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${with_freetype}" >&5 printf "%s\n" "${with_freetype}" >&6; } if test x${with_freetype} != xno; then ## with_freetype { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for FreeType support in cairo" >&5 printf %s "checking for FreeType support in cairo... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef CAIRO_HAS_FT_FONT #error nope, no ft #endif _ACEOF if ac_fn_c_try_compile "$LINENO" then : has_cairo_ft=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${has_cairo_ft}" >&5 printf "%s\n" "${has_cairo_ft}" >&6; } need_xtra_ft_flags=no if test "${has_cairo_ft}" = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether FreeType needs additional flags" >&5 printf %s "checking whether FreeType needs additional flags... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { cairo_ft_font_face_create_for_pattern(0); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : else $as_nop need_xtra_ft_flags=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${need_xtra_ft_flags}" >&5 printf "%s\n" "${need_xtra_ft_flags}" >&6; } fi if test "${need_xtra_ft_flags}" = yes; then if test -n "${PKGCONF}"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pkg-config knows about fontconfig or freetype2" >&5 printf %s "checking whether pkg-config knows about fontconfig or freetype2... " >&6; } ftmod='' for module in fontconfig freetype2; do if "${PKGCONF}" --exists ${module}; then ftmod="${ftmod} ${module}"; fi done if test -n "${ftmod}"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } FT_CPPFLAGS=`"${PKGCONF}" --cflags ${ftmod}` FT_LIBS=`"${PKGCONF}" --libs ${PKGCONF_LIB_ADD} ${ftmod}` else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "${FT_LIBS}"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether fontconfig/freetype2 location can be guessed" >&5 printf %s "checking whether fontconfig/freetype2 location can be guessed... " >&6; } FCI=''; FTI=''; FCL=''; FTL='' for pre in /usr /usr/X11 /usr/X11R6 /usr/local /opt /sw; do if test -z "${FCI}" -a -e "${pre}/include/fontconfig/fontconfig.h"; then FCI="-I${pre}/include" FCL="-L${pre}/lib" fi if test -z "${FTI}" -a -e "${pre}/include/freetype2/freetype/freetype.h"; then FTI="-I${pre}/include/freetype2" FTL="-L${pre}/lib" fi done if test "${FCI}" = -I/usr/include; then FCI=''; fi if test "${FCL}" = "-L/usr/lib"; then FCL=''; fi if test "${FTL}" = "-L/usr/lib"; then FTL=''; fi if test "${FTL}" = "${FCL}"; then FTL=''; fi if test -z "${FCI}" -a -z "${FTI}"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } as_fn_error $? "Cannot find fontconfig/freetype2 although cairo claims to support it. Please check your cairo installation and/or update cairo if necessary or set CAIRO_CFLAGS/CAIRO_LIBS accordingly." "$LINENO" 5 fi FT_CPPFLAGS="${FCI} ${FTI}" FT_LIBS="${FCL} ${FTL} -lfontconfig -lfreetype -lz" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: possibly" >&5 printf "%s\n" "possibly" >&6; } fi zLIBS="${LIBS}" LIBS="${LIBS} ${FT_LIBS}" zCPPFLAGS="${CPPFLAGS}" CPPFLAGS="${CPPFLAGS} ${FT_CPPFLAGS}" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether additional flags work" >&5 printf %s "checking whether additional flags work... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { cairo_ft_font_face_create_for_pattern(0); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } CAIRO_LIBS="${CAIRO_LIBS} ${FT_LIBS}" CAIRO_CFLAGS="${CAIRO_CFLAGS} ${FT_CPPFLAGS}" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } as_fn_error $? "Cannot use cairo-ft backend, although cairo claims it is working. Please check your caito installation and/or update cairo if necessary or set CAIRO_CFLAGS/CAIRO_LIBS accordingly." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi fi ## with_freetype # --- check for JPEG support --- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether libjpeg works" >&5 printf %s "checking whether libjpeg works... " >&6; } zLIBS="${LIBS}" LIBS="${LIBS} -ljpeg" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(void) { struct jpeg_compress_struct cinfo; jpeg_create_compress(&cinfo); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } printf "%s\n" "#define SUPPORTS_JPEG 1" >>confdefs.h else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } LIBS="${zLIBS}" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext # --- check for Harfbuzz/ICU support --- # Check whether --with-harfbuzz was given. if test ${with_harfbuzz+y} then : withval=$with_harfbuzz; with_harfbuzz=$withval else $as_nop with_harfbuzz=auto fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether Harfbuzz layout is desired" >&5 printf %s "checking whether Harfbuzz layout is desired... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${with_harfbuzz}" >&5 printf "%s\n" "${with_harfbuzz}" >&6; } if test x${with_harfbuzz} != xno; then if test x${has_cairo_ft} != xyes; then if test x${with_harfbuzz} = xyes; then as_fn_error $? "ERROR: Harfbuzz support is requested, but FreeType is not available. Harfbuzz requires cairo with FreeType support to be present." "$LINENO" 5 else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: NOTE: Harfbuzz requires cairo with FreeType support which is not available." >&5 printf "%s\n" "$as_me: NOTE: Harfbuzz requires cairo with FreeType support which is not available." >&6;} fi with_harfbuzz=no fi fi if test x${with_harfbuzz} != xno; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether Harfbuzz + ICU works" >&5 printf %s "checking whether Harfbuzz + ICU works... " >&6; } zLIBS="${LIBS}" zCPPFLAGS="${CPPFLAGS}" if test -n "$PKGCONF"; then : ${HB_CPPFLAGS=`"${PKGCONF}" --cflags harfbuzz-icu icu-uc`} : ${HB_LIBS=`"${PKGCONF}" --libs ${PKGCONF_LIB_ADD} harfbuzz-icu icu-uc`} fi if test -z "${HB_LIBS}"; then HB_LIBS='-lharfbuzz-icu -licuuc -licudata -lharfbuzz' fi ## ICU uses C++ (sadly) so requires stdc++ - this may not be very portable ... LIBS="${LIBS} ${HB_LIBS} -lstdc++" CPPFLAGS="${CPPFLAGS} ${HB_CPPFLAGS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include int main(void) { UBiDi *bidi = 0; UChar *text = 0; bidi = ubidi_open(); hb_buffer_t *buf = hb_buffer_create(); hb_buffer_set_unicode_funcs(buf, hb_icu_get_unicode_funcs()); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } printf "%s\n" "#define HAVE_HARFBUZZ 1" >>confdefs.h else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } LIBS="${zLIBS}" CPPFLAGS="${zCPPFLAGS}" HB_CPPFLAGS='' fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi # --- check for TIFF support { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether libtiff works" >&5 printf %s "checking whether libtiff works... " >&6; } zLIBS="${LIBS}" if test -n "$PKGCONF"; then ## FIXME: --cflags? TIFF_LIBS=`"${PKGCONF}" --libs ${PKGCONF_LIB_ADD} libtiff-4` fi if test -z "${TIFF_LIBS}"; then TIFF_LIBS=-ltiff fi LIBS="${LIBS} ${TIFF_LIBS}" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main(void) { TIFF *out = TIFFOpen("new.tif", "w"); TIFFSetField (out, TIFFTAG_IMAGEWIDTH, 100); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } printf "%s\n" "#define SUPPORTS_TIFF 1" >>confdefs.h else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } LIBS="${zLIBS}" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext ## our CPPFLAGS included R's CPPFLAGS which we don't need to ## set so only include those we detected in addition to the ## R CMD config CPPFLAGS CPPFLAGS="${CAIRO_CFLAGS} ${HB_CPPFLAGS} ${HAVE_RCONN_H}" # Check whether --enable-debug was given. if test ${enable_debug+y} then : enableval=$enable_debug; want_debug="${enableval}" else $as_nop want_debug=no fi if test ${want_debug} = yes; then CPPFLAGS="-DJGD_DEBUG=1 ${CPPFLAGS}" fi ac_config_files="$ac_config_files src/Makevars" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 printf "%s\n" "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by Cairo $as_me 1.3, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ Cairo config.status 1.3 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" Copyright (C) 2021 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) printf "%s\n" "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) printf "%s\n" "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) printf "%s\n" "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX printf "%s\n" "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/cconfig.h") CONFIG_HEADERS="$CONFIG_HEADERS src/cconfig.h" ;; "src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 printf "%s\n" "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`printf "%s\n" "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi