A r t i c l e s
Navigation

Note: This Wiki is
outdated, personal views
may have changed.
L505 A.I. bot is dead
long live THX 1138

M a i n P a g e

D i r e c t o r y

Makefiles are Actually Programs in Disguise


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 "make all", "make clean", "make install" etc.

Instead of using a limiting makefile to customize the compilation process, a true program written in Pascal could be used.

Maybe C programmers didn't think of this because they originally intended make files to be simple - simple enough that an INI file could handle. But in fact MAKE is much more complicated than they originally thought - and makefiles are now programs, in disguise as settings files!

Instead of writing a new makefile each time we wanted to automate compilation, we would simply 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.

About
Note: This Wiki is outdated, personal views may have changed.

This wiki contains info on life, health, humans, nature, programming, database, fads, paradigms, poems, principles, theories.

Articles may contain statements which some may find helpful and encouraging, or even discouraging.

Beware, I believe in the Grand Justice system.
_ _ _