
:- make(_,_).

:- use_package([functions]).

:- use_module(library('make/system_extra'),[ls/2,do/2,(-)/1,set_perms/2]).
:- use_module(library(terms),[atom_concat/2]).

execpermissions := perm(rwx,rwx,rx).
datapermissions := perm(rw, rw, r ).

pdf <= ps :: FileBase :-
	do(['ps2pdf ',FileBase,'.ps ',FileBase,'_bitmap.pdf'], nofail),
	-(set_perms(~atom_concat([FileBase,'_bitmap.pdf']),~datapermissions)).

%% main(_) :-
%% 	ls('*.ps',PsFiles),
%% 	process_ps_files(PsFiles).
%% 
%% process_ps_files([]).
%% process_ps_files([PsFile|PsFiles]) :-
%% 	file_name_extension(PsFile,BaseName,'.ps'),
%% 	file_name_extension(PdfFile,BaseName,'.pdf'),
%% 	file_name_extension(PdfBitMapFile,BaseName,'_bitmap.pdf'),
%% 	needs_processing(PsFile,PdfFile),
%% 	process_ps_files(PsFiles).
%% 
%% needs_processing(Source,Target) :-
%% 	( \+ file_exists(Target)
%% 	; modif_time0(Source, STime),
%% 	  modif_time0(Target, TTime),
%% 	  STime > TTime ).

