Commits

camlspotter  committed 10944bc

defaulting when ARG_WANT_* is not specified

  • Participants
  • Parent commits b888ab4

Comments (0)

Files changed (1)

 
 ##################################################### Auto configuration
 
-failwith(msg) =
-  eprintln(Error: $(msg))
-  exit 1
-
-
 print_configured() =
   println(--- Configuring)
   println(wordsize  $(WORD_SIZE))
   println(---)
 
 true_if_not_defined(var)=
-    if $(not $(defined $(var))): 
+    if $(not $(defined $(var))) 
       true
     else
-      $(var)
+      value $(getvar $(var))
+
+failwith_if_defined(var, msg) =
+  if $(defined $(var)):
+      eprintln(Error: $(msg))
+      exit 1
 
 .STATIC:
   # Variables must be initialized inside .STATIC, if they should be
   OCAMLPACKS[]=
 
   # GIF
-  SUPPORT_GIF = false
+  SUPPORT_GIF=false
   LDFLAGS_gif=
+  HAVE_GIF=
   if $(true_if_not_defined ARG_WANT_GIF)
     HAVE_GIF = $(Check_header_library gif, gif_lib.h, DGifOpenFileName)
     SUPPORT_GIF = $(HAVE_GIF)
       LDFLAGS_gif=-lgif
       SUPPORTED_FORMATS+=gif
       export
+    else
+      failwith_if_defined(ARG_WANT_GIF, gif requested but not found)
     export
 
   # PNG
   SUPPORT_PNG=false
   LDFLAGS_png=
+  HAVE_Z=
+  HAVE_PNG=
   if $(true_if_not_defined ARG_WANT_PNG)
     HAVE_Z = $(Check_header_library z, zlib.h, zlibVersion)
     HAVE_PNG = $(Check_header_library png, png.h, png_create_read_struct)
       SUPPORTED_FORMATS+=png
       export
     else
-      failwith(png requested but not found)
+      failwith_if_defined(ARG_WANT_PNG, png requested but not found)
     export
 
   # JPEG
   SUPPORT_JPEG=false
   LDFLAGS_jpeg=
+  HAVE_JPEG=
   if $(true_if_not_defined ARG_WANT_JPEG)
     HAVE_JPEG = $(Check_header_library jpeg, jpeglib.h, jpeg_read_header)
     SUPPORT_JPEG = $(HAVE_JPEG)
       SUPPORTED_FORMATS+=jpeg
       export
     else
-      failwith(jpeg requested but not found)
+      failwith_if_defined(ARG_WANT_JPEG, jpeg requested but not found)
     export
 
   # EXIF
   SUPPORT_EXIF=false
+  HAVE_EXIF=
+  LDFLAGS_exif=
   if $(true_if_not_defined ARG_WANT_EXIF)
     HAVE_EXIF = $(Check_header_library exif, exif-data.h, exif_data_load_data)
     SUPPORT_EXIF = $(HAVE_EXIF)
-    LDFLAGS_exif=
     if $(SUPPORT_EXIF)
       LDFLAGS_exif=-lexif
       SUPPORTED_FORMATS+=exif
       export
     else
-      failwith(exif requested but not found)
+      failwith_if_defined(ARG_WANT_EXIF, exif requested but not found)
     export
 
   # TIFF
   SUPPORT_TIFF=false
   LDFLAGS_tiff=
+  HAVE_TIFF=
   if $(true_if_not_defined ARG_WANT_TIFF)
     HAVE_TIFF = $(Check_header_library tiff, tiff.h, TIFFOpen)
     SUPPORT_TIFF = $(and $(HAVE_Z) $(HAVE_JPEG) $(HAVE_TIFF))
       SUPPORTED_FORMATS+=tiff
       export
     else
-      failwith(tiff requested but not found)
+      failwith_if_defined(ARG_WANT_TIFF, tiff requested but not found)
     export
 
   # XPM
   SUPPORT_XPM=false
   LDFLAGS_xpm=
+  HAVE_XPM=
   if $(true_if_not_defined ARG_WANT_XPM)
     HAVE_XPM = $(Check_header_library Xpm, X11/xpm.h, XpmReadFileToXpmImage)
     SUPPORT_XPM = $(HAVE_XPM)
       SUPPORTED_FORMATS+=xpm
       export
     else
-      failwith(xpm requested but not found)
+      failwith_if_defined(ARG_WANT_XPM, xpm requested but not found)
     export
 
   # PS
       SUPPORTED_FORMATS+=ps
       export
     else
-      failwith(ps requested but not found)
+      failwith_if_defined(ARG_WANT_GS, ps requested but not found)
     export
 
   # LABLGTK2
       OCAMLPACKS+=lablgtk2
       export
     else
-      failwith(lablgtk2 requested but not found)
+      failwith_if_defined(ARG_WANT_LABLGTK2, lablgtk2 requested but not found)
     export
 
   # GRAPHICS
       OCAMLPACKS+=graphics
       export
     else
-      failwith(graphics requested but not found)
+      failwith_if_defined(ARG_WANT_GRAPHICS, graphics requested but not found)
     export
 
   # FREETYPE
       SUPPORTED_NON_FORMATS+=freetype
       export
     else
-      failwith(freetype requested but not found)
+      failwith_if_defined(ARG_WANT_FREETYPE, freetype requested but not found)
     export
 
   SUPPORTED_SUBPACKAGES= $(SUPPORTED_FORMATS) $(SUPPORTED_NON_FORMATS)