Makefile debug的经验
来源:互联网 发布:曦力音视频转换mac版 编辑:程序博客网 时间:2024/06/03 11:40
1. 使用warning指令
warning 是个不错的命令,可以打印出消息,来判断makefile执行的流程
如 , 这是一个普通的编译kernel module的Makefile,但是我忘记这个文件的执行顺序了。
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
#CROSS_COMPILE = /opt/toolchains/uclibc-crosstools-gcc-4.2.3-3/usr/bin/mips-linux-uclibc-
#export CROSS_COMPILE
ifneq ($(KERNELRELEASE),)
$(warning A top-level warning)
obj-m := hello_world.o
# hello_world-objs :=
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
$(warning A Bottom-level waring)
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
#KERNELDIR ?= /home/wyang2/WFG500N/bcm963xx/kernel/linux
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
执行的结果是,这样我就发现,实际上时先执行下面那一段,然后再执行上面一段的 。
$make
Makefile:14: A Bottom-level waring
make -C /lib/modules/2.6.23.1-42.fc8/build M=/home/wyang2/test/kmodule modules
make[1]: Entering directory `/usr/src/kernels/2.6.23.1-42.fc8-i686'
/home/wyang2/test/kmodule/Makefile:8: A top-level warning
Building modules, stage 2.
MODPOST 1 modules
LD [M] /home/wyang2/test/kmodule/hello_world.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.23.1-42.fc8-i686'
2.使用ifeq ifneq
当makefile被多次调用到的时候,如果都输出warning,那么就显得输出内容太多,找不到到底是哪个了。
使用ifeq/ifneq可以选择性输出,对大型的工程比较好用。
ifeq ($(obj),arch/x86/boot)
$(warning building the bzImage?)
endif
3. 输出隐藏的变量
有时候我需要看看,这次make执行中到底定义了哪些变量,一个个打太麻烦,而且打出来的都是自己知道的。
原帖在
http://www.cmcrossroads.com/ask-mr-make/6521-dumping-every-makefile-variable
.PHONY: printvars
printvars:
@$(foreach V,/
$(sort $(.VARIABLES)), /
$(if $(filter-out environment% default automatic, $(origin $V)),/
$(warning $V=$($V) ($(value $V)))/
) /
)/
printvars1:
# echo $(.VARIABLES)
@$(foreach V,/
$(sort $(.VARIABLES)), $(warning $V=$($V) ($(value $V)) $(origin $V)) /
)
上面两个例子分别打印了,在文件中定义的,和所有的makefile变量。
4。 使用-p选项
使用-p选项可以输出规则和变量。
- Makefile debug的经验
- Makefile debug的经验
- debug的一些经验
- debug的一些经验
- 数据的库debug经验
- Makefile Debug:
- debug经验
- 关于makefile的一些学习经验
- 如何debug makefile文件
- makefile debug && release 模式
- 用xcode来debug以makefile组织的程序
- CMake 生成 Linux 下 Debug 版本的 Makefile 方法
- 用xcode来debug以makefile组织的程序
- debug经验一二三
- debug经验一二三
- Debug方法和经验
- debug经验汇总
- Debug一些经验
- 【Python排序搜索基本算法】之冒泡排序
- github
- POJ3411--Paid Roads
- poj 3468 A Simple Problem with Integers(线段树区间更新 or 树状数组区间更新)
- UIKit 图片的移动、位移、旋转、缩放、翻转、翻页等特效的使用
- Makefile debug的经验
- TQ2440开发板open ssh移植
- 安卓的简单开发应用
- 安卓开发之意图对象篇 比如打电话 发短信
- 腾讯2012实习
- CloudSuite环境搭建
- Java设计模式透析之 —— 适配器(Adapter)
- Container With Most Water
- android制作一个简单登入界面的部分代码