Makefiles involving files in different directories requiring different compilers

Makefiles involving files in different directories requiring different compilers

Post by hzmo.. » Wed, 11 Jan 2006 02:17:26



Let's say I have a directory "work" and a subdirectory "tools" under
it.  Both have their own Makefiles.  tools are also used by files other
than those in work.  I have in work's Makefile something like this:
OBJ = a.o b.o ../tools/c.o ../tools/d.o
myexec:  $(OBJS)
        g++ -c main.cc -o myexec
%.o: %.cc

And in tool's Makefile:
%.o: %.c

That is, the files in work are C++ programs whereas those in tools are
C programs; and myexec depends on files in tools.
The way work's Makefile is now written would compile c and d using g++,
if they are outdated, but not gcc.  That causes a problem for me.  What
is the best way to write the Makefiles so that c and d are always
compiled using gcc?  Thx.
 
 
 

Makefiles involving files in different directories requiring different compilers

Post by Stachu 'Dozzie' K » Wed, 11 Jan 2006 06:15:11



> Let's say I have a directory "work" and a subdirectory "tools" under
> it.  Both have their own Makefiles.  tools are also used by files other
> than those in work.  I have in work's Makefile something like this:
> OBJ = a.o b.o ../tools/c.o ../tools/d.o
> myexec:  $(OBJS)
>         g++ -c main.cc -o myexec
> %.o: %.cc

> And in tool's Makefile:
> %.o: %.c

> That is, the files in work are C++ programs whereas those in tools are
> C programs; and myexec depends on files in tools.
> The way work's Makefile is now written would compile c and d using g++,
> if they are outdated, but not gcc.  That causes a problem for me.  What
> is the best way to write the Makefiles so that c and d are always
> compiled using gcc?

You mean "how to execute compilation of c.o and d.o in ../tools/
directory accordingly to ../tools/Makefile", don't you? You need to add
an additional target:
#v+
../tools/%.o:

# or

#v-
I tried to write this target as general as possible, but I don't know
any other make utility than GNU make so I probably used something
GNU make-specific. I hope you catch the idea.

--
Feel free to correct my English
Stanislaw Klekot

 
 
 

Makefiles involving files in different directories requiring different compilers

Post by Chris F.A. Johnso » Wed, 11 Jan 2006 03:20:58



> Let's say I have a directory "work" and a subdirectory "tools" under
> it.  Both have their own Makefiles.  tools are also used by files other
> than those in work.  I have in work's Makefile something like this:
> OBJ = a.o b.o ../tools/c.o ../tools/d.o
> myexec:  $(OBJS)
>         g++ -c main.cc -o myexec
>%.o: %.cc

> And in tool's Makefile:
>%.o: %.c

> That is, the files in work are C++ programs whereas those in tools are
> C programs; and myexec depends on files in tools.
> The way work's Makefile is now written would compile c and d using g++,
> if they are outdated, but not gcc.  That causes a problem for me.  What
> is the best way to write the Makefiles so that c and d are always
> compiled using gcc?  Thx.

   A Makefile is not a shell script; you should ask in a group
   dedicated to programming, or a GNU group such as gnu.gcc.help.

--
   Chris F.A. Johnson, author   |    <http://cfaj.freeshell.org>
   Shell Scripting Recipes:     |  My code in this post, if any,
   A Problem-Solution Approach  |          is released under the
   2005, Apress                 |     GNU General Public Licence

 
 
 

1. search and delete different files in different directories

Good day,

I need to write a shellscript and I hope you can help me:

I have got 30 directories, each has a different name. In the
directories, files are stored which are built up like this: XXX.000,
XXX.001 ....up to XXX.500

XXX can be everything from i.e. test1(.066) to actock77(.003).

Now I need to find the file with the highest extension (i.e. XXX.050)
and delete all files that have a lower extension (XXX.000 - XXX.049),
so that only XXX.050 remains. Approximately 2300 files are to be
deleted.

After that, the computer should switch to the next directory and
continue the progress.

With kindest regards,

Chris

2. Establishing Connection Speed...

3. Different File/Directory Priveledges for 2 Different Groups

4. where is source code to in.telnetd???

5. How to redirect the the object (.o ) files to a different directory in a Makefile

6. x = close(sockfd);

7. Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue)

8. help w/full duplex

9. requiring different users based at different IP addresses?

10. NFS /home directory : Different machines need different desktops

11. using different cgi-bin directories for different virtuals

12. Makefiles: source and objects in different directories.

13. different file names under different shells