Hi, I am seeing a problem with the semantics of pattern matching with GNU Make. My example Makefile is as follows:
#---------------------------------------------------------------------------- # $Id: Makefile,v 1.17 2002/02/15 12:50:37 kitty Exp $ # #---------------------------------------------------------------------------- # List of all files that make up the project # FILES = director \ player \ player_driver \ director_driver \ script # List of all the source files that we will use # SRC = $(addsuffix .cc, $(FILES)) OBJS = $(SRC:%.cc=%.o) realclean: -$(RM) $(BIN) $(OBJS) The problem is with OBJS. I am trying to extract the names of the object files from the source files. This works fine when my files in the directory end with .cc. But if by mistake, if OBJS is defined as follows: OBJS = $(SRC:%.cpp=%.o) or OBJS = $(SRC:.cpp=.o) then the pattern matches end up not finding the .cpp in SRC and hence includes the whole name i.e foo.cc in $(OBJS). When I do a make realclean, boom... All my source files are deleted. But for Emacs I would have screwed. I know this seems more of a pilot error but shouldn't make do something to help the user ? Specifically is there any way in GNU Make to specify that if a pattern substitute fails to replace anything, return null. If I understand what Make does now, it tries to match the longest entry for % and ends up matching the whole name but still doesn't find .cc and hence doesn't perform the replace. But the problem arises because Make returns the whole % at this point even if no match requested was found. If it's not possible to change the semantics (legacy reasons et al, though I don't know if anybody will really want this behaviour), will it be possible to issue a warning option if a variable pattern substitution results in a value which is the same as the original variable ? Even something that detects such a thing in only this specified syntactic usage is also very welcome. More info on environment: samba> uname -a Linux samba 2.4.17 #2 SMP Fri Feb 15 21:32:35 CST 2002 i686 unknown samba> make -v GNU Make version 3.79.1, by Richard Stallman and Roland McGrath. Built for i586-pc-linux-gnu Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Report bugs to <[EMAIL PROTECTED]>. samba> dpkg -p make Package: make Priority: standard Section: devel Installed-Size: 784 Maintainer: Manoj Srivastava <[EMAIL PROTECTED]> Architecture: i386 Version: 3.79.1-12 Depends: libc6 (>= 2.2.4-4), fileutils (>= 4.0) Filename: pool/main/m/make/make_3.79.1-11_i386.deb Size: 386308 MD5sum: 5606dee81b90629a54771b8963461f44 Description: The GNU version of the "make" utility. GNU Make is a program that determines which pieces of a large program need to be recompiled and issues the commands to recompile them, when necessary. More information about GNU Make can be found in the `make' Info page. The upstream sources for this package are available at the location ftp://ftp.gnu.org/gnu/make/ -kitty. -- Krishnakumar B <kitty at cs dot wustl dot edu> Distributed Object Computing Laboratory, Washington University in St.Louis _______________________________________________ Bug-make mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-make