OffTopic: Need help with Make on Linux
Posted in 2000
Topics: Server Administration, Platform-Specific Issues
Fellow Hackers: I am trying to run this *very* simple make file, but I cannot get the bloody thing to work. Not sure what I am missing. I have tried a number of things like including *cc -c main.c* to see if I could force make to recognize the rules/dependencies. No luck. Any help would be appreciated? Below is a copy of: * Makefile * Error listings. * Directory Listing * Versions of make, uname -a --------------------------------------------------------------------- [root@dba xml]# make build make: *** No rule to make target `main.o', needed by `build'. Stop. [root@dba xml]# make main.o make: *** No rule to make target `main.c', needed by `main.o'. Stop. --------------------------------------------------------------------- [root@dba xml]# more Makefile build : main.o cc -o main main.o main.o : main.c cc -c main.c --------------------------------------------------------------------- [root@dba xml]# ls Makefile main main.c main.o --------------------------------------------------------------------- [root@dba xml]# cc -dumpversion egcs-2.91.66 --------------------------------------------------------------------- [root@dba xml]# uname -a Linux dba.execrisk.com 2.2.12-20 #1 Mon Sep 27 10:40:35 EDT 1999 i686 unknown [root@dba xml]# make -version GNU Make version 3.77, by Richard Stallman and Roland McGrath. Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98 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 <bug-make@gnu.org>. --------------------------------------------------------------------- -- Steve Romankiw Chubb / Executive Risk 82 Hopmeadow Street Simsbury, CT 06070
Steve Romankiw wrote: > I am trying to run this *very* simple make file, but I cannot get the > bloody thing to work. Not sure what I am missing. I have tried a number > of things like including *cc -c main.c* to see if I could force make to > recognize the rules/dependencies. No luck. > > Any help would be appreciated? > > Below is a copy of: > * Makefile > * Error listings. > * Directory Listing > * Versions of make, uname -a > > --------------------------------------------------------------------- > [root@dba xml]# make build > make: *** No rule to make target `main.o', needed by `build'. Stop. > > [root@dba xml]# make main.o > make: *** No rule to make target `main.c', needed by `main.o'. Stop. > --------------------------------------------------------------------- > [root@dba xml]# more Makefile > build : main.o > cc -o main main.o > > main.o : main.c > cc -c main.c > --------------------------------------------------------------------- > [root@dba xml]# ls > Makefile > main > main.c > main.o > --------------------------------------------------------------------- > [root@dba xml]# cc -dumpversion > egcs-2.91.66 > --------------------------------------------------------------------- > [root@dba xml]# uname -a > Linux dba.execrisk.com 2.2.12-20 #1 Mon Sep 27 10:40:35 EDT 1999 i686 > unknown > > [root@dba xml]# make -version > GNU Make version 3.77, by Richard Stallman and Roland McGrath. > Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98 > Free Software Foundation, Inc. Try: make -f /dev/null main If that doesn't work, then there's something very weird going on. You don't have MAKEFLAGS=-r or MAKEFLAGS=r set in your environment, do you? And the lines that contain the cc compiler invocations really do start with a tab and not with, say, 4 spaces? Assuming, then, that /dev/null makes an adequate makefile, we probably want to start with "mv Makefile junk.Makefile". Next, create a new Makefile which reads: main: Now try make again. It should be OK. If that fails, then you'd better report back... If that works, then you can try adding a build rule before it: build: main main: If that doesn't work, report back. If it works, then change the last line to two lines: main: main.o $(CC) -o $@ main.o Some gibberish there using standard make rules. There's a tab at the start of the $(CC) line; that is *critical*. One or more spaces is an error, though usually make will report a problem with the makefile. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v1.00.PC1 -- see http://www.perl.com/CPAN #include <disclaimer.h>