What should Linux/Unix 'make install' consist of?

后端 未结 3 1369
南笙
南笙 2020-12-07 19:22

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 fol

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-07 19:38

    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.

提交回复
热议问题