discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Howto write GNUmakefile.preamble with using C API


From: David Chisnall
Subject: Re: Howto write GNUmakefile.preamble with using C API
Date: Tue, 22 Jul 2008 11:13:10 +0100

On 22 Jul 2008, at 11:01, Nicola Pero wrote:


If you want to migrate it to Objective-C, then rename your test.c file to
test.m, and slightly modify your GNUmakefile:
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = test
test_OBJC_FILES = test.m
ADDITIONAL_OBJCFLAGS += $(shell mysql_config --cflags)
ADDITIONAL_TOOL_LIBS += $(shell mysql_config --libs)
include $(GNUSTEP_MAKEFILES)/tool.make

It doesn't work
[...]
test.c:1:19: warning: mysql.h: No such file or directory
[...]

Something is going wrong here - it was supposed to be compiling test.m here,
not test.c ;-)

This is a bug in GNUstep Make which I've encountered before. It is due to the convoluted way in which it builds dependency chains.

When GS Make parses the _OBJC_FILES and _C_FILES lists, it performs a substitution of .c or .m to .o and then DISCARDS the information about the source. It then uses implicit make rules to compile. This is a really horrible way of doing things, because it means that having .c and .m (or .cpp) files with the same prefix, or renaming a file and changing its extension gives really unexpected results.

Possibly a better solution would be for the .o files to be named .c.o, .m.o, .cpp.o and so on, and the dependency rules constructed to match. The two hundred layers of indirection in GS Make hurt my brain though, so I have no idea how easy this is.

The only work around I've found is to ensure that the prefix for every file is different and delete all of the .d files periodically.

I suggest when you try to switch to Objective-C, create a new empty directory, and put only test.m and your GNUmakefile in there. Make sure to do all changes
to the GNUmakefile, then try again.

Removing the .d files and the .c file should be enough.

David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]