如何为 32 位和 64 位创建单个 makefile? [英] How do I create a single makefile for both 32- and 64-bit?
本文介绍了如何为 32 位和 64 位创建单个 makefile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 makefile
可以透明地用于 Linux (x86_64
) 和 OS X Intel (x86_64
).这使用 64 位特定的 GCC 选项.
I have a makefile
that works transparently for Linux (x86_64
) and OS X Intel (x86_64
). This uses 64-bit specific GCC options.
有没有办法调整 makefile 以便我可以为 32 位和 64 位 OS X PPC(ppc
、ppc64
)构建而无需维护单独的、特定于架构的 makefile——也许类似于可以在构建之前确定架构的预处理器指令?
Is there a way to adjust the makefile so that I could build for 32-bit and 64-bit OS X PPC (ppc
, ppc64
) without having to maintain separate, arch-specific makefiles — perhaps something like a pre-processor directive that can determine the architecture before building?
推荐答案
ARCH := $(shell getconf LONG_BIT)
CPP_FLAGS_32 := -D32_BIT ... Some 32 specific compiler flags ...
CPP_FLAGS_64 := -D64_BIT
CPP_FLAGS := $(CPP_FLAGS_$(ARCH)) ... all the other flags ...
这篇关于如何为 32 位和 64 位创建单个 makefile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文