Makefile not work. Why?


 
Thread Tools Search this Thread
Top Forums Programming Makefile not work. Why?
# 1  
Old 02-20-2008
Makefile not work. Why?

Code:
[root@zet c1(0)]# ls
c1.0.cc  info  makefile  x.c
[root@zet c1(0)]# cat makefile 
CC=/usr/bin/g++
CFLAGS=-pedantic -ansi 
LFLAGS=
#NAME=c1.0
AUTHOR= Marcin

%.o: %.c
        $(CC) $(CFLAGS) -c $<

%: %.cc 
        $(CC) $(CFLAGS) $*.cc $(LFLAGS) -o $*

# to na wypadek gdyby pliki o tych nazwach istniały
.PHONY: clean info install

install:
        @echo "Not implemented"

#clean:
#       rm -f $(NAME1) $(NAME2)

info:
        @echo "$(AUTHOR)"
        @echo " GPL vRelease"
[root@zet c1(0)]# make
Not implemented
[root@zet c1(0)]#

# 2  
Old 02-21-2008
check thest following
$which make
$make -f Makefile
$make install
$make hai

The first one will show you the version of the make if present
the second one will force make to read the 'Makefile'
the third one will tell make to make the target install
the fourth one will tell make to make the target hai, for which there is no rule, and hence would give an error 'no rule to make target hai'

best Regards,
Rakesh UV
# 3  
Old 02-21-2008
Thx for replay but the problem is not in make program but in the makefile
Please read first post carefully Smilie

the lines with main problems :

Code:
%.o: %.c
    $(CC) $(CFLAGS) -c $<

%: %.cc
    echo $* 
    $(CC) $(CFLAGS) $*.cc $(LFLAGS) -o $*

# 4  
Old 02-21-2008
hi,
make file are processed from line 1 and the first lines of you file are variables (ok) but then a role
and soon this role is processed it stops.

All you need is in the begining

myprg: myprg.o mymodul.o

since make KNOWS how to generate a binary from an .o and KNOWS how to generate a .o from
several sources including .c this should work.


Quote:
Originally Posted by marcintom
Code:
[root@zet c1(0)]# ls
c1.0.cc  info  makefile  x.c
[root@zet c1(0)]# cat makefile 
CC=/usr/bin/g++                                       <- iff you have more than one , else gcc/g++ alone is sufficent 
CFLAGS=-pedantic -ansi                       <- -better -Wall
LFLAGS=                                              <- i guess you want LDFLAGS, not used so remove
#NAME=c1.0
AUTHOR= Marcin

%.o: %.c
        $(CC) $(CFLAGS) -c $<                           <- Make knows this  remove

%: %.cc 
        $(CC) $(CFLAGS) $*.cc $(LFLAGS) -o $*   <- Make knows this  remove

# to na wypadek gdyby pliki o tych nazwach istniały
.PHONY: clean info install

install:                                                                <- 1. real rule it will executed make will stop here
        @echo "Not implemented"

#clean:
#       rm -f $(NAME1) $(NAME2)                <- $(RM)       

info:
        @echo "$(AUTHOR)"
        @echo " GPL vRelease"
[root@zet c1(0)]# make
Not implemented
[root@zet c1(0)]#

# 5  
Old 02-22-2008
Hi Marcintom,
->i was just trying to see if those checks would help you
->the error was interesting, not seen before, thats why i was keen on the version of make
->and secondly you can call make in these ways
->make
it will try to make the first target and there is no constraints, that the target name should be in the first line(make parses not in a single strech, it has do a lot of substitution, get the values of macros, include other makefiles etc etc and at last it tries to make targets)

->make target
here it will try to make the target
->but in any of the two cases there is no chance that it would give a error like that (assuming that the lines in make have proper spaces and tabs)

->i was not able to get the same error when tried in read had machine with make 3.80
->please post the solution if have found one

Best Regards,
Rakesh Uv
# 6  
Old 02-22-2008
Thank you guys for all advices.

I see now that my problem was in not to write the main target
If I correctly understand you.

and I run something lik this ( this work fine Smilie )

