【问题标题】:Is there a way to define global Makefile (implicit) rules?有没有办法定义全局 Makefile(隐式)规则?
【发布时间】:2021-09-09 09:25:34
【问题描述】:

即使目录中没有 Makefile,我也可以通过运行 make test 来编译 c 程序 test.c。那是因为make有built-in implicit rules

我想对 LaTeX 文件做同样的事情。我想在目录中没有 Makefile 的情况下键入 make test.pdf,然后 make 将搜索 test.tex 并构建 pdf。

我已经知道如何定义pattern rules。我想知道是否可以定义全局模式规则,这样我就不需要将 Makefile 复制到我有 Tex 文件的任何地方。

【问题讨论】:

    标签: makefile


    【解决方案1】:

    您可以定义名为MAKEFILES 的环境变量,它将列出隐式包含的Makefile。那会做你想做的事,例如:

    $ ls
    foo.tex  implicit.mk
    
    $ make foo.pdf
    make: *** No rule to make target 'foo.pdf'.  Stop.
    
    $ cat implicit.mk
    %.pdf: %.tex
            echo Make $@ from $<
    
    $ export MAKEFILES=implicit.mk
    $ make -s foo.pdf
    Make foo.pdf from foo.tex
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 2011-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多