Makefile 中的 ifeq 的缩进导致的错误

转自:http://stackoverflow.com/questions/4483313/make-error-for-ifeq-syntax-error-near-unexpected-token

 

【问题】

 

 

[plain] view plain copy

  1. ARCH = $(shell getconf LONG_BIT)  
  2.   
  3. all:  
  4.     make  
  5.     ifeq ($(ARCH), 64)  
  6.         cp ../3rd/lib64/libxxx.so ../lib  
  7.     else  
  8.         cp ../3rd/lib/libxxx.so ../lib  
  9.     endif  


上面的Makefile在make时报错:

 

 

 

 

[plain] view plain copy

  1. /bin/sh: -c: line 0: syntax error near unexpected token `64,'  
  2. /bin/sh: -c: line 0: `ifeq (64, 64)'  

 

 

 

【原因】

 

Makefile中,当 ifeq, else 和 endif 没有缩进时,make会正确识别它们,将其作为分支选择的标识

当 ifeq, else 和 endif 有缩进时,make将它们当做普通的shell script

 

【解决】

 

去掉 ifeq, else 和 endif 的缩进,像下面这样

 

[plain] view plain copy

  1. ARCH = $(shell getconf LONG_BIT)  
  2.   
  3. all:  
  4.     make  
  5. ifeq ($(ARCH), 64)  
  6.     cp ../3rd/lib64/libxxx.so ../lib  
  7. else  
  8.     cp ../3rd/lib/libxxx.so ../lib  
  9. endif  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值