- 论坛徽章:
- 0
|
A 运行在PC上的代码:
*.c
/* file: hello.c */
#include stdio.h>
int main(void)
{
printf("Hello, World!\n");
return 0;
}
makefile
#--------------Starting---------------
CC=gcc
EXEC=hello
OBJS=hello.o
CFLAGS+=
LDFLAGS+=
$(EXEC):$(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
clean: -rm -f *.o $(EXEC)
B.运行在ARM下的代码
/* file: hello.c */
#include stdio.h>
int main(void)
{
printf("Hello, World!\n");
return 0;
}
makefile
#--------------Starting---------------
prefix=/opt/host/armv4l/bin/armv4l-unknown-linux-
CC=$(prefix)gcc
EXEC=hello
OBJS=hello.o
CFLAGS+= \
-I/opt/host/armv4l/armv4l-unknown-linux/include \
-Wstrict-prototypes \
-Wno-trigraphs \
-os \
-fno-strict-aliasing \
-fno-common \
-pipe \
-mapcs-32
LDFLAGS+= -elf2flt -static
$(EXEC):$(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
#Cleaning....
.PHONY:clean
clean:
-rm -f *.o $(EXEC)
#-rm: ignore errors
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/77027/showart_1276211.html |
|