Chinaunix首页 | 论坛 | 博客
  • 博客访问: 72661
  • 博文数量: 8
  • 博客积分: 1526
  • 博客等级: 上尉
  • 技术积分: 100
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-24 14:29
文章分类

全部博文(8)

文章存档

2013年(1)

2012年(2)

2011年(2)

2010年(1)

2009年(2)

我的朋友

分类: LINUX

2009-08-28 00:14:21

建立include, src, out文件夹
 
#
# filename: Makefile
#
# Authors: Li Bo <>
# Version: 1.0
#
# Create Time: 2009.8.14
# Last Modified: 2009.8.14
#
src = $(wildcard src/*.c)
obj = $(patsubst src/%.c, out/%.o,$(src))
CC = gcc
CFLAGS = -g -Wall
LDFLAGS = -pthread
target = app
vpath %.o out
vpath %.c src
vpath %.h include
all: $(target)
$(target): $(obj)
 $(CC) $(LDFLAGS) -o $@ $(obj) -Iinclude
$(obj): $(patsubst out/%.o, src/%.c, $(@))
 $(CC) $(CFLAGS) -c -o $@  $(patsubst out/%.o, src/%.c, $(@)) -Iinclude
.PHONY:
clean:
 rm -f $(obj)
 rm -f $(target)
 
#
# filename: Makefile for static lib
#
# Authors: Li Bo <>
# Version: 1.0
#
# Create Time: 2009.8.14
# Last Modified: 2009.8.14
#
src = $(wildcard src/*.c)
obj = $(patsubst src/%.c, out/%.o, src/add.c src/sub.c)
AR = ar
CC = gcc
CFLAGS = -g -Wall
LDFLAGS = -pthread
target = out/libaddsub.a
vpath %.a out
vpath %.o out
vpath %.c src
vpath %.h include
all: $(target)
$(target): $(obj)
 $(AR)  -cr $@ $(obj)
$(obj): $(patsubst out/%.o, src/%.c, $(@))
 $(CC) $(CFLAGS) -c -o $@  $(patsubst out/%.o, src/%.c, $(@)) -Iinclude
.PHONY:
clean:
 rm -f $(obj)
 rm -f $(target)
 
#
# filename: Makefile for dynamic lib
#
# Authors: Li Bo <>
# Version: 1.0
#
# Create Time: 2009.8.14
# Last Modified: 2009.8.14
#
src = $(wildcard src/*.c)
obj = $(patsubst src/%.c, out/%PIC.o, src/add.c src/sub.c)
CC = gcc
CFLAGS = -g -Wall
CFLAGSLIB = -fPIC
LDFLAGS = -shared
target = out/libaddsub.so
vpath %.o out
vpath %.c src
vpath %.h include
all: $(target)
$(target): $(obj)
 $(CC) $(LDFLAGS) -o $@ $(obj) -Iinclude
$(obj): $(patsubst out/%PIC.o, src/%.c, $(@))
 $(CC) $(CFLAGSLIB) -c -o $@  $(patsubst out/%PIC.o, src/%.c, $(@)) -Iinclude
.PHONY:
clean:
 rm -f $(obj)
 rm -f $(target)
 
 
all: app
app:
 gcc src/main.c -o app -laddsub -Lout/ -Iinclude
 
 
 
#
# add path to /etc/ld.so.conf
# ldconfig
#
# ldd app
#
all: app
app:
 gcc -o app src/main.c -laddsub -Lout -Iinclude
阅读(1705) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:uboot源码分析-运行时内存分布

给主人留下些什么吧!~~