Code:
CC= gcc
CFLAGS= -Wall -pedantic -ansi

myprog: x.o
    $(CC) $(CFLAGS) x.o -o myprog
%.o: %.c
    $(CC) $(CFLAGS) -c $<


to uvrakesh

yes "make" work fine
Code:
[root@zet c1(0)]# make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
[root@zet c1(0)]# ls
c1.0  c1.0.cc  info  makefile  makefile.tmp  myprog  x.c  x.o
[root@zet c1(0)]# rm myprog x.o 
rm: delete this file `myprog'? t
rm: delete this file `x.o'? t
[root@zet c1(0)]# ls
c1.0  c1.0.cc  info  makefile  makefile.tmp  x.c
[root@zet c1(0)]# make -f makefile.tmp 
gcc -Wall -pedantic -ansi  x.o -o myprog
[root@zet c1(0)]# ls
c1.0  c1.0.cc  info  makefile  makefile.tmp  myprog  x.c  x.o

PS
Sorry for my english Smilie

Last edited by marcintom; 02-25-2008 at 02:56 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Discussion at work, would a router work pluging a cable in wan1 and lan1?

hi all. and sorry for the random question, but this sparkled a raging flame-war at work and i want more points of view situation a router, with linux of some sort, dhcp client requesting for ip in wan1 (as usual with wan ports) dhcp server listening in lan1, and assigning ip (as usual... (9 Replies)
Discussion started by: broli
9 Replies

2. Shell Programming and Scripting

My script work on Linux but not work in sunos.

My script work on Linux but not work in sun os. my script. logFiles="sentLog1.log sentLog2.log" intial_time="0 0" logLocation="/usr/local/tomcat/logs/" sleepTime=600 failMessage=":: $(tput bold)Log not update$(tput rmso) = " successMessage="OK" arr=($logFiles)... (7 Replies)
Discussion started by: ooilinlove
7 Replies

3. IP Networking

NIC will not work, but it did work.

I have a client machine that was built and loaded with SCO UNIX 2.1.3, (yes it is old). The machine worked fine on the closed network that I tested on in my shop. I then had to change it to the network that it would be connected to. Below is the host file, router and subnet mask file that I usually... (0 Replies)
Discussion started by: NC user
0 Replies

4. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

5. UNIX for Advanced & Expert Users

Makefile executing another Makefile first?

I have 2 libraries in 2 different directories that I build with Makefiles. library B depends on library A. If I modify a .cpp file in library A and run lib B's Makefile can I have B's makefile to automatically rebuild library A? I am now rebuilding A, followed by B... but I'd like B to... (0 Replies)
Discussion started by: wwuster
0 Replies

6. Programming

[Makefile] nothing to be done for 'all'

hello, I have a firts makefile who call others makefile. for this i use: $ make -f linux.mak and output his: $ make -f linux.mak all make -C DerelictAL all PLATFORM=linux make: Entering directory `/home/builder/rpmbuild/SOURCES/derelict2-20100407/DerelictAL' make: Nothing to be done for... (2 Replies)
Discussion started by: bioinfornatics
2 Replies

7. Shell Programming and Scripting

makefile

Hi, I have problem related to makefile in c in linux(ubuntu). What is the meaning of @prefix@ what this two @ symbols mean here? Thanks, Vivek (0 Replies)
Discussion started by: vivek146
0 Replies

8. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies

9. Programming

Makefile

I am writing my first makefile, and I face a problem: all: sequential pthreads1 pthreads2 openmp1 openmp2 sequential: sequential/main.c sequential/definitions.h gcc -o seq sequential/main.c pthreads1: pthreads1/main.c pthreads1/definitions.h gcc -o pthr1 pthreads1/main.c -lpthread ... (0 Replies)
Discussion started by: myle
0 Replies

10. UNIX for Dummies Questions & Answers

Script doesn't work, but commands inside work

Howdie everyone... I have a shell script RemoveFiles.sh Inside this file, it only has two commands as below: rm -f ../../reportToday/temp/* rm -f ../../report/* My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Discussion started by: cheongww
2 Replies
Login or Register to Ask a Question