Mail Archives: djgpp/2000/04/05/18:03:41
Eli Zaretskii wrote:
>
> Damian Yerrick wrote:
> >
> > %.o: %.c $(HEADS)
> > gcc $(CFLAGS) -o $@ -c $<
>
> This rule is redundant: Make knows how to compile .c files into .o files
> without your telling it. It also knows that every .o file depends on the
> corresponding .c file. The only piece of knowledge you need to convey to
> Make is that the .o files depend on the headers. Here's how you do that:
>
> $(OBJS): $(HEADS)
>
> That's it! Do NOT put any commands under this line, because this isn't a
> rule, it's just a dependency description.
Make knows how to compile C files, but is there any easy way to make it
compile C++ files? What I'm doing right now is this:
CC = gpp
CFLAGS = -Wall -O3
OBJS = file1.o file2.o
HEADS = file1.h file2.h
file.exe: $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS)
file1.o: $(HEADS)
$(CC) $(CFLAGS) -c file1.cpp
file2.o: $(HEADS)
$(CC) $(CFLAGS) -c file2.cpp
This gets very long in big projects.. :\ There must be a way to simply
tell make to take each .cpp file and compile them with gpp with those
flags.
Thanks,
.(Trancelucid).
. Jaune .
- Raw text -