Cross-Platform Builds(Digest from www.ddj.com)

All it takes is five rules and 42 lines

Rule #1: Use GNU Make(http://www.gnu.org/software/make)

The following is the top-level Makefile stored in src/:


MODULES=library executable
include $(addsuffix /Makefile,$(MODULES))

Typing make in src/ builds all the object files, library, and executable. The MODULES variable is a list of the directories containing components that must be built. include $(addsuffix /Makefile,$(MODULES)) turns into include library/ Makefile executable/Makefile and includes the Makefiles that describe each of the separate components.

Rule #2: No Spaces in Filenames, No Drive Letters

Rule #3: Decide What Platform the Make is Running On

The simplest way to determine your platform is the uname command,like

X_ARCH := $(shell uname -ms | sed -e s"/ /_/g" )

on CYGWIN, X_ARCH will be CYGWIN_NT-5.0_i686; on Solaris, SunOS_sun-4u; and on Linux, Linux_i686.

Rule #4: Separate Output on a Per-Platform Basis

Rule #5: Override Built-In Rules

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值