Source

camlimages / OMakefile

#*********************************************************************#
#                                                                     #
#                          Caml Images                                #
#                                                                     #
#            Franis Pessaux, projet Cristal, INRIA Rocquencourt     #
#            Pierre Weis, projet Cristal, INRIA Rocquencourt          #
#            Jun Furuse, projet Cristal, INRIA Rocquencourt           #
#                                                                     #
#  Copyright 1999-2004,                                               #
#  Institut National de Recherche en Informatique et en Automatique.  #
#  Distributed only by permission.                                    #
#                                                                     #
#*********************************************************************#

include OMyMakeroot

########################################## You may want to change these

# Specify non standard include directories
INCLUDES[]=
  /usr/include/X11
  /usr/local/include

public.CheckCLib(libs, funs) =
    LDFLAGS += $(addprefix -l, $(libs))

    return $(TryLinkC $"""
#ifdef __cplusplus
extern "C"
#endif
#pragma warning( disable : 4100 )
/* Override any gcc2 internal prototype to avoid an error.  */
$(add-wrapper $(nl)extern char , $'();', $(funs))
int main(int argc, char **argv) {
    /* Usage */
$(add-wrapper $(nl)    , $'();', $(funs))
    return 0;
}
""")

# Specify non standard library directories
LDFLAGS[]+=
# for example, 
# LDFLAGS[]+= -L/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/

# Specify directories where X's rgb.txt can be found
PATH_RGB_TXT[]=
  /etc/X11
  /usr/share/X11

BYTE_ENABLED=1
NATIVE_ENABLED=1

########################################################################

VERSION=4.0.3

# for src/META
PACKAGE_NAME=camlimages
PACKAGE_VERSION=$(VERSION)

OCAMLMKLIB=ocamlmklib

##################################################### Auto configuration

print_configured() =
  println(--- Configuring)
  println(wordsize  $(WORD_SIZE))
  println(--- C libraries)
  println(libgif:   $(HAVE_GIF))
  println(libpng:	  $(HAVE_PNG))
  println(libjpeg:  $(HAVE_JPEG))
  println(libtiff:  $(HAVE_TIFF))
  println(libxpm:	  $(HAVE_XPM))
  println(libz:	  $(HAVE_Z))
  println(--- Subpackages)
  println(gif:      $(SUPPORT_GIF) \($(string $(LDFLAGS_gif)\)))
  println(png:	  $(SUPPORT_PNG) \($(string $(LDFLAGS_png)\)))
  println(jpeg:	  $(SUPPORT_JPEG) \($(string $(LDFLAGS_jpeg)\)))
  println(tiff:	  $(SUPPORT_TIFF) \($(string $(LDFLAGS_tiff)\)))
  println(xpm:	  $(SUPPORT_XPM) \($(string $(LDFLAGS_xpm)\)))
  println(freetype: $(SUPPORT_FREETYPE) \($(PATH_FREETYPE_CONFIG)\) \($(string $(LDFLAGS_freetype))\))
  println(ps:       $(SUPPORT_PS) \($(PATH_GS)\))
  println(rgb.txt:  $(SUPPORT_RGB_TXT) \($(string $(PATH_RGB_TXT))\))
  println(lablgtk2: $(SUPPORT_LABLGTK2))
  println(graphics: $(SUPPORT_GRAPHICS))
  println(--- Summary)
  println(supported subpackages:  $(string $(SUPPORTED_SUBPACKAGES)))
  println(supported formats:  $(string $(SUPPORTED_FORMATS)))
  println(supported non-formats:  $(string $(SUPPORTED_NON_FORMATS)))
  println(CFLAGS:   $(string $(CFLAGS)))
  println(LDFLAGS:  $(string $(LDFLAGS)))
  println(---)

.STATIC:
  # Variables must be initialized inside .STATIC, if they should be
  # exported out.

  if $(not $(OCAMLFIND_EXISTS))
     eprintln(This project requires ocamlfind\, but is was not found.)
     eprintln(You need to install ocamlfind and run "omake --configure".)
     exit 1

  OCAMLMKLIB_EXISTS = $(CheckProg $(OCAMLMKLIB))
  if $(not $(OCAMLMKLIB_EXISTS))
     eprintln(This project requires ocamlmklib, but is was not found.)
     eprintln(You need to install ocamlmklib and run "omake --configure".)
     exit 1

  CFLAGS = $(addprefix -I , $(INCLUDES))

  WORD_SIZE = $(Word_size)

  # Image formats implemented using external libraries or binaries
  FORMATS= gif png jpeg tiff xpm ps

  # Image formats with necessary libraries supported
  SUPPORTED_FORMATS[]=

  # GUI/font rendering libraries supported
  SUPPORTED_NON_FORMATS[]=

  # SUPPORTED_FORMATS + SUPPORTED_NON_FORMATS
  SUPPORTED_SUBPACKAGES[]=

  # OCaml packages found likable
  OCAMLPACKS[]=

  HAVE_GIF = $(Check_header_library gif, gif_lib.h, DGifOpenFileName)
  SUPPORT_GIF = $(HAVE_GIF)
  LDFLAGS_gif=
  if $(SUPPORT_GIF)
    LDFLAGS_gif=-lgif
    SUPPORTED_FORMATS+=gif
    export

  HAVE_Z = $(Check_header_library z, zlib.h, zlibVersion)
  HAVE_PNG = $(Check_header_library png, png.h, png_create_read_struct)
  SUPPORT_PNG = $(and $(HAVE_Z) $(HAVE_PNG))
  LDFLAGS_png=
  if $(SUPPORT_PNG)
    LDFLAGS_png=-lpng -lz
    SUPPORTED_FORMATS+=png
    export

  HAVE_JPEG = $(Check_header_library jpeg, jpeglib.h, jpeg_read_header)
  SUPPORT_JPEG = $(HAVE_JPEG)
  LDFLAGS_jpeg=
  if $(SUPPORT_JPEG)
    LDFLAGS_jpeg=-ljpeg
    SUPPORTED_FORMATS+=jpeg
    export

  HAVE_TIFF = $(Check_header_library tiff, tiff.h, TIFFOpen)
  SUPPORT_TIFF = $(and $(HAVE_Z) $(HAVE_JPEG) $(HAVE_TIFF))
  LDFLAGS_tiff=
  if $(SUPPORT_TIFF)
    LDFLAGS_tiff=$(array -ltiff -ljpeg -lz)
    SUPPORTED_FORMATS+=tiff
    export

  HAVE_XPM = $(Check_header_library Xpm, xpm.h, XpmReadFileToXpmImage)
  SUPPORT_XPM = $(HAVE_XPM)
  LDFLAGS_xpm=
  if $(SUPPORT_XPM)
    LDFLAGS_xpm=-lXpm
    SUPPORTED_FORMATS+=xpm
    export

  SUPPORT_PS = $(Check_prog_in_path gs)
  PATH_GS = $(WHERE)
  LDFLAGS_ps=
  if $(SUPPORT_PS)
    LDFLAGS_ps=
    SUPPORTED_FORMATS+=ps
    export

  SUPPORT_LABLGTK2 = $(Check_ocamlfind_package lablgtk2)
  if $(SUPPORT_LABLGTK2)
    SUPPORTED_NON_FORMATS+=lablgtk2
    OCAMLPACKS+=lablgtk2
    export

  # CR: ocamlfind registers graphics even if not available
  SUPPORT_GRAPHICS = $(Check_ocamlfind_package_compilation graphics, Graphics)
  if $(SUPPORT_GRAPHICS)
    SUPPORTED_NON_FORMATS+=graphics
    OCAMLPACKS+=graphics
    export

  SUPPORT_FREETYPE = $(Check_prog_in_path freetype-config)
  PATH_FREETYPE_CONFIG = $(WHERE)
  LDFLAGS_freetype=
  if $(SUPPORT_FREETYPE)
    println(SUPPORT_FREETYPE=$(SUPPORT_FREETYPE)!)
    CFLAGS= $(CFLAGS) $(shell freetype-config --cflags)
    LDFLAGS_freetype= $(shell freetype-config --libs)
    export
  if $(SUPPORT_FREETYPE)
    SUPPORTED_NON_FORMATS+=freetype
    export

  SUPPORTED_SUBPACKAGES= $(SUPPORTED_FORMATS) $(SUPPORTED_NON_FORMATS)

  SUPPORT_RGB_TXT = $(Check_file_in_path $(PATH_RGB_TXT), rgb.txt)
  PATH_RGB_TXT = $(WHERE)

  print_configured()

# for config.h
CGeneratedFiles(config.h)
section:
  PACKAGE=\"camlimages\"
  PACKAGE_BUGREPORT=\"jun.furuse@gmail.com\"
  PACKAGE_NAME=$(PACKAGE)
  PACKAGE_STRING=\"camlimages $(VERSION)\"
  PACKAGE_TARNAME=$(PACKAGE)
  PACKAGE_VERSION=\"$(VERSION)\"
  SIZEOF_LONG=$(WORD_SIZE)
  VERSION=$(PACKAGE_VERSION)
  ConfReplaceConfigH(config.h)

.SUBDIRS: src test examples
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.