Date: | Thu, 13 Apr 2006 20:05:18 +0300 |
From: | Diomidis Spinellis <dds@aueb.gr> |
Organization: | Athens University of Economics and Business |
User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060130 SeaMonkey/1.0 |
MIME-Version: | 1.0 |
Newsgroups: | comp.os.linux.development.apps |
Subject: | Re: Very sophisticated Makefile problem |
References: | <e1l9f6$mgi$1@daniel-new.mch.sbs.de> |
In-Reply-To: | <e1l9f6$mgi$1@daniel-new.mch.sbs.de> |
Content-Type: | text/plain; charset=ISO-8859-1; format=flowed |
Content-Transfer-Encoding: | 7bit |
Bernhard Agthe wrote: > Hi, > > for a few days I've been trying but I didn't solve my problem yet. So I > present it here (shortened to the essentials) hoping someone can help me > ;-) > > At the moment: > > Files: > - obj/ > - src/abc.c > - lib/abc.c > - Makefile > - dependencies > > Makefile (simplified): > abc: obj/abc.o obj/abc.o > \t link-command > obj/%.o: %.c > \t CC -c -o $@ $< > include dependency > > dependency file: > obj/abc.o: src/abc.c > obj/abc.o: lib/abc.c > > As you can easily see this doesn't work. My solution is to change the > file names of the object files like this: > - obj/src_abc.o (src/abc.c) > - obj/lib_abc.o (lib/abc.c) > > What I can do already is writing a Makefile with the new object file > names and change the dependency file. What I don't want to do (cannot) > is writing a separate rule for each source file (the "obj/%.o: %.c" > construct must stay, but can be modified). What I can't do is change the > file names. > > Thanks for your help, > Berny Agthe. If I understand correctly, you want your rule to create object files of the form obj/src_abc.o. To do this, modify the rule along the following lines: obj/%.o: %.c \t CC -c -o `dirname $@`/`dirname $<`_`basename $@` $< You could also do the above more efficiently by utilising the GNU make variable replace facilities. -- Diomidis Spinellis Code Quality: The Open Source Perspective (Addison-Wesley 2006) http://www.spinellis.gr/codequality?colda