Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!necntc!custom!boykin From: boykin@custom.UUCP (Joseph Boykin) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: Strange makefile construct Message-ID: <781@custom.UUCP> Date: Fri, 4-Sep-87 12:20:02 EDT Article-I.D.: custom.781 Posted: Fri Sep 4 12:20:02 1987 Date-Received: Sat, 5-Sep-87 18:23:25 EDT References: <1162@nrcvax.UUCP> Organization: Custom Software Systems; Natick, MA Lines: 39 Summary: $(?:.o=.c) is a macro substitution sequence Xref: mnetor comp.unix.questions:3884 comp.unix.wizards:4084 In article <1162@nrcvax.UUCP>, chris@nrcvax.UUCP (Chris Grevstad) writes: > I was looking at some source that came across the net some time ago and > ran across a very strange construct in the makefile. It appears that this > makefile is targeted for a SYSV system and I am familiar only with 4.2BSD > make. > > This is the weirdness: > > target: file1.o file2.o file3.o file4.o > $(CC) $(CFLAGS) $(?:.o=.c) > > Any suggestions? [....] > > My interpretation says: > This: > $(CC) $(CFLAGS) $(?:.o=.c) > becomes this: > $(CC) $(CFLAGS) file1.c file2.c file3.c file4.c You're correct, except for one caveat. Here's what the PC/MAKE documenation says about this: "The sequence :string1=string2 is a substitution sequence. All occurrences of string1 which appear prior to a blank or tab are replaced by string2. For example, substitute .c for all occurrences of .obj in the macro OBJECTS: $(OBJECTS:.obj=.c) In the example you have, $(?.o=.c) will generate files with a .c extension from those dependencies which were found to be newer than the target. The problem with this particular command is that 'target' may now be compiled with only three (or less) files instead of all four if one or more of the .o files was not modified; given the command, this may cause an error. Joe Boykin Custom Software Systems ...necntc!custom!boykin