Date: Wed, 12 Mar 2003 21:07:56 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: classy-kg4wou AT kg4wou DOT com Message-Id: <9743-Wed12Mar2003210755+0200-eliz@elta.co.il> X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9 CC: djgpp AT delorie DOT com In-reply-to: (message from H Johnson on Mon, 10 Mar 2003 10:52:08 -0600) Subject: Re: Problems with file names with Make References: <3i5i6vsg9rgbfbn00p2dna50v1e943ucpf AT 4ax DOT com> <1858-Sat08Mar2003112910+0200-eliz AT elta DOT co DOT il> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: H Johnson > Newsgroups: comp.os.msdos.djgpp > Date: Mon, 10 Mar 2003 10:52:08 -0600 > > > >Please tell why do you need this. Unless absolutely necessary, it is > >not recommended to use backslashes in file names inside Makefiles; see > >the file README.DOS in the Make distribution for the reasons and > >explanations. > > Because I also have a "clean" target which does the following: > for %X in ($(SRCDIR)) do del *.o > > > > >> Nothing I have tried seems to work including escaping the "\". > > > ... snip > > >Again, please tell why do you need to see backslashes. DOS doesn't > >care, DJGPP programs don't care, so why should you care? > > Apparently DOS does care because my clean function does not work... You are mistaken in that you attribute this to DOS. It's not DOS the operating system that cares about forward slashes, it's COMMAND.COM. The DEL command is implemented in COMMAND.COM, and that implementation indeed doesn't (easily) grok file names with forward slashes. > For example, the SRCDIR variable has "dir1/subdir1 dir1/subdir2". All > files compile and link just fine. But when you try to do the "clean" > target above, DOS does not correctly parse SRCDIR so you get the > following output: > > del dir1 *.o > del ubdir1 *.o > del dir1 *.o > del ubdir2 *.o > > DOS interprets the /s in the path name to be a switch or control > character (or something else). At any rate it does not work. If the above FOR command is the exact command you have in your Makefile, it is in error. You should instead have said this: for %X in ($(SRCDIR)) do del %X/*.o This would have failed as well, since COMMAND.COM's DEL command chokes on forward slashes in file names. However, if you modify the command like this: for %X in ($(SRCDIR)) do del "%X/"*.o (note the quotes), it might work with most modern versions of COMMAND.COM. The quotes prevent COMMAND.COM from interpreting the slashes as switch characters, so the file names with forward slashes get passed intact to DOS system calls, and it works because, as I said, DOS system calls supports forward slashes just fine. Finally, failing all that, you can use the built-in Make functions $subst or $patsubst to replace all forward slashes with backslashes in the above FOR command. That is, run %X/*.o through $subst that replaces / with \\. > clean: > del *.o /s > > in the make file. But that does not work either because when I do a > "make clean" I get: > > del *.o /s > Invalid switch - /s That's because DEL, at least on my machine, doesn't support the /S switch. > Yet running "del *.o /s" from the command line does work as expected. Probably because you have some alias or maybe your default shell is not COMMAND.COM. What version of Windows do you run?