Date: Thu, 18 Sep 1997 12:09:44 +0300 (IDT) From: Eli Zaretskii To: Cesar Scarpini Rabak cc: Hans-Bernhard Broeker , djgpp AT delorie DOT com Subject: Re: make 3.75 ported to DJGPP not handling correctly comments In-Reply-To: <1.5.4.32.19970917163710.0069e6f4@dce03.ipt.br> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Wed, 17 Sep 1997, Cesar Scarpini Rabak wrote: > Other makefiles for MS-DOG operate correctly with this syntax, so the > _expected behaviour_ of a make for this OS would be that the comment > character be ignorated by the system; I don't understand. Are you telling that other versions of the Make program for DOS support # comments in the command lines of a Makefile? If so, please tell which versions of Make are those. If you are talking about Makefiles, please explain what does ``other makefiles for MS-DOG operate correctly with this syntax'' mean? > from your explanation, it seems that adapting the DJGPP port of make > to strip comments in the command lines would be bennign when other shells > that recognize '#' as comment (the remainder of the line would have been > already stripped out); Sigh. If only life were that simple... I think it would be very difficult to teach Make to recognize such comments. Unless I miss something, ignoring the rest of the line after the `#' character would be dead wrong. For example, how about the following rule: foo: bar sed -e 's/^#.*//' $< > $@ So now we need to teach Make about quotes, right? Then we will need to teach it about backslash escapes, because \# is not a comment either. And then there are the $#, ${#param} and ${param##word} constructs, and numbers like 16#FFFE, which also aren't comments. Pretty soon you will end up teaching Make a lot of shell's syntax. This is precisely what Make should avoid doing, IMHO, because people could use any shell they want, where all these feature might have different meanings. > will avoid people to have to edit makefiles coming from unixy > environments or install bash to be able to use them w/o modifications. I agree with the goal, but it is only achievable up to a point. Please note the following excerpts from the Make manual: * `#' in a line of a makefile starts a "comment". It and the rest of the line are ignored, except that a trailing backslash not escaped by another backslash will continue the comment across multiple lines. Comments may appear on any of the lines in the makefile, except within a `define' directive, and perhaps within commands (where the shell decides what is a comment). A line containing just a comment (with perhaps spaces before it) is effectively blank, and is ignored. ... The shell that is in use determines whether comments can be written on command lines, and what syntax they use. When the shell is `/bin/sh', a `#' starts a comment that extends to the end of the line. So even the manual advises against using comments within commands, and only specifically allows it when the shell is /bin/sh. People who want to use this feature, need to make sure /bin/sh is available on the target system.