let make_output_dir 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 ;
      dir
    end
  else
    begin
      try
        Unix.mkdir dir 0o770 ;
        debug "Created output directory '%s'" dir ; dir
      with e ->
        debug "System error '%s'" (Printexc.to_string e) ;
        abort "Can not create output directory '%s'" dir
    end