Linux/Unix的"make install"应该包括什么? [英] What should Linux/Unix 'make install' consist of?

查看:89
本文介绍了Linux/Unix的"make install"应该包括什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个C ++程序(命令行,可移植代码),并且试图与Windows版本同时发布Linux版本.我编写了一个makefile,如下所示:

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

到目前为止很简单;但据我了解,通常需要执行第二步,即进行安装.因此,当我将install:目标放入makefile中时,应将哪个命令与之关联? (如果可能的话,我希望它可以在所有Unix系统以及Linux上运行.)

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.)

推荐答案

安装

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

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:

  • 可执行文件放入$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
  • 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

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

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

在makefile的顶部.然后,用户可以通过在其外壳中设置环境变量来覆盖它.

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

您有时还会看到make install,它们会构建清单以帮助卸载.清单甚至可以编写为脚本来完成工作.

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.

另一种方法是让make uninstall查找make install放置的东西,并删除它们(如果存在).

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"应该包括什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