为了更好的说明我的问题,首先拿一个Android源码目录下的一个Android.mk文件来作例子,在Android源码路径:Android目录/hardware/ril/reference-ril/下的Android.mk文件,内容如下:
5 LOCAL_PATH:= $(call my-dir)
6 include $(CLEAR_VARS)
7
8 LOCAL_SRC_FILES:= \
9 reference-ril.c \
10 atchannel.c \
11 misc.c \
12 at_tok.c
13
14 LOCAL_SHARED_LIBRARIES := \
15 libcutils libutils libril
16
17 # for asprinf
18 LOCAL_CFLAGS := -D_GNU_SOURCE
19
20 LOCAL_C_INCLUDES := $(KERNEL_HEADERS)
21
22 ifeq ($(TARGET_DEVICE),sooner)
23 LOCAL_CFLAGS += -DOMAP_CSMI_POWER_CONTROL -DUSE_TI_COMMANDS
24 endif
25
26 ifeq ($(TARGET_DEVICE),surf)
27 LOCAL_CFLAGS += -DPOLL_CALL_STATE -DUSE_QMI
28 endif
29
30 ifeq ($(TARGET_DEVICE),dream)
31 LOCAL_CFLAGS += -DPOLL_CALL_STATE -DUSE_QMI
32 endif
33
34 ifeq (foo,foo)
35 #build shared library
36 LOCAL_SHARED_LIBRARIES += \
37 libcutils libutils
38 LOCAL_LDLIBS += -lpthread
39 LOCAL_CFLAGS += -DRIL_SHLIB
40 LOCAL_MODULE:= libreference-ril
41 include $(BUILD_SHARED_LIBRARY)
42 else
....
1:一般在进行源码单个模块编译时,比如用mmm hardware/ril/reference-ril 这样的指令编译某个单个模块时,这个模块默认包含的头文件包含路径除了当前目录外,还有某他路径是什么?
2:我知道Android.mk文件中可以通过LOCAL_C_INCLUDES这个变量来指定包含的C语言头文件目录,比如上面例子中的20行:LOCAL_C_INCLUDES := $(KERNEL_HEADERS),问题是这个$(KERNEL_HEADERS)指的具体目录是哪?
3:有什么方法可以知道当前Android.mk文件中某些变量的值?比如上个问题中的$(KERNEL_HEADERS)这个我怎么才能知道它代表的具体值或内容是什么?
4:我在Linux下写了一个有关线程间通信的程序,并且在Ubuntu下测试没有发现任何问题,这个程序包含了这些头文件:
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <sys/msg.h>
现在移植放到Android源码下,并制作了一个Andoid.mk文件后用mmm编译,结果如下:
hardware/mcu/mcu.c:10:21: error: sys/msg.h: No such file or directory
hardware/mcu/mcu.c: In function '_mcu_send':
hardware/mcu/mcu.c:121: warning: implicit declaration of function 'msgsnd'
hardware/mcu/mcu.c: In function '_mcu_send_thread_entry':
hardware/mcu/mcu.c:194: warning: implicit declaration of function 'msgrcv'
hardware/mcu/mcu.c: In function '_mcu_send_mq_init':
hardware/mcu/mcu.c:265: warning: implicit declaration of function 'ftok'
hardware/mcu/mcu.c:269: warning: implicit declaration of function 'msgget'
hardware/mcu/mcu.c:269: error: 'IPC_CREAT' undeclared (first use in this function)
hardware/mcu/mcu.c:269: error: (Each undeclared identifier is reported only once
hardware/mcu/mcu.c:269: error: for each function it appears in.)
hardware/mcu/mcu.c: In function '_mcu_rev_mq_init':
hardware/mcu/mcu.c:367: error: 'IPC_CREAT' undeclared (first use in this function)
hardware/mcu/mcu.c: In function '_mcu_rev_framehandle':
hardware/mcu/mcu.c:491: warning: comparison between signed and unsigned integer expressions
make: *** [out/target/product/generic/obj/EXECUTABLES/mcu_intermediates/mcu.o] Error 1
make: Leaving directory `/home/arthur/WORKING_DIRECTORY'
我想是头文件包含的问题,由于目前对Android.mk文件头文件包含问题不是很清楚,特提此问题。该如何改?
------解决方案--------------------
楼主的问题我只能回答第2个和第3个,因为对android的c头文件的包含我了解的不多......
一般一些为子项目编译所定义的环境变量都是build/core/package.mk这里声明的,如果你想找makefile文件里边一个变量的意义,建议你执行一下. build/envsetup.sh这个脚本,然后使用命令mgrep "KERNEL_HEADERS"来搜索,可以搜索到这个变量在哪定义.
仅供参考.