[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 istniay
.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)]#
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
Thx for replay but the problem is not in make program but in the makefile
Please read first post carefully
the lines with main problems :
%.o: %.c
$(CC) $(CFLAGS) -c $<
%: %.cc
echo $*
$(CC) $(CFLAGS) $*.cc $(LFLAGS) -o $*
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.
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
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 )
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
[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