如何创建为一个单一的makefile 32位和64位? [英] How do I create a single makefile for both 32- and 64-bit?

查看:924
本文介绍了如何创建为一个单一的makefile 32位和64位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生成文件的透明运行于Linux( x86_64的)和OS X的英特尔( x86_64的)。这将使用64位GCC特定的选项。

有没有办法调整makefile文件,这样我可以建立32位和64位OS X PPC( PPC PPC64 ),而无需维护独立,特定拱的makefile - 也许有点像pre处理器指令,可以在制作之前,确定架构


解决方案

  ARCH:= $(壳在getconf LONG_BIT)CPP_FLAGS_32:= -D32_BIT ...一些32项具体的编译器标志...
CPP_FLAGS_64:= -D64_BITCPP_FLAGS:= $(CPP_FLAGS _ $(ARCH))...所有的其它标志...

I have a makefile that works transparently for Linux (x86_64) and OS X Intel (x86_64). This uses 64-bit specific GCC options.

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 ...

这篇关于如何创建为一个单一的makefile 32位和64位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