let get_output () =
  match OutputDir.get () with
    | "" -> 
        begin
          match !tmp_dir with
            | Some dir -> dir
            | None ->
                let dir = Extlib.temp_dir_cleanup_at_exit "wp" in
                tmp_dir := Some dir ; dir
        end
    | dir -> 
        if Sys.file_exists dir then
          begin
            if not (Sys.is_directory dir) then 
              abort "File '%s' is not a directory (WP aborted)" dir ;
          end
        else
          begin
            try 
              Unix.mkdir dir 0o770 ;
              debug "Created output directory '%s'" dir
            with e -> 
              debug "System error '%s'" (Printexc.to_string e) ;
              abort "Can not create output directory '%s'" dir 
          end ;
        dir