Server Help

Non-Subspace Related Coding - Makefiles and dependencies

Bak - Mon Sep 25, 2006 2:32 am
Post subject: Makefiles and dependencies
So I have a Makefile that has some dependencies:

Quote:
...

$(MODULE_OUTPUT_DIR)SS_Items.so: $(MODULE_DIR)Module.h $(MODULE_DIR)SS_Items/SS_Items.h $(MODULE_DIR)SS_Items/SS_Items.cpp
$(CC) $(MODULE_FLAGS) -I$(MODULE_DIR) -o $(MODULE_OUTPUT_DIR)SS_Items.so $(MODULE_DIR)SS_Items/SS_Items.cpp

...

$(MODULE_DIR)SS_Items/SS_Items.h: $(MODULE_DIR)SS_Items/Antiwarp.h $(MODULE_DIR)SS_Items/Brick.h $(MODULE_DIR)SS_Items/Cloak.h $(MODULE_DIR)SS_Items/Gun.h $(MODULE_DIR)SS_Items/Portal.h $(MODULE_DIR)SS_Items/Rocket.h $(MODULE_DIR)SS_Items/Thor.h $(MODULE_DIR)SS_Items/Bomb.h $(MODULE_DIR)SS_Items/Burst.h $(MODULE_DIR)SS_Items/Decoy.h $(MODULE_DIR)SS_Items/Mine.h $(MODULE_DIR)SS_Items/Repel.h $(MODULE_DIR)SS_Items/Stealth.h $(MODULE_DIR)SS_Items/XRadar.h

...


Then when I edit a file, let's say Gun.h, and do "make", it doesn't remake SS_Items.so. What gives?

Here's the relavent portion of the "make -d" log:

Quote:

Considering target file `../Modules/SS_Items/SS_Items.h'.

...

Considering target file `../Modules/SS_Items/Gun.h'.
Looking for an implicit rule for `../Modules/SS_Items/Gun.h'.
Trying pattern rule with stem `Gun.h'.
Trying implicit prerequisite `../Modules/SS_Items/Gun.h,v'.
Trying pattern rule with stem `Gun.h'.
Trying implicit prerequisite `../Modules/SS_Items/RCS/Gun.h,v'.
Trying pattern rule with stem `Gun.h'.
Trying implicit prerequisite `../Modules/SS_Items/RCS/Gun.h'.
Trying pattern rule with stem `Gun.h'.
Trying implicit prerequisite `../Modules/SS_Items/s.Gun.h'.
Trying pattern rule with stem `Gun.h'.
Trying implicit prerequisite `../Modules/SS_Items/SCCS/s.Gun.h'.
No implicit rule found for `../Modules/SS_Items/Gun.h'.
Finished prerequisites of target file `../Modules/SS_Items/Gun.h'.
No need to remake target `../Modules/SS_Items/Gun.h'.

...

Finished prerequisites of target file `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Antiwarp.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Brick.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Cloak.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Gun.h' is newer than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Portal.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Rocket.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Thor.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Bomb.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Burst.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Decoy.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Mine.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Repel.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/Stealth.h' is older than target `../Modules/SS_Items/SS_Items.h'.
Prerequisite `../Modules/SS_Items/XRadar.h' is older than target `../Modules/SS_Items/SS_Items.h'.
No commands for `../Modules/SS_Items/SS_Items.h' and no prerequisites actually changed.

No need to remake target `../Modules/SS_Items/SS_Items.h'.


Is there something I'm not getting about makefiles?
Mine GO BOOM - Mon Sep 25, 2006 4:10 am
Post subject:
I don't write Makefiles very often. It is either a one-lined GCC command or I use autoconf/automake. But it looks to me like you don't actually have a command to update the file. You know, the following line, the thing it is complaining about? Thus, it knows the file needs to be updated, it just doesn't have anything to do it.
Bak - Mon Sep 25, 2006 4:28 am
Post subject:
But doesn't need to update the .h file, that's what programmers are for. The command is to build a .so file and I'm listing the dependencies. It's not complaining about anything, it just doesn't rebuild the .so file when I do "make"; I end up having to delete it before it relizes it needs to recompile it.

It seems to note that one of the dependencies of the file has changed, then proceeds to say that none of them have.

Oh mmm... I think I kinda see what you mean. What's the fix?
Mine GO BOOM - Mon Sep 25, 2006 5:29 am
Post subject:
Make it touch SS_Items.h or list all those things as dependencies of SS_Items.so. There is probably a better way, as I don't do makefiles often.
Anonymous - Mon Sep 25, 2006 8:14 am
Post subject:
Mine GO BOOM wrote:
list all those things as dependencies of SS_Items.so.
That's the way I would do it:
Code: Show/Hide
$(MODULE_OUTPUT_DIR)SS_Items.so: $(MODULE_DIR)SS_Items/Gun.h

Bak - Mon Sep 25, 2006 2:04 pm
Post subject:
Hmm the touch thing seems like a good idea...

I'd do it that way Smong, except that in the more general case, let's say Modules.h depends on some files and every module uses modules.h, I'd end up having to add all those files to every module...
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group