OMakefile 5.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#*********************************************************************#
#                                                                     #
#                          Caml Images                                #
#                                                                     #
#            Fran輟is 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.                                    #
#                                                                     #
#*********************************************************************#

.PHONY: all clean libraries install

.DEFAULT: all

LIBRARY_PREFIX=camlimages

####################################################################### C FILES

CFILES_freetype[]=
  ftintf

CFILES_freetype_na[]=
  ftintf_na

CFILES_gif[]=
  gifread
  gifwrite

CFILES_gif_na[]=
  gif_na

CFILES_jpeg[]=
  jpegread
  jpegwrite

CFILES_jpeg_na[]=
  jpeg_na

43 44 45 46 47 48
CFILES_exif[]=
  exif_c

CFILES_exif_na[]=
  exif_na

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
CFILES_png[]=
  pngread
  pngwrite

CFILES_png_na[]=
  png_na

CFILES_tiff[]=
  tiffread
  tiffwrite

CFILES_tiff_na[]=
  tiff_na

CFILES_xpm[]=
  xpmread
  xpmwrite

CFILES_xpm_na[]=
  xpm_na

CFILES_ps[]=

CFILES_ps_na[]=

CFILES_lib(name) =
75
  CFILES_VAR = $(if $(mem $(name), all all_formats supported $(SUPPORTED_SUBPACKAGES)), CFILES_$(name), CFILES_$(name)_na)
76 77 78 79 80 81
  value $(getvar $(CFILES_VAR))

CFILES_supported=
  foreach(p, $(SUPPORTED_FORMATS))
    value $(CFILES_lib $(p))

82
CFILES_all_formats=
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
  foreach(p, $(FORMATS))
    value $(CFILES_lib $(p))

###################################################################### ML FILES

FILES_core[]=
  bitmap
  blend
  camlimages
  cmyk32
  color
  colorhist
  genimage
  geometry
  images
  index16
  index8
  jis_table
  jis_unicode
  mstring
  oColor
  oImages
  reduce
  region
  rgb24
  rgba32
  tmpfile
  units
  bmp
  oBmp
  ppm
  oPpm
  xvthumb
  oXvthumb

FILES_gif[]=
  gif
  oGif

FILES_jpeg[]=
  jpeg
  oJpeg

126 127 128 129 130 131 132 133
FILES_exif[]=
  exifutil
  exif
  exifanalyze

exifanalyze.auto.mli: exifanalyze.ml
    $(OCamlC) -c -i exifanalyze.ml > $@

134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
FILES_png[]=
  png
  oPng

FILES_tiff[]=
  tiff
  oTiff

FILES_freetype[]=
  freetype
  ftlow
  fttext
  oFreetype

FILES_xpm[]=
  xpm
  oXpm

FILES_ps[]=
  ps
  oPs

FILES_supported=
  foreach(p, $(SUPPORTED_FORMATS))
    value $(getvar FILES_$(p))

160
FILES_all_formats=
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
  foreach(p, $(FORMATS))
    value $(getvar FILES_$(p))

FILES_graphics[]=
  graphic_image
  oGraphic

FILES_lablgtk2[]=
  imagegdk
  oXimage
  oXimage2
  ximage
  ximage2

####################################################################### LDFLAGS

LDFLAGS_core[]=

LDFLAGS_supported=
  x=
  foreach(p, $(SUPPORTED_FORMATS))
    x+= $(getvar LDFLAGS_$(p))
    export
  value $(x)

186
LDFLAGS_all_formats=
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
  x=
  foreach(p, $(FORMATS))
    x+= $(getvar LDFLAGS_$(p))
    export
  value $(x)

###################################################################### PACKAGES

PACKS_graphics[]=
  graphics

PACKS_lablgtk2[]=
  lablgtk2

################################################################## C BUILD RULE

203 204 205 206 207 208 209 210
CFLAGS_supported=
  x=
  foreach(p, $(SUPPORTED_SUBPACKAGES))
    x+= $(getvar CFLAGS_$(p))
    export
  value $(x)

