Re: Why is make building all targets



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I realize that your original question has been answered (a few times
over) but now, days later, I tossed this make file together:

VPATH = src:inc:../src:../inc

CXXFLAGS += -Iinc -I../inc -O2 -Wall -MMD

STEMS = main Mod1 Mod2

OBJS = $(patsubst %,%.o,$(STEMS))
DEPS = $(patsubst %,%.d,$(STEMS))

llfd : $(OBJS)
$(CXX) -o $@ $^

clean:
rm -f llfd $(OBJS) $(DEPS)

include $(DEPS)

%.d:
@touch $@

OK, so a command you might use to build your project is:

$ ARCH=`uname -i` mkdir $ARCH ; make -f ../Makefile -C $ARCH

You could also build in the src directory with "make -f ../Makefile"
or from the top level with just "make". Gives you some flexibility
about what directory you run the make from.

I like to make the compiler keep track of the dependencies for me.
You also don't need a main.h unless you want one.

It's been a while since I've used raw make (I've been automake-ing
recently) so I'm sure there's room for improvement.

Enjoy,

-- Gene

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFGbizt+6lOFXNSgQwRAm8FAKDhpba6DjJTIyPgpolZ67oy6jAbVQCgxFfq
0EYv5jilSO4mlQmomZFw6ro=
=B0zF
-----END PGP SIGNATURE-----
.