Sunday, July 25, 2010

Make file in GCC

missing separator. Stop.
-------------------------------
From: http://www.delorie.com/djgpp/v2faq/faq22_17.html

Q: When I invoke Make, it refuses to do anything and prints a cryptic message: "makefile:10: *** missing separator. Stop." Now what kind of excuse is that?

A: Unlike most other DOS Make programs which accept any whitespace character at the beginning of a command in a rule, GNU Make insists that every such line begins with a TAB. (Most other Unix Make programs also require TABs, and the Posix standard requires it as well.) Make sure that the line whose number is printed in the error message (in this case, line 10) begins with a TAB.

Hello world sample using make file
-------------------------------------
[q.yang@localhost Gsn_HelloEclipse]$ pwd
/home/q.yang/lpc3250/ltib-qs/rootfs/home/user/Gsn_HelloEclipse

[q.yang@localhost Gsn_HelloEclipse]$ tree

.
|-- Makefile
|-- debug
|-- include
`-- sources
|-- Makefile
`-- hellocpp.cpp


[q.yang@localhost Gsn_HelloEclipse]$ cat Makefile

all:
make -C sources
mv ./sources/*.o ./debug
mv ./sources/hellocpp ./debug
clean:
rm -f ./debug/*.o
rm -f ./debug/hellocpp


[q.yang@localhost Gsn_HelloEclipse]$ cat ./sources/Makefile

OBJS = hellocpp.o
CC = arm-none-linux-gnueabi-g++
DEBUG = -g
CFLAGS = -Wall -c $(DEBUG)
LFLAGS = -Wall $(DEBUG)
INCL = -I. -I../ -I../Include

all:hellocpp

hellocpp: $(OBJS)
$(CC) -o hellocpp $(OBJS)

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


[q.yang@localhost Gsn_HelloEclipse]$ cat ./sources/hellocpp.cpp

#include

using namespace std;

int main()
{
cout << "Hello world!" << endl;
cout << "Hello there. First GsnCpp from Eclipse IDE.\n";

return 0;
}


[q.yang@localhost Gsn_HelloEclipse]$ make

make -C sources
make[1]: Entering directory `/home/q.yang/lpc3250/ltib-qs/rootfs/home/user/Gsn_HelloEclipse/sources'
arm-none-linux-gnueabi-g++ -c -Wall -c -g -I. -I../ -I../Include hellocpp.cpp -o hellocpp.o
arm-none-linux-gnueabi-g++ -o hellocpp hellocpp.o
make[1]: Leaving directory `/home/q.yang/lpc3250/ltib-qs/rootfs/home/user/Gsn_HelloEclipse/sources'
mv ./sources/*.o ./debug
mv ./sources/hellocpp ./debug

[q.yang@localhost Gsn_HelloEclipse]$ tree

.
|-- Makefile
|-- debug
| |-- hellocpp
| `-- hellocpp.o
|-- include
`-- sources
|-- Makefile
`-- hellocpp.cpp


[q.yang@localhost Gsn_HelloEclipse]$ make clean

rm -f ./debug/*.o
rm -f ./debug/hellocpp

[q.yang@localhost Gsn_HelloEclipse]$ tree

.
|-- Makefile
|-- debug
|-- include
`-- sources
|-- Makefile
`-- hellocpp.cpp

No comments: