[fpc-pascal] fpcmake packaging
Tomas Hajny
XHajT03 at hajny.biz
Tue Sep 1 15:59:23 CEST 2020
On 2020-09-01 15:29, Ryan Joseph via fpc-pascal wrote:
>> On Sep 1, 2020, at 7:46 PM, Tony Whyman via fpc-pascal
>> <fpc-pascal at lists.freepascal.org> wrote:
>>
>> fpcmake is a pre-processor that generates makefiles for fpc projects.
>> You can use it to do just about anything a standard makefile can do,
>> including including resource files and running scripts. I use it all
>> the time for building production versions of lazarus programs and
>> prior to packaging the programs and resources in .deb and .rpm files.
>>
>> On 01/09/2020 13:37, Ryan Joseph via fpc-pascal wrote:
>>
>
> Apparently there is fpmake and fpcmake, which I didn't know.
>
> I guess what you're saying is that I start with fpcmake and get
> makefiles which I can then use to do packing and all the stuff I need?
> I've thought of using makefiles before but I ran into the problem of
> have all this logic that I need to duplicate for each project. What
> I'm really after is something more like lazbuild that takes a config
> file and does all the commands for you. I guess I could even use
> lazbuild but again, the packaging doesn't seem possible since lazbuild
> is so Lazarus focused (obviously).
In case of fpcmake, the file Makefile.fpc is basically equivalent to a
configuration file:
-----------------
[package]
name=fcl-res
version=3.3.1
[target]
units=acceleratorsresource bitmapresource coffconsts coffreader
cofftypes \
coffwriter dfmreader elfconsts elfreader elftypes elfwriter
externalreader \
externaltypes externalwriter fpcrestypes groupcursorresource
groupiconresource \
groupresource icocurtypes machoconsts machoreader machotypes
machowriter \
resdatastream resfactory resmerger resource resourcetree resreader
reswriter \
stringtableresource strtable tlbreader versionconsts
versionresource versiontypes \
winpeimagereader xcoffwriter
rsts=versiontypes stringtableresource resource resfactory
[compiler]
options=-S2h
sourcedir=src
[install]
fpcpackage=y
[default]
fpcdir=../..
[rules]
.NOTPARALLEL:
====================
You _may_ define additional logic (on top of the prebuilt things known
to the fpcmake tool / defined in fpcmake.ini) in the [rules] section,
but that is not strictly necessary as long as you don't have special
dependencies, don't need to invoke the compiler or other tools with
special parameters for different targets, etc.
In case of fpmake, the "configuration" is a rather simple pascal program
(fpmake.pp):
---------------------------------
{$ifndef ALLPACKAGES}
{$mode objfpc}{$H+}
program fpmake;
uses fpmkunit;
Var
T : TTarget;
P : TPackage;
begin
With Installer do
begin
{$endif ALLPACKAGES}
P:=AddPackage('fcl-res');
P.ShortName:='fcle';
{$ifdef ALLPACKAGES}
P.Directory:=ADirectory;
{$endif ALLPACKAGES}
P.Version:='3.3.1';
P.Dependencies.Add('rtl-objpas');
P.Dependencies.Add('fcl-base');
P.Dependencies.Add('tplylib');
P.Author := 'Giulio Bernardi';
P.License := 'LGPL with modification, ';
P.HomepageURL := 'www.freepascal.org';
P.Email := '';
P.Description := 'Resource handling of Free Component Libraries
(FCL), FPC''s OOP library.';
P.NeedLibC:= false;
P.OSes:=AllOSes-[embedded,msdos,win16,macosclassic,palmos,zxspectrum,msxdos,amstradcpc];
if Defaults.CPU=jvm then
P.OSes := P.OSes - [java,android];
P.SourcePath.Add('src');
P.IncludePath.Add('src');
T:=P.Targets.AddUnit('acceleratorsresource.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resfactory');
end;
T:=P.Targets.AddUnit('bitmapresource.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resfactory');
AddUnit('resdatastream');
end;
T:=P.Targets.AddUnit('coffconsts.pp');
T:=P.Targets.AddUnit('cofftypes.pp');
T:=P.Targets.AddUnit('coffreader.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resourcetree');
AddUnit('cofftypes');
AddUnit('coffconsts');
AddUnit('resdatastream');
end;
T:=P.Targets.AddUnit('coffwriter.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resourcetree');
AddUnit('cofftypes');
AddUnit('coffconsts');
end;
T:=P.Targets.AddUnit('xcoffwriter.pp');
with T.Dependencies do
begin
AddUnit('cofftypes');
AddUnit('coffwriter');
AddUnit('coffconsts');
AddUnit('fpcrestypes');
end;
T:=P.Targets.AddUnit('dfmreader.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resdatastream');
AddUnit('resfactory');
end;
T:=P.Targets.AddUnit('tlbreader.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resdatastream');
AddUnit('resfactory');
end;
T:=P.Targets.AddUnit('elfconsts.pp');
T:=P.Targets.AddUnit('elftypes.pp');
T:=P.Targets.AddUnit('elfreader.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('elfconsts');
AddUnit('elftypes');
AddUnit('resdatastream');
AddUnit('resfactory');
AddUnit('resourcetree');
AddUnit('strtable');
AddUnit('fpcrestypes');
AddInclude('elfsubreader.inc');
AddInclude('elfdefaulttarget.inc');
end;
T:=P.Targets.AddUnit('elfwriter.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('elfconsts');
AddUnit('elftypes');
AddUnit('resourcetree');
AddUnit('strtable');
AddUnit('fpcrestypes');
AddInclude('elfsubwriter.inc');
AddInclude('elfdefaulttarget.inc');
end;
T:=P.Targets.AddUnit('externaltypes.pp');
T:=P.Targets.AddUnit('externalreader.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resourcetree');
AddUnit('externaltypes');
AddUnit('resdatastream');
AddUnit('resfactory');
end;
T:=P.Targets.AddUnit('externalwriter.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resourcetree');
AddUnit('externaltypes');
AddUnit('strtable');
end;
T:=P.Targets.AddUnit('fpcrestypes.pp');
T:=P.Targets.AddUnit('groupcursorresource.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('groupresource');
AddUnit('resfactory');
AddUnit('resdatastream');
AddUnit('icocurtypes');
end;
T:=P.Targets.AddUnit('groupiconresource.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('groupresource');
AddUnit('resfactory');
AddUnit('resdatastream');
AddUnit('icocurtypes');
end;
T:=P.Targets.AddUnit('groupresource.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resdatastream');
AddUnit('icocurtypes');
end;
T:=P.Targets.AddUnit('icocurtypes.pp');
T:=P.Targets.AddUnit('machotypes.pp');
T:=P.Targets.AddUnit('machoconsts.pp');
with T.Dependencies do
begin
AddUnit('machotypes');
end;
T:=P.Targets.AddUnit('machoreader.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('machotypes');
AddUnit('machoconsts');
AddUnit('resfactory');
AddUnit('resourcetree');
AddUnit('resdatastream');
AddUnit('fpcrestypes');
AddInclude('machosubreader.inc');
AddInclude('machodefaulttarget.inc');
end;
T:=P.Targets.AddUnit('machowriter.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('machotypes');
AddUnit('resourcetree');
AddUnit('machoconsts');
AddUnit('strtable');
AddUnit('fpcrestypes');
AddInclude('machosubwriter.inc');
AddInclude('machodefaulttarget.inc');
end;
T:=P.Targets.AddUnit('rcparser.pas');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('acceleratorsresource');
AddUnit('groupiconresource');
AddUnit('stringtableresource');
AddUnit('bitmapresource');
AddUnit('versionresource');
AddUnit('versiontypes');
AddUnit('groupcursorresource');
AddInclude('rcparserfn.inc');
AddInclude('rclex.inc');
AddInclude('yyinclude.pp');
AddInclude('yypreproc.pp');
end;
T:=P.Targets.AddUnit('rcreader.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resdatastream');
AddUnit('resfactory');
AddUnit('rcparser');
end;
T:=P.Targets.AddUnit('resdatastream.pp');
with T.Dependencies do
begin
AddUnit('resource');
end;
T:=P.Targets.AddUnit('resfactory.pp');
with T.Dependencies do
begin
AddUnit('resource');
end;
T.ResourceStrings := True;
T:=P.Targets.AddUnit('resmerger.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('stringtableresource');
AddUnit('groupiconresource');
AddUnit('groupcursorresource');
end;
T:=P.Targets.AddUnit('resource.pp');
with T.Dependencies do
begin
AddUnit('resdatastream');
AddUnit('resourcetree');
AddUnit('resmerger');
end;
T.ResourceStrings := True;
T:=P.Targets.AddUnit('resourcetree.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resfactory');
end;
T:=P.Targets.AddUnit('resreader.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resdatastream');
AddUnit('resfactory');
end;
T:=P.Targets.AddUnit('reswriter.pp');
with T.Dependencies do
begin
AddUnit('resource');
end;
T:=P.Targets.AddUnit('stringtableresource.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('resfactory');
end;
T.ResourceStrings := True;
T:=P.Targets.AddUnit('strtable.pp');
with T.Dependencies do
begin
AddUnit('resource');
end;
T:=P.Targets.AddUnit('versionconsts.pp');
T:=P.Targets.AddUnit('versionresource.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('versiontypes');
AddUnit('resfactory');
end;
T:=P.Targets.AddUnit('versiontypes.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('versionconsts');
end;
T.ResourceStrings := True;
T:=P.Targets.AddUnit('winpeimagereader.pp');
with T.Dependencies do
begin
AddUnit('resource');
AddUnit('coffreader');
end;
{$ifndef ALLPACKAGES}
Run;
end;
end.
{$endif ALLPACKAGES}
===================
Again, you may add special logic, but you don't need to for most common
cases.
Tomas
More information about the fpc-pascal
mailing list