23.Automake不能满足使用时

本系列文章均翻译自Automake官方文档:Automake Manual,github同步项目:question

扩展Automake规则

Makefile.in文件从三个源(Makefile.am、configure.ac以及automake自身)构建。遵守以下约定:

  1. 用户在Makefile.am中定义的变量的优先级大于在configure.ac中使用AC_SUBST定义的变量,AC_SUBST的优先级大于automake定义的变量。
  2. 对于同一个目标,用户定义的规则的优先级大于任何automake定义的规则。

覆盖默认规则

当你相要覆盖默认的规则时,需要重写的规则的目标是:

    all-recursive check-recursive cscopelist-recursive 
    ctags-recursive dvi-recursive html-recursive info-recursive 
    install-data-recursive install-dvi-recursive 
    install-exec-recursive install-html-recursive 
    install-info-recursive install-pdf-recursive 
    install-ps-recursive install-recursive installcheck-recursive 
    installdirs-recursive pdf-recursive ps-recursive 
    tags-recursive uninstall-recursive

比如相应覆盖默认的make check规则,需要这样重写:

check-recursive:
    @echo "I'm not the default make check."

warning:重写之后其相应的后缀规则也会失效。比如check-local将不再执行。

补充默认规则(无序)

可以在Makefile.am中指定多种目标的-local版本,Automake会用-local目标来补充标准的目标。支持的目标有:*all, info, dvi, ps, pdf, html, check, install-data, install-dvi, install-exec, install-html, install-info, install-pdf, install-ps, uninstall, installdirs, installcheck *and the various clean targets (mostlyclean, clean, distclean, and maintainer-clean)

clean-local:
        -rm -rf testSubDir

note:带有-local的目标不能确定其执行顺序。

补充默认规则(有序)

相反的,一些规则有运行另一个规则的方法,称作hookhook总是在主规则执行完毕后执行。
支持-hook的目标有:install-data, install-exec, uninstall, dist, distcheck

install-exec-hook:
        ln $(DESTDIR)$(bindir)/program$(EXEEXT) \
           $(DESTDIR)$(bindir)/proglink$(EXEEXT)

第三方MakefileS

第三方MakefileS应该支持的规则有:
all distdir install install-data install-exec
uninstall install-dvi install-html install-info
install-ps install-pdf installdirs check
installcheck mostlyclean clean distclean maintainer-clean
dvi pdf ps info html tags ctags

只在DIST_SUBDIRS中列出而不在SUBDIRS中需要的只有三个规则:distclean, maintainer-clean, distdir

猜你喜欢

转载自blog.csdn.net/SHRINKSHR/article/details/85838911