应该包含哪些内容

应该包含哪些内容

本文介绍了Linux/Unix 'make install' 应该包含哪些内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个 C++ 程序(命令行、可移植代码)并且我正在尝试在发布 Windows 版本的同时发布一个 Linux 版本.我写了一个makefile如下:

绫音:*.cpp *.hg++ -Wno-write-strings -oayane *.cpp

到目前为止足够简单;但我明白通常有第二步,make install.因此,当我将 install: 目标放在 makefile 中时...应该关联什么命令?(如果可能,我希望它可以在所有 Unix 系统以及 Linux 上运行.)

解决方案

安装

一个不太简单的安装程序会复制一些东西到位,首先确保存在适当的路径(使用 mkdir -p 或类似的).通常是这样的:

  • 可执行文件进入$INSTALL_PATH/bin
  • 任何为外部使用而构建的库都在 $INSTALL_PATH/lib$INSTALL_PATH/lib/yourappname
  • 手册页位于 $INSTALL_PATH/share/man/man1 中,如果合适,可能还有其他部分
  • 其他文档在 $INSTALL_PATH/share/yourappname
  • 默认配置文件位于 $INSTALL_PATH/etc/yourappname
  • 其他链接的标题在 $INSTALL_PATH/include/yourappname

安装路径

INSTALL_PATH 是构建系统的输入,通常默认为 /usr/local.这使您的用户可以灵活地在其 $HOME 下安装,而无需提升权限.

在最简单的情况下使用

INSTALL_PATH?=/usr/local

在 makefile 的顶部.然后用户可以通过在他们的 shell 中设置一个环境变量来覆盖它.

卸载

您偶尔还会看到 make install 构建清单以帮助卸载.清单甚至可以写成脚本来完成这项工作.

另一种方法是使用 make uninstall 来查找 make install 放置的东西,并在它们存在时将其删除.

I've written a C++ program (command line, portable code) and I'm trying to release a Linux version at the same time as the Windows version. I've written a makefile as follows:

ayane: *.cpp *.h
    g++ -Wno-write-strings -oayane *.cpp

Straightforward enough so far; but I'm given to understand it's customary to have a second step, make install. So when I put the install: target in the makefile... what command should be associated with it? (If possible I'd prefer it to work on all Unix systems as well as Linux.)

解决方案

Installation

A less trivial installer will copy several things into place, first insuring that the appropriate paths exists (using mkdir -p or similar). Typically something like this:

  • the executable goes in $INSTALL_PATH/bin
  • any libraries built for external consumption go in $INSTALL_PATH/lib or $INSTALL_PATH/lib/yourappname
  • man pages go in $INSTALL_PATH/share/man/man1 and possibly other sections if appropriate
  • other docs go in $INSTALL_PATH/share/yourappname
  • default configuration files go in $INSTALL_PATH/etc/yourappname
  • headers for other to link against go in $INSTALL_PATH/include/yourappname

Installation path

The INSTALL_PATH is an input to the build system, and usually defaults to /usr/local. This gives your user the flexibility to install under their $HOME without needing elevated permission.

In the simplest case just use

INSTALL_PATH?=/usr/local

at the top of the makefile. Then the user can override it by setting an environment variable in their shell.

Deinstallation

You also occasionally see make installs that build a manifest to help with de-installation. The manifest can even be written as a script to do the work.

Another approach is just to have a make uninstall that looks for the things make install places, and removes them if they exist.

这篇关于Linux/Unix 'make install' 应该包含哪些内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 06:03