Forum > General

[Solved] Compile auxilliary units via Makefile

(1/1)

Wesbat:
Hi there.

I'm trying to understand how to write a Makefile.fpc to compile a program.

I'm using the GO32V2 version of the compiler, but this process should apply to any, right? (Please correct me if I'm wrong)

This is my test program:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program MyProg; uses  graph,  myunit; BEGIN  sayhi;END. 
and my test unit:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit myunit; interface procedure sayhi; implementation procedure sayhi;begin  WriteLn('hello world');end; end. 
and my Makefile.fpc:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---[require]unitdir=c:\pp\units\go32v2\graph [target]units=myunitprograms=myprog 
I run "fpcmake" to generate the GNU Makefile, after which I run "make":

Linking .\Myprog .exe
myprog.pp(9,1) Warning: Object myunit.o not found, Linking nay fail !
myprog.pp(9,1) Error: Can't open object file: myunit.o
myprog.pp(9,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted

However if I open myunit.pp with the fp.exe IDE and compile it (producing the myunit.o object) first, then obviously make finds it and succeeds.

I thought the [target] units directive in Makefile.fpc would compile myunit.o from what I read in the documentation, but this does not seem to be the case.

Any hints will be much appreciated :)

Thaddy:
I am missing entries for [default], [install] and maybe [package] (because you have multiple files).
You are correct to assume that it should work anywhere if the format is correct and complete.
See programmers guide, appendix E. for a thorough explanation.

The way fpcmake works means you can't just skip entries that you assume you don't need. Usually you need at least all but one ([require]) sections.

Wesbat:
Roger that Thaddy. Thank you for your answer, it prompted me to re-read the documentation.

I discovered that by listing "myunit" in the programs list, it gets compiled and linking succeeds. I realize this is not an idiomatic solution, so I will keep trying different configurations to find the proper way.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---...[target]programs=myunit myprog...

Navigation

[0] Message Index

Go to full version