当前位置: 技术问答>linux和unix
请教Makefile怎么写
来源: 互联网 发布时间:2016-11-28
本文导语: 我的.h文件全放在include下,makefile在bin文件夹下,.c全在source文件夹下,我makefile里面应该怎么写才能引用到这些.h啊? 我以前是这样的: PWD := $(shell pwd) INCLUDE_DIR = $(PWD)/include EXTRA_CFLASS += $(INCLUDE_DIR) ……………...
我的.h文件全放在include下,makefile在bin文件夹下,.c全在source文件夹下,我makefile里面应该怎么写才能引用到这些.h啊?
我以前是这样的:
PWD := $(shell pwd)
INCLUDE_DIR = $(PWD)/include
EXTRA_CFLASS += $(INCLUDE_DIR)
………………
可以make通过
现在升级到了新内核(以前的是2.6.18,现在是2.6.28.6)却不行了,为什么啊?应该怎么办啊?
(我把PWD换成绝对路径好像还是可以的,但是我不能每次拷贝都修改Makefile………………)
诸位大神来教教小菜鸟吧………………
我以前是这样的:
PWD := $(shell pwd)
INCLUDE_DIR = $(PWD)/include
EXTRA_CFLASS += $(INCLUDE_DIR)
………………
可以make通过
现在升级到了新内核(以前的是2.6.18,现在是2.6.28.6)却不行了,为什么啊?应该怎么办啊?
(我把PWD换成绝对路径好像还是可以的,但是我不能每次拷贝都修改Makefile………………)
诸位大神来教教小菜鸟吧………………
|
PWD := $(shell pwd)
INCLUDE_DIR = $(PWD)/include
EXTRA_CFLASS += $(INCLUDE_DIR
INCLUDE_DIR = $(PWD)/include
EXTRA_CFLASS += $(INCLUDE_DIR
|
现在make有什么输出?
|
makefile 应该与.c文件同一个目录吧!
|
PWD := $(shell pwd)
INCLUDE_DIR = $(PWD)/include
EXTRA_CFLASS += $(INCLUDE_DIR)
写成PWD := `pwd`
INCLUDE_DIR = ${PWD}/include
EXTRA_CFLASS += ${INCLUDE_DIR}试试
INCLUDE_DIR = $(PWD)/include
EXTRA_CFLASS += $(INCLUDE_DIR)
写成PWD := `pwd`
INCLUDE_DIR = ${PWD}/include
EXTRA_CFLASS += ${INCLUDE_DIR}试试
|
CFLAGS += -I
LDFLAGS += -L/
LDFLAGS += -L/
|
比如当前目录是工作目录下的source目录,目录结构为
project
|--source
|--include
|--bin
则可以这样编写
CFLAGS += -I./../include/
http://blog.csdn.net/jernymy/archive/2011/05/06/6401065.aspx
|
加入下面的语句
INCLUDE_DIR += -Ibin/
INCLUDE_DIR += -Ibin/