V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
youthy
V2EX  ›  问与答

makefile echo 宏变量

  •  
  •   youthy · Feb 3, 2016 · 2698 views
    This topic created in 3737 days ago, the information mentioned may be changed or developed.

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

    all:
    echo "${TPL}"

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

    5 replies    2016-02-04 21:05:48 +08:00
    framlog
        1
    framlog  
       Feb 3, 2016
    感觉直接用\n 吧
    tracyone
        2
    tracyone  
       Feb 3, 2016 via Android
    无法重现,感觉 XXXX 是导致错误的关键……
    youthy
        3
    youthy  
    OP
       Feb 4, 2016
    @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
       Feb 4, 2016
    @framlog \n 也没有效果。。。。
    framlog
        5
    framlog  
       Feb 4, 2016
    @youthy 我指的是全写一行然后该换行的地方用\n 。不过这么多行你直接用 subst 吧。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3593 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 04:50 · PVG 12:50 · LAX 21:50 · JFK 00:50
    ♥ Do have faith in what you're doing.