Makefile参数字符串比较 [英] Makefile Argument string comparision

查看:560
本文介绍了Makefile参数字符串比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将参数传递给makefile目标.我想对参数进行字符串比较.这是我的代码,

I am passing an argument to makefile target. I want to do string compare of the argument. This is my code,

mode = p
install:
    @echo mode is $(mode)
    ifeq ($(mode),"p")
        @echo mode is production
    else
        @echo mode is development
    endif

我收到以下错误,

mode is d
ifeq (d,"p")
/bin/sh: 1: Syntax error: word unexpected (expecting ")")

比较bash脚本中的字符串有什么错误和一般规则是什么?

What is the error and what is General rule for comparing strings in bash scripts?

推荐答案

您正在使用纯make语法(ifeq)作为配方(该行以制表符开头).试试这个,代替:

You are using pure make syntax (ifeq) as a recipe (the line starts with a tab). Try this, instead:

mode = p
install:
    @echo mode is $(mode)
ifeq ($(mode),p)
    @echo mode is production
else
    @echo mode is development
endif

这篇关于Makefile参数字符串比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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