Date: Fri, 8 May 1998 12:40:54 +0300 (IDT) From: Eli Zaretskii To: ed toivanen cc: djgpp AT delorie DOT com Subject: Re: I run make, but get no target, or no rule for target test1. In-Reply-To: <35525424.F6809612@bc.sympatico.ca> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Thu, 7 May 1998, ed toivanen wrote: > I am running make 3.76.1, and wrote my first makefile, test1.mak and > test1.mk. When I run make, or make test1, I get the above error > messages. You need to say "make -f test1.mak". By default, Make looks for a file named Makefile; if your makefile has a different name, you need to use the -f switch. This is all explained in the docs, btw; even "make --help" prints enough info to get this straight. > make clean also doesn't work. That's because you have written the ``clean:'' rule incorrectly: > clean : del/y test1 $(objects) Make assumes that the names after the colon are the files on which the target depends. So what the above says to Make is that `clean' depends on files called `del/y', `test1', and those listed in $(objects), and that the rule to make the target `clean' is empty. This is not what you want. You need to say either this: clean : ; del/y test1 $(objects) (note the semi-colon) or this: clean : del/y test1 $(objects) This "del/y" probably means you are using 4dos or ndos, so be aware that this makefile won't work with other shells, including command.com. Also, please note that the other rules in your makefile should begin with a TAB, not with spaces, or else Make will complain about ``missing separator''. For example, this line > gpp -o test1 $(objects) begins with spaces, which is wrong. Make sure your editor doesn't convert TABs into spaces without telling you. > I copied the makefile from the faq, with appropriate changes Which FAQ was that? The DJGPP FAQ doesn't have any makefile fragments, IIRC. > Normally I just run gpp*.cpp, but am trying to expand my horizons by > using make. Please invest some time in reading the docs. Make is a tremendously powerful, flexible and complex program, but you need to learn how to unleash all that power. Copying existing makefiles without sufficient understanding what they do is IMHO a bad idea. For example, if you read the docs, you'd realize that Make already knows how to compile C and C++ programs, so you don't need to tell it. Armed with that knowledge, you could have written your makefile much more elegantly, like below. (It assumes that your source files are renamed into *.cc instead of *.cpp.) -------------------------- cut here ----------------------------- objects = main.o cgi.o mem.o test1: $(objects) gpp -o test1 $(objects) clean: 4dos.com /c del/y test1 $(objects) main.o: main.h cgi.o: cgi.h mem.o: mem.h