天天看點

Makefile和automake中判斷CPU位數

Makefile中:

cpu_bit=$(shell getconf LONG_BIT)

ifeq ($(cpu_bit),64)

    MY_CXXFLAGS=

else

    MY_CXXFLAGS=-march=pentium4

endif

x::

        @echo $(cpu_bit)

        @echo $(MY_CXXFLAGS)

automake中要稍複雜些:

首先要在configure.ac檔案中添加一行:

AM_CONDITIONAL(bit_32,test "x`getconf LONG_BIT`"="x32")

然後再在Makefile.am檔案中添加:

if bit_32

這樣就可以了.

上一篇: Rsync詳解