open Conf;;
open Printf;;	

let spec =
  [
	findlib_check "str";
    (* findlib_check "pxp"; Granule doesn't matter anymore *)
    findlib_check "unix";
    param "nogtk" ~doc:"Do not include the GTK interface" (Bool false);
  ]
    
let configuration = Conf.configure spec
  
open AutoMake

let gtklibs, gtkincludes, gtksrcs, gtkflag =
  if configuration # get_bool "nogtk" then
    [], [], [], ""
  else
    ["lablgtk"], ["+lablgtk2"], ["GtkUi.mli"; "GtkUi.ml"], " -DGTK"
      
      
let sources = Util.prefix "src" (["Util.mli"; "Util.ml";
                                  "Architecture.ml";
                                  "Config.mli"; "Config.ml"; 
                                  "Debug.mli"; "Debug.ml";
                                  "Parser.mly";
                                  "Lexer.mll";
                                  "InputOutput.mli"; "InputOutput.ml";
                                  "FileHandling.mli"; "FileHandling.ml";
                                  "Entry.mli"; "Entry.ml";
                                  "Quiz.mli"; "Quiz.ml";
                                  "Data.mli"; "Data.ml";
                                  "CardBox.mli"; "CardBox.ml";
                                  "ConsoleUi.mli"; "ConsoleUi.ml";
                                 ] @ gtksrcs)


let pack =
    (package
	     ~package:"cardflasher"
         
	     ~version:"0.2"
         
	     ~findlibs:["str"; "unix"]
         
         ~cleaned:["src/*~"]
         
         ~flags:[
             [`compile; `ml], ["-w m"; "-warn-error A"; 
                               "-pp 'camlp4o pa_macro.cmo"^gtkflag^"'" ];
             [`byte; `ml], ["-g"];
             [`document], ["-colorize-code"; "-keep-code"; "-sort"]
         ]
         
         ~includes:(gtkincludes @ ["src"])
         
         ~libs:gtklibs
         
	     [
           executable "cardflasher" ~sources:(sources @ ["src/main.ml"]);
           (* executable "sanity_check" 
             ~sources:(sources @ ["src/sanity_check.ml"]); *)
           toplevel "toplevel" ~sources;
	     ]
    )

let _ =
    output_makefile ~configuration:(configuration :> AutoMake.configuration) pack;


;;
