Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1718325
  • 博文数量: 1493
  • 博客积分: 38
  • 博客等级: 民兵
  • 技术积分: 5834
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-19 17:28
文章分类

全部博文(1493)

文章存档

2016年(11)

2015年(38)

2014年(137)

2013年(253)

2012年(1054)

2011年(1)

分类:

2012-06-21 08:31:15

1.简化主机架构名称(HOSTARCH)和主机操作系统名称(HOSTOS)------L31~L40
  1. HOSTARCH := $(shell uname -m | \
  2.     sed -e s/i.86/i386/ \
  3.      -e s/sun4u/sparc64/ \
  4.      -e s/arm.*/arm/ \
  5.      -e s/sa110/arm/ \
  6.      -e s/powerpc/ppc/ \
  7.      -e s/macppc/ppc/)

  8. HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
  9.      sed -e 's/\(cygwin\).*/cygwin/')
在此使用了 shell 命令 sed ,此命令会把主机架构名“i686”替换为“i386”,把主机操作系统“Linux”替换为“linux”,目的是尽量统一主机的架构名和操作系统类型。
2.指定编译链接时目标文件的输出目录
  1. ifdef O
  2. ifeq ("$(origin O)", "command line")
  3. BUILD_DIR := $(O)
  4. endif
  5. endif

  6. ifneq ($(BUILD_DIR),)
  7. saved-output := $(BUILD_DIR)

  8. # Attempt to create a output directory.
  9. $(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})

  10. # Verify if it was successful.
  11. BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
  12. $(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
  13. endif # ifneq ($(BUILD_DIR),)
有两种方式指定输出文件的目录:
(1)Add O= to the make command line
# 'make O=/tmp/build all'
(2) Set environement variable BUILD_DIR to point to the desired location
# 'export BUILD_DIR=/tmp/build'
# 'make'

阅读(231) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~