24 August 2024, 09:31 | #1 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 966
|
Small problem with makefile
I have a small problem with a make file. In summary in this project I am doing a copy of all code in source directory to a temp directory. I then do some place holder text replacements and finally I continue with compilation.
So for example, given /source/main.c, the make file will copy this to /temp/main.c, modify /temp/main.c and then compile from /temp/main.c. However the first time I run the make file it always gives me the error: No match for main.o No objects to link make: **** [Example] error 5 The second time I run the command it then works ok and continues to work until I run "make clean" (which deletes the temp directory). If I compile directly from source directory then the error does not happen. I am working on WinUAE (not sure if on real hardware the error happens or not). Anyone knows of what possible solution there is to resolve this? I can work around it (as second time and following that it compiles) but it is just annoying. |
24 August 2024, 11:41 | #2 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 696
|
maybe there is an error in line 127 of your makefile...
... or you should always create the temp folder if it does not exist |
24 August 2024, 18:15 | #3 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 966
|
I do have a rule to always create the temp directory, and I can see the temp directory exists and source files have been moved to this.
The issue seems like a timing issue. Here are my rules: Code:
all: dirs copysrc MyApp dirs: -makedir temp -makedir bin copysrc: copy all source/ temp In summary the make file first tries to create the directory, than copy the source to temp and finally it tries to compile the solution. It seems that 'MyApp' is being evaluated before copysrc completes. |
24 August 2024, 20:00 | #4 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,504
|
The order is not "timing", the issue is that you seem to imply that the rules are executed in a specific order, but they are not. They only deffine logical dependencies. Thus, "dirs" should probably be "temp", because "make" can check whether "temp" exist, and "copysrc" should explicitly depend on "temp" because it needs the directory to exist to work.
|
24 August 2024, 23:14 | #5 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 696
|
Quote:
Code:
all: copysrc MyApp .PHONY: dirs dirs: -makedir temp -makedir bin copysrc: dirs copy all source/ temp Code:
copysrc: mkdir -p temp copy all source/ temp |
|
25 August 2024, 10:23 | #6 | |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 966
|
I have changed my makefile to this to make it simpler:
Code:
all: copy MyApp clean: -delete temp bin main.o MyApp all temp: -makedir temp copy: temp copy all source/ temp # SETDATE temp ALL - Did not work. # WAIT 10 SECS - Did not work. # RULE A %.o : temp/%.c $(CC) $(COPT) -c $< -o $@ # RULE B MyApp : main.o $(CC) $^ -o $@ $(LIBS) main.o: temp/main.h The output of the first run is as follows: Code:
System:example> make makedir temp copy all source/ temp COPY mode main.h ..copied main.c ..copied vc +aos68k main.o -o MyApp -lamiga -lauto -ldebug # RULE B No match for main.o No objects to link make: *** [MyApp] Error 5 Code:
COPY mode main.h ..copied main.c ..copied vc +aos68k -c temp/main.c -o main.o # RULE A vc +aos68k main.o -o MyApp -lamiga -lauto -ldebug # RULE B The only reason I can think of for this is that make is not detecting any changes happened to (in my case) temp/main.c and therefore does not run the associated command. I therefore tried SETDATE temp ALL (sort of like touch in Linux) but that did not work, same exact behavior. I cannot understand, everything seems to be running in order, directories created, source files copied but then that RULE is not being run first time but runs the second time . I also ran WAIT 10 secs just in case maybe when RULE A is running the files in temp are not being detected. But that did not work either. Quote:
@bebbo, thank you for the scripts, I took some of the ideas in the above script. Tried PHONY too but did not seem to have an effect. Last edited by Sim085; 25 August 2024 at 11:06. |
|
25 August 2024, 14:44 | #7 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,583
|
Quote:
Code:
main.o: temp/main.c temp/main.h |
|
25 August 2024, 19:20 | #8 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 696
|
|
25 August 2024, 20:02 | #9 | |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 966
|
This worked . But I do not understand why I thought that dependency is covered by RULE A.
Code:
# RULE A %.o : temp/%.c <----- HERE $(CC) $(COPT) -c $< -o $@ Quote:
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Small FastATA ZIV problem | utri007 | support.Hardware | 1 | 20 July 2021 16:43 |
Small problem with expansions setting page | mark_k | support.WinUAE | 1 | 22 June 2017 12:44 |
small problem with caracteres ?? | Alexfrench | project.ClassicWB | 3 | 04 June 2012 16:37 |
A small problem | clownstyle | New to Emulation or Amiga scene | 1 | 20 January 2004 20:47 |
small problem | pulley | support.Hardware | 2 | 05 November 2002 13:21 |
|
|