Difference between revisions of "Fpcmake"

From Lazarus wiki
Jump to navigationJump to search
(Typo/lang sweep)
 
(20 intermediate revisions by 8 users not shown)
Line 1: Line 1:
Fpcmake is a makefile generator. It generates a makefile named "Makefile" from a definition file called "Makefile.fpc" and its own built-in template.
+
'''Fpcmake''' is a [[makefile]] generator, to control the [[make]] [[utility]] by [[GNU]]. It generates a makefile named "Makefile" from a definition file called "Makefile.fpc" and its own built-in template.
 +
It is used in the FPC source tree (e.g. in FPC 2.6.0), but is planned to be succeeded by [[FPMake]].
  
 
This template is located in utils/fpcm/fpcmake.ini, but since fpcmake.ini is included in the binary (to avoid path-searching issues), fpcmake has to be regenerated for each fpcmake.ini change.
 
This template is located in utils/fpcm/fpcmake.ini, but since fpcmake.ini is included in the binary (to avoid path-searching issues), fpcmake has to be regenerated for each fpcmake.ini change.
  
The manual has a quite good chapter about Makefile.fpc syntax, examples teach the rest (fpcmake.ini, the various Makefile.fpc's in the FPC source tree).
+
The manual has a quite good [https://www.freepascal.org/docs-html/current/prog/progap5.html#x294-310000E chapter about Makefile.fpc syntax], and examples teach the rest (fpcmake.ini, the various Makefile.fpcs in the FPC source tree).
  
 
It defines some default targets that are always present:
 
It defines some default targets that are always present:
Line 9: Line 10:
 
* Cleanall -- also clean all units (*.ppu).
 
* Cleanall -- also clean all units (*.ppu).
  
===Trouble Shooting===
+
==Troubleshooting==
* I get an error message that the command  ''__missing_command__ '' is missing. -- This happens when a tool required by the make process is not found. Remedy: Add the path to the tool as an option to make, like DATA2INC=/path/to/data2inc, for the tool data2inc
+
* I get an error message that the command  ''__missing_command__'' is missing. -- This happens when a tool required by the make process is not found. Remedy: Add the path to the tool as an option to make, like DATA2INC=/path/to/data2inc, for the tool data2inc
* Clean does not delete the files I expect. -- This happens when the files was generated by a call to make where certain options was given. Remedy: Call make clean with the same options. Options which may affect this are:
+
* Clean does not delete the files I expect. -- This happens when the files were generated by a call to make where certain options were given. Remedy: Call make clean with the same options. Options which may affect this are:
 
** OS_TARGET
 
** OS_TARGET
 
** CPU_TARGET
 
** CPU_TARGET
Line 18: Line 19:
 
* Target not supported: bad parameters were used when generating the makefile, you need to regenerate it with -Tall (see next paragraph)
 
* Target not supported: bad parameters were used when generating the makefile, you need to regenerate it with -Tall (see next paragraph)
  
===Regenerating makefiles===
+
==Regenerating makefiles==
  
Regenerating ''Makefile'' from ''Makefile.fpc'' is quite easy. The basic syntax is
+
Regenerating a ''Makefile'' from ''Makefile.fpc'' is quite easy. The basic syntax is
  
fpcmake -w -Tall
+
fpcmake -w -Tall
  
* -w    :  actually _write_ the Makefile.
+
* -w    :  actually '''write''' the Makefile.
* -Tall :  generate the makefile so as to work on all platforms (default is only the host platform). '''DON'T FORGET THIS WHEN COMMITTING TO FPC CVS SERVER!'''
+
* -Tall :  generate the makefile so as to work on all platforms (default is only the host platform).  
 +
'''DON'T FORGET THIS WHEN COMMITTING TO FPC / LAZARUS SVN SERVER!'''.
 +
For Lazarus developers:
 +
'''YOU MUST USE THE FPC DEVELOPER VERSION (trunk, e.g. 2.7.1) TO GET ALL PLATFORMS'''.
 
* It is possible to add -v to increase verbosity.
 
* It is possible to add -v to increase verbosity.
  
If you regenerate makefiles outside the fpc/ CVS tree, (e.g. for lazarus in
+
If you regenerate makefiles outside the fpc/ SVN tree, (e.g. for Lazarus in projects), and fpcmake complains it can't find package.fpc for the RTL package, try setting the environment variable FPCDIR to the FPC source directory using commands like the following:
projects), and fpcmake complains it can't find package.fpc for the RTL package, try setting the enviroment variable FPCDIR to the fpc source directory fpc/:
 
  
(bash/sh)
+
* Unix/Linux/OSX bash/sh
 +
<syntaxhighlight lang="bash">
 +
# e.g. if your FPC directory is located in /location/to/fpc:
 
export FPCDIR=/location/to/fpc
 
export FPCDIR=/location/to/fpc
 +
</syntaxhighlight>
  
(dos/windows/OS/2)
+
* DOS/Windows/OS/2
 +
<syntaxhighlight lang="dos">
 +
REM e.g. if your FPC directory is located in c:\location\to\fpc:
 
set FPCDIR=c:\location\to\fpc
 
set FPCDIR=c:\location\to\fpc
 +
</syntaxhighlight>
 +
 +
==Extending==
 +
===CPU/OS===
 +
When adding a new operating system or CPU it's needed to extend fpcmake utility, so MAKE utility will call the proper binaries for the new target.
 +
 +
The following types and constants needs to be extended. The arrays are declared at '''fpcmmain.pp''' unit.
 +
* TCpu - the enum listing all possible CPUs. A new entry needs to be added for a new CPU
 +
:* CpuStr - is the constant of representing strings for each TCPu entry
 +
:* CpuSuffix - the CPU string used as a suffix. Simply by prefixing "_"
 +
:* ppcSuffix - the CPU suffix to be used in the executable name
 +
* TOS - the num listing all operating systems
 +
:* OSStr - the constant listing representing TOS as a string. The value is used when writing a file or parsing parameters
 +
:* OSSuffix - the constant listing representing OS as a suffix
 +
* OSCpuPossible - the matrix that reflects what OS and CPU combination is possible
 +
 +
==See also==
 +
* [http://www.freepascal.org/docs-html/prog/progap5.html Free Pascal Programmers Guide (Appendix E)]
 +
 +
[[Category:FPC]]
 +
[[Category:Utilities]]

Latest revision as of 12:49, 17 February 2022

Fpcmake is a makefile generator, to control the make utility by GNU. It generates a makefile named "Makefile" from a definition file called "Makefile.fpc" and its own built-in template. It is used in the FPC source tree (e.g. in FPC 2.6.0), but is planned to be succeeded by FPMake.

This template is located in utils/fpcm/fpcmake.ini, but since fpcmake.ini is included in the binary (to avoid path-searching issues), fpcmake has to be regenerated for each fpcmake.ini change.

The manual has a quite good chapter about Makefile.fpc syntax, and examples teach the rest (fpcmake.ini, the various Makefile.fpcs in the FPC source tree).

It defines some default targets that are always present:

  • Clean -- clean all programs and the units explicitly stated to be cleaned, but not other units.
  • Cleanall -- also clean all units (*.ppu).

Troubleshooting

  • I get an error message that the command __missing_command__ is missing. -- This happens when a tool required by the make process is not found. Remedy: Add the path to the tool as an option to make, like DATA2INC=/path/to/data2inc, for the tool data2inc
  • Clean does not delete the files I expect. -- This happens when the files were generated by a call to make where certain options were given. Remedy: Call make clean with the same options. Options which may affect this are:
    • OS_TARGET
    • CPU_TARGET
    • FPC or PP (Tells make which version of the compiler created the files, this affects *.*w files generated for Windows for fpc < 1.1. To erase these files, please give an fpc 1.0 compiler as a parameter)
  • Make cannot find tools asw, ldw. Happens only when making for fpc 1.0.*. Remedy: Make a copy of the tools as and ld, rename them asw, ldw.
  • Target not supported: bad parameters were used when generating the makefile, you need to regenerate it with -Tall (see next paragraph)

Regenerating makefiles

Regenerating a Makefile from Makefile.fpc is quite easy. The basic syntax is

fpcmake -w -Tall
  • -w : actually write the Makefile.
  • -Tall : generate the makefile so as to work on all platforms (default is only the host platform).
DON'T FORGET THIS WHEN COMMITTING TO FPC / LAZARUS SVN SERVER!. 

For Lazarus developers:

YOU MUST USE THE FPC DEVELOPER VERSION (trunk, e.g. 2.7.1) TO GET ALL PLATFORMS.
  • It is possible to add -v to increase verbosity.

If you regenerate makefiles outside the fpc/ SVN tree, (e.g. for Lazarus in projects), and fpcmake complains it can't find package.fpc for the RTL package, try setting the environment variable FPCDIR to the FPC source directory using commands like the following:

  • Unix/Linux/OSX bash/sh
# e.g. if your FPC directory is located in /location/to/fpc:
export FPCDIR=/location/to/fpc
  • DOS/Windows/OS/2
REM e.g. if your FPC directory is located in c:\location\to\fpc:
set FPCDIR=c:\location\to\fpc

Extending

CPU/OS

When adding a new operating system or CPU it's needed to extend fpcmake utility, so MAKE utility will call the proper binaries for the new target.

The following types and constants needs to be extended. The arrays are declared at fpcmmain.pp unit.

  • TCpu - the enum listing all possible CPUs. A new entry needs to be added for a new CPU
  • CpuStr - is the constant of representing strings for each TCPu entry
  • CpuSuffix - the CPU string used as a suffix. Simply by prefixing "_"
  • ppcSuffix - the CPU suffix to be used in the executable name
  • TOS - the num listing all operating systems
  • OSStr - the constant listing representing TOS as a string. The value is used when writing a file or parsing parameters
  • OSSuffix - the constant listing representing OS as a suffix
  • OSCpuPossible - the matrix that reflects what OS and CPU combination is possible

See also