Difference between revisions of "FPMake"

From Lazarus wiki
Jump to navigationJump to search
Line 29: Line 29:
  
  
== Example fpmake.pp ==
+
== Simple example fpmake.pp ==
  
 
   program fpmake;
 
   program fpmake;
Line 55: Line 55:
  
 
   fpc fpmake.pp
 
   fpc fpmake.pp
 +
 +
== More complex example fpmake.pp ==
 +
program fpmake;
 +
 +
Type
 +
  TWidgetSet = (wsGDI,wsX,wCarbon);
 +
 +
Var
 +
  WidgetSet : TWidgetSet;
 +
 +
procedure DetermineWidgetSet;
 +
 +
Var
 +
  I : Integer;
 +
 +
begin
 +
  Case Installer.OS of
 +
    Windows : WidgetSet:=wsGDI;
 +
    Linux : Widgetset:=wsX;
 +
    macos : WidgetSet:=wsCarbon
 +
  end;
 +
  // Check paramstr() to see if the widgetset was overridedn on the commandline;
 +
  For I:=1 to ParamCount do
 +
    If ParamStr(i)='--widgetset=X' then
 +
      WidgetSet:=wsX;
 +
end;
 +
 +
begin
 +
  DetermineWidgetSet;
 +
  With Installer do
 +
  /// ....
 +
  Case WidgetSet of
 +
    wsGDI : T.UnitPath:='corelib/gdi';
 +
    wsX  : T.UnitPath:='corelib/x11';
 +
    // etc.
 +
  end;
 +
  ...
 +
  Run;
 +
  end;
 +
end.
  
 
== Targets ==
 
== Targets ==

Revision as of 22:29, 10 August 2007

Introduction

This page summarizes all available knowledge on FPMake. FPMake is a pascal based build system developed for and distributed with FPC. It possible to use FPMake with non FPC development related projects as a replacement for Make or other build systems (like cons, scons, etc).

Basics

The upcoming 2.2 will contain the basics for a package system. Look at all directories in the fpc source dirs. You'll find there a fpmake.pp or fpmake.inc.

The idea is that you do a

 fppkg <packagename>

this will look in a database for the package, extract it, and the compile fpmake.pp and run it. The fpmake contains all configuration to make and zip the package.

You could download a package manually, compile fpmake.pp and run

 ./fpmake --build

or

 ./fpmake --install

which would install the file.

The fpmake.pp file is very simple, just look at the examples, they are scattered all over the place.

The idea is that the release after 2.2 will use this system.


Simple example fpmake.pp

 program fpmake;
 uses fpmkunit;
 Var
   T : TTarget;
 begin
   With Installer do
   begin
     StartPackage('MyNiceProgram'); // Actually optional.
     Targets.DefaultOS:=[win32,openbsd,netbsd,freebsd,darwin,linux];
     T:=Targets.AddUnit('myunit');
     T.ResourceStrings:=True; 
     T:=Targets.AddUnit('myprogram');
     T.AddDependency('myunit');
     EndPackage; // Actually optional.
     Run;
   end;
 end.

Compile with

 fpc fpmake.pp

More complex example fpmake.pp

program fpmake;

Type

 TWidgetSet = (wsGDI,wsX,wCarbon);

Var

 WidgetSet : TWidgetSet;

procedure DetermineWidgetSet;

Var

 I : Integer;

begin

 Case Installer.OS of
   Windows : WidgetSet:=wsGDI;
   Linux : Widgetset:=wsX;
   macos : WidgetSet:=wsCarbon
 end;
 // Check paramstr() to see if the widgetset was overridedn on the commandline;
 For I:=1 to ParamCount do
   If ParamStr(i)='--widgetset=X' then
     WidgetSet:=wsX;

end;

begin

 DetermineWidgetSet;
 With Installer do
  /// .... 
  Case WidgetSet of
   wsGDI : T.UnitPath:='corelib/gdi';
   wsX   : T.UnitPath:='corelib/x11';
   // etc.
  end;
 ...
 Run;
 end;

end.

Targets

 ./fpmake --build

This will build your project. Or,

 ./fpmake --install

will install it.

 ./fpmake --archive

will create a zip.

The plan is to also add

 ./fpmake --innosetup

Which will generate a file tha can be included in an inno setup file.