CFLAGS+= -fPIC -I $(OCAML_WHERE) $(CFLAGS_supported)
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244

MakeLibC(name) =
  OCamlMkLibC($(LIBRARY_PREFIX)_$(name), \
	$(CFILES_lib $(name)), \
	$(getvar LDFLAGS_$(name)))

################################################################# ML BUILD RULE

MakeLibOCaml(name) =

  OCAMLPACKS=
    try
      getvar(PACKS_$(name))
    default
      array() # default is empty

  pure=
    try $(equal 0, $(length $(getvar CFILES_$(name))))
    default
      value true

  if $(pure)
    # pure ocaml library
    OCAML_LIB_FLAGS=
      try
        -linkall $(mapprefix -cclib, $(LDFLAGS) $(getvar LDFLAGS_$(name)))
      default
        array()
    OCamlLibrary($(LIBRARY_PREFIX)_$(name), $(getvar FILES_$(name)))

  else # inpure
    $(LIBRARY_PREFIX)_$(name).cma $(LIBRARY_PREFIX)_$(name).cmxa: $(MakeLibC $(name))
    # OCAML_{BYTE,NATIVE}_LINK_FLAGS do not work for OCamlLibrary
    # Bit dirty workaround
245
    OCAMLCFLAGS+=-dllib -l$(LIBRARY_PREFIX)_$(name) -cclib -l$(LIBRARY_PREFIX)_$(name)
246 247 248 249 250 251 252 253
    OCAMLOPTFLAGS+=-cclib -l$(LIBRARY_PREFIX)_$(name)
    # use mapprefix instead of addprefix, otherwise "-cclib -lgif"
    # is considered one option.
    OCAML_LIB_FLAGS=-linkall $(mapprefix -cclib, $(LDFLAGS) $(getvar LDFLAGS_$(name)))
    OCamlLibrary($(LIBRARY_PREFIX)_$(name), $(getvar FILES_$(name)))

LIBRARIES=
  # CR jfurue: lablgtk2, freetype and graphics may not be buildable
254
  foreach(i, core $(FORMATS) all_formats supported $(SUPPORTED_NON_FORMATS))
255 256 257 258 259
    MakeLibOCaml($(i))

libraries: $(LIBRARIES)

clean:
260
  rm -f *.sp*t *.cmt*
261 262 263 264 265 266 267 268 269 270 271 272 273
  rm -f $(filter-proper-targets $(ls R, .))

LocalOCamlGeneratedFiles(camlimages.ml)
ConfReplaceAt(camlimages.ml)

ConfReplaceAt(META)

all: libraries META

INSTALL_TARGETS()=
    value META \
      $(glob i, *.mli) \
      $(glob i, *.cmi) \
274 275
      $(glob i, *.cmt) \
      $(glob i, *.cmti) \
276 277 278 279 280 281 282 283 284 285 286 287
      $(glob i, *.cma) \
      $(glob i, *.cmxa) \
      $(glob i, *.a) \
      $(glob i, *.so)

INSTALL()=
  value $(OCAMLFIND) install $(LIBRARY_PREFIX) $(INSTALL_TARGETS)

UNINSTALL()=
  value $(OCAMLFIND) remove $(LIBRARY_PREFIX)

install: all
288
  $(UNINSTALL) # I get bored typing ocamlfind remove camlimages each time before omake install
289 290
  $(INSTALL)

291 292 293 294 295
.PHONY: uninstall

uninstall:
  $(UNINSTALL)

296 297 298 299 300 301 302
# Author's personal thing
if $(defined BIG_ROOT)
    %.cmx %.cmo %.cmi %.cma %.cmxa %.annot %.spot %.spit: $(INSTALLED)/lablgtk2
    $(INSTALLED)/camlimages: $(LIBRARIES) META
        $(touch_installed_md5 camlimages, $(INSTALL_TARGETS))
        $(UNINSTALL)
        $(INSTALL)