This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: about makefile


Dear nickg,
now i have modify my makefile as following:
(1)
HEAD_DIR = include
VPATH = src include

test: test.o cs.o
gcc -o test test.o cs.o

cs.o: cs.c cs.h
gcc -c src/cs.c -I$(HEAD_DIR) test.o: test.c cs.c cs.h
gcc -c test.c src/cs.c -I$(HEAD_DIR)
clean:
-rm *.o

it work well!
(2)
but :
HEAD_DIR = include
VPATH = src:include

test: test.o cs.o
gcc -o test test.o cs.o

cs.o: cs.c cs.h
gcc -c cs.c -I$(HEAD_DIR) test.o: test.c cs.c cs.h
gcc -c test.c cs.c -I$(HEAD_DIR)
clean:
-rm *.o

make
make: *** No rule to make target `cs.c', needed by `cs.o'. Stop.

make can not find file 'cs.c' yet,unless i replace cs.c with src/cs.c.
it seem that VPATH does not work.
(3)
but:
HEAD_DIR = include
#VPATH = src include

test.exe: test.o cs.o
gcc -o test test.o cs.o

cs.o: cs.c cs.h
gcc -c src/cs.c -I$(HEAD_DIR) test.o: test.c cs.c cs.h
gcc -c test.c src/cs.c -I$(HEAD_DIR)
clean:
-rm *.o
make
make: *** No rule to make target `cs.c', needed by `cs.o'. Stop.
it seem that the lack of VPATH,makefile does not work
(4)

#HEAD_DIR = include
VPATH = src include

test.exe: test.o cs.o
gcc -o test test.o cs.o

cs.o: cs.c cs.h
gcc -c src/cs.c #-I$(HEAD_DIR) test.o: test.c cs.c cs.h
gcc -c test.c src/cs.c #-I$(HEAD_DIR)
clean:
-rm *.o
make
make*** cs.h:no such file or directory.stoped

I am confused! help me!


From: Nick Garnett <nickg@ecoscentric.com>
To: ÕÅ ÁÁ <johnsonest@hotmail.com>
CC: ecos-discuss@sources.redhat.com
Subject: Re: about makefile
Date: 26 Sep 2002 18:00:28 +0100

ÕÅ ÁÁ <johnsonest@hotmail.com> writes:

> Dear nickg,
> i have difficulty in orgnizing my header file and source file with
> makefile:
> I create two folder ,named after "include" and "src" in current
directory:
> >ls
> include src test.c
>
> in test.c, i want to call codes in "include" and "src" folder:
>
> #include <stdio.h>
> #include "cs.h" //in include folder
>
> int main() {
> ....
> ...
> call fucntions in file "cs.c" in folder "src"
> ...
> }
>
> to compile this
> my makefile is:
>
> HEADER_DIR = include
> test: test.o cs.o gcc -o test test.o cs.o
> test.o: test.c cs.h gcc -c test.c cs.o : cs.c cs.h
> gcc -c cs.c -I$(SOURCE_DIR) clean:
> -rm *.o
>
> but:
> >make
> make: *** No rule to make target `cs.c', needed by `cs.o'. Stop.
> in fact,my cs.c is a set of functions called each other,no entry
function.
>
> i am a newcomer about makefile,could you check my makefile ,tell me
> where error occur?
>

This is not really relevant to eCos, and it is not my job to teach you
how to use make, but I'll give you a few pointers:

Make does not know that you want it to look into the src subdirectory
for cs.c. You need to tell it, either by referring to src/cs.c
explicily in the makefile, or by using the VPATH mechanism. Find and
read the GNU make documentation for details.


--
Nick Garnett - eCos Kernel Architect
http://www.eCosCentric.com/



_________________________________________________________________
Ãâ·ÑÏÂÔØ MSN Explorer: http://explorer.msn.com/lccn/


--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]