我正在尝试配置Android.mk以交叉编译本机代码以支持不同的芯片组,即armeabi,mips和x86.我知道我可以用以下方式配置Application.mk来编译不同芯片组的源代码:
APP_ABI := all
Run Code Online (Sandbox Code Playgroud)
这将触发Android-NDK的构建脚本来编译所有芯片组的源代码.但是,我想动态告诉Android.mk寻找使用不同芯片组编译的不同静态库依赖项.
# Get the architecture info
ARCH := ????
include $(CLEAR_VARS)
LOCAL_MODULE:= mylib
LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILT_STATIC_LIBRARY)
Run Code Online (Sandbox Code Playgroud)
这可能吗?如果是这样,有人可以建议如何这样做吗?
更新:我在Application.mk中尝试过类似的东西:
Run Code Online (Sandbox Code Playgroud)APP_ABI := armeabi armeabi-v7a mips x64使用Android.mk:
Run Code Online (Sandbox Code Playgroud)# Get the architecture info ARCH := $(APP_ABI) include $(CLEAR_VARS) LOCAL_MODULE:= mylib LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) include $(PREBUILT_STATIC_LIBRARY)但它有以下错误:
Run Code Online (Sandbox Code Playgroud)The LOCAL_SRC_FILES for a prebuilt static library should only contain one item这是有道理的.我想在Application.mk中传递APP_ABI:= all并能够动态引用它.有任何想法吗?
我想在ifGNU make文件的循环中检查多个条件.这是一个例子:
ifeq ($(TEST_FLAG),TRUE && ($(DEBUG_FLAG),FALSE))
true statement
else
false statement
endif
Run Code Online (Sandbox Code Playgroud)
什么是正确的方法呢?
在我的Makefile中,我想检查以下复杂情况:
ifdef VAR1 || VAR2 || VAR3
action
endif
Run Code Online (Sandbox Code Playgroud)
但文档说不支持这样的语法.因此,我想到的唯一简单的解决方法是使用串联:
ifneq ($(VAR1)$(VAR2)$(VAR3),)
action
endif
Run Code Online (Sandbox Code Playgroud)
还有其他更正确的解决方案吗?
对于以下情况:
ifdef VAR1 && VAR2 && VAR3
action
endif
Run Code Online (Sandbox Code Playgroud)
一个人需要写
ifdef VAR1
ifdef VAR2
ifdef VAR3
action
endif
endif
endif
Run Code Online (Sandbox Code Playgroud)
这也很难看.还有更优雅的选择吗?
是否有'ifneq ... endif'语句的逻辑OR运算符?
也就是说,如果定义了变量'var1'或'var2',我不想执行某些语句.像这样的东西:
ifneq ($(WNDAP660),y) OR $(WNADAP620),y))
...
endif
Run Code Online (Sandbox Code Playgroud)
我试过ifneq ($(WNDAP660),$(filter $(WNADAP620),y y)),但它没有用.
我想在我的makefile中启用详细编译,但我无法弄清楚如何创建一个条件OR.
让我解释一下:我希望能够通过设置或指定一个详细的编译.我想保持可用,因为我们有一些使用它的脚本(并且使用其他makefile只知道)V=1 VERBOSE=1VERBOSE=1VERBOSE
所以结果必须是这两个命令是相同的:
make all VERBOSE=1 # pain to write
make all V=1
Run Code Online (Sandbox Code Playgroud)
现在,我的makefile今天看起来像这样:
ifdef VERBOSE
[issue compilation commands with verbose mode]
endif
Run Code Online (Sandbox Code Playgroud)
我想要实现的是接近C中的预处理器:
if defined(VERBOSE) || defined(V)
[issue compilation commands with verbose mode]
endif
Run Code Online (Sandbox Code Playgroud)
你知道怎么做吗?
我想要多个 if 条件并想要组合。
ifeq ($(TAG1), on)
LD_FLAGS += -ltestlibrary
endif
ifeq ($(TAG2), on)
LD_FLAGS += -ltestlibrary
endif
Run Code Online (Sandbox Code Playgroud)
我想做一些事情,比如:
ifeq ($(TAG1) || $(TAG2), on)
LD_FLAGS += -ltestlibrary
endif
Run Code Online (Sandbox Code Playgroud)
我该怎么做?SO Makefile ifeq logical or or How to Use of Multiple condition in 'ifeq' 语句中的答案给出了其他方法。
我想使用ifeq检查makefile中的条件,并且不确定如何去做:
ifeq ( cond1 = yes || cond2 = yes )
set value x = 1;
else
set value x = 2;
endif
Run Code Online (Sandbox Code Playgroud)
请提出正确的做法吗?
给定以下ifeq语句,如何压缩它以便可以在一个ifeq块中处理字符串检查?
OS:=$(shell uname -s)
ifeq ($(OS), Linux)
foo
endif
ifeq ($(OS), Darwin)
bar
endif
ifeq ($(OS), FreeBSD)
bar
endif
ifeq ($(OS), NetBSD)
bar
endif
Run Code Online (Sandbox Code Playgroud)
我已经研究过类似的问答,但不确定它如何完全适用于这个问题。
像这样的东西:
ifeq ($(OS), Linux)
foo
endif
ifeq ($(OS) in (Darwin, FreeBSD, NetBSD)) # <- something like this
bar
endif
Run Code Online (Sandbox Code Playgroud) makefile ×7
gnu-make ×2
android ×1
android-ndk ×1
conditional ×1
gnu ×1
linux ×1
logic ×1
unix ×1
verbose ×1