V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
youthy
V2EX  ›  问与答

makefile echo 宏变量

  •  
  •   youthy · 2016-02-03 19:45:34 +08:00 · 1965 次点击
    这是一个创建于 3031 天前的主题,其中的信息可能已经有所发展或是发生改变。

    对 makefile 不是很熟,有个问题
    假如定义一段宏代码
    define TPL
    XXXX
    XXXX
    endef

    all:
    echo "${TPL}"

    会报 Unterminated quoted string 错误
    要怎么按照原格式打印出这段宏呢

    5 条回复    2016-02-04 21:05:48 +08:00
    framlog
        1
    framlog  
       2016-02-03 20:33:02 +08:00
    感觉直接用\n 吧
    tracyone
        2
    tracyone  
       2016-02-03 20:48:42 +08:00 via Android
    无法重现,感觉 XXXX 是导致错误的关键……
    youthy
        3
    youthy  
    OP
       2016-02-04 10:23:30 +08:00
    @tracyone 确实是, TPL 是一段 erlang 代码 如果只有一行是成功的,但是好多行就失败了 宏如下
    define tpl_supervisor
    -module($(n)).
    -behaviour(supervisor).

    -export([start_link/0]).
    -export([init/1]).

    start_link() ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).

    init([]) ->
    Procs = [],
    {ok, {{one_for_one, 1, 5}, Procs}}.
    endef
    youthy
        4
    youthy  
    OP
       2016-02-04 10:28:59 +08:00
    @framlog \n 也没有效果。。。。
    framlog
        5
    framlog  
       2016-02-04 21:05:48 +08:00
    @youthy 我指的是全写一行然后该换行的地方用\n 。不过这么多行你直接用 subst 吧。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2679 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 14:05 · PVG 22:05 · LAX 07:05 · JFK 10:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.