gct
gct

Reputation: 14583

Building sse switches for GCC from /proc/cpuinfo

I've got a Makefile that's I'd like to parse the flags in /proc/cpuinfo and build up a list of available sse instruction sets to pass to gcc (-msse -msse2, etc). This is the best I've come up with so far, which Make isn't happy with at all:

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

So I thought I'd see here if anyone had any ideas.

Upvotes: 3

Views: 553

Answers (1)

gct
gct

Reputation: 14583

For anyone that comes after me, this does what I want:

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

Upvotes: 3

Related Questions