[lug] OT: Makefile oddity
Ken Weinert
mc at morat.net
Mon Apr 22 05:41:18 MDT 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Saturday 20 Apr 2002 17:43, you wrote:
> >>>>> ">" == D Stimits <stimits at idcomm.com> writes:
>
> Tom> However, there's a bug here. It is the classic recursive make
> Tom> bug: you only have a dependency on the .cpp file. So if you
> Tom> `touch config.h', nothing will be rebuilt -- which is wrong.
>
> >> I don't really consider this a bug, just a limitation of the
> >> technology. makedepend would almost work, except it is designed
> >> for C instead of C++, and fails to deal properly with .cpp or .cxx
> >> extensions.
I see that according to the above paper my method can suffer from some
problems, but in the general case it works well for me.
Here's an excerpt from a Makefile in a current project:
include ../../make.cfg
SRC = attributes.c depth.c logit.c power.c mapstuff.c bprintf.c \
walls.c getGameInfo.c getNextLine.c palette.c sph.c \
getPlayerInfo.c getUnits.c support.c strupr.c rollDie.c storage.c
OBJ = $(SRC:.c=.o)
all $(ADJROOT)/lib/libbattle.a : $(ADJROOT)/lib/libbattle.a($(OBJ))
clean :
rm -f *~ *.o *.d $(ADJROOT)/lib/libbattle.a
include $(OBJ:.o=.d)
%.d: %.c
$(CC) -M -MG $(CFLAGS) $(INCLUDES) $(LOCAL_DEFINES) $< > $@
Yes, it's gcc/g++ dependent - that's a feature, not a bug :) The -M flag
works for C++ files and it will include the-not-.h-terminated-filename
headers (although the -MG explicitly removes the dependency on system
headers).
- --
Ken Weinert mc at morat.net
GnuPG KeyID: 9274F1CE GnuPG available at http://www.gnupg.org/
GnuPG Key Fingerprint: 1D87 3720 BB77 4489 A928 79D6 F8EC DD76 9274 F1CE
E Pluribus Modem
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAjzD9uIACgkQ+OzddpJ08c5XKACfUViC57p5NnVBwPRf2BH12qaj
Ca8AoJJv5bf15XKqvF8mwkXNit7+YoLi
=mT08
-----END PGP SIGNATURE-----
More information about the LUG
mailing list