makefile - 从/proc/cpuinfo 为 GCC 构建 sse 开关

标签 makefile sse

我有一个 Makefile,我想解析/proc/cpuinfo 中的标志并建立一个可用的 sse 指令集列表以传递给 gcc(-msse -msse2 等)。这是迄今为止我想出的最好的,Make 对此一点都不满意:

DUMM     = $(foreach tag,$(SSE_TAGS),
            ifneq ($(shell cat /proc/cpuinfo | grep $(tag) | wc -l),"") 
            OPT_FLAG += -m$(tag) 
            endif)

所以我想如果有人有任何想法,我会在这里看到。

最佳答案

对于任何追随我的人,这就是我想要的:

SSE_TAGS = $(shell /bin/grep -m 1 flags /proc/cpuinfo | /bin/grep -o \    
    'sse\|sse2\|sse3\|ssse3\|sse4a\|sse4.1\|sse4.2\|sse5')
NUM_PROC = $(shell cat /proc/cpuinfo | grep processor | wc -l)

ifneq (${SSE_TAGS},) 
    CCOPTS += -mfpmath=sse
    CCOPTS += $(foreach tag,$(SSE_TAGS),-m$(tag))
endif

关于makefile - 从/proc/cpuinfo 为 GCC 构建 sse 开关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4911962/

相关文章:

c++ - 找不到 Protocol Buffer 生成命令 libprotobuf.dll.a

Linux Makefile : Why include/config/%. conf 总是被构建?

makefile - 模式规则取决于另一个模式规则

delphi - 将字节值广播到 Delphi ASM 中的所有 16 个 XMM 插槽

c++ - 对齐、总大小和 SSE

c - AVX 标量运算要快得多

c++ - OpenCV GTK+2.x 错误 - "Unspecified error (The function is not implemented...)"

bash - 如何检查列表中的文件是否包含 makefile 中的内容?

c++ - vector 的数据如何对齐?

c++ - 一个 SSE Stdlib 式的库?