如果您是通过搜索引擎找到这儿来的,我想您应该也是正在读 《Autotools: a practitioner's guide to GNU autoconf, automake, and libool》 这本书
我在这儿列出了一些书中我目前不太能理解的片段,如果您能留言解释,实在是感谢!
我自己也会不定期更新我对这些内容的理解。
Page 48
------------------------------------------------------------ -----------------------------
...
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
export prefix
export exec_prefix
export bindir
...
------------------------------------------------------------ -----------------------------
Listing 2-26: Makefile: Adding the bindir variable
------------------------------------------------------------ -----------------------------
...
install:
install -d $(bindir)
install -m 0755 jupiter $(bindir)
uninstall:
-rm $(bindir)/jupiter
...
------------------------------------------------------------ -----------------------------
Listing 2-27: src/Makefile: Adding the bindir variable
Even though we only use bindir in src/Makefile, we have to export prefix, exec_prefix, and bindir because bindir is defined in terms of exec_prefix, which is itself defined in terms of prefix. When make runs the install commands, it will first resolve bindir to $(exec_prefix)/bin, then to $(prefix)/bin, and finally to /usr/local/bin. Thus, src/Makefile needs to have access to all three variables during this process.
我不太理解的是,bindir 在外层目录的Makefile中,被export到环境时,不是已经被展开(expanded)了吗,
为何文中还说,在src/Makefile中需要 “resolve bindir to $(exec_prefix)/bin, then to $(prefix)/bin, and finally” ?
to /usr/local/bin