[fpc-pascal] Makefiles vs Pascal Automation

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Oct 28 17:55:39 CEST 2006


On Sat, 28 Oct 2006 01:04:12 -0600
L505 <fpcmail at z505.com> wrote:

> In many cases makefiles take about just as long to create as shell
> scripts or pascal programs - they just offer a nice framework to
> automate compiling in an easy way - but in sort of a funny syntax.
> But makefiles kind of become ugly when they get big - and because
> they have a poor syntax compared to pascal programs - couldn't one
> just write a pascal program to automate the compilation process,
> instead of a makefile? (if a good framework was in place).
> 
> A reusable "automation" unit or framework would need to be created so
> that automating the compile process from within a pascal program was
> easy.
> 
> After thinking about it, I determined that makefiles are actually
> PROGRAMS in disguise - not config files, as their syntax seems to
> lead us to believe. They are config files on steroids. Config files
> generally don't execute instructions.. config files are more geared
> toward storage of settings. But makefiles do execute instructions!
> Makefiles are programs, not settings files.
> 
> So if makefiles are actually mini-programs, why couldn't we simply
> write makefiles in pascal instead of writing makefiles in
> makefile-language/fpcmake-language?
> 
> Psuedo Example.. let's consider I have to make four CGI programs in
> one shot. I want to rename EXE or ELF programs to CGI programs after
> the compilation is done. Compiling four programs using Make is
> possible, writing up a makefile.. but it could also be done this way:
> 
> program Maker;
> uses
>   CompileTools; //the framework that simulates MAKE
> const
>   targets : array of [1..4] = ('index.pp', 'main.pp', 'login.pp',
> 'logout.pp'); begin
>   // compile several programs
>   Compile(targets);
>   if OStarget = linux then
>      writeln('compiling 4 programs for linux..');
>   // 4 could actually be "CompileCount", if framework implemented
> such a thing if OStarget = windows then
>      writeln('compiling 4 programs for windows..');
>   for i:= 1 to 4 do
>    RenameFile(CompiledEXE[i], CompiledEXEName[i] + '.cgi');
>   DeleteFiles('*.ppu', '*.a', '*.o');
> end;
> 
> At the command line:
>   maker all
> 
> Instead of using make:
>   make all
> 
> The framework in the maker program would handle "all", "clean", etc.
> Instead of writing a new makefile each time we wanted to automated
> compilation, we would simple write a new pascal program which used
> the maker framework.
> 
> Why did I come across this idea? The same reason I sometimes build a
> pascal program instead of using a shell script!
> The same reason that HTML files would make poor executables! The same
> reason that config files are really not meant to be programs... but
> rather settings files. Similarly, a config file is really not a
> program - and makefiles are becoming INI files on steroids - programs!
> 
> If compiling the MAKER program each time is too much work, then maybe
> this would be a good use for PascalScript.
> 
> So basically my main point is that make files have become executable
> INI files - something INI files really aren't intended to be - with
> less power and clarity than a real pascal program.

That's why FPC is switching to fpmake.pp files. And eventually/probably
lazarus too.

Mattias



More information about the fpc-pascal mailing list