Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-11

setting defines in makefile

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sebastian Kraft

Hello,

just trying to create a makefile for a project...
How can I pass a define to compiler only for a special target?

for example a makefile.fpc snippet

[rules]
debpackage: all
set define DEBPACKAGE # passes -dDEBPACKAGE option to compiler

zippackage: all
set define ZIPPACKAGE # passes -dZIPPACKAGE option to compiler

I know there is this part in Makefile.fpc
[compiler]
options="-dxxx -OP2"

But this sets options for all targets I think.

Regards,
Sebastian

Reply by email

Graeme Geldenhuys
to Sebastian Kraft
Sebastian Kraft wrote
Hello, just trying to create a makefile for a project... How can I pass a define to compiler only for a special target?

I don't know, but why don't you rather try the new 'fpmake' build system. From what I have seen, it's much easier to use that Makefiles
- once you have a nice example to work from.

Henry Vermaak created a fpmake.pas example for fpGUI. You can find it here...

http://fpgui.svn.sourceforge.net/viewvc/fpgui/trunk/src/fpmake.pas?view=markup

It has sections that have OS specific handling for Windows and Linux. The fpmake build system was designed to replace Makefile's and have been available since fpc 2.2.0 I believe.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Sebastian Kraft
to Graeme Geldenhuys
Graeme Geldenhuys wrote
On Sun, Nov 2, 2008 at 10:43 AM, Sebastian Kraft
Show quoted text 9 lines
> Hello, > > just trying to create a makefile for a project... > How can I pass a define to compiler only for a special target? I don't know, but why don't you rather try the new 'fpmake' build system. From what I have seen, it's much easier to use that Makefiles - once you have a nice example to work from.

Did not know this exists. Looks interesting... But as far as I can see only predefined targets are usable(clean, build, ..) and there is no possibility to create a own .deb package target/command. Or did I miss something?

Sebastian

Reply by email

Graeme Geldenhuys
to Sebastian Kraft
Sebastian Kraft wrote 5 lines
Did not know this exists. Looks interesting... But as far as I can see only predefined targets are usable(clean, build, ..) and there is no possibility to create a own .deb package target/command. Or did I miss something?

I don't know much about 'fpmake', but there is a PDF document somewhere regarding fpmake. Otherwise Michael or Henry or somebody else might be able to help you.

Your original question was how to add a specific define for a target. The following code does that.

    if Defaults.OS in AllUnixOSes
      then Defaults.Options := Defaults.Options + '-dX11'
      else Defaults.Options := Defaults.Options + '-dGDI';

As for targets... <package>.Targets is a TCollection, so I'm pretty sure you can add custom targets to that collection.

fpmake.pas or fpmake.pp is all over the FPC source directories. So I'm pretty sure if you take a look at a few of those examples, it will reveal more information.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Sebastian Kraft
to Sebastian Kraft: just trying to create a makefile for a project... How can I pass a define to compiler…

I found the following in a makefile.fpc in the internet.

debpackage: all
override COMPILER+=-dNODEBUG # passes -dNODEBUg to compiler options

Works for me... But can someone explain me in short what this command does and why?

For me looks like it adds -dNODEBUG to compiler commandline which is stored in COMPILER. What does override mean here?

sebastian

Reply by email