“ make install”和“ make altinstall”在细节上的区别

我的情况是这样的:

我正在使用 Ubuntu 10.04(Lucid Lynx)。系统的默认 Python 是 v2.6.5,但我需要 Python v2.7。所以我从 python.org 下载了源代码并试图安装它。

我第一次安装它的时候,我运行:

cd Python2.7.4
./configure --prefix=/usr
make
su root
make install

这将在我的系统中安装 Python 2.7。它将创建一个链接,“ python”,在 /usr/bin中链接到 python2.7,在 /usr/bin中也是如此。因此,当我键入 >python时,系统将为我启动 Python 2.7.4,就像我键入 >python2.7时一样。

但是当我这样安装的时候:

cd Python2.7.4
./configure --prefix=/usr
make
su root
make altinstall

/usr/bin中的链接“ python”仍然存在,并且链接到 python2.6,这是默认的系统版本。当然,我可以删除它,并创建一个新的软链接到 python2.7的链接。

除了 /usr/bin中的链接之外,命令“ make install”和“ make altinstall”之间的区别是什么?

97784 次浏览

Let's take a look at the generated Makefile!

First, the install target:

install:         altinstall bininstall maninstall

It does everything altinstall does, along with bininstall and maninstall

Here's bininstall; it just creates the python and other symbolic links.

# Install the interpreter by creating a symlink chain:
#  $(PYTHON) -> python2 -> python$(VERSION))
# Also create equivalent chains for other installed files
bininstall:     altbininstall
-if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
else true; \
fi
(cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(EXE) $(PYTHON))
-rm -f $(DESTDIR)$(BINDIR)/python2$(EXE)
(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python2$(EXE))
... (More links created)

And here's maninstall, it just creates "unversioned" links to the Python manual pages.

# Install the unversioned manual pages
maninstall:     altmaninstall
-rm -f $(DESTDIR)$(MANDIR)/man1/python2.1
(cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python$(VERSION).1 python2.1)
-rm -f $(DESTDIR)$(MANDIR)/man1/python.1
(cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python2.1 python.1)

TLDR: altinstall skips creating the python link and the manual pages links, install will hide the system binaries and manual pages.

Simply: The altinstall target will make sure the default Python on your machine is not touched, or to avoid overwriting the system Python.